Shop OBEX P1 Docs P2 Docs Learn Events
Thumbwheels — Parallax Forums

Thumbwheels

gtslabsgtslabs Posts: 40
edited 2008-01-09 00:58 in General Discussion
I ordred 4 Thumbwheel switches today, 0-9 BCD output that I plan on getting a value from 0 to 9999 from.
I wrote some code to read the condition of the inputs on SX48 RB.D and RB.E I have not tested it yet but it compiles ok.

I am looking for some schematics for wiring up these Thumbwheel switches. The Datasheets mainly give the truth tables and not much on other info like pullup resistors or diodes if needed.
Thanks in advance

DEVICE          SX48, OSC4MHZ
FREQ            4_000_000
Thumbwheel_12      Var       RD     ' 8 Input pins for ones and tens places
Thumbwheel_34      Var       RE     ' 8 Input pins for hundreds and thousands places
 
ones        Var Byte
Tens        Var Byte
Hundreds    Var Word
Thousands   Var Byte
Total       Var Word
 
PROGRAM Start
Start:
Main:
 
Ones = Thumbwheel_12 & $0F 'Get lower 4 bits of RD
 
Tens = Thumbwheel_12 & $F0 'Get Higher 4 bits of RD
Tens= Tens>>4    
Tens = Tens*10
 
Hundreds = Thumbwheel_34 & $0F 'Get lower 4 bits of RE
Hundreds = Hundreds * 100
 
Thousands = Thumbwheel_34 & $F0 'Get Higher 4 bits of RE
Thousands= Thousands>>4 
 
Total = Thousands*1000
Total = Total+Hundreds
Total = Total+ Tens
Total = Total+Ones
GOTO Main

Comments

  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2008-01-04 19:16
    You did not specify what thumbwheels you are using. However, I image they will be very straightforward to connect. Assuming they use simple open or closed contacts simply connect them between the SX pins and ground. Activate the internal pullup resistors on the SX to read a one when the switch is open and a zero when the switch is closed. (You may have to invert the bit pattern if the truthtable assumes the opposite switching conditions.)

    It should be very easy. If not, write back!

    - Sparks
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-01-05 03:22
    pic attached
    519 x 345 - 14K
  • gtslabsgtslabs Posts: 40
    edited 2008-01-08 22:38
    Thanks for the help guys. I got these up and running today.
    Is there much danger if I connect these directly to the I/O pins without using the 220 R?
  • JonnyMacJonnyMac Posts: 9,218
    edited 2008-01-09 00:58
    Only if you make the pins outputs and high, and have switch closed to ground. If you're careful with your coding and don't ever make those pins outputs, you'll be fine.
Sign In or Register to comment.