Using delays in a state machine

I'm using a finite state machine to control the voltage of power supply.

I've three states programmed:

OFF
ON
Stop

enter image description here

OFF state: the output voltage is 0V, the microcontroller is waiting for an input if there is no input it remains in the same state.

ON state: In this state the output voltage will increase progressively until it reaches some preset value if this value is reached the power supply will turn off. From this state the power supply can also change to Stop or to OFF if the proper signal is received

Stop: In this state, the output voltage will reaming constant at the last reached in the ON state. From this state, the power supply can return to ON and continue increasing the output or go to OFF.

My concern is the following, while in the ON state if the voltage limit is reached the state won't change immediately, the output will remain constant for a time delta_t, and then it will go to OFF I'm already implementing that behavior in the ON state, should I add a different state for this time for this transition when the voltage isn't increasing? or it is correct to have the delay within the state? This new state will basically just be a delay.

enter image description here

Edit.

This is the ideal output when the power supply is in ON state, It starts at 0, the increase until it reaches a preset value, remains in this value for a given time and the it goes to OFF state.

I've put current instead off voltage in this image, but since the load is pure resistive it makes no difference.

enter image description here

Upvotes: 0

Views: 2630

Answers (1)

user20160
user20160

Reputation: 1394

If the voltage plateau is an intended behavior (i.e. you have instantaneous control over the voltage, and your state machine is deliberately holding it high): It could make sense to split the 'ON' state into separate 'RAMP' and 'HOLD' states.

If the voltage plateau is a consequence of external hardware (e.g. your state machine stops sending the 'on' signal, but there's some delay before the actual behavior of the system catches up: It could make sense to add a separate 'WAIT' state, which either waits for a fixed time (if the delay is very repeatable), or operates in closed-loop fashion (e.g. measure the voltage, stay in 'WAIT' while it's nonzero, then transition to 'OFF').

In either case, it seems like the system is doing something different than during the voltage ramping phase, so a separate state makes sense.

Upvotes: 1

Related Questions