EEVblog Electronics Community Forum
Electronics => Microcontrollers => Topic started by: BorisKontorovich on April 18, 2018, 07:42:30 pm
-
Hello Everyone
I 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!!!
-
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.
-
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.
-
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.
If 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.
-
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.
200 ms is very slow. You can use practically any MCU. Unless your calculations are very complex.
-
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.
-
Ok, I will give it a try.
Thanks everyone for the info.
B.
-
Ok, I will give it a try.
Thanks everyone for the info.
B.
Just make sure you learn about and use hardware timers. Don't fall into the common beginners trap of using software delays for everything.
-
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.
What 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.
-
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.