Shop OBEX P1 Docs P2 Docs Learn Events
Using Resistance on switches to expand inputs with ADC — Parallax Forums

Using Resistance on switches to expand inputs with ADC

TheVigTheVig Posts: 41
edited 2013-01-24 18:40 in Propeller 1
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

Comments

  • manzanamanzana Posts: 24
    edited 2013-01-24 10:22
    I am intrigued. 8-) Sounds like you have 128 on-off switches that you want to encode into 8 sets of 4 binary bits. You could no doubt do it your way if you had an ohmmeter to check your resistances, but why not just use $2 worth of encoders from digi-key and skip all the analog stuff??
  • StefanL38StefanL38 Posts: 2,292
    edited 2013-01-24 10:37
    Hi Jim,

    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
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2013-01-24 11:18
  • TheVigTheVig Posts: 41
    edited 2013-01-24 11:21
    Stefan,

    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
  • TheVigTheVig Posts: 41
    edited 2013-01-24 11:29
    Guess I'll ask this now, what component would be used to get more outputs from a single prop pin?

    :-)
  • StefanL38StefanL38 Posts: 2,292
    edited 2013-01-24 12:40
    74HC595 works the other way round serial input parallel output.
    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

  • TheVigTheVig Posts: 41
    edited 2013-01-24 13:09
    Thank you so much. I feel like it is christmas....or there's gonna be a catch...like too good to be true.

    -Jim
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-01-24 13:43
    TheVig wrote: »
    Thank you so much. I feel like it is christmas....or there's gonna be a catch...like too good to be true.

    -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).
  • Mark_TMark_T Posts: 1,981
    edited 2013-01-24 13:50
    TheVig wrote: »
    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

    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...
  • WurlitzerWurlitzer Posts: 237
    edited 2013-01-24 14:17
    TheVig wrote: »
    Guess I'll ask this now, what component would be used to get more outputs from a single prop pin?

    :-)

    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
  • TheVigTheVig Posts: 41
    edited 2013-01-24 15:25
    Realistically I am looking at 40 inputs and 40 outputs.

    This is all neat stuff. I'd like to know more!

    -Jim
  • kwinnkwinn Posts: 8,697
    edited 2013-01-24 18:40
    TheVig wrote: »
    Realistically I am looking at 40 inputs and 40 outputs.

    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.
Sign In or Register to comment.