Decoding a BCD input
Stevezila
Posts: 35
Can anyone advise me in the best way to decode BCD inputs from a 0-9 digit BCD thumbwheel switch? Actually I need to have two thumbwheel switches to represent a given time between 1 and 5 seconds with 1/2 second intervals. eg. 1.5 2 2.5 3 3.5 ect. The first thumbwheel would be the whole number and I only need to be concerned with the first three pins on the switch 1,2,4. On the second switch I really only need to look at the 1 and 4 pins because it is either a half second or not. I suppose that I could do an If statement to evaluate each of the pins, something like If 1=1 and 2=1 and 4=0 then timer=3 seconds but is this the best way to do this. I will need to evaluate two of sets these·of thumbwheels plus I have·7 or so inputs and 3 outputs already planned so I think I'm running out of pins on my BS2 unless I evaluate my timers and then use those pins for other inputs/outputs. Please advise
Thanks··
Thanks··
Comments
Can You be more specific with the hardware inputs?
I'm afraid to post any code with out knowing this first. as I would be picked apart piece by piece, Cut to shreds for a simple typo.
__________$WMc%_______
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Truth is out there············································ BoogerWoods, FL. USA
I am trying to take the value of·two BCD thumb wheel switches·and come up with a decimal number that I can·put into the value of·a "wait" command. I have two seperate counters that I need to do this for.For this application an operator sets values on two seperate sets of thumbwheels to adjust the time·for a "wait" before the program continues·with a range of between 1 and 5 seconds with adjustments in 1/2 second increments. the reason for two thumbwheels is·so that the operator has a better "Picture" of the adjustments they·are making 3.5,4.7 ect.·They make thumbwheels in a decimal configuration- 9 pins with a common- and BCD config. 4 pins with a common. Not sure how best to do this but I am concerned about not having enough I/O using a BS2.·as I have other inputs /outputs as well.
Comments and advise appreaciated
Thanks
If you're really shy of inputs, you could use a single pin on the Stamp.· Put resistors to ground from the 4 bits of the switch; tie the other ends of the switch contacts together, add a capacitor, and measure the resulting RC time constant with a single Stamp I/O pin.· For example, if you used resistors of 100, 200, 400, 800 ohms, there would be 16 possible RC time constants, depending on which contacts were open and which were closed in each of the 16 switch positions.· The program could then decide how many half-seconds were meant.
By my calculations, there are exactly 1.73433 gazillion other ways to do this if you don't happen to like this way.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i@arrl.net
This link will expand on the method Carl suggested.· http://www.emesystems.com/BS2rct.htm#switches
Take a look at the rest of this site.· Lots of good stuff.
agfa
First I think that using a hex switch is·probably better than using two switches and second using the RC method I'm really going down on the use of inputs.
agfa thanks for the link, really cool site
Thanks again
I would stay away from RC circuits – too component tolerance dependent and you are shifting from software solution to hardware.
Have you considered multiplexing your devices?
Most applications are not that “real time” sensitive, but you would have to multiplex more than two BDC switches ( in you case only 3 + 2 wires which is not much saving) to make it effective.
·
Thanks