Using a digital input to ramp up, stay active until DI is false

Topics about the Software of Revolution Pi
Post Reply
Tontonsam
Posts: 1
Joined: 17 Jul 2024, 23:37

Using a digital input to ramp up, stay active until DI is false

Post by Tontonsam »

Hey I have a question about a ramp up i'm trying to create.

case : I have a speedcontroller -10 to +10V regulated. i want to use a potmeter to set the nominal speed. (value X) but before reaching that value, I would like a ramp up and ramp down set with a time value (time to nominal speed).

I found a "ease" node, that contains all the fancy ramps i need, but having a digital pin start a ramp up, nominal -> until the Digital Pin changes to false and then ramp down.

curious if this is possible!
u.biakoup
KUNBUS
Posts: 201
Joined: 14 Apr 2022, 13:04

Re: Using a digital input to ramp up, stay active until DI is false

Post by u.biakoup »

Hello tontonsam,

It’s definitely possible to create a ramp up and ramp down for your speed controller using a potentiometer to set the nominal speed and an “ease” node to manage the transitions. The “ease” node can animate a value between a start and end value using an easing function, which is perfect for creating smooth ramp up and down effects1.
  • Potentiometer Input: Use the potentiometer to send the desired nominal speed (value X) to Node-RED.
  • Ease Node Configuration: Configure the “ease” node to use the appropriate easing function that matches the type of ramp you want (e.g., easeInCubic, easeOutCubic, easeInOutCubic for cubic transitions)
.
  • Digital Pin Trigger: Use a digital pin to trigger the start of the ramp up. When the digital pin is set to true, the “ease” node begins the ramp up to the nominal speed.
  • Ramp Up to Nominal Speed: The “ease” node will smoothly increase the speed from the starting value to the nominal speed over the specified time duration.
  • Ramp Down: When the digital pin changes to false, trigger the “ease” node to start the ramp down from the nominal speed back to the starting value or to a safe stop value.
You can also use a “node-red-contrib-edge-trigger” node to detect changes in the digital pin state, which can be useful for starting and stopping the ramping process based on rising or falling edges2

Here’s a simple example of a function you might use in Node-RED to control the ramping:

Code: Select all

// Function to start ramping up or down based on digital pin state
msg.payload = {
  from: 0, // Starting value
  to: msg.nominalSpeed, // Nominal speed set by potentiometer
  duration: msg.rampTime, // Time to nominal speed
  interval: 10 // Output a value every 10 ms
};

// Check the state of the digital pin
if (msg.digitalPinState === true) {
  // Start ramping up
  return { payload: msg.payload };
} else if (msg.digitalPinState === false) {
  // Start ramping down
  msg.payload.from = msg.nominalSpeed;
  msg.payload.to = 0; // Or to a safe stop value
  return { payload: msg.payload };
}

Make sure to adjust the from, to, duration, and interval values to match your specific requirements. The msg.nominalSpeed and msg.rampTime would be dynamic values you’ve obtained from the potentiometer and your configuration, respectively.
Remember to handle cases where the digital pin might change state before the ramp up or down is complete, to avoid any abrupt changes in speed. You can do this by sending a message with the topic reset to the “ease” node to cancel any currently running easing function1.
I hope this helps you set up your ramping functionality! If you need further assistance, feel free to ask.
Here’s how you can set up your Node-RED flow for the speed controller ramp up and down functionality:
  • Input Node: A node to read the potentiometer value that sets the nominal speed.
  • Function Node: A function node to process the potentiometer value and set the ramp parameters (start value, end value, duration).
  • Ease Node: The “ease” node configured to create a smooth transition between the start and end values over the specified duration.
  • Trigger Node: A node that listens to the digital pin state to start the ramp up or ramp down.
  • Output Node: A node to send the adjusted value from the “ease” node to the speed controller.
Here’s a textual description of how these nodes might be connected:
  • The Input Node is connected to the Function Node. The function node receives the potentiometer value and prepares the message for the “ease” node.
  • The Trigger Node is also connected to the Function Node and is set up to send a true to start the ramp up or a false to start the ramp down
.
  • The Function Node then sends the parameters to the Ease Node.
  • The Ease Node creates the smooth transition and sends the adjusted value to the Output Node, which ultimately controls the speed controller.
Best Regards

Ulrich Kouatang Biakoup | field application engineer
Post Reply