Pushing the Evelope
alnajjar1
Posts: 110
I need help with some tricky coding!
We have 8 push-buttons that visitors trigger, each of which turns on a 12VDC water valve to activate a portion of an exhibit. I want this done very quickly so when a visitor pushes the buttons, the valve opens for a certain short period of time and closes.
To achieve this, I used a HC595 for outputs and HC165 to read the inputs. This gives me a byte showing the status of the push-buttons, and an output byte from the BS2 to trigger the valves via the 595. I also added a 5k pot to control the amount of time the valves stay on.
I developed a simple code to do this - attachedCombined Pumps.bs2. The circuit and code work but it is sluggish unless the value of the pot (the wait time or the rate the switches are being read) is very low. The problem here is that if the wait is too short, the valve don't stay on long enough.
Further, it would be ideal if I can have different on-time for each valve.
I can write the code by looking at each input individually but that slows things down. Also, having BS2 circuits is not an option!
Any ingenious way of doing this?
Many thanks in advance,
Al
We have 8 push-buttons that visitors trigger, each of which turns on a 12VDC water valve to activate a portion of an exhibit. I want this done very quickly so when a visitor pushes the buttons, the valve opens for a certain short period of time and closes.
To achieve this, I used a HC595 for outputs and HC165 to read the inputs. This gives me a byte showing the status of the push-buttons, and an output byte from the BS2 to trigger the valves via the 595. I also added a 5k pot to control the amount of time the valves stay on.
I developed a simple code to do this - attachedCombined Pumps.bs2. The circuit and code work but it is sluggish unless the value of the pot (the wait time or the rate the switches are being read) is very low. The problem here is that if the wait is too short, the valve don't stay on long enough.
Further, it would be ideal if I can have different on-time for each valve.
I can write the code by looking at each input individually but that slows things down. Also, having BS2 circuits is not an option!
Any ingenious way of doing this?
Many thanks in advance,
Al
Comments
-Phil
Whether a button is pressed or not pressed the "getswitches" will scan and then goto "sendout". So if no button has been pressed the Stamp is just going to be unresponsive for as long as 2 seconds until it comes back to scan the switches again. During that time it is possible it may miss the users input.
Also the switches must be in a pressed state when "inload" receives its pulse, this means that if you had for example 5 users pressing buttons any small difference in time between when they pressed the buttons would give you an apparent error on the output, in other words you would read some but not all of the user inputs.
I think it would be better if you verified there actually was user input before moving into the output routine. Something like the following might work, the first read checks for input and the second read gives time for everyone to press. The pause can be adjusted to whatever works best.
Jeff T.
What time range do you want to have for the individual pump run times? Do you need to have these individual pump run times field programmable, or could they be fixed?
If you maintain 8 separate timers for each pump, you could have different times for each of them and they could run simultaneously. Eliminating the re-reading of the POT will speed processing up, and if the pump run times don't change (or are only changed by you) then they can be done outside of the normal loop.
Al
Thanks for your thought...
What I'm suggesting is to setup 8 counters that all run in parallel, and only one pause to set the timing on them. I've added that to your original program. Take a look and see if it works for you.
I will try it and report back.
Many thanks Sapphire.
Al