Jun-23-2024, 04:57 PM
hello,
why am I working on the 2nd core?
I am working with a stepper motor that makes a movement from left to right, which takes about 25,000 pulses, 1 pulse is about 1 millisecond.
for every 100 pulses I want to send a message over the UART, which takes about 75 milliseconds.
but the movement of the stepper motor must remain smooth.
so I think: I send a start veriable every 100 pulses to the 2nd core, and let the message be sent there.
I think that should just work.
I am testing that in the code below.
Now I actually have 2 questions:
1 - Does that work with the method I want to use?
2 - I get an error message in this code: where is the error comming from ? the global with test is working fine.
thank you in advance.
why am I working on the 2nd core?
I am working with a stepper motor that makes a movement from left to right, which takes about 25,000 pulses, 1 pulse is about 1 millisecond.
for every 100 pulses I want to send a message over the UART, which takes about 75 milliseconds.
but the movement of the stepper motor must remain smooth.
so I think: I send a start veriable every 100 pulses to the 2nd core, and let the message be sent there.
I think that should just work.
I am testing that in the code below.
Now I actually have 2 questions:
1 - Does that work with the method I want to use?
2 - I get an error message in this code: where is the error comming from ? the global with test is working fine.
thank you in advance.
Traceback (most recent call last): File "<stdin>", line 33, in <module> SyntaxError: identifier redefined as global
from machine import Pin
import machine
import utime
import time
import _thread
button=Pin(22, Pin.IN, Pin.PULL_DOWN)
led_15 = Pin(15, Pin.OUT)
led_15. value(0)
led_16 = Pin(16, Pin.OUT)
led_16. value(0)
test = False
def core1_task():
global test
while True:
time.sleep_ms (5)
if test == True:
led_15. value(1)
time.sleep_ms (1)
led_15. value(0)
print ("meassage frome core_1")
test = False
_thread.exit()
once = 0
while True:
global once
led_16. value(1)
time.sleep_ms (1)
led_16. value(0)
time.sleep_ms (5)
if button() == 0 and once == 0:
once = 1
test = True
_thread.start_new_thread(core1_task, ())
print ("meassage frome core_0")
I'm not French, but from the netherlands
