Author Topic: Stepper Stepping Bit ?  (Read 13339 times)

Mark P.

  • Newbie
  • Posts: 6
    • View Profile
Stepper Stepping Bit ?
« on: January 13, 2019, 07:52:24 AM »
Hello

I have an application where I am useing several stepper functions.

All work well but I am in need of some way to know if the stepper output is putting
out pluses in the logic.

The really available on the STEPMOVE or STEPMOVEABS are very unreliable.

I have tried to look at the output that is stepping in the logic but at least a rung level it shows
nothing while stepping.

Any thoughts ?

If output pluses are being put out of output would like to know.
And turn this into a bit (stepper stepping)

Possibility there is some memory location behind the scenes I could look at ?

Thank you

Mark

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:Stepper Stepping Bit ?
« Reply #1 on: January 13, 2019, 03:31:16 PM »
Mark,

I think what you really what to know is when is the stepper controller busy and when the stepper controller has completed a move operation.

Please note that the argument "r" in the step move command allows you to specify an internal PLC RELAY to set when the STEPMOVE has issued "count" pulses to the stepper channel specified by "ch".

STEPMOVE ch, count, r

The STEPMOVE and STEPMOVEABS statements are "non-blocking".  These statements execute quickly and the TBASIC goes on to the next part of the program before any step pulses are issued. The actual movement of the stepper might take from a few milliseconds to a few millennia depending on number of steps in the "count" argument. You don't want the PLC hung up waiting for the stepper movement to complete.

For Stepper channel #1, I define a RELAY named Ch1CmdCmp and issue a stepper command like this:

StepMove 1,Ch1Arg1,Ch1CmdCmp

The RELAY named Ch1CmdCmp will be reset to 0 by the execution of the StepMove statement. The same RELAY will be set to 1 when the stepper motion has completed.  So when the CH1CmpCmp RELAY is 1 then you can issue a new StepMove or StepMoveAbs command. When the CH1CmpCmp RELAY is 0 the CH1 stepper controller is busy moving the stepper.

There is a small issue with the StepMove and StepMoveAbs, and this is that if the count argument would result in no stepper pulses being issued (no motion) then the RELAY, "r", will be cleared but will not be set to 1.  This is how I make the behavior of the RELAY consistent:


       ' The StepMove statement will not set the Ch1CmdCmp RELAY if the
       ' the statement will result in no physical motion of the stepper motor
       '
       ' The fix is to execute the StepMove statement and then
       ' set the Ch1CmdCmp RELAY
       '
       StepMove 1,Ch1Arg1,Ch1CmdCmp
       if (Ch1Arg1 = 0)
              SetIO Ch1CmdCmp       ' set the command completion RELAY
       endif



       ' The StepMoveAbs statement will not set the Ch1CmdCmp RELAY if the
       ' statement will result in no stepper motion
       '
       ' The fix is to test if the current absolute position is the same
       ' and the position specified in the argument to StepMoveAbs and after
       ' the StepMoveAbs statement is executed, set the Ch1CmdCmp RELAY to indicate
       ' that the statement completed
       '
       s = StepCountAbs(1) - Ch1Arg1       ' s is the distance to the new position
       StepMoveAbs 1,Ch1Arg1,Ch1CmdCmp       ' issue the stepper command
       if (s = 0)
              SetIO Ch1CmdCmp       ' the Ch1CmdCmp Relay will not be set, so force it.
       endif



I have posted a full up stepper motor test system on this forum.  I have included documentation, PLC firmware as a .pc6 and firmware to support a the MT8050iE HMI that TRI offers on their website.

This code provides a full stepper test system for a single stepper.  The PLC code is very small and very fast and uses all of the stepper commands.  The code can be run without hardware with the simulator and if you have no HMI, you can run the code on real hardware using On-line monitoring.  I think that I put hints in the documentation on these things.

Look for the topic: "Stepper Motor Demo Code".
The posting date was May 02, 2018, 03:10:38 PM.
http://www.triplc.com/yabbse/index.php?board=1;action=display;threadid=2347

Best regards,

Gary D*ckinson

[Forum Editor's Note]: Have edited this post and removed the funny characters that were present in the original post.
« Last Edit: February 08, 2019, 01:15:21 PM by support »