Shop OBEX P1 Docs P2 Docs Learn Events
How to Setup Two (2) MCP3208 Analog to Digital Converters connected to One (1) Propeller — Parallax Forums

How to Setup Two (2) MCP3208 Analog to Digital Converters connected to One (1) Propeller

Dear forum,

I want to create a sensor device that has 16 A2D inputs. I am using 2 MCP3208 converters each with 8 inputs. I know how to setup 1 MCP3208 using the regular MCP3208.spin object, by connecting the Din and Dout pins of the MCP to the same pin in the propeller, CLK of the MCP to another pin in the propeller, and CS/SHDN to another pin in the propeller. Should I use another 3 propeller inputs for the second MCP, and call a second object MCP3208-2.spin (copy of MCP3208.spin), or since it is SPI, there is another way.

Please help me.

Thank you!!

Comments

  • They way I do it is. I use a separate pin set for each MCP3208. And then duplicate the spin object and change the pin numbers
  • There is absolutely another way, but you'll need to modify the MCP3208 object so that the Spin driver for talking I2C can support two different I2C lines most likely. I don't know exactly which MCP3208 driver you're using (nor am I the right person to give Spin advice) but at a high-level: yes it's possible. The difficulty of making that change will depend on the specific driver you found.
  • The SCLK, DI (MOSI), and DO (MISO) pins can be shared. Connect them on a bus to the Propeller (3 pins). Connect the /CS pin of each device to Vdd through a 4.7K-10K resistor. You will need a pin for each device. To select an ADC, pull the /CS pin for it low, get a reading, and then let that pin float (make it an input); the pull-up will disable the chip.

    For two ADCs you'll need five pins using a standard SPI bus setup.

    I made made a version of my simple MCP3208 object that will let you have multiple MCP3208s on a shared bus.
  • There's a routine in the Object exchange that supports three MCP3208's (MCP3208 fast ADC 12 bit 24 chnl Multi-Chip).
  • Awhile back I wrote some code to read two MCP3208's simultaneously, not just one and then the other. This was part of a resolver reading project where any discrepancy in delay between the Sine and Cosine channels would result in a positioning error. I'll see if I still even have that code, but as I remember, I modified the PASM code so that there was one shared clock and two data lines within the same object. I used two MCP3208's for X,Y, and Z positioning.... One MCP3208 for Sine, and the other for Cosine.... two channels were left over. ... One spare on each MCP3208.
  • Here is what I could find in the way of a program.... It seems to be missing a "simple numbers Light.spin" file, but should get you started.

    The Assembly program makes use of a Sync pin used with the resolver to sample the ADC at 90 deg and 270 deg so you might need to modify or remark those lines of code in the PASM.

    It's been over 3 years since I really programmed the Propeller and I sold off all of my Parallax/Propeller gear.

    You-Tube video of Resolver program in action:
  • JonnyMac wrote: »
    The SCLK, DI (MOSI), and DO (MISO) pins can be shared. Connect them on a bus to the Propeller (3 pins). Connect the /CS pin of each device to Vdd through a 4.7K-10K resistor. You will need a pin for each device. To select an ADC, pull the /CS pin for it low, get a reading, and then let that pin float (make it an input); the pull-up will disable the chip.

    For two ADCs you'll need five pins using a standard SPI bus setup.

    I made made a version of my simple MCP3208 object that will let you have multiple MCP3208s on a shared bus.
    As always, Thank you for your help Jonny!

    It was really helpful and saved me some pins!
Sign In or Register to comment.