Author Topic: Changing STEPSPEED  (Read 16029 times)

acxysty

  • Newbie
  • Posts: 35
  • I'm a llama!
    • View Profile
Changing STEPSPEED
« on: October 13, 2019, 01:36:30 AM »
I want to increase/decrease slowly the PPS of a stepper motor without going through acceleration/decceleration phases from/to 0. Is that possible using the STEPSPEED command ?

In different topics it is said that it is possible to modify the PPS of a stepper motor using the STEPSPEED command providing this is not done during the acceleration or decelarration phases.

By doing so is the PPS be varied 'level' by level with going down to 0 each time?

Thank you in advance

Regards

Thierry


garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re: Changing STEPSPEED
« Reply #1 on: October 13, 2019, 04:23:30 PM »
Thierry,

You will have to test this.  I have tested most of the stepper motor hardware and firmware, but have not attempted to change the PPS (step rate) of a running stepper. 

I do use the PWM outputs to generate variable frequency pulses.  The PWM outputs will change frequency while running. I have verified this with a digital oscilloscope and see that the output goes to the new frequency very "cleanly".  You could use a PWM OUPTUT to control a stepper motor and change the frequency, periodically.

The following code has been extracted from one of my products that is in production.  The code is called every 0.1 second (10 Hz rate) and changes the PWM frequency.  The code is used to simulate the output of a flow meter. The physical flow meter outputs a variable frequency signal that is proportional to the flow of fluid through the flow meter.

if (VFDCurrentHz < 5.00)
   ' Main Pump speed is too low to generate meaningful flow values
   '
   SimProductGPM = 0.0
   SetPWM 1, 0, 1         ' 0% duty cycle so output is "OFF"
else
   ' The main pump is running so we will calculate flows based on VFD frequency
   '
   SimProductGPM    = 0.0007 * VFDCurrentHz * VFDCurrentHz + 0.0194 * VFDCurrentHz + 0.7229

   ' Generate pulse output for flow.
   '
   SetPWM 1, 5000, SimProductGPM / 60.0 * ProductPPG
endif


Best regards,

Gary Dickinson

acxysty

  • Newbie
  • Posts: 35
  • I'm a llama!
    • View Profile
Re: Changing STEPSPEED
« Reply #2 on: October 14, 2019, 03:19:40 AM »
Hello Gary

Thank you for your answer.

I will think over you suggestion and make measurments.
I would have thought that setting a pwm to a new value would have produced a brutal change in frequency like it is the case on micro-controller.

That raises another question related to my first post : What happen when you apply a STEPSPEED command immediately followed by a STEPMOVE command while still in the middle of the previous STEPMOVE command ? According to some older posts the built-in stepper motor pulse generator will modify its parameters (frequency and number of pulse). How the frequency transition will occur ? Brutal or according to the acceleration law define by STEPSPEED ?

In advance thank you for your replies and you help !

Regards

Thierry






 

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re: Changing STEPSPEED
« Reply #3 on: October 14, 2019, 12:45:10 PM »
Hello Thierry,

In regards to issuing a StepSpeed command during an active step move command, what I have observed is:
  • The step rate jumps to the PPS specified by the new StepSpeed command
  • The "acc" argument is ignored. There is no ramp. The step output jumps to the PPS value in the new StepSpeed command.

My testing of the StepMove statement is that it is ignored while the stepper is executing a StepMove command.  This approach will not get the behavior that you want.

The PLC stepper motor control hardware/firmware is very simplistic.  It assumes that you just need to move a stepper from one position to another.  The acceleration/de-acceleration and maximum step rate is specified before the StepMove statement executes.

The only thing that you can do while a StepMove is executing is to abort it with a StepStop statement.  This command just shuts down the stepper control system and the steps are abruptly stopped.

I do use the StepStop statement in production PLC code. I use this to stop the stepper system when a switch is closed indicating that the system is in the "home" position. However, the move statement that I use to find the "home" position has the PPS set to a very low rate and no acceleration/de-acceleration is used.

If you are really in need of a variable speed stepper based system you have only a few choices:
  • Stick with the PLC. If you speed changes are great enough for your system to lose steps then you will need to issue several intermediate StepSpeed statements before you get to your next target speed.
  • Look into some sort of motion control system that is external to the PLC. For some motor control needs I use 3 phase motors and VFDs.  The PLC communicates to the VFD via RS-485 (Modbus RTU).  VFDs manage the acceleration profiles to smooth out abrupt speed change requests that the PLC may make.

Best regards,

Gary Dickinson
« Last Edit: October 14, 2019, 07:31:26 PM by garysdickinson »