Controlling 8 solenoid air valves. - Page 1
Forum section: electronics / general

author: BorisKontorovich
author_rank: Newbie
timestamp: April 18, 2018, 07:42:30 pm
content: Hello EveryoneI need to build a controller to open and close 8 solenoid air valves at precisely timed intervals. Open and closed time does not change during operation, but each line has different timing independent from all other lines. I have a circuit to drive solenoids figured out, but I am looking for a good general approach to how I would control the system. The time it takes the solenoid valve to open is 100 milliseconds, so I would not have on or off periods shorter than 200 milliseconds.Let me know if I provided enough info to give an answer or if more detail is needed.Thank you!!!

author: rstofer
author_rank: Super Contributor
timestamp: April 18, 2018, 08:33:18 pm
content: I would just use an Arduino to drive your solenoid drivers. You didn't describe the solenoid driver so there's nothing I can say about interfacing between the Arduino and driver but it shouldn't be hard.You can then program the Arduino to cycle the valves in any sequence you wish.You didn't give a range of on-off times. Are we talking a complete cycle takes a few seconds or a few days? Either way, the Arduino is probably the easiest way to get it done.There are alternative solutions with 555 timers but it depends on how the sequence actually works as to whether a discrete approach is workable or not.

author: BorisKontorovich
author_rank: Newbie
timestamp: April 21, 2018, 01:55:32 pm
content: Thank you for reply.My concern with running it on Arduino is for very short pulses 200 ms I would have to run some amount of code checking timing - I am concerned that for such a short period of time, I wont be able to finish all the calculations in time.

author: mikerj
author_rank: Super Contributor
timestamp: April 21, 2018, 06:50:24 pm
content: Quote from: BorisKontorovich on April 21, 2018, 01:55:32 pmIf the open/closed times don't change then there's very little for the Arduino to do. If there are any heavy calculations needed to calculate the times, they could be completed before you start the timer running.I suspect you could quite easily handle everything from a single timer interrupt and still keep jitter in the low microseconds range.

author: NorthGuy
author_rank: Super Contributor
timestamp: April 21, 2018, 08:08:24 pm
content: Quote from: BorisKontorovich on April 21, 2018, 01:55:32 pm200 ms is very slow. You can use practically any MCU. Unless your calculations are very complex.

author: james_s
author_rank: Super Contributor
timestamp: April 22, 2018, 04:40:19 am
content: Yeah 200mS is an eternity to a microcontroller. That was something that took some getting used to when I first started working with microcontrollers, just how blindingly fast they are. Think about it this way, even running at a very slow clock speed of 1MHz most microcontrollers will be running something around 100,000 C instructions during each of those 200mS, surely whatever calculations you're doing are not going to require anywhere near 100,000 instructions. 1MHz is very slow, the bog standard Arduino runs at 16MHz, that's millions of instructions per second.

author: BorisKontorovich
author_rank: Newbie
timestamp: April 25, 2018, 01:21:54 am
content: Ok, I will give it a try.Thanks everyone for the info.B.

author: mikerj
author_rank: Super Contributor
timestamp: April 25, 2018, 08:33:39 am
content: Quote from: BorisKontorovich on April 25, 2018, 01:21:54 amJust make sure you learn about and use hardware timers. Don't fall into the common beginners trap of using software delays for everything.

author: brucehoult
author_rank: Super Contributor
timestamp: April 30, 2018, 07:41:55 am
content: Quote from: BorisKontorovich on April 21, 2018, 01:55:32 pmWhat kind of calculations?Even a standard Arduino Uno with 16 MHz CPU can do about 20000 floating point operations in 200 ms. That's with software FP emulation as they don't have hardware FP. If you can use integer or fixed point then you can do millions of adds or subtracts per second, even in 16 or 32 bit. Or millions of 8x8 -> 16 multiplies too.They're plenty fast enough to make self-balancing machines, run a bunch of stepper motors on 3D printers, or even control autonomous model aircraft.

author: sorsor
author_rank: Newbie
timestamp: May 23, 2018, 08:22:09 pm
content: I did similar thing and I used the following approach.I registered the start_time for each solenoid when I received a command to turn the solenoid on. I had an on_flag vector saying if the solenoid is on or off.Then, I check if anything needs to be turned off (start_time[1:8] - current_time > desired_pulse[1:8]). I used millis() to get the current time. Pay attention to overflows, though. This worked very well on an Arduino.Hope this helps.