Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
UART & I2C slow down a loop
#1
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.
Reply
#2
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.
Reply
#3
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.
Reply
#4
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.
Reply
#5
ok using the 2nd core, that does indeed seem useful.
I've never worked with that before.
thanks for the input.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to clean UART string Joni_Engr 4 2,503 Dec-03-2021, 05:58 PM
Last Post: deanhystad
  UART Serial Read & Write to MP3 Player Doesn't Work bill_z 15 5,853 Jul-17-2021, 04:19 PM
Last Post: bill_z
Smile send hexadecimal package variable UART santos20 2 2,205 Oct-30-2020, 11:40 AM
Last Post: Larz60+
  wrong data reading on uart fahri 6 3,390 Sep-29-2020, 03:07 PM
Last Post: Larz60+
  Slow loop due to row & column consolidation Etrigan 0 1,934 Nov-27-2018, 05:06 AM
Last Post: Etrigan

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020