Steering Servo Step responses

Dependencies:   FRDM-TFC mbed

main.cpp

Committer:
oj3g13
Date:
2016-11-24
Revision:
0:4a3f069b314a

File content as of revision 0:4a3f069b314a:

#include "mbed.h"
#include "TFC.h"
#define MULTIPLIER 0.25

DigitalOut gpo(D0);

int main()
{
        TFC_Init();
        TFC_InitServos(0.00052,0.00122,0.02);
        float i;
        wait(3);
        float rand_max=RAND_MAX;
        while(true)
        {
        i = (rand()/rand_max)*MULTIPLIER;
        


        
        gpo = !gpo; // toggle pin 
        TFC_SetServo(0,-1.0);
        wait(i);
        i = (rand()/rand_max)*MULTIPLIER;
        
        gpo = !gpo; 
        TFC_SetServo(0,0.4);
        wait(i);
        i = (rand()/rand_max)*MULTIPLIER;
                
        gpo = !gpo; 
        TFC_SetServo(0,0);
        wait(i);
        i = (rand()/rand_max)*MULTIPLIER;
                
        gpo = !gpo; 
        TFC_SetServo(0,-0.6);
        wait(i);
        i = (rand()/rand_max)*MULTIPLIER;
                
        gpo = !gpo; 
        TFC_SetServo(0,-0.5);
        wait(i);
        i = (rand()/rand_max)*MULTIPLIER;
                
        gpo = !gpo; 
        TFC_SetServo(0,-0.7);
        wait(i);
        i = (rand()/rand_max)*MULTIPLIER;
                
        gpo = !gpo; 
        TFC_SetServo(0,0.9);
        wait(i);
        i = (rand()/rand_max)*MULTIPLIER;

        gpo = !gpo; 
        TFC_SetServo(0,0.5);
        wait(i);
        i = (rand()/rand_max)*MULTIPLIER;

        }   
    }