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.
Revision 2:2195a4abdf8c, committed 2018-11-28
- Comitter:
- drewrobinson
- Date:
- Wed Nov 28 21:00:21 2018 +0000
- Parent:
- 1:e2865ed633bb
- Commit message:
- best mast to date
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Nov 28 15:13:58 2018 +0000
+++ b/main.cpp Wed Nov 28 21:00:21 2018 +0000
@@ -35,20 +35,25 @@
DigitalOut dir( p24 );
DigitalOut I(p26);
DigitalOut slp(p29); //sleep
-float d_ang = 180.0;
-float pos = 180.0;
+DigitalOut r_slp(p30);
+DigitalOut m_led(LED1);
+float d_ang;
+float pos;
float RC_O;
//**get position**
-float posi(float in);
+float posi();
int main(void)
{
-
- I=0;
- motor.period(.001);
- motor.pulsewidth(0);
+ I=0; //sets for 1.5amp output
+ motor.period(.001); //sets the pulse width modulation period
+ motor.pulsewidth(0);
+ slp = 0;
+ r_slp = 0; //sstarts the current driver in off state
+ wait(10);
+ m_led = 1; //indicate that the wait period is over
// loop
while(1) {
//now = rtos::Kernel::get_ms_count();
@@ -56,27 +61,27 @@
if (rx.valid) {
RC_O = rx.channel[0];
- pc.printf(" rc: %f\n",rx.channel[0]);
+ //pc.printf(" rc: %f\n",rx.channel[0]);
} else {
- pc.printf(" invalid\r\n");
+ //pc.printf(" invalid\r\n");
slp = 0;
}
//39.19
d_ang = (RC_O/6.77)+39.19;
pos = (ain-.108)/.002466;
- //pc.printf(" %.3f\n",);
- if((pos > (d_ang-3.0)) && (pos < (d_ang+3.0))) {
+ pc.printf(" %.3f\n",pos);
+ if((pos > (d_ang-3.0))) {
motor.pulsewidth(0);
slp = 0;
}
- if( (pos > (d_ang+3.0)) && pos < 270.0) {
+ if( (pos > (d_ang+3.0))) {
slp = 1;
while(pos > d_ang) {
dir = 1; //left??
motor.pulsewidth(.0005);
- pc.printf("pos: %.3f\n",pos);
- pos = posi(ain);
+ //pc.printf("pos: %.3f\n",pos);
+ pos = posi();
}//while pos
motor.pulsewidth(0);
}//if pos
@@ -85,8 +90,8 @@
while(pos < d_ang) {
dir = 0; //right??
motor.pulsewidth(.0005);
- pc.printf("pos: %.3f\n",pos);
- pos = posi(ain);
+ //pc.printf("pos: %.3f\n",pos);
+ pos = posi();
}//while pos
motor.pulsewidth(0);
}
@@ -97,7 +102,7 @@
-float posi(float in)
+float posi()
{
float p1;
float p2;