Using Resistance on switches to expand inputs with ADC
TheVig
Posts: 41
I have this idea to expand the number of inputs using resistors and an analog to digital converter with the propeller.
My first thought was to use a binary weighted resistor network (1R, 2R, 4R, 8R, 16R...) to deduce the binary pattern of 1 and 0's.
-This would use a lot of resistors and tolerance would be a big issue. Resistors don't really seem to come in binary friendly values (unless I am missing something)
I came across this paper: http://www.ingelec.uns.edu.ar/pds2803/Materiales/Articulos/SedraSmith.pdf
It describes an R-2R resistive ladder.
Has anyone worked with any concept similar to this?
Basically, my thought is to be able to expand 3 prop pins using a single 8 channel ADC (MCP3208) to handle more like 128 inputs (16 on each pin of the ADC).
-Jim
My first thought was to use a binary weighted resistor network (1R, 2R, 4R, 8R, 16R...) to deduce the binary pattern of 1 and 0's.
-This would use a lot of resistors and tolerance would be a big issue. Resistors don't really seem to come in binary friendly values (unless I am missing something)
I came across this paper: http://www.ingelec.uns.edu.ar/pds2803/Materiales/Articulos/SedraSmith.pdf
It describes an R-2R resistive ladder.
Has anyone worked with any concept similar to this?
Basically, my thought is to be able to expand 3 prop pins using a single 8 channel ADC (MCP3208) to handle more like 128 inputs (16 on each pin of the ADC).
-Jim
Comments
do I understand right that you want to expand digital inputs (= switches)?
If yes another idea is to use parallel input serial-output shiftregisters like the 74HC597.
These shiftregsiters can be even cascaded so that you can have 16,24,32 or how many inputs you like which are all read
through a serial interface on 3 pins.
There is already an object in the OBEX http://obex.parallax.com/objects/381/
best regards
Stefan
http://web.archive.org/web/19990219160556/http://www.ionet.net/~bschwabe/BasicStampII/0000.html
From OBEX 74hc597 driver: "Data Acquisition cog reading up to 4 74hc597's in series" --which would be 32
vs.
"you can have 16,24,32 or how many inputs you like"
Could you string together 5 and get 40? or more? Is there a reason the OBEX limits to four in the documentation?
Also in the OBEX:
On the final 74hc597 the pin 9 goes to "prop pin Qh" - What is Qh? This seems to be the only Prop pin connection, but you say, "read through a serial interface on 3 pins" Obviously I'm missing something.
"Tie all ~Sload, Rck,Sck and ~Sclr together"...any idea why these are all tied together? Do they go anywhere?
By the way...thank you totally for steering me in a better direction! I don't know what is inside all these magic black boxes yet.
-Jim
:-)
There is an object too in the OBEX.
Both 74hc595 and 74hc597 can be cascaded.
Sload Rck Sck are tied together that all cascaded chips get the same signals at the same time
-Jim
The catch is sampling time and update time.
If you're using '595 shift registers to light LEDs and want to have adjustable brightness, the time it takes to shift out all those bits can be a problem.
For example when I used '595 shift registers to control an 8x8 RGB LED array, I had to limit the brightness range to 5-bits or the PWM flicker would become apparent.
This same problem can occur when shifting in lots of inputs. You wont be able to sample lots of inputs very quickly.
It would be nice if one could use an input shift register to monitor a bunch of quadrature ecoder lines but if the quadrature encoder states are changing quickly you'd miss some transistions if you used shift registers.
I've use '595 serial to parallel but I haven't ever used '597 chips. The parallel to serial chip I have used are the '165 chips. Here's a link to my all Spin '165 program I wrote to make sure I understood how the chips work. I used the program from the StampWorks book as a guide.
Often you'll see the number of these chips chained together limited to four chips. I think this limit exisits because it's easier to deal with the 32 bits of the four chips by using a long. You can certainly use more than four chips but you'd need store the bits sent or received in more than just one variable (as Stefan pointed out above).
The issue with the R-2R ladder is that the switches need to be SPDT, since each leg of the network must either be at 0V or Vcc...
Simple push-buttons won't work with it as expected. The simplest binary weighted scheme I know of that will work with push buttons is
a current-summing junction plus R, 2R, 4R, 8R etc...
I have a prop driving a bunch of 32 bit shift register to scan a series of keyboards and stop taps in an organ.
Currently it is scanning approx 500 inputs. I just place a high at the data input pin, then just keep clocking until all inputs are scanned. Each output of the S/R is connected to a key or stop tab switch. The prop handles this without breaking a sweat all done in one cog. I then convert the data into MIDI and let another cog handle that. All in PASM
As these devices have approx 120 ma output capacity (open collector outputs) the very same device is used in the pipe chamber to activate the individual pipe magnets. In this case I am driving over 1100 outputs. Again, one prop handles the entire pipe chamber by accepting a MIDI data stream then sending the appropriate bit patterns to the 32 bit S/R latched drivers.
I used to use an ALLEGRO device but they have been discontinued. These appear to be the same.
http://html.alldatasheet.com/html-pdf/13618/PANASONIC/DN8648FBP/408/1/DN8648FBP.html
This is all neat stuff. I'd like to know more!
-Jim
40 inputs and 40 outputs is not a problem for the propeller. It could be done in Spin if it does not need to be high speed, or in PASM using a single cog if it needs to be fast. Having the input and output done in the same routine can make the average speed faster and save I/O pins.