Author Topic: Stepper Motor Control  (Read 13724 times)

cthompson

  • Newbie
  • Posts: 7
    • View Profile
Stepper Motor Control
« on: February 02, 2013, 01:41:10 PM »
I am new to Ladder Logic Programming and am sure that this will be the first of many questions to come, so please be patient.
Is it possible to send one pulse to a stepper motor driver?  I have an application in which certain motors will index one step at predetermined intervals.  
I cannot seem to do this in the simulator.  When i set the stepmove command to 1 step, the popup in the simulator says it moved 0 steps.  Anything two steps or more works fine.
I would like to do this without microstepping if possible, as i read that it reduces torque.
Also, is there a command to clear all IO without clearing the Data Memory?  I have certain DM locations that i would like to retain duiring a stop condition.

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Stepper Motor Control
« Reply #1 on: February 04, 2013, 02:56:24 PM »
In T100MD+ and T100MX+ PLC the minimum number of steps to be sent to stepper motor is 2. The simulator still adhere to that convention and does not simulate single step.

If you are using a Nano-10, FMD or F-series PLC you can send a single step (STEPMOVE of 1 step) to the stepper motor controller/driver.  The simulator may not show single step but the actual PLC is able to output single step.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

cthompson

  • Newbie
  • Posts: 7
    • View Profile
Re:Stepper Motor Control
« Reply #2 on: February 04, 2013, 06:55:50 PM »
Thank you for your prompt reply.  I have purchased the F2424, but have not put it into operation.  I am in the process of finishing the programming on the simulator before sending to the PLC.
I have another custom function/stepper control question.  I am using a while loop to read the value from an analog sensor attached to ADC(1).  This is compared to a set value and the stepper moves a number of steps until the values converge.  
Will the loop pause until all the stepper has moved, or will the loop continue?  
In the case that the values don't converge, i have set the loop to exit after 100 iterations. I don't won't the loop to exit until the stepper has moved as required, but also don't want to end up in an endless loop.

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Stepper Motor Control
« Reply #3 on: February 05, 2013, 12:33:10 AM »
If you put a while loop to read the ADC the CPU will be spending all its time at the while loop until the program exit the while loop. This may be acceptable in certain situation but it could also mean the PLC is not processing other parts of the program, which may not be desirable.

A better way is to run the custom function once every scan (use {CusFn} ) to read the ADC and check the position. This will work if you don't have other part of the program that could hold up processing (e.g. another long while loop)

Another way is to setup a periodic timer interrupt (PIT) such that at every fixed time period your custom function is called and the program can check the ADC readings and make the control decision.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

cthompson

  • Newbie
  • Posts: 7
    • View Profile
Re:Stepper Motor Control
« Reply #4 on: February 07, 2013, 11:38:50 AM »
Thanks for the reply.  This is to be used as a calibration loop which will set the stephome position for stepper channel 1.  After calibration, the loop would not be run until the next time calibration is required. This is the loop portion of the calibration routine.
STEPSPEED 1,300,50
J=2307 ' Approximate Number of Steps per Unit Change in ADC Value.  (Actual Value is .2307)
C=0
A=ADC(1)   'Get Value of ADC Channel 1
E=DM[303]-A  'Calculate the differnce between the Target Value and the ADC Reading

WHILE ABS(E)>4 AND C<100
   V=E*J/10000
   STEPMOVE 1,V,150
   A=ADC(1)
   E=DM[303]-A
   C=C+1
ENDWHILE

My concern was that the loop would be sending a new stepmove command before the previous command had finished executing.  If this is the case, then the ADC(1) value would be read before the stepper had finished moving.  This could cause the loop to never converge.  That is why i had asked if the loop continued processing even if the stepper had not completed the move.
Thank you for your help.

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Stepper Motor Control
« Reply #5 on: February 10, 2013, 01:04:52 AM »
Running a STEPMOVE on a stepper channel that is already in motion will have no effect as the PLC will ignore the command. STEPMOVE can only be run when the stepper motor has already completed its last movement or was forced stop by STEPSTOP command.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS