Stepper motor position from step signal

Forum for discussing PicoScope version 6 (non-automotive version)
Post Reply
Posts: 0
Joined: Sun May 19, 2019 7:32 pm

Stepper motor position from step signal

Post by biiber » Sun May 19, 2019 9:39 pm

Hi there,

I am trying to trace the stepper motor position over time by measuring the STEP signal on the circuit.
The direction signal is ignored.

I have found a quick & dirty solution:

The STEP signal outputs a 4.153us pulse @ 3.767V for every step on channel B. This corresponds to 15.64uVs per step. My example shows 1000 steps. Accumulate all the steps with integral(B). This should result in a final value of 15.64mVs.

The measured value has an error of 66% (see attached screenshot).
A slight offset of the input channel accumulated to the final value. And due to time quantization, each pulse width is sightly bigger or smaller than 4.153us, depending on the sample rate.

Math functions:
freq(B) represents the motor speed (orange)
integral(B) represents an approximation of the motor position (black)

This method gives a rough idea of the SHAPE of the motor position over time, but not the absolute value.


A much more elegant solution would be a math function called stepcount(), which increment the trace value at every rising or falling edge over time. This would deliver a perfect representation of the motor position over time, without any drifting.

The measurement "edge count" counts the number of edges over the whole trace but delivers one static value.

The picoSDK may allows such functionality, but a build-in math function stepcount() like freq() and integral() would be much more intuitive and available for all users.

Does anyone know a workaround for this?

I am using the Picoscope 3206b with PicoScope

Thanks for your help!
(2.18 MiB) Downloaded 64 times

Posts: 471
Joined: Mon Aug 11, 2014 11:14 am

Re: Stepper motor position from step signal

Post by Gerry » Mon May 20, 2019 6:02 pm

Hi Biiber,

I'm not sure that you can do what you ask in the currently available Math Channels. The only way I can think of doing it is to integrate the number of cycles of B across the range of interest while multiplying by your more accurate voltage value. So, your function would be integral(freq(B)*T)*15.64 (or if you wanted the measured value of voltage it would be the running average value, i.e. integral(B/T) ), which crashes the calculation (which seems to be related to the way Time with a frequency calculation is combined).

I will put in a bug fix request for (Freq * T) used in a Math Channel.


Technical Specialist

Post Reply