nRF24L01, encoder, pca9685, pid
Dependencies: mbed QEI-1 LibPN532 nRF24L01P xiugai
Diff: main.cpp
- Revision:
- 4:652d2be11b35
- Parent:
- 3:ee5e434e047e
- Child:
- 6:7db9b13ece76
--- a/main.cpp Wed Oct 16 13:59:33 2019 +0000 +++ b/main.cpp Fri Oct 25 02:58:18 2019 +0000 @@ -18,11 +18,9 @@ QEI qei_PA_0(PA_0,PA_1,NC,13,QEI::X4_ENCODING); Serial Serial_2(PA_2,PA_3); -Ticker tick622103; PwmOut myServoPB_0(PB_0); PwmOut myServoPB_1(PB_1); - - +Ticker tick561436; void PID_Caculation() { Error = 0 - Position; @@ -60,7 +58,7 @@ } } -void tick622103_handle() { +void tick561436_handle() { Position = Position + qei_PA_0.getPulses(); qei_PA_0.reset(); Serial_2.printf("%d\n",Position); @@ -72,10 +70,12 @@ int main() { Serial_2.baud(9600); -tick622103.attach(&tick622103_handle,0.05); - +tick561436.attach(&tick561436_handle,0.05); Position = 0; qei_PA_0.reset(); +P = 1; +I = 0; +D = 10; while (true) { }