Quadrature Encoder Analyser

Hi,

I was wondering if I could get some advice on how best to interface with my Saleae Logic 16 for a project I am working on.

Basically I have a stepper motor with a quadrature encoder and I am looking to characterise that motor within a mechanical system. The quadrature encoder outputs two square wave signals as shown below:

image

Basically the number of rising edges gives you the distance moved, the time between the rising edges gives you the velocity, and finally the phase of the two signals gives you the direction. In this test setup I am only interested in distance and velocity, so will only need to analyse one signal.

What I would like is to be able to begin recording before the motor begins to move, wait for a predetermined time for the motor to finish moving, and then to stop recording. When recording has commenced I would then like to plot a graph of distance and velocity against time, and also print out the total distance moved and average velocity.

I am happy to have some user intervention (starting and stopping the capture or a script for example) but would like to automate as much as possible - we will be conducting hundreds of 10s tests.

My question then (and thanks for sticking with me this far) is what would be the recommended way to do something like this? Can this be done as an extension or measurement from within the Saleae Logic 2 software or do I need to use the automation SDK without the Logic Software?

In principle if I could get a dump of the edges, the time of the edge, and it’s type (rising or falling) then the velocity and distance I am looking to measure would be easy to compute in python. I would like to ideally automatically start the logic 16 and save the dump somewhere before reading and processing all in one script.

Thanks!

@mattc Thanks for describing your use case in detail! I’d like to start off by saying that Logic 2 doesn’t have support for our Automation API just yet, so there will be some amount of user intervention required because of this. We also don’t have a way of directly exporting measurements (although we have the measurement tools available in the UI to measure things like number of edges and frequency and pulse widths).

One way to do what you need, assuming you will only capture data from 1 channel (A or B).

  1. Set your capture as a “Trigger” mode capture
  2. Set up a rising edge trigger on the channel of interest
  3. Set your “Capture duration after trigger” for the predetermined time you expect
  4. Start the capture → Begin your motors. Trigger should automatically begin the capture when the first rising edge occurs.
  5. Once the capture is complete, you can use a measurement box to take your measurements.
  6. Our default “Clock Stats” measurement extension (pre-installed) will allow the measurement box to report the number of edges and avg frequency within the measurement box.

Info on measurement boxes below:

When recording has commenced I would then like to plot a graph of distance and velocity against time, and also print out the total distance moved and average velocity.

Unfortunately, we don’t currently have a way of plotting measurements over time or in table format, but this is certainly something we want to add to the software in the future. Here is the idea we are tracking below. If this is something you’d need, please add your votes/comments to it to help us with prioritization.

In principle if I could get a dump of the edges, the time of the edge, and it’s type (rising or falling) then the velocity and distance I am looking to measure would be easy to compute in python. I would like to ideally automatically start the logic 16 and save the dump somewhere before reading and processing all in one script.

For your ultimate goal above, our older Logic 1.x software could support this. This would be a much more involved approach, but would provide the automation you need. The export file would contain raw data (txt/csv format) of the edge transitions, and the timestamps of the transitions, and you can automate the capturing of data and exporting of the underlying data. Once exported, you would need to create an external script to parse it. Again, much more involved than above. Information on our automation API is below:

Automation API:

Logic 1.2.29:
https://support.saleae.com/logic-software/legacy-software/latest-beta-release

I hope this helps!

Although you can’t automate Logic 2 yet, you can write high level analyzers in Python and use your analyzer to write whatever you want to a file. You could for example create a CSV file containing time, edge and channel data, then process that externally to create graphs or whatever else might be required.

With a little cunning you could end up with a system that just required clicking the start button in Logic2 to kick off a complete measurement and analysis cycle.

1 Like

Many thanks for the detailed responses.

I have now written a python script making use of the automation API for the Logic 1.x software that works a treat. Exactly what I was looking for.

Would love to see this functionality in Logic 2!

Hi Matt,
I’m a product manager here at Saleae and wanted to see if you might have some time to walk me through how you finally implemented this and what was difficult/easy in the process. You can find available times for me here: Calendly - Neel Banerjee
Thanks,
Neel

Hi Tim,

When will the automation API be available with 2.x, I like the new version and would prefer not going back to 1.x?

I have almost exactly the same quadrature decoder use case as Matt so I’d like to externally control my Logic 16 via socket API to start the capture and export the data for each run, ideally also running a measurement automatically after each run.

Thanks,
Andrew

@aqueisser Thanks for checking on this. We currently don’t have this on the roadmap just yet, as we have some higher priority tasks to accomplish. Sorry that you’ll have to use Logic 1.x in the meantime…

The Automation API is in fact the most requested feature thus far for Logic 2. See the feature request we are tracking below. I went ahead and added a comment to that idea post with your need.
https://ideas.saleae.com/b/feature-requests/application-api/

Feel free to add your vote to it and any other comments you might have! We’re certainly aware of everyone’s need for it. It’s a big update and would require a fairly large effort to get this added in.

In the idea post above, it could also be useful to understand what kind of automation features you would need at a bare minimum, so we can have an idea of which functions to prioritize when we get to working on this.