thijs ruikes
/
PROJECT-BATJEPOSTITIE
vor bas
Revision 0:b48b8c18b1bd, committed 2014-10-30
- Comitter:
- wiesdat
- Date:
- Thu Oct 30 17:10:14 2014 +0000
- Child:
- 1:d157905a98d1
- Commit message:
- BATJE positie, naar links en rechts bewegen, encoder op nul stellen en uitlezen
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Encoder.lib Thu Oct 30 17:10:14 2014 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/vsluiter/code/Encoder/#18b000b443af
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Oct 30 17:10:14 2014 +0000 @@ -0,0 +1,54 @@ +#include "mbed.h" +#include "mbed.h" +#include "encoder.h" +#define K_P (0.1) +#define K_I (0.1) +#define K_D (0.0005 /TSAMP) +#define TSAMP 0.001 +#define I_LIMIT 1. +#include <iostream> + +Encoder encoderA(PTD5,PTA13); + +PwmOut pwm(PTC8); +DigitalOut dir(PTC9); + +int32_t enc = 0,enca2 =0,enca1=0, encp=0, counts =0; +float speed = 0.1, out =0; +int pos =0,zero =0, fout; +float v=0; +float out_i = 0; +int y; + + +int main() +{ + while(1){ + cout<<"typ 1 voor links, 2 voor rechts: "<<endl; + cin>>y; + switch(y) { + case 1: + cout<<"links"<<endl; + dir = 1; + pwm.write(0.4); + wait(0.01); + pwm.write(0); + break; + case 2: + cout<<"rechts"<<endl; + dir = 0; + pwm.write(0.4); + wait(0.01); + pwm.write(0); + break; + case 3: + cout<<encoderA.getPosition()<<endl; + break; + case 4: + encoderA.setPosition(0); + break; + } +} + + +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Oct 30 17:10:14 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/031413cf7a89 \ No newline at end of file