This project will enable remote control of a motorised turntable via a WiFi enabled TCP link using ACKme's (http://ack.me/) Wi-Fi enablement platform
main.cpp@2:a73037a7d85d, 2014-08-27 (annotated)
- Committer:
- Stathisn
- Date:
- Wed Aug 27 12:28:48 2014 +0000
- Revision:
- 2:a73037a7d85d
- Parent:
- 1:7b420a2ea7db
Cleaned up control code and created an object to handle its operation; Integrated feedback over serial for debugging purposes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Stathisn | 0:01fd80c0a524 | 1 | #include "mbed.h" |
Stathisn | 2:a73037a7d85d | 2 | #include "TurntableControl.h" |
Stathisn | 2:a73037a7d85d | 3 | #include "ConsoleSerial.h" |
Stathisn | 0:01fd80c0a524 | 4 | |
Stathisn | 2:a73037a7d85d | 5 | #define CONSOLE_BAUD 115200 |
Stathisn | 2:a73037a7d85d | 6 | |
Stathisn | 2:a73037a7d85d | 7 | |
Stathisn | 0:01fd80c0a524 | 8 | |
Stathisn | 0:01fd80c0a524 | 9 | DigitalOut my_led(LED1); // Sanity LED |
Stathisn | 2:a73037a7d85d | 10 | TurntableControl tc; // Turntable controller |
Stathisn | 1:7b420a2ea7db | 11 | |
Stathisn | 1:7b420a2ea7db | 12 | |
Stathisn | 2:a73037a7d85d | 13 | ConsoleSerial cs(SERIAL_TX, SERIAL_RX); |
Stathisn | 0:01fd80c0a524 | 14 | |
Stathisn | 0:01fd80c0a524 | 15 | |
Stathisn | 0:01fd80c0a524 | 16 | int main() { |
Stathisn | 0:01fd80c0a524 | 17 | |
Stathisn | 0:01fd80c0a524 | 18 | |
Stathisn | 2:a73037a7d85d | 19 | cs.setBaud(CONSOLE_BAUD); |
Stathisn | 2:a73037a7d85d | 20 | |
Stathisn | 2:a73037a7d85d | 21 | cs.printf("resetting\n\r"); |
Stathisn | 1:7b420a2ea7db | 22 | |
Stathisn | 2:a73037a7d85d | 23 | // Step 1: reset the turntable |
Stathisn | 2:a73037a7d85d | 24 | tc.reset(); |
Stathisn | 2:a73037a7d85d | 25 | cs.printf("reset\n\rcalibrating\n\r"); |
Stathisn | 1:7b420a2ea7db | 26 | |
Stathisn | 2:a73037a7d85d | 27 | // Step 2: calibrate the turntable |
Stathisn | 2:a73037a7d85d | 28 | cs.printf("Max encoder = %d\n\r", tc.calibrate()); |
Stathisn | 1:7b420a2ea7db | 29 | |
Stathisn | 2:a73037a7d85d | 30 | // Step 3: rotate to a specified quarter |
Stathisn | 2:a73037a7d85d | 31 | tc.quarterTurns(4); |
Stathisn | 2:a73037a7d85d | 32 | |
Stathisn | 2:a73037a7d85d | 33 | cs.printf("Done incrementing\r\n"); |
Stathisn | 2:a73037a7d85d | 34 | cs.printf("Encoder Current = %d\r\n", tc.getEncoderCurrent()); |
Stathisn | 2:a73037a7d85d | 35 | |
Stathisn | 0:01fd80c0a524 | 36 | // Step 4: Include WiConnect Library |
Stathisn | 0:01fd80c0a524 | 37 | // Step 5: Interpret commands sent over TCP |
Stathisn | 0:01fd80c0a524 | 38 | |
Stathisn | 0:01fd80c0a524 | 39 | |
Stathisn | 0:01fd80c0a524 | 40 | // Configure sanity LED to blink |
Stathisn | 0:01fd80c0a524 | 41 | while(1) { |
Stathisn | 2:a73037a7d85d | 42 | my_led = !my_led; |
Stathisn | 0:01fd80c0a524 | 43 | wait(0.5); |
Stathisn | 0:01fd80c0a524 | 44 | } |
Stathisn | 0:01fd80c0a524 | 45 | } |