calibrate

Dependencies:   FastPWM MODSERIAL QEI mbed

main.cpp

Committer:
s1737619
Date:
2018-10-30
Revision:
0:46c28ea3feb9

File content as of revision 0:46c28ea3feb9:

#include "mbed.h"

//global variables

double EMG_filt1;
double EMG_filt2;
double EMG_filt3;
double EMG_filt4;
bool calibrationbool;
double EMG_max1 = 10000.0; 
double EMG_max2 = 10000.0;
double EMG_max3 = 10000.0;
double EMG_max4 = 10000.0;

void calibrationbutton
{
    calibrationbool = true;
    EMG_max1 = 0.0001;
    EMG_max2 = 0.0001;
    EMG_max3 = 0.0001;
    EMG_max4 = 0.0001;
    
}

void switchtostate
{
    calibrationbool = false //Dit moet waarschijnlijk anders in het hele script.
}

void calibratie()
{
    static int count

    if     (0.95*EMG_filt1>EMG_max1)
    {
        EMG_max1 = 0.95*EMG_filt1;
    }
    if     (0.95*EMG_filt2>EMG_max2)
    
    {
        EMG_max2 = 0.95*EMG_filt2;
    }
    
    if     (0.95*EMG_filt3>EMG_max3)
    {
            EMG_max3 = 0.95*EMG_filt3;
    }
    if     (0.95*EMG_filt4>EMG_max4)
    {
        EMG_max4 = 0.95*EMG_filt4;
    }

        count++;
        if (count == eengetal)
        {
        switchtostate()   
        }
    }   
}
    
    InterruptIn button
    

int main
{
    button.fall(calibrationbutton)
    
    while (true)
    {
        }