Ramon Waninge / Mbed 2 deprecated Milestone1

Dependencies:   FastPWM mbed QEI biquadFilter HIDScope MODSERIAL

main.cpp

Committer:
efvanmarrewijk
Date:
2018-10-22
Revision:
18:ca084c362855
Parent:
17:0ae9e8c958f8
Child:
20:695140b8db2f
Child:
45:53c4fca47ed4

File content as of revision 18:ca084c362855:

// Inclusion of libraries
#include "mbed.h"
#include "FastPWM.h"    
#include "QEI.h"        // Includes library for encoder
#include "MODSERIAL.h"
#include "HIDScope.h"
#include "BiQuad.h"

// Input

// Output

// Utilisation of libraries
MODSERIAL   pc(USBTX, USBRX);
QEI         Encoder1(D11,D10,NC,4200);      // Counterclockwise motor rotation is the positive direction
QEI         Encoder2(D9,D8,NC,4200);        // Counterclockwise motor rotation is the positive direction
QEI         Encoder3(D13,D12,NC,4200);      // Counterclockwise motor rotation is the positive direction

// Global variables
const float    pi = 3.14159265358979;


// Functions
void Encoderinput()
{   int counts1;
    int counts2;
    int counts3;
    float  angle1;
    float  angle2;
    float  angle3;
    counts1 = Encoder1.getPulses();
    counts2 = Encoder2.getPulses();
    counts3 = Encoder3.getPulses();
    angle1 = ((float)counts1*2.0*pi)/4200.0;
    angle2 = ((float)counts2*2.0*pi)/4200.0;
    angle3 = ((float)counts3*2.0*pi)/4200.0;
         
    pc.printf("Counts1: %i  Angle1: %f      Counts2: %i  Angle2: %f\r\n",counts1,angle1,counts2,angle2);
}

// Main program
int main()
{   
    pc.baud(115200);
    
            
    while   (true)
    {   Encoderinput();
    }
}