Author Topic: Stepper motor  (Read 1180 times)

Rookie 2017

  • Newbie
  • *
  • Posts: 10
    • View Profile
Stepper motor
« on: September 01, 2017, 12:15:47 PM »
Hey guys,

We have a stepper motor with advanced driver from Automation direct.
Can someone tell me if it's possible, (and point me in the right direction  on how to) communicate with the driver via serial command from Adv hmi?

Eg. In the host window, "VE(XX)cr"  sets the velocity, how would I go about setting it up so I could enter that on the HMI screen and send to the driver?



Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5261
    • View Profile
    • AdvancedHMI
Re: Stepper motor
« Reply #1 on: September 01, 2017, 12:23:22 PM »
In the Toolbox, in the Components Group, is a SerialPort component. You can add that to the form, then use code to send commands. Something like this:

SerialPort1.Open()
SeriaPort1.Write("VE(xx)")
SerialPort1.Write(13)

Rookie 2017

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Stepper motor
« Reply #2 on: September 11, 2017, 03:34:44 PM »
Thanks, I am just getting back to this project now,

Can you give an example of how I would set the distance?

For example,
operator enters a number via keyapd, hits enter
that number prints a command of FLXXXXXX

timryder

  • Jr. Member
  • **
  • Posts: 83
  • Still trying to figure it out
    • View Profile
Re: Stepper motor
« Reply #3 on: September 13, 2017, 11:51:39 AM »

Go and get this .pdf from AutoDirect's website

https://cdn.automationdirect.com/static/manuals/surestepmanual/scl_manual.pdf

it tells you all of the commands on the first few pages but the Absolute move command is "FP" on page 30 of the document or "FL" for a relative move pg 27

"FPXXXXXX" where the x is the number of motor steps you want to move.

It looks like this stepper controller works in raw counts so if you wanted to move by Engineering units like mm or in then you'd have to do some math.
First determine how many motor steps it takes to move 1 engineering unit you want, let's take Inches (assuming you're using a linear stage and not a rotary chuck).

Most motors have 200 count/rev or steps/rev without Micro stepping turned on.  So lets say it takes 1000 steps to move the stage 1 linear inch then it's 1/1000 = 0.001" per motor step.
We don't know what interface you're trying to do but if you gave the operator a Text Box which is a standard control in Visual Studio and this was where they could type in the distance they wanted to go, you would simply convert it from a String to an integer and do math on it to get the number of steps to move.

Code: [Select]
Dim steps as Integer = Convert.ToInt16(Me.TextBox1.Text) / 0.001
You could do this on the TextChanged event of the textbox so it's always calculating the steps amount after they are done entering the value.

Code: [Select]
Public steps as Integer = 0
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
     steps = Convert.ToInt16(Me.TextBox1.Text) / 0.001
End Sub

Then if you wanted to have a button transmit that command to the stepper driver, you could do add a standard button to your form, then double click it to edit the Click event for the button.
Add some code like this in conjunction with what Archie has already told you above.

Code: [Select]
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Me.SerialPort1.Open()
    Me.SerialPort1.WriteLine(steps)
    Me.SerialPort1.Close()
End Sub

This is all incredibly crude but it would work.
Still just trying to figure out this thing called Life.

bachphi

  • Hero Member
  • *****
  • Posts: 642
    • View Profile
Re: Stepper motor
« Reply #4 on: September 15, 2017, 03:03:09 PM »
Nice, I would put some limits in the steps, just in case :=)
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================