Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp
- Committer:
- x58alex41
- Date:
- 2017-11-22
- Revision:
- 7:edd065946e9b
- Parent:
- 6:688449345fff
- Child:
- 9:76e4808df4cb
File content as of revision 7:edd065946e9b:
#include "mbed.h"
#include "PID.h"
#include "controls.h"
#include "globals.h"
AnalogIn LL_t (PC_0);
AnalogIn L_t (PC_1);
AnalogIn R_t (PA_4);
AnalogIn RR_t (PA_0);
DigitalOut LL_e (PB_7);
DigitalOut L_e (PB_0);
DigitalOut R_e (PC_11);
DigitalOut RR_e (PC_10);
InterruptIn cM1_1(PB_3); //interrupt from encoders
InterruptIn cM1_2(PA_15);
InterruptIn cM2_1(PA_1);
InterruptIn cM2_2(PC_4);
PwmOut M1F(PC_7); //motor direction and speed control
PwmOut M2B(PA_7);
PwmOut M1B(PB_10);
PwmOut M2F(PB_6);
Serial pc(SERIAL_TX, SERIAL_RX);
volatile unsigned long counterM1 = 1; // counter for hall sensors
volatile unsigned long counterM2 = 1;
void incrementM1()
{
++counterM1;
}
void incrementM2()
{
++counterM2;
}
int main()
{
M1B.write(0);
M2B.write(0);
M1F.write(0);
M2F.write(0);
LL_e=1;
RR_e=1;
cM1_1.rise(&incrementM1);
cM1_1.fall(&incrementM1);
cM1_2.rise(&incrementM1);
cM1_2.fall(&incrementM1);
cM2_1.rise(&incrementM2);
cM2_1.fall(&incrementM2);
cM2_2.rise(&incrementM2);
cM2_2.fall(&incrementM2);
move(.05, 1000000, forward, forward, &PID_e );
}