opzetje van cases

Dependencies:   mbed

main.cpp

Committer:
charloverwijk
Date:
2017-11-01
Revision:
1:be295a50eb53
Parent:
0:0a4a244cb867

File content as of revision 1:be295a50eb53:

#include "mbed.h"

enum States (Cal1, Cal2, CalEMG, Home, EMG, Rest, Demo);
int State, Counter;
bool Position_controller_on;
float Looptime = 0.002f;
volatile vorigepositie

int main()
{
    State = Cal1;
    Position_controller_on = false;
    Counter = 0;
    
    Main_loop.attach(&loop_function, looptime);
}

void Loop_funtion()
{   
    switch(State){
        case Cal1: //Calibration motor 1
               if (Huidigepositie1== 0)
               {
                    SetMotor1(value); //value is waarde encoder voor loodrechte hoeken,.
                    if (fabs(huidigepositie1-home1)<0.01) {
                        state=Cal2
                    }
                }
                else {
                    SetMotor1(0);
                    Loop_function();
                }
            break;
            
        case Cal2: //Calibration motor 2
                 if (Huidigepositie2== 0)
                 {
                       if (encoder2.read)<0.01){
                       state=CalEMG;
                 }
                 else {
                     SetMotor2(0);
                     Loop_function();
                 }
            break;
        case CalEMG: // Calibration EMG
            calibrationEMG();   //calculates average EMGFiltered at rest and measures max signal EMGFiltered.
            //measure mean at restand substract always--> no treshold needed.
            //1/MVC
            state=SelectDevice;
            break;    
        case SelectDevice: //Looks at the difference between current position and home. Select aansturen EMG or buttons
            if button=1; {
                state=EMG;
            }
            if button=0; {
                state=Demo;
            }
            break;
            
        case EMG: //Aansturen met EMG
            break;
        case Demo: // Aansturen met toetsenbord
            break;
} 

//after this the kinematics and control wil come  
}