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

Dependencies:   mbed

Committer:
Stathisn
Date:
Tue Aug 26 05:04:24 2014 +0000
Revision:
0:01fd80c0a524
Child:
1:7b420a2ea7db
Initial commit, added place holders for some functions pertaining to the initialisation and calibration of the turntable

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Stathisn 0:01fd80c0a524 1 #include "mbed.h"
Stathisn 0:01fd80c0a524 2
Stathisn 0:01fd80c0a524 3 enum calib_state_t {
Stathisn 0:01fd80c0a524 4 UNCALIBRATED,
Stathisn 0:01fd80c0a524 5 CALIBRATED,
Stathisn 0:01fd80c0a524 6 CALIBRATING,
Stathisn 0:01fd80c0a524 7 INITIALISING,};
Stathisn 0:01fd80c0a524 8
Stathisn 0:01fd80c0a524 9 DigitalOut my_led(LED1); // Sanity LED
Stathisn 0:01fd80c0a524 10 DigitalOut ttDrive(PA_14); // the drive signal for the turntable
Stathisn 0:01fd80c0a524 11 InterruptIn encoder(PA_13); // Signal from encoder
Stathisn 0:01fd80c0a524 12 InterruptIn limitSwitch(PA_15); // Signal from limit switch
Stathisn 0:01fd80c0a524 13
Stathisn 0:01fd80c0a524 14 calib_state_t calib_state = 0; // Flag for calibration state
Stathisn 0:01fd80c0a524 15 int encoderMax = 0; // Calibrated maximum value for the encoder
Stathisn 0:01fd80c0a524 16
Stathisn 0:01fd80c0a524 17 void calibrate(void); // synchronises and calibrates MCU to turntable
Stathisn 0:01fd80c0a524 18 void increment(int *i); // increments value i, used as an interrupt target
Stathisn 0:01fd80c0a524 19
Stathisn 0:01fd80c0a524 20
Stathisn 0:01fd80c0a524 21 int main() {
Stathisn 0:01fd80c0a524 22
Stathisn 0:01fd80c0a524 23
Stathisn 0:01fd80c0a524 24 // Step 1: Attach interrupt signals to appropriate functions
Stathisn 0:01fd80c0a524 25 // Step 2: Calibrate MCU to the turn table
Stathisn 0:01fd80c0a524 26 // Step 3: Control turntable using hard coded commands
Stathisn 0:01fd80c0a524 27 // Step 4: Include WiConnect Library
Stathisn 0:01fd80c0a524 28 // Step 5: Interpret commands sent over TCP
Stathisn 0:01fd80c0a524 29
Stathisn 0:01fd80c0a524 30
Stathisn 0:01fd80c0a524 31 // Configure sanity LED to blink
Stathisn 0:01fd80c0a524 32 while(1) {
Stathisn 0:01fd80c0a524 33 my_led = !my_led;
Stathisn 0:01fd80c0a524 34 wait(0.5);
Stathisn 0:01fd80c0a524 35 }
Stathisn 0:01fd80c0a524 36 }
Stathisn 0:01fd80c0a524 37
Stathisn 0:01fd80c0a524 38 void calibrate(void)
Stathisn 0:01fd80c0a524 39 {
Stathisn 0:01fd80c0a524 40 // Step 1: Get the motor turning
Stathisn 0:01fd80c0a524 41 // Step 2: Continue turning until calibration state is "CALIBRATED"
Stathisn 0:01fd80c0a524 42 // the actual calibration will be handled by interrupts
Stathisn 0:01fd80c0a524 43 }
Stathisn 0:01fd80c0a524 44
Stathisn 0:01fd80c0a524 45 void increment(int *i)
Stathisn 0:01fd80c0a524 46 {
Stathisn 0:01fd80c0a524 47 // Step 1: De-refference pointer and increment the value
Stathisn 0:01fd80c0a524 48 }