This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:iot-open:remotelab:itt:servo [2019/10/27 10:52] – pczekalski | en:iot-open:remotelab:itt:servo [2020/07/20 12:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ===== ITT Servo module ===== | ||
| + | This laboratory is located in the office of ITT Group in Tallinn, Estonia. | ||
| + | |||
| + | ==== Introduction | ||
| + | This laboratory can be used to practice controlling the servo motor attached to the controller. | ||
| + | |||
| + | {{: | ||
| + | |||
| + | ==== Prerequisites ==== | ||
| + | For this laboratory, the student should understand basic MQTT concepts like topics, broker, subscribing and publishing. | ||
| + | |||
| + | ==== Technical details ==== | ||
| + | This laboratory consists of a servo with the add-on module attached to the ITT IoT controller module. | ||
| + | |||
| + | === Sensors === | ||
| + | This laboratory does not have any sensors. | ||
| + | |||
| + | === Specifications === | ||
| + | <table Ref.Tab.1.1> | ||
| + | < | ||
| + | ^ Specification ^ Value ^ | ||
| + | | Speed at 6V | 0,07 sec/60°| | ||
| + | | Stall torque at 6V | 0,042 N-m | | ||
| + | | Speed at 4,8V | 0,09 sec/60°| | ||
| + | | Stall torque at 4,8V | 0,028 N-m | | ||
| + | </ | ||
| + | |||
| + | === Electrical connection === | ||
| + | |||
| + | The signal lead of the servo is connected to D3 pin of the controller. | ||
| + | |||
| + | === Software, libraries and externals === | ||
| + | * ITTIoT libary - used to program the controller module. | ||
| + | * Servo libary - used to control the servo. | ||
| + | |||
| + | === Communication === | ||
| + | The user can connect and program this controller using the Distancelab environment. | ||
| + | |||
| + | === Limits === | ||
| + | At the same time, only one user can program the controller. But all users connected to the Distancelab MQTT broker can subscribe and publish to topics specified. | ||
| + | |||
| + | ==== Hands-on labs ==== | ||
| + | |||
| + | === Example code === | ||
| + | |||
| + | <code c> | ||
| + | /* | ||
| + | * IoT Servo example | ||
| + | * | ||
| + | * This example subscribe to the " | ||
| + | * change servo position | ||
| + | * | ||
| + | * Created 11 Sept 2017 by Heiko Pikner | ||
| + | */ | ||
| + | |||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | //Pin definition for the Servo (D3) | ||
| + | #define SERVO_PIN | ||
| + | |||
| + | Servo myservo; | ||
| + | |||
| + | // Change the servo position (value between 0 and 180) | ||
| + | // mosquitto_pub -u test -P test -t " | ||
| + | // = this calls servo motor to change position | ||
| + | |||
| + | void iot_received(String topic, String msg) | ||
| + | { | ||
| + | Serial.print(" | ||
| + | Serial.print(topic); | ||
| + | Serial.print(" | ||
| + | Serial.println(msg); | ||
| + | |||
| + | Serial.print(" | ||
| + | Serial.println(msg); | ||
| + | |||
| + | myservo.write(msg.toInt()); | ||
| + | } | ||
| + | |||
| + | // Function started after the connection to the server is established | ||
| + | void iot_connected() | ||
| + | { | ||
| + | Serial.println(" | ||
| + | // Subscribe to the topic " | ||
| + | iot.subscribe(" | ||
| + | iot.log(" | ||
| + | } | ||
| + | |||
| + | void setup() | ||
| + | { | ||
| + | Serial.begin(115200); | ||
| + | Serial.println(" | ||
| + | |||
| + | // Print json config to serial | ||
| + | iot.printConfig(); | ||
| + | // Initialize IoT library | ||
| + | iot.setup(); | ||
| + | |||
| + | myservo.attach(SERVO_PIN); | ||
| + | } | ||
| + | |||
| + | void loop() | ||
| + | { | ||
| + | // IoT behind the plan work, it should be periodically called | ||
| + | iot.handle(); | ||
| + | delay(200); | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | ==== Support ==== | ||
| + | info@ittgroup.ee | ||