Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1275

Python • Re: Stepper control via PIO for a dosing device

$
0
0
Took your project to make my first steps into the PICO PIO programming.

I introduced a (boolean) flag dosing. The flag is set (True) when a new_cycle is started. It is cleared (False) when the cycle is finished; the pio statemachine generates an interrupt (IRQ0) at the end of the cycle, and an interrupt handler than clears the dosing flag.

The dosing flag is checked in the new_cycle function (called when the inject button is pressed).
When dosing is set, just bail out (return). Otherwise kick the statemachine by putting the two values Inject_Steps and Reject_Steps.

Attached the modified code; my modifications are marked with jehutting.

The output on the (visual code) terminal

Code:

>>> welcomenew_cycle...oknew_cycle...skippednew_cycle...skippedCycle finishednew_cycle...okCycle finished
main.py.zip

Statistics: Posted by jehutting — Sat Jul 27, 2024 5:38 am



Viewing all articles
Browse latest Browse all 1275

Trending Articles