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: MODSERIAL mbed Encoder
Revision 11:28a196a3d898, committed 2013-10-23
- Comitter:
- Socrates
- Date:
- Wed Oct 23 13:32:39 2013 +0000
- Parent:
- 10:2e66843bb6d7
- Child:
- 12:100cbba6cd96
- Commit message:
- Werkt op x, met duty cycle
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Oct 21 13:52:39 2013 +0000
+++ b/main.cpp Wed Oct 23 13:32:39 2013 +0000
@@ -5,11 +5,12 @@
//Rechts is x, links is y
AnalogIn emgtl(PTB1);
AnalogIn emgbl(PTB0);
-//PwmOut pwm_x(PTA5);
-//PwmOut pwm_y(PTA12);
-AnalogOut pwm_x(PTE30);
+PwmOut pwm_x(PTA5);
+PwmOut pwm_y(PTA12);
+//AnalogOut pwm_x(PTE30);
MODSERIAL pc(USBTX,USBRX);
+
volatile bool looptimerflag;
void setlooptimerflag(void)
@@ -19,6 +20,8 @@
int main()
{
+pwm_x.period(1.0/1000.0);
+pwm_y.period(1.0/1000.0);
Ticker looptimer;
const float ts=0.001;
looptimer.attach(setlooptimerflag,ts);
@@ -27,7 +30,8 @@
float xbr,ybr,y1br,x1br,zbr,z1br,z2br,yabsbr,yabs1br,yabs2br,kbr;
float xtl,ytl,y1tl,x1tl,ztl,z1tl,z2tl,yabstl,yabs1tl,yabs2tl,ktl;
float xbl,ybl,y1bl,x1bl,zbl,z1bl,z2bl,yabsbl,yabs1bl,yabs2bl,kbl;
- float zx,zy,xdir,ydir;
+ float zx,zy;
+ float xdir,ydir;
x1tr=0; y1tr=0; z1tr=0; z2tr=0; yabs1tr=0; yabs2tr=0;
x1br=0; y1br=0; z1br=0; z2br=0; yabs1br=0; yabs2br=0;
@@ -83,10 +87,10 @@
x1bl=xbl; y1bl=ybl; z2bl=z1bl; z1bl=zbl; yabs2bl=yabs1bl; yabs1bl=yabsbl;
if (ztr>zbr) {
- zx=ztr*5.0;
+ zx=ztr*2.5;
xdir=0;
} else {
- zx=zbr*5.0;
+ zx=zbr*2.5;
xdir=1;
}
@@ -105,15 +109,15 @@
zy=0.99999;
}
- if (zx<0.35){
+ if (zx<0.20){
zx=0;
}
- if (zy<0.35){
+ if (zy<0.20){
zy=0;
}
- //pwm_x.write(abs(zx));
- //pwm_y.write(abs(zy));
- pc.printf("%f\n\r",kbr);
+ pwm_x.write(abs(zx));
+ pwm_y.write(abs(zy));
+ pc.printf("%f\n\r",zx);
}
}
\ No newline at end of file
