Motor Controller Labview/TestStand Example

Motor_Control_Labview_TestStand.zip (1.7 MB)
I created a library of VI’s and packed library that can be used as-is within LabView 2018 and called from TestStand to drive various features of the motor controller. It was only tested with the T249 but was built using the CS_ClassLibrary_TicDotNet.dll I created. I included the original TicDotNet files created by jigarciacortazar (or maybe Daniel Castelli for PyTic) but with a small change to make the Tic class public plus I added Forward/Reverse/Homing enums as boolean variables. Otherwise the TicDotNet.dll isn’t able to be used directly in LabView without being a public class.

I created this in order to test product that uses stepper motors where we might run up to 10k a year. The product doesn’t include a controller as it’s only a sub-assembly (the brains are added later as a higher level assembly) so the T249 was a quick solution to include in my test system. However we need to read back important info and also include safety features to avoid over-driving the different assemblies and/or operator safety. So Kill Switch and Limit Switches were important outputs we wanted to monitor.

The VI’s call the CS_ClassLibrary_TicDotNet.dll and you can select public methods like Energize, Get Step Mode, etc. It relies on the LibUsbDotNet.LibUsbDotNet.dll which the project includes when building a packed library.
In the Pololu_T249_Test.vi the Open and Close calls are included and the middle sub-vi can be any of the Public VI’s I created so far. For example, if you’d like to see all controller variables you could call Get_Status. Or if you’d like to drive the motor until it reaches a Forward or Reverse limit you could use Pololu_T249_Motor_Drive_to_Limit.vi. This assumes you have configured the DIO pins of your controller of course :). The velocity is set with an RPM instead and auto-calculated based on step-mode, steps-per-rev (motor dependent) and accel/decel profile (default is just the velocity divided by 10 but can be adjusted as needed).

I’ll be adding more features as I continue debugging and designing test systems with this controller so I’m providing what I have as-is for anyone’s use. For the most part, it’s as complete as it needs to be. If you have any suggestions or want any features added let me know and I’ll see what I can do with the time I have available.

thanks!

Quick update, I accidently mis-read how the step mode input works. It was a numeric parameter (selector of 0-5) so inputting “32” would cause some funky motor sounds. I updated the appropriate VI’s so that the step mode is now a drop-down selector (ring control) instead.
Also added a few features such as Enter/Exit Safe Start and Clear Driver Errors. Also you can input the RPM instead of the velocity and the VI figures it out for you based on Step Mode and the motors steps-per-rev.
For ease of use, I include a Test VI that should be able to run stand-alone (if you have LabView). It includes input settings of Controller Type, Serial Number, and RPM values. The Steps-per-rev, step mode, and max speed/acel/decel are default values that worked for my use.

Motor_Control_Labview_TestStand.zip (1.7 MB)

Thank you for sharing your work! We do not use LabVIEW, so we have not tested it, but it sounds great and I’m sure a lot of people will find it very useful.

Brandon

Hi,

I never sign up to anything, but this site I did to let you know how much I appreciate your efforts on this one. I was half a day into developing my own when I thought I should have a deep dive in the forums.

Great work!!

I’m glad to hear it will be useful! I had a few changes to the VI’s worth sharing based on on-going debug in our lab here. Since it’s been a few months, I can’t say what specifically changed without comparing each VI but the source DLL should still be the same.
Have fun and let me know if you find anything you felt was worth changing!
Pololu VI’s.zip (830.4 KB)

1 Like