Connecting the FL86STH65-2808A Stepper Motor to a Microcontroller.

The other day I got my hands on an FL86STH65-2808A stepper motor with an SMD-4.2 driver, and the task was to learn to control it with a microcontroller.

First, the motor needs to be connected to the driver: 8 wires come out of the motor, and they can be connected in two ways, as shown in the picture below.
Connecting the FL86STH65-2808A Stepper Motor to a Microcontroller.


With the windings connected in series, maximum torque can only be achieved at low speeds, while power consumption is low; the advantage of the parallel connection shows at high speeds — the torque drops more slowly than with the series connection; the drawback is higher power consumption. The torque versus speed graph is shown in the picture below.
Connecting the FL86STH65-2808A Stepper Motor to a Microcontroller.

In my case it's important that the motor has enough torque at high speeds, so I connected the windings in parallel.

We twist the wires together and clamp them in the terminal block.
Connecting the FL86STH65-2808A Stepper Motor to a Microcontroller.

To get the required current, I specially bought a 48-volt power supply, but for tests you can use an ordinary computer power supply.

What did I mean by getting the required current?

Since we connected the motor windings in parallel, the current through the motor equals Iphase * √2 or 1.4*Iphase. This is very easy to understand: the documentation specifies the rated current of a winding/phase and its resistance. The maximum power consumed by the motor stays the same for parallel and series winding connections and is equal to

P = (Iphase)² *R


With the windings connected in parallel, the total resistance of the motor is half the winding resistance; let's substitute it into the formula

(Iphase)²*R = (I)²*½ R


I = Iphase *√2


Which is what we needed to prove.

The power lines are connected; all that's left is to connect the signal lines. Three signals are used to control the motor: ENABLE, DIR and STEP; their names make it clear what each one does. For those who studied German at school, let me explain: the level of the DIR signal determines the direction of rotation, and a step is taken on each edge of the STEP signal. The motor windings are de-energized when the ENABLE signal goes from low to high. The oscillogram of the control signals is shown below.
Connecting the FL86STH65-2808A Stepper Motor to a Microcontroller.


If you look at the driver, you can see that 6 inputs are provided for the control signals instead of three; this is done so that the motor rotation can be controlled with signals of either polarity.
Connecting the FL86STH65-2808A Stepper Motor to a Microcontroller.

The current through the signal lines can be from 10 to 16mA, so they can be connected directly to the MCU pins.

As the source of the control signals we'll choose an open-collector circuit; below is the diagram of connecting the driver to an Atmega16.
Connecting the FL86STH65-2808A Stepper Motor to a Microcontroller.

Now let's write code so that when one button is pressed the motor turns in one direction, and when the other button is pressed, in the other.

#define F_CPU 8000000UL

#define en 0
#define dir 1
#define step 2
#define bt1 3
#define bt2 4

#define forward PORTA |= (1<<dir);
#define reverse PORTA &= ~(1<<dir);

#include <avr/io.h>
#include <avr/delay.h>

void spin_motor(void)
{
	uint8_t i;
	for (i = 0; i < 50; i++)
	{
		PORTA |= (1<<step);
		_delay_ms(2);
		PORTA &= ~(1<<step);
		_delay_ms(2);	
	}
	
}

int main(void)
{
	//signal pins as outputs
	DDRA |= (1<<en) | (1<<dir) | (1<<step);
	//pins the buttons are connected to as inputs
	DDRA &= ~(1<<bt1) | (1<<bt2);
	//with pull-up
	PORTA |= (1<<bt1) | (1<<bt2);
	//energize the windings
	PORTA |= (1<<en);
	
	while(1)
	{
		if(!(PINA & (1<<bt1)))
		{
			forward;
			_delay_ms(5);
			spin_motor();
		}
		
		if (!(PINA & (1<<bt2)))
		{
			reverse;
			_delay_ms(5);
			spin_motor();
			
		}
	}
}

In the control signal oscillogram taken from the datasheet, the delay between commands is given in microseconds, but with such a delay the motor didn't turn, so I had to increase it. I'd also like to note that in holding mode the motor makes a loud hissing sound at any winding current; forums say this is caused by magnetostriction.
I asked a consultant from the http://electroprivod.ru website about the hissing; he said it was normal, but I have another motor that, admittedly, has only 2 phases, and it doesn't hiss. So it turns out that hissing in holding mode is not a mandatory attribute of stepper motors but an extra feature that everyone would be glad to get rid of)))