UART & I2C slow down a loop - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: UART & I2C slow down a loop (/thread-41329.html) |
UART & I2C slow down a loop - trix - Dec-23-2023 hello, I am working on writing a program for a stepper motor with a driver (pulse/dir). this is done with acc and decc. in the part with the constant speed I create the pulses for the driver with a for loop. but I need to be able to jump out of that for loop, with 2 conditions. 1 - I release the push button (touch screen) 2 - the limit switch has been reached (extended I/O board). the first comes in via UART (touchscreen). and the second comes in with I2C (extended I/O board). now I do that with "polling" the UART and the I2C. but this slows down the "loop". Now this can be solved by using interrupts for the UART and the I2C. but I had read somewhere that there was no interrupt for the UART. and I don't know if there is an interrupt for the I2C? Does anyone here know how I can best solve this problem ? thank you. RE: UART & I2C slow down a loop - deanhystad - Dec-23-2023 Threads? Does your platform support them? With threading you would do the UART and I2C in one thread and the velocity loop in a different thread. RE: UART & I2C slow down a loop - trix - Dec-24-2023 thank you. I forgot to tell you that I use the raspberry pico. I don't really know what you mean by threads, so i don't know ore the raspberry pico have them. RE: UART & I2C slow down a loop - deanhystad - Dec-26-2023 Quote:I don't really know what you mean by threads, so i don't know ore the raspberry pico have them.Lots of pages came up when I googled "raspberry pi pico threading". Threading is something you should know about. It is very useful when trying to do multiple things at the same time. RE: UART & I2C slow down a loop - trix - Dec-28-2023 ok using the 2nd core, that does indeed seem useful. I've never worked with that before. thanks for the input. |