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-rtos mbed PinDetect
Fork of FinalMotorControl by
Revision 6:ac5d277bd497, committed 2016-04-20
- Comitter:
- mjhaugsdal
- Date:
- Wed Apr 20 12:11:51 2016 +0000
- Parent:
- 5:fdc7a779d525
- Child:
- 7:ba0caeb296bb
- Child:
- 16:a3555918c025
- Commit message:
- Commit before making changes, splitting methods 1 for each engine
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Apr 18 12:18:06 2016 +0000
+++ b/main.cpp Wed Apr 20 12:11:51 2016 +0000
@@ -10,10 +10,10 @@
DigitalOut IN3(A2);
DigitalOut IN4(A3);
//Second engine
-DigitalOut IN5(D2);
-DigitalOut IN6(D3);
-DigitalOut IN7(D4);
-DigitalOut IN8(D5);
+DigitalOut IN5(D3);
+DigitalOut IN6(D4);
+DigitalOut IN7(D5);
+DigitalOut IN8(D6);
static int fart = 1000;
@@ -23,51 +23,96 @@
void step4Right()
{
+ //engine 1
IN1=0;
IN2=1;
IN3=0;
IN4=1;
+ //engine 2
+ IN5=0;
+ IN6=1;
+ IN7=0;
+ IN8=1;
wait_us(fart); //legg som global variabel "fart"
+ //engine 1
IN1=0;
IN2=1;
IN3=1;
IN4=0;
+ //engine 2
+ IN5=0;
+ IN6=1;
+ IN7=1;
+ IN8=0;
wait_us(fart);
+ //engine 1
IN1=1;
IN2=0;
IN3=1;
IN4=0;
+ //engine 2
+ IN5=1;
+ IN6=0;
+ IN7=1;
+ IN8=0;
wait_us(fart);
+ //engine 1
IN1=1;
IN2=0;
IN3=0;
IN4=1;
+ //engine 2
+ IN5=1;
+ IN6=0;
+ IN7=0;
+ IN8=1;
wait_us(fart);
}
void step4Left()
{
+ //engine 1
IN1=1;
IN2=0;
IN3=0;
IN4=1;
+ //engine 2
+ IN5=1;
+ IN6=0;
+ IN7=0;
+ IN8=1;
wait_us(fart);
-
+ //engine 1
IN1=1;
IN2=0;
IN3=1;
IN4=0;
+ //engine 2
+ IN5=1;
+ IN6=0;
+ IN7=1;
+ IN8=0;
wait_us(fart);
-
+ //engine 1
IN1=0;
IN2=1;
IN3=1;
IN4=0;
+ //engine 2
+ IN5=0;
+ IN6=1;
+ IN7=1;
+ IN8=0;
wait_us(fart);
-
+ //engine 1
IN1=0;
IN2=1;
IN3=0;
IN4=1;
+ //engine 2
+ IN5=0;
+ IN6=1;
+ IN7=0;
+ IN8=1;
wait_us(fart);
}
@@ -116,16 +161,13 @@
{
fart = 1000;
//global_direction = '1';
- step4Right();
- // steps = steps + step;
- //printf("%i", &steps);
- //printf("RIGHT \n");
-
+ step4Right();
}
else
{
//global_direction = 'x';
}
+
if (m_cmd == 'a')
{
fart = 2000;
@@ -147,10 +189,10 @@
}
else if (m_cmd == 'k')
{
- int steps = 485;
+ int steps = 242;
- //Steps = 485 gives a 120' rotation to the left.
+ //Steps = 242 gives a 60' rotation to the left.
while (steps >= 0)
{
step4Left();
@@ -160,8 +202,8 @@
}
else if (m_cmd == 'l')
{
- int steps = 485;
- //Steps = 485 gives a 120' rotation to the right.
+ int steps = 242;
+ //Steps = 242 gives a 60' rotation to the right.
while (steps >= 0)
{
step4Right();
