I’m currently working on trying to control an ATX power supply (that will power two linear actuators) with an Arduino. I have the power supply all hooked up and whatnot and have confirmed that the Arduino can turn it on and off, I just don’t know how to control it under certain conditions.
- I want for the power supply to turn on right as I flip the switches for the linear actuators to activate. This is easy because I can just say the following
digitalWrite(psuOnOff, HIGH); delay(5000);
before I tell my motors to run. This will enable the transistor that I have inside of the PSU, which will in turn allow it to power on. I also have the 5 second delay in there to ensure that the PSU turns on completely before any other commands are carried out.
I want for the PSU to turn off after 30 seconds of no commands being sent to the actuators. This is really where I’m having trouble. I’m unsure of how to integrate keeping time with this requirement, and also with the next.
I want for the counter to reset back to 0 if I issue a command before it reaches 30 seconds.
I’ve looked into finite state machines, but I’m unsure of whether or not this is what I need. Most FSMs that I have seen use the millis() function… but all that does is keep track of how long the program has been running, from what I understand. My program will be running continuously, so I don’t think that’s what I’m looking for.
Any help or suggestions would be appreciated. Thanks!