Shop OBEX P1 Docs P2 Docs Learn Events
MCP3208_fast_multi howto setup pins if out of I/O's — Parallax Forums

MCP3208_fast_multi howto setup pins if out of I/O's

courtenscourtens Posts: 101
edited 2012-11-15 17:40 in Propeller 1
I would like to use the object MCP3208_fast_multi but ran into a unusual roadblock.

I have used the object before, however, this time I am out of I/O's. The object allows for up to 3 chips, but I am using only 1 (dpin1, cpin1, spin1)

Assigning the pins happen like this
adc.start(dpin1, cpin1, spin1, dpin2, cpin2, spin2, dpin3, cpin3, spin3)

but with out any extra I/O's available I can not assign bogus pins for the none existing chip 2 and 3 -- dpin2, cpin2, spin2, dpin3, cpin3, spin3

What would I need to assign to these pins: dpin2, cpin2, spin2, dpin3, cpin3, spin3 to? Would 50 or -1 work?

Thanks in advance for your suggestion.

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2012-11-15 15:55
    Using 50 or -1 wouldn't work (well sort of). The mask convertion will only look at the lower 5 bits anyway (18/31). From looking at the code - halfway through my morning coffee - you can simply assign anything to them, whether it's used depends on the chip you sample. In this case you'd only use chip 1 (2 and 3 unused). Better even, make all triples the same as this avoids accidents in case you get the chip number wrong. HTH
  • courtenscourtens Posts: 101
    edited 2012-11-15 17:06
    kuroneko wrote: »
    you can simply assign anything to them, whether it's used depends on the chip you sample.

    Sorry for not being clear enough. I ran out of I/O's on the propeller chip. So I do not have any remaining IO's that I can assign for chip 2 (unused) and 3 (unused). I us to have one I/O left over P27 and would assign all remaining assignment to P27, like this:

    dpin2 := 27
    cpin2 := 27
    spin2 := 27
    dpin3 := 27
    cpin3 := 27
    spin3 := 27

    but now I can't do this any more.
  • kuronekokuroneko Posts: 3,623
    edited 2012-11-15 17:20
    courtens wrote: »
    Sorry for not being clear enough. I ran out of I/O's on the propeller chip. So I do not have any remaining IO's that I can assign for chip 2 (unused) and 3 (unused).
    Let's assume chip 1 uses pins 3, 4 and 5. As you only use one chip anyway start your driver with:
    adc.start(3, 4, 5, 3, 4, 5, 3, 4, 5)
    
    The driver prepares the masks internally but only uses them (assign to dira) when you actually ask for chip N, e.g. if you never use chip 2 you could set all three pins the same (and any value). Assigning the same pin triple to all three chips will be the best option here as doing so makes the chip number a wildcard (1, 2 or 3).
  • courtenscourtens Posts: 101
    edited 2012-11-15 17:40
    My coffee buzz is not helping much 11 hours later...

    I wasn't sure about the communication between the MCP3208 chip and the propeller. Was afraid that the AD converter would somehow get overwhelmed by all the request. But if that works, sure -- why not.

    Thanks a bunch!
Sign In or Register to comment.