![]() |
Forum Index : Microcontroller and PC projects : Pimoroni Motor 2040
Author | Message | ||||
Tinine Guru ![]() Joined: 30/03/2016 Location: United KingdomPosts: 1646 |
Using the PIO for QEI (quadrature encoder interface) ![]() Craig |
||||
circuit Senior Member ![]() Joined: 10/01/2016 Location: United KingdomPosts: 277 |
Absolutely fascinating. Is there any possibility of programming this with Micromite Basic instead of Python whilst keeping the PIO operational? Probably a big ask... |
||||
Tinine Guru ![]() Joined: 30/03/2016 Location: United KingdomPosts: 1646 |
It's a question for our resident PIO wizards. I seem to remember Volhout doubting the possibility....dunno. Craig |
||||
Tinine Guru ![]() Joined: 30/03/2016 Location: United KingdomPosts: 1646 |
The PIO would be ideal for 3-phase commutation, it's all state machine stuff and we already have lots of PWMs. ![]() Craig |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5089 |
The PIO should be capable enough to read the quadrature encoders. The bottleneck is in the communication from PIO to MMbasic. But now I have proven the MMBasic PIO EXEC works I am pretty sure we can do this. The system would have to work like this: The PIO would decode the quadrature encoders to a 32 bit number in the ISR (input shift register). The control loop in MMBasic would run on a fixed frequency (SETTICK) and the interrupt would execute a PUSH instruction in the PIO forcing it to push the ISR into the FIFO. The MMBasic program reads the fifo, calculates the speed and current position, performs the PID and sets PWM accordingly. So yes, it can be done with the current knowledge I have. Multiple motors would require multiple PIO state machines, running the identical code. The complexity is in time syncronizing of the MMBasic PID control algorythms. Not so important for independent axis, but more so for dependent axis (like running a car in a straight line). Edited 2022-10-23 05:58 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
Tinine Guru ![]() Joined: 30/03/2016 Location: United KingdomPosts: 1646 |
Not a big deal. Should be able to handle 4 PIDs comfortably with a SETTICK 5 and then every 10ms, run the trajectory planner. Not much computation at all. ![]() Craig Edited 2022-10-23 07:21 by Tinine |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |