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
Fork of Robotics_Lab_DCMotor by
Diff: main.cpp
- Revision:
- 6:da43b63ffb24
- Parent:
- 5:ff3b5f31a9ce
- Child:
- 9:85cbef9febe7
- Child:
- 10:7954ec17021d
diff -r ff3b5f31a9ce -r da43b63ffb24 main.cpp
--- a/main.cpp Thu Apr 14 08:51:41 2016 +0000
+++ b/main.cpp Thu Apr 14 09:29:00 2016 +0000
@@ -27,6 +27,8 @@
Ticker timer1;
void timer1_interrupt(void);
+int timer1_counter;
+
void CN_interrupt(void);
void init_TIMER(void);
@@ -49,6 +51,7 @@
int main() {
+ init_BLUETOOTH();
init_TIMER();
init_PWM();
init_CN();
@@ -131,6 +134,16 @@
TIM1->CCER |= 0x40;
PIout_2_old = PIout_2;
+
+ timer1_counter ++;
+ if (timer1_counter == 5)
+ {
+ timer1_counter = 0;
+ if(bluetooth.writeable())
+ {
+ bluetooth.printf("V1: %f V2: %f\n",v1,v2);
+ }
+ }
}
void CN_interrupt(void)
@@ -143,16 +156,16 @@
if (stateA_1 == 0)
{
if (stateB_1 == 0)
- state_1 = 1;
+ state_1 = 0;
else
- state_1 = 2;
+ state_1 = 1;
}
else
{
if (stateB_1 == 1)
- state_1 = 3;
+ state_1 = 2;
else
- state_1 = 4;
+ state_1 = 3;
}
//Forward: v1Count +1
@@ -172,16 +185,16 @@
if (stateA_2 == 0)
{
if (stateB_2 == 0)
- state_2 = 1;
+ state_2 = 0;
else
- state_2 = 2;
+ state_2 = 1;
}
else
{
if (stateB_2 == 1)
- state_2 = 3;
+ state_2 = 2;
else
- state_2 = 4;
+ state_2 = 3;
}
//Forward: v2Count +1
@@ -195,6 +208,7 @@
void init_TIMER(void)
{
timer1.attach_us(&timer1_interrupt, 10000);//10ms interrupt period (100 Hz)
+ timer1_counter = 0;
}
void init_PWM(void)
