PDA

View Full Version : two BCD switches



Mugel
- 9th November 2006, 23:11
Hi you all!
solved my LCD flashing problem with your help: donīt need to clear the display every second but used the "Dec5" command. has zeros in front instead but works fine for me.

New problem: Wanna read the status of 2 bcd-rotary switches with digits from 0 to 9 making a variable from 00 to 99 ( 10 to 99 would do ....) for a digital overrev switch in an electronic ignition.

But I donīt have any clues how to tell my favorite 16F628A to read the two switches ......

I couldnīt use RB0 because I need this to count the frequency.

so letīs assume I got 8 Input ports........

oh yes: and I need the external crystal too, so RA6 & RA7 are in use...


PLEASE Help!

Archangel
- 9th November 2006, 23:24
Hi Mugel,
IF you have enough ports THEN . . .

MyVar var byte
If PortA.0 != 0 Then
my var = 0
else If portA.1 != 0 then
myvar = 1 . . . . and so on

here is another way using analog inputs
http://www.romanblack.com/keypad.htm

mister_e
- 10th November 2006, 00:43
If i'm right, the following may be something to play 'round of


Switch1 Var Byte ' let's say it's connected on PORTB<7:4>
Switch2 var Byte ' let's say it's connected on PORTA<4:0>
Result var byte

start:
Switch1=PORTB>>4
Switch2=PORTA & $0F
Result=(Switch1*10)+Switch2

Mugel
- 21st November 2006, 20:29
Hi guys!

thanks for your help, everything works fine for me Pic related of course, haha.

got to measure engine speed, rev limit with two BCD switches AND ignition shutoff while engine stands still to save the coil. WOW never thought this goes that easy, meaning: I am able to build that.

Ok youre right, this is just the lab version on a veroboard with a frequency counter as "test engine". But iīm shure it will work in Reality too because Iīm experienced in spike pested engine electrics

Iīll tell more!

Mugel

Archangel
- 21st November 2006, 22:53
Hi Mugel,
Glad you got it working.
If it's not top secret I would like to eyeball that code :)
JS