2024-10-29 09:07 AM - last edited on 2024-10-30 02:22 AM by Peter BENSCH
Hi all, I'm using a L6482H on a PCB with STM32F439VIT6 to drive a stepper motor.
MCU and driver are connected via SPI.
I have an issue with the GetStatus command; when the switch input on the L6482H is closed and the driver receives a GetStatus command, sometimes it moves the stepper motor to order to open the switch input.
It does not move the motor everytime, but sometimes it happens. I tested this behaviour by repeatedly sending the GetStatus command with the switch closed (200 ms between every command).
If the MCU send a MOVE command and ask the Status continously to test the "Busy" flag, the drive sometimes moves incoerently. It seems to happen when the Status is asked with the switch closed.
Is there any relation between the GetStatus and the Switch input? I configured the drive to don't use the switch as "HARD STOP" interrupt (SW_MODE = 1 in CONFIG register) and the ALARM_EN mask the external switch condition
Thank you for the support.
Solved! Go to Solution.
2024-11-04 04:43 AM
Hello @Dan_ST and welcome to the ST Community.
It seems that during communication something went wrong: for some reason a command is sent, which is not a GetStatus, causing the motor movement.
I suggest you to monitor the SPI signals to verify that there are no communication problems and that the timing of the signals is always respected.
2024-11-04 04:43 AM
Hello @Dan_ST and welcome to the ST Community.
It seems that during communication something went wrong: for some reason a command is sent, which is not a GetStatus, causing the motor movement.
I suggest you to monitor the SPI signals to verify that there are no communication problems and that the timing of the signals is always respected.
2024-11-05 11:42 PM
Hi Cristiana, thank you for the reply. I will check the SPI signals and communications, but I don't understand why everything seems fine if I don't connect any sensor and I have random problems when the sensor is working. It seems that there is some interaction that makes the motor running incoherently.
I'm giving the MOVE command (1600 steps), then I read continously with the GET_STATUS the busy flag then, when the MOVE is done, I wait a certain time with a HAL_Delay command. I checked that nothing change if the pause time is short or long.
When the sensor on the switch input is disconnected, everything seems fine, with the motor stopping at the same position every cycle, but if I connect the switch, sometimes, the motor run incoherently, changing the stop position or running indefinitely.
How the switch can interact with the SPI or movement? I tried to MASK the switch event in the ALARM_EN setting, but nothing changed.
Thank again for the support.
2024-11-08 07:21 AM
Hi Cristiana, I solved the problem.
It was a command related issue ineed, but related to the HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout) routine; this routine use the pData array you want to be "filled" with the SPI answer you're expecting, to perform a HAL_SPI_TransmitReceive(hspi, pData, pData, Size, Timeout).
I expected this routine send a 0x00 message to collect the data from the slave, but it actually sends the present value of pData and if you don't clear your pData before calling HAL_SPI_Receive, you may have command errors.
Thank you for your hint.
Regards