Timing solenoids to 0.1ms increments--How??
Lloyds
Posts: 75
Hi,
I am a total newbie to BASIC stamp but would love to learn, especially if it will work for my project.
I need to control two solenoids with sub-millisecond repeatability. Repeatability is important; actual times are not.
I believe I can use a ULN2003 to drive the two solenoids. They are 12VDC, 5watt.
The timing sequence will be approximately as follows, but will fine tuned by trial and error to compensate for solenoid lag.
1) Start with solenoid 1 and 2 de-energized.
2) Energize solenoid 1 for 4.7ms (Possibly use the PULSOUT command??)
3) After solenoid 1 has been energized for 3.3ms, energize solenoid 2 for 8.5ms.
How to achieve the 3.3ms delay between energizing solenoid 1 and solenoid 2 has me stumped. It seems like the PAUSE command should work , but its resolution only goes down to 1ms, and I need a tenth of a millisecond resolution.
Can any of the stamp models achieve this?
Any help will be greatly appreciated!
Thanks,
Lloyd
I am a total newbie to BASIC stamp but would love to learn, especially if it will work for my project.
I need to control two solenoids with sub-millisecond repeatability. Repeatability is important; actual times are not.
I believe I can use a ULN2003 to drive the two solenoids. They are 12VDC, 5watt.
The timing sequence will be approximately as follows, but will fine tuned by trial and error to compensate for solenoid lag.
1) Start with solenoid 1 and 2 de-energized.
2) Energize solenoid 1 for 4.7ms (Possibly use the PULSOUT command??)
3) After solenoid 1 has been energized for 3.3ms, energize solenoid 2 for 8.5ms.
How to achieve the 3.3ms delay between energizing solenoid 1 and solenoid 2 has me stumped. It seems like the PAUSE command should work , but its resolution only goes down to 1ms, and I need a tenth of a millisecond resolution.
Can any of the stamp models achieve this?
Any help will be greatly appreciated!
Thanks,
Lloyd
Comments
Jeff T
Ahhhh, so to get a 3.3ms pause I could try PAUSE 3, and then run a little dummy loop for a certain number of times to delay things for the additional 0.3ms. Sounds like it should work.
Thanks!
Lloyd
Yes, i see what you mean. And I really like your way of looping it by a factor of 10,000 to get an easily measurable time indicator. Now that you mention it, I remember having to do a similar thing several years ago using BASIC to write to a purchased blackbox stepper motor controller. The PC and blackbox communicated fine on our old Windows 98 machines, but was too fast on the new Windows 2000 machines. Adding loops in a few strategic places made it work.
So it sounds like the Basic Stamp will do what i need. Time for me to get down to business!
Thanks again,
Lloyd
> 1) Start with solenoid 1 and 2 de-energized.
> 2) Energize solenoid 1 for 4.7ms (Possibly use the PULSOUT command??)
> 3) After solenoid 1 has been energized for 3.3ms, energize solenoid 2 for 8.5ms.
Lloyds, I don't think PULSOUT will work for this application. As far as I know(but I could be wrong), when a PULSOUT command is run, no further commands will operate until that PULSOUT has finished running. So if your first PULSOUT is 4.7ms, the second PULSOUT command will not begin until at least 4.7ms after the first.
One way that may work is to use the HIGH and LOW commands instead, which don't suffer from this problem. HIGH activates a solenoid, LOW deactivates it(at least generally.)
It might look something like this (in pseudocode):
HIGH solenoid1
PAUSE 3.3ms
HIGH solenoid2
PAUSE 1.4ms
LOW solenoid1
PAUSE 7.1ms
LOW solenoid2
Since PAUSE may not have the required resolution you can substitute in something that does, like the technique Mike suggested. Another method to pause with better resolution could be to send a PULSOUT to an unused pin.
One more thing to consider, the 5watt solenoid may draw considerably more power for a very brief period when it is first energized, as an "inrush current." Something to watch out for; I'm not sure whether the ULN2003 would like this, but it could be fine.
Post Edited (BobLowry) : 7/8/2008 5:04:30 AM GMT
Thanks for noticing. I completely missed the overlap of the solenoids. Your solution is perfect.
The only thing to watch out for is the execution time of the loops used for the pauses. The
HIGH and LOW statements take some time to execute and that has to be worked into the times.
Bob, Yes, I follow what you are saying regarding the non-overlap in the execution of the PULSOUT command.· That will give me another approach to try when my parts arrive.··I can also see that with·the short·durations involved, it would have been difficult to diagnose where the problem really was and therefore, which of the various durations to adjust.· But using Mike's method of putting a 10,000 times mutiplier in appropriate places, I should be able to physically time the sequence of events until I get the functionality of the project where I want it.· At least I now·have some caution areas to watch out for.
Regarding the suitability of the ULN2003, a friend·has suggested this L295 solenoid driver.
http://www.datasheetcatalog.org/datasheet/SGSThomsonMicroelectronics/mXrzqut.pdf
·It looks more robust and·can still control·both solenoids.· I'm thinking it would interface similar to the way the ULN2003 would?·
Or is it possible to parallel the pins in the ULN2003?· As a beginner, I'd like to take the most trouble free approach.
Thanks for all the help!
Lloyd
Will Do!
Lloyd
That's just a thought.
No, I'm with you on that and have been experimenting with mechanically operated micro switches to control the electrically operated air solenoids see if the mechanical part of the system is even capable of a quick cycle like I'm after.· I think it is.
Basically, I've got a light weight (6/6 nylon piston and rod), short stroke, double acting air cyclinder that directly drives a "plunger".· The ultimate goal is to have precise control of the "plunger" "open time".
The two solenoids I am trying to drive/control are Mac brand air solenoids that will·power the air cylinder, one to open it, the other to shut it.· The solenoids·are rated at 4ms to open, and 8ms to close, which by themselves, are too slow·for my application.· But by·having the 2 solenoids work independently of each other, and against each other, and control·both directions of the air cylinder, I believe I will be able to contol the open time of the "plunger" to the milli second level.· ·It will be like variable valve timing on an engine where the second·solenoid starts to shut the valve before the first solenoid even has the valve fully open.· Like an air operated Desmodromic valve arrangement.· Kind of, anyway.
The odd timing numbers that I have in my initial post are based on calculations, partially backed up by empirical data.· When all is said and done, I won't really to be able to tell if the plunger is open for 3.3ms or for 4.3ms, but through the functioning of the system, I should be able to tell how precisely I am varying the plunger open time.· I've got the mecahnical stuff pretty well under control, but the electronics is new to me.
I definitely appreciate all the help and comments, including pointing out potential problems.
Lloyd
and your thinking that by opening the second it will make the first shut down faster. where does the air go from the first solenoid once shut down ( is it a three way valve )
you might want to look into 4 way valves one valve·does the job
12VDC Solenoid Valve
Lloyds, if you do have trouble operating the solenoids with these short pulses you might try increasing the voltage. Of course, if you go over the rated voltage there are no guarantees that they would continue to work correctly or reliably, so be very careful. But if you kept the solenoid on-time short enough(both average and peak), you may not have any problems. You could also try experimenting with PWMing the solenoids.
Post Edited (BobLowry) : 7/8/2008 6:38:41 PM GMT
The 4 way air solenoid could be a nice clean approach, but I haven't been able to find·one that will·shuttle fast enough in the air volume and pressure·I am working with.
The two solenoids I am using are 3 ways, but the trick··is that I have "quick exhaust valves" hooked up between the solenoids and·the·ports on the cylinder.· (OK, its not really a trick, someone told me about QEVs and I am eternally thankful!· They work great!)· I'll see if I can come up with a decent sketch.
This provides a little better explanation about QEVs than I can.· Click on the pdf of QEVs for a flow schematic:
http://www.mead-usa.com/products/detail.aspx?id=46&type=1
The QEV allows the exhaust to dump directly to atmosphere once the pressure in the cylinder becomes higher than the residual pressure in the supply line.· It works a little like a check valve and is configured so that the exhaust doesn't have to be routed back through the solenoid valve. With a QEV, you can actually use a simple 2 way air solenoid valve·at each end of the cylinder and still get really fast reversing speeds.· Yes, there is that transition period where the two sides of the piston are fighting each other, but once the cracking pressure in the QEV is reached,·the reversal·is instantaneous.
Still, whether·I will be succesfull in implementing the electronic controls has yet to be seen.· But what is life with a good challenge every now and then!
Regards,
Lloyd
·