Switch it on here, switch it off over there...
Ttailspin
Posts: 1,326
PUB Switch_Changed | CurrentSwitchState
'if any switch changes state for long enough,
'then turn SSR pin on if it's off,
'or off if it's already on.
I want to upgrade the vacuum system in my workshop.
I have three push on/push off switches(SPST), and would like to have as many as eight.
I would like to be able to activate the switches like three way switches on a flight of stairs or a hallway... In other words I would like to turn on the vacuum here, and be able to turn it off over there.
I can't seem to grasp such simple logic using Spin. It's not Spin, it's just me...
I tried a few things, but they seem 'Cludgy' and not very elegant.
How would you go about this, using a Propeller MCU and Spin?
Brother, can you spare a few lines of code to get me started?
-Tommy (can't figure it out) Tailspin
'if any switch changes state for long enough,
'then turn SSR pin on if it's off,
'or off if it's already on.
I want to upgrade the vacuum system in my workshop.
I have three push on/push off switches(SPST), and would like to have as many as eight.
I would like to be able to activate the switches like three way switches on a flight of stairs or a hallway... In other words I would like to turn on the vacuum here, and be able to turn it off over there.
I can't seem to grasp such simple logic using Spin. It's not Spin, it's just me...
I tried a few things, but they seem 'Cludgy' and not very elegant.
How would you go about this, using a Propeller MCU and Spin?
Brother, can you spare a few lines of code to get me started?
-Tommy (can't figure it out) Tailspin
Comments
If they are toggle switches you respond to any of them changing state by changing the output state.
This is not that difficult, just run a loop which checks the input states of the switches (use software debounce for the switches).
if INA 1, 2, 3, or 4, then change OUTA 5 state of relay.
EDIT: Or you could simply control relay state with the Prop, and then control the vacuum system with three-ways and four-ways after the relay
On the propeller end each time the pin goes low and then high you change the state of the pin that controls the vacuum with a simple if statement.
I have one 40A SSR and three "toggle" switches in parallel much like kwinn describes.
Currently I must turn off the switch that turned the vacuum on, in other words, I have to turn it on here, and turn it off here.
I would like to toggle the SSR pin from any switch at any time,
PUB CheckSwitchStateChange
CurrentSwitchState := ina[8..15]
Check If CurrentSwitchState changes <<<(this is the line of code I am having trouble with)
If any change, then toggle SSR pin..
I am having a hard time getting the code right for "Check if CurrentSwitchState changes"... again, it's not spin, it's just me...
-Tommy
That should do it.
I am assuming this comment is intended for a common single pole toggle switch, with an on and off position, because I cannot see how this would apply to a momentary single pole switch, such as a pushbutton.
Additionally, I cannot understand why "switch state" storage is necessary. Since the goal of the switches is to simply change the state of the relay pin, unless one of the switches is out of hearing range of the vacuum system, why not just change the state of the relay pin?
I always thought this would inverse the current pin state: ..... !OUTA[RELAY]
EDIT:
Please disregard this comment due to irrelevancy
Thanks Sapphire and all, that will indeed do what i need done..
It is in my nature to over think everything, and paralyze the progress of entire projects, You guys are lifesavers.
@idbruce, Funny you should mention that, Because all of the switches are now out of hearing range of the vacuum...
Clogged filters and screaming ShopVacs are a thing of the past for me. YEAH!..
Thanks again everybody.
-Tommy(thinks he has it figured)Tailspin
Otherwise, if any switches are ON when the program starts they will cause the SSR to toggle at startup.
Now I 'get' to debounce the switches,
Some folks swear that Hardware debouncing is the best. Then again, some folks swear that Software debouncing is the best.
As for me, I just try not to swear...
Two of the wire runs for the switches will be thirty feet, Three of the switches are only ten feet from the control panel.
One is on the control panel, and one is a spare, because you just never know, seven switches might not be enough to turn on one Shop Vacuum...
The switches are Toggle on/off type, But they are not all the same make and model.
How will I go about debouncing all these switches?. Software? Hardware? Noware? Oh great, now i've paralyzed the project,..again...
-Tommy
As far as I gather you are reading 8 switches on 8 separate inputs and using exclusive OR to detect changes.
You can debounce all 8 switches at the same time using XOR as well. The basic idea is to repeatedly read the inputs and use XOR to detect changes. If there is no change for some number of reads then you have a stable, debounced, switch reading.
In pseudo code something like this: That results in all switches having to be stable for one tenth of a second before the input is used as CurrentSwitchState. You can tweak the repetition rate and count limit to suit your system.
I guess this is just a small modification of the code you already have.
-Phil
Actually a single pole normally open push button is the ideal type of switch for what I suggested. Other types of switches can be used, but they must be returned to the open position position or they will disable the system. Switch state storage is also required for the switch debounce code.
BTW, a microcontroller is not really required. A J-K flip flop would do as long as the switch signal is debounced.
Phil, the Engineer's Mini-Notebook from Radio Shack has a circuit like you describe on page 20,
I will try to list the Design Criteria more clearly, When i get home tonight. It's a big list!.
-Tommy
The number one thing on the Design Criteria list would be:
Extravagance, Luxury, and genuine envy from my Woodworking peers.
I have to go to work now.
-Tommy
That comment was for the simple circuit I suggested in post 5. My very first circuit for controlling lights from multiple locations consisted of several doorbell push buttons, a 555 timer wired as a one shot, and a J-K FF. Put in a few of those, but when single chip micros dropped below $5.00 I switched over.
For your application a microcontroller is definitely the way to go even if Extravagance, Luxury, and genuine envy from your Woodworking peers was not a requirement. Just think of all the other things you could automate with that propeller ;-)
-Phil
For sure I would like to use a Propeller for this project, I think it will be very luxurious and most extravagant. Of course, In my Trailer Park, luxury and extravagance is Relative..
Phil, Those are all great ideas, But they all assume you can actually hear this Vacuum running. Which you can't, unless you climb inside the box, Which you shouldn't, Unless you have hearing protection...
Note the Casters that came with the Vacuum remain uninstalled and are still safely quarantined in their original packaging..
-Tommy
No apology required. I did get a laugh from the "Extravagance, Luxury, and genuine envy from my Woodworking peers", particularly the envy part.
4-way 120V switches are expensive however, so using low voltage switches and a relay would be a good option.
A 3-way switch is nothing but a SPDT switch. A DPDT switch can be wired as a 4-way.
Flipping any of these switches will toggle the load on/off. (NOTE - the circle represents the light or a relay, etc)
If you need more switches, just insert another DPDT (4-way) switch in the circuit...
As a practical matter, you need 3 conductor wire running between the switches - see link below...
http://electrical101.com/4way-switches.html
http://www.do-it-yourself-help.com/4_way_switch_diagram.html
http://forums.parallax.com/showthread.php/161004-Capacitive-touch-sensor-SPDT-toggle-using-CD4027-Flip-Flop?p=1329376&viewfull=1#post1329376
Another option would be to drive a relay with a CD4027 circuit with multiple momentary contact push button switches in parallel.
Pushing any MOM button would latch the relay on/off.
(This video has a push button and capacitive switch in parallel)
http://www.electronicshub.org/jk-flip-flop-using-cd4027/
It's time to grasp the future, A future with no /four way switches(or casters) making people lazy, Taking the easy way out, Don't get caught up in that...
I am fully qualified(and have the tools) to install the 120V, 20A, eight switch, four wire 12AWG of permanently mounted, always in the way, spaghetti nightmare...
None of that for me anymore, This is the future I will embrace...
Note the simulated steel braiding for super flexibility, and solid cast aluminum nearly watertight box connector ends,
A solid steel body with integral spiral ribbing is used to hold the matching spiral ribbing of the high strength nylon switch holder securely.
The future is here.
Here is another picture of the future, It's already installed and ready for hard work at a moments notice...
Using any available magnet, I am able to mount the switch to any machine I am using, Saving steps and thus valuable time.
In this next picture, I am using a more traditional switch holder as I know a switch will always be in this location...
I could post a video of the Shop Vac running, but all you would hear is (KPIG)(94 oink 9) on the shop radio.
I like the idea of using some extra IC chips to help add to the fun, I do expect to make some custom circuit boards for this overly extravagant vacuum system.
The XBEE radios will for sure need some custom boards.
I think I would like to try an MCP23017 since I already have some laying about, one of those could watch the switches and run the indicator LED's too...
All part of the fun I guess...
-Tommy
Thought you were looking for a straight forward, simple (and inexpensive) solution to control a vacuum.
Guess you could add WiFly modules and wireless routers or mobile phone apps to the mix for even more fun..
Personally, I'm a fan of the K.I.S.S. principle.
Fewer fail points = less aggravation.
The Shop Vac in the picture, comes with a big, fat, bright red switch, built right in, just give it a slap and it starts to screaming...
Does not get much simpler that that, i suppose.
This is all for fun and games, something to keep me off the streets at night, Maybe better myself in the meantime, And hey, is it really all that wrong to want a little Vacuum envy?.
-Tommy(had it all figured out, but now he doesn't)Tailspin
While I generally lean towards simplicity and moderation in all things (including moderation) there are times when one has to go all out on a project. Keep up the excessive Luxury and Extravagance.