cancel
Showing results for 
Search instead for 
Did you mean: 

L6474 communication works but motor is not turning

ZHama.1
Associate II

I have connected various stepper motors to multiple x-nucleo-ihm01a1 shields on a NUCLEO F466RE.

The code is the same as ST's X-CUBE-SPN1 (i just changed the function names) In main() after SPI has been initiliazited at 2MHz at mode 3, I set the registers to their init settings ( begin() ) then attempt to move the motor forward 16000 steps.

L6474 myL6474;
 
  int32_t pos;
  uint16_t mySpeed;
 
//----- Init
  /* Start the library to use 1 shield */
  /* The L6474 registers are set with the predefined values */
  /* from file l6474_target_config.h*/
  myL6474.Begin(1);
  chThdSleepMilliseconds(500);
 
//  /* Move shield 0 of 16000 steps in the FORWARD direction*/
  myL6474.Move(0, FORWARD, 16000);
  
// See whats happening in status register after move command
  myL6474.GetStatus(0);
 
//  /* Wait for the motor of shield 0 ends moving */
  myL6474.WaitWhileActive(0);
 
 

The SPI communication is working as the waveforms show the right commands (commands in hex on the right side of screen). (Pic 3 is init , pic 2 is move 16000 steps, pic 1 is get status .... pics are in reverse order.

The motor gets powered but is stuck and doesnt move and the program gets stuck forever at the WaitWhileActive() command. On sending the getstatus command, none of the error flags are triggered and HiZ is low as desired. Everything looks good unless i've missed something, why doesnt the motor move?0693W00000WIwHTQA1.jpg 

0693W00000WIwGuQAL.png0693W00000WIwGpQAL.png0693W00000WIwGGQA1.png

1 REPLY 1
KiptonM
Lead

You need to put logic probe on the STCK and DIR pins. The motor will turn when the STCK steps. I am surprised you got as much as you did to work. Their code is from 2016 and the STM32CubeIDE has changed a lot since then.

For my first try I made a simple loop to change the STCK pin without using the timer. Just to make it move. Start slow. On my stepper I started too fast and it missed steps. So start with something slower than 400 Hz. And it should move if your parameters are not too far off.

PWM pin is connected to the STCK pin.

void SM_Simple_Steps(uint32_t steps, uint32_t delay)
{
	uint32_t i;
	uint32_t j;
 
	for (i=0;i<steps;i++)
	{
		HAL_GPIO_WritePin(PWM1_GPIO_Port, PWM1_Pin, GPIO_PIN_RESET);
		for (j=0;j<delay;j++) __NOP();
		HAL_GPIO_WritePin(PWM1_GPIO_Port, PWM1_Pin, GPIO_PIN_SET);
		for (j=0;j<delay-16;j++) __NOP();
	}
 
Then call it with this:
 
uint32_t steps;
uint32_t delay;
steps = 400;
delay = 8000;
 
SM_Simple_Steps(steps, delay);
 

Try to make it do 1 revolution. I put a paper clip on the shaft so I could see the position.

Once this works, then try to get the timer function working.

Kip