Analog Ramping Like A Variable Speed Drive

Hi All,

I'm looking for some guidance on how I can mimic what an inverter does with a 0-10V input in the following context.

  • A basic inverter gets a 0-10V signal from a PLC or potentiometer or whatever.
  • Based on the settings of the inverter the motor is spooled up and down based on the acceleration and deceleration times you set.
  • You can then often monitor the ramp using a pair of analog out ports which give a 0-10v signal to tell you what it is doing.

What I am wanting to build is this:

  • Generic module which controls the rate of change for any 0-10V analogue signal
  • 0-10V input
  • Acceleration speed input variable (say 60 seconds)
  • Deceleration speed input variable (say 10 seconds)
  • Code which reads the input constantly and updates the output voltage accordingly based on the above timing variables
  • 0-10V output.

Now I know how to do the basics of reading the analogue in and outputting a PWM through a low pass filter and op-amp to give the 0-10V output. The piece I am struggling to figure out in my mind is how does an inverter typically calculate the ramp? I assume it isn't PID based as this would not give a slow smooth acceleration over 60 seconds and would be too erratic.

Glad of any input.

Take a look at the Fade Example

If you are trying to accomplish a particular acceleration, you need to measure the results of trying to do and adjust the increasing rate of the ramp.

PID would be useful here. What you do not have yet is the required input, which here would be the acceleration the motor is making at an instant.

Inputs: desired acceleration, current acceleration
Output: throttle

If the acceleration is too low, the throttle is increased. if the acceleration is too high, the throttle is reduced. With a fast enough loop, there is no need to expect that this would not be smooth.

Obvsly something else has to set the desired acceleration to zero when the speed is attained.

Many acceleration or fading or ramping things are done open loop. A LED just gets brighter, no need for feedback. A motor that is never asked to do more that it was found able to do in testing is just ramped up blindly, with the ramp slope determining the acceleration.

a7

Thanks @DVDdoug

I assume you are thinking I do something like:

  • Take first reading
  • Take second reading
  • Flag if it is increasing or decreasing
  • Divide the difference between the first and second reading by the number of seconds (60 or 10)
  • Add or subtract this as required to the output voltage
  • Loop every second

Or have I missed your point?

The fading code boils down to

  brightness = brightness + fadeAmount;
 
  delay(30);

Change the brightness one step every 30 milliseconds.

The rest of the code handles switching directions when the min or max of the fade range is reached.

As such it is totally open loop. The value would go from, say, 0 minimum to 255 maximum over 30 * 255 milliseconds, 7.65 seconds.

So you can do the same, adjust the step size and time between steps. You will be writing a linearly increasing value to the motor speed input, who knows what the motor will or won't do? Not the open loop control algorithm this is.

a7

there are basically two parallel actions

a) the potentiometer/the user/the interfaces defines the target voltage
b) if the current voltage is below the target voltage increase the current voltage by one step
if the current voltage is above the target voltage decrease the current voltage by one step

the periode of how often you call for action b) defines the slope of the ramp, hence you can also give different periods for ramping up and ramping down.

edit:
may be something like this

1 Like

you might consider this code i just posted for moving a servo more slowly. you can add a delay argument and replace the servo.write() with an analogWrite() to generate PWM

int pos;

void
move (
    int target )
{
    if ((target - pos) > 0)
        servo.write (++pos);
    else if ((target - pos) < 0)
        servo.write (--pos);
    delay (15);
}

Nice demo. Here's a place where the serial monitor graphical output can be fun.

Swap in this modified update method and turn on the serial plotter, in the woki that's a button in the lower right hand corner, in the IDE open the "Serial Plotter" from the Tools menu.

    // the run method to be called in loop
    void update(uint32_t currentMillis = millis()) {
      if ((current < target) && (currentMillis - previousMillis > intervalUp)) {  // increase PWM
        previousMillis = currentMillis;
        current++;
        analogWrite(pin, current);
//        Serial.print("up "); Serial.println(current);  // just for debug/demo - comment it out if you see it works 
      }
      else if ((current > target) && (currentMillis - previousMillis > intervalDown)) {  // decrease PWM
        previousMillis = currentMillis;
        current--;
        analogWrite(pin, current);
//        Serial.print("down "); Serial.println(current);  // just for debug/demo - comment it out if you see it works
      }
      Serial.print(target);
      Serial.print(", ");
      Serial.println(current);
    }

I thought it was broken until I noticed separate manifest constants for the up and down timing.

a7

1 Like

because of entry post:

1 Like

Wow! Thank you so much all of you.

The responses on here are fantastic and the Wokwi makes it incredibly easy to understand.

Really appreciate all the effort gone into the replies, I think I now have some understanding of how that works on an inverter.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.