Corrected header file include guards.

Dependencies:   FiniteStateMachine HipControl Knee LinearBlend1 LocalFileSystem_Read dataComm hapticFeedback initExoVars mbed Blend_Generator Brad_poly_gait Gait_Generator MM_gait Encoders IMUdriver

Fork of Motion Control by HEL's Angels

Committer:
mzling
Date:
Fri Mar 20 23:09:02 2015 +0000
Revision:
19:70b2124c7370
Parent:
18:03d7c5fdc0c7
Child:
20:cf8e99d989a6
Added range to variables

Who changed what in which revision?

UserRevisionLine numberNew contents of line
perr1940 0:d38d627c922f 1 /**************************************
perr1940 0:d38d627c922f 2 This is the main file for the "RyanEXO" control software.
perr1940 0:d38d627c922f 3 This sets up the main control loop that operates at a 1kHz frequency
perr1940 0:d38d627c922f 4 and controls the flow of the rest of the software
perr1940 0:d38d627c922f 5
perr1940 0:d38d627c922f 6 The configuration for the exo system that this software runs:
perr1940 0:d38d627c922f 7 amplifiers: 2 Copley Controls 10A digital amplifiers
perr1940 0:d38d627c922f 8 sensors: 2 Austria Microsystems 12 bit magnetic encoders, handled by encoders.h
perr1940 0:d38d627c922f 9 motors: 2 maxon EC90 DC brushless motors, handled by HipMotorControl.h (called in FSM.h)
perr1940 0:d38d627c922f 10 Knees: wrap spring clutch controlled by Firgelli PQ12P linear actuators, controlled in linearActuatorControl.h
cashdollar 3:9719ad064a2c 11 **************************************/
perr1940 0:d38d627c922f 12
perr1940 0:d38d627c922f 13 #include "mbed.h"
perr1940 0:d38d627c922f 14 #include "initExoVars.h"
perr1940 0:d38d627c922f 15 #include "FSM.h"
perr1940 2:89b78367d173 16 #include "dataBedComm.h"
mzling 13:c588cb388240 17 #include "dataComm.h"
mzling 18:03d7c5fdc0c7 18 short dataIn[7];
mzling 18:03d7c5fdc0c7 19 short dataOut[]={0xFF,30,31,0, 0, 0, 0xFE};
mzling 18:03d7c5fdc0c7 20 dataComm dc = dataComm();
mzling 18:03d7c5fdc0c7 21 Timer dbg;
mzling 15:3596b7ca1c20 22
perr1940 0:d38d627c922f 23 ///////////////////////////////////////////////////////////////////////////
cashdollar 3:9719ad064a2c 24
cashdollar 3:9719ad064a2c 25 // periodicFcns runs at the start of every control loop cycle
cashdollar 3:9719ad064a2c 26 // It initiates communication with dataBed, checks for errors/safety, and starts the FSM
perr1940 0:d38d627c922f 27 void periodicFcns()
perr1940 0:d38d627c922f 28 {
mzling 18:03d7c5fdc0c7 29 dbg.reset();
mzling 18:03d7c5fdc0c7 30 //float temp1 = dbg.read_us();
mzling 18:03d7c5fdc0c7 31
mzling 18:03d7c5fdc0c7 32 //dbg.start();
perr1940 2:89b78367d173 33 dataOut[1]=encoder_L.readRaw();
mzling 18:03d7c5fdc0c7 34 //dataOut[2]=fsm.error();
mzling 18:03d7c5fdc0c7 35 short* ptr=dataIn;
mzling 18:03d7c5fdc0c7 36 ptr=sendData(dataOut, 7, dataIn);
mzling 18:03d7c5fdc0c7 37 //dbg.reset();
mzling 18:03d7c5fdc0c7 38 /*for (int i = 0; i < 7; i++) {
mzling 17:b77c31807825 39 pc.printf("%x, ", dataIn[i]);
mzling 18:03d7c5fdc0c7 40 }
mzling 18:03d7c5fdc0c7 41 pc.printf("\r\n");*/
mzling 18:03d7c5fdc0c7 42 dc.process_write(dataIn, 7);
perr1940 7:d44555be84b7 43 //pc.printf("%d, %d, %d, %d,", dataIn[0], dataIn[1], dataIn[2], dataIn[3]);
mzling 18:03d7c5fdc0c7 44
cashdollar 3:9719ad064a2c 45 // Run state change/analysis in FSM
mzling 17:b77c31807825 46 int exoState=fsm.state(dataIn[1]);
mzling 18:03d7c5fdc0c7 47 float temp=dbg.read_us();
mzling 19:70b2124c7370 48 //pc.printf("%f\r\n",temp);
mzling 18:03d7c5fdc0c7 49
perr1940 0:d38d627c922f 50 }
perr1940 0:d38d627c922f 51
perr1940 0:d38d627c922f 52 int main()
perr1940 0:d38d627c922f 53 {
cashdollar 5:498c9bfc56f0 54 pc.printf("\r\nExoStart \r\n");
perr1940 0:d38d627c922f 55 initializeExoIOs();
mzling 18:03d7c5fdc0c7 56 //pc.printf("Test\r\n"); // keep for debugging compile errors
perr1940 2:89b78367d173 57
perr1940 0:d38d627c922f 58 pc.printf("Starting exo...\n\r");
cashdollar 5:498c9bfc56f0 59
perr1940 0:d38d627c922f 60 //If desired, a startup sound can be played. This function is defined in the DatabedCode, because it will command a sound to be played once it detects a heartbeat from ControlBed
perr1940 0:d38d627c922f 61 wait(2);
mzling 18:03d7c5fdc0c7 62 dbg.start();
perr1940 0:d38d627c922f 63 Ticker doControl;
mzling 14:8929f5a9837c 64 dataBedSPI.format(16,0);
perr1940 0:d38d627c922f 65 doControl.attach(&periodicFcns, SAMPLE_TIME);
perr1940 0:d38d627c922f 66
mzling 18:03d7c5fdc0c7 67 while (1);
perr1940 0:d38d627c922f 68 }