Investigating a DRV8834 Stepper Motor Driver

The Barometer uses small car dashboard stepper motors for driving the dials, but it has never been entirely satisfactory as the dials easily lose position.  This seems to be due to random movement, especially because they sometimes flip backwards a notch at the end of their motion as described here: Inaccurate stepping.  I am now trying to get to the bottom of this, using the oscilloscope I acquired for the purpose.

The steppers are bipolar, meaning they have two coils which need to be energised in a certain sequence.  For the reasons mentioned here: Thinking about the electronics I bought DRV8834 low-voltage stepper drivers to operate the dials.

With these drivers, you only need to set the direction and supply the pulses.  There is a pin to wake or sleep the drivers when not used, which is great because the barometer only changes when the weather forecast is updated and the dial hands will stay in place when not energised.

The drivers can be set to move in full steps and fractional steps.  However, fractional steps required the motor coils to be kept energised, so I was intending to use full steps.

Connecting the Oscilloscope

My oscilloscope has four input channels: in essence, each channel measures the voltage on its input, relative to ground.  In common with most electronics, my circuit has the negative rail grounded, but to ensure a good ground connection, I connected the negative rail of the circuit to the ground connection of the oscilloscope.  (Oscilloscopes have a very high input impedance, so without a good ground, the signal will can be obscured by mains ‘hum’ and RF pickup, giving a fuzzy display.)

I selected a particular stepper and connected Channels 1 and 2 to opposite ends of motor coil 1, and Channels 3 and 4 to opposite ends of motor coil 2.  Using a short Python routine, I sent ten 2 ms pulses to the motor.  The pulses are preceded by raising a wake signal to the driver and terminated by dropping the wake signal.

Two coils being pulsed


Two coils displayed

The above oscilloscope display shows a sequence of 10 pulses on motor coil 1 (ch1 = yellow, ch 2= blue) and motor coil 2 (ch 3 = Green, ch 4 = Red).  Using 1 to represent high and 0 to represent low, we can see:

1 0 0 1
1 0 1 0
0 1 1 0
0 1 0 1
1 0 0 1
1 0 1 0
0 1 1 0
0 1 0 1
1 0 0 1
1 0 1 0

Looking at this sequence both coils are always energised, but in a sequence that rotates:
coil 1 north, coil 2 south
coil 1 north, coil 2 north
coil 1 south, coil 2 north
coil 1 south, coil 2 south

After the last long pulse, there is a short but strong pulse on 2 and 4, equal to 0101.  I’m assuming this is generated by the ‘sleep’ pulse, as the motors are then de-energised.

The horizontal scale represents time, at 5 ms per division so each pulse lasts for 4 ms. I had assumed that the coils would only be energised for the time that the pulse pin was held high, followed by an un-energised pause, but this is not the case: the pulse pin is held high for 2 ms, then set low for the 2 ms pause before the next pulse, but the coils remain energised in their current state until the next pulse.  This makes sense where microsteps are obtained by partial energisation of the coils.

The final step in the sequence will depend on how many pulses were sent.  If it is not a multiple of four, the motor could end up in some random end state such that it might not be able to respond to the initial pulse, as I don’t suppose the chip remembers the last state it was in.  So it could lose as many as three pulses on each movement, which over a few days would certainly throw it out.  The answer would be to round the pulses to a multiple of four.

I am also concerned as to why the voltage on ch1 is only about 0.5 V and on ch 2 about 4 V – this means coil 1 is energised more strongly in one direction than the other – but this is something for later.

So now I have something to work on!



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.