2024-05-06 06:36 AM
Hello everyone,
i'm working on a programm on a Nucleo-L031K6 that send data to a stepper motor's driver (Enable, Direction and Pulse).
It's a basic program that receive instruction from a python script (i send frames). I've a callback function which is triggered at every interruption (basically at every bytes of my frame). At every interruption bytes are stored in a table and at the same time the programm look at the bytes to see what's in, and instructions are done when specific data have been sent. When the full frame is received the programm enter in a switch case that put pins on high levels in terms of the frame.
My problem is that when i send a frame my stepper motor just keep rotating without stopping but he should stop and i dont know why at all. I ran my programm in Debug mode but it worked perfectly so i'm completly lost. There is a problem in the code but i dont find it.
I dont have any compiling error or warning.
Thanks by advance for your help and i put the callback, switch case and library that contains all function for the stepper motor.
2024-05-06 07:04 AM
what kind of motor are you using those small 5V ?
it keeps rotating because it receives pulses.
I do not know what kind of controller but it keeps sending pulses as long as it receives from your Nucleo-L031K6
2024-05-06 07:16 AM
To be more precise i dont have the motor and the driver yet. I use and oscilloscope to see if the direction pin go on high level, i use the internal green LED to see if the Enable pin is controlled or not and i put an external red LED to see if the pulse is sent, so i see if the red LED is blinking.
I know the frame (i created a script to send always the same frame 1300100 in order to find the problem) is received by my board because every pins and LED that i talked about just above are on high level so if you look at my switch case i go till the function movechariot(receiveddistance) and i cant get out from this function and do the rest of the programm. But i keep looking for any error or problems in this function but i definitely cant find it.
2024-05-06 07:18 AM
But i agree with you because i see it, the board keeps sending the pulse and also the other data.
The execution gets stuck in movechariot function.