Shop OBEX P1 Docs P2 Docs Learn Events
Propeller C3 ADC (MCP3202) — Parallax Forums

Propeller C3 ADC (MCP3202)

I inherited a prop c3 board from my dad, and I am in the process of writing a game for it. I am attempting to connect a joystick I have to the board's built in ADC, but so far, I have had no success. The board uses a 4-bit counter to access several spi devices without having multiple chip select lines. I have been heavily using the
"Unleashing the Propeller C3" pdf by Andre LaMothe (https://www1.parallax.com/sites/default/files/downloads/32209-Unleashing-Propeller-C3v1.0.pdf)

The PDF further discusses the structure of the adc.

Attached is the code I am using to select the adc from the several spi devices, initialize it, read the channel and display it to the serial terminal. This is code from the "Unleashing the propeller c3" PDF.

When I run this program, the serial terminal displays "Channel 0: 0" and nothing else, even when I rotate the joystick.

I know that the device has been selected, because I have an oscilloscope and I can see the clock pin going high and low. I can also see the MOSI pin going high and low, but the MISO pin does not change at all.

I would like to make sure that there isn't anything else wrong before I decide the adc is shot.

Any help would be appreciated!

Comments

  • Here are some pictures of my setup.

    The first two are of the clock and MOSI pins, the second is of the MISO pin, and the third is of the setup in general.




  • Hi guys, I've got an update. I checked the chip select line for the adc and saw that it was low. This means that the spi mux is not selecting the right device, or it is not selecting any devices at all.

  • JonnyMacJonnyMac Posts: 9,159
    edited 2022-10-04 00:48

    I found the same thing. The only SS pins brought out to a header are 6 and 7, but I cannot get them to go low, either. I'm going to double-check my mux bits as I'm using code from a stand-alone MCP3202 driver that I wrote and used a long time ago. Still, that doesn't explain which I can't get SS6 or SS7 to drop.

    I looked at your program -- you have some formatting errors that will be a problem once the chip-select thing is worked out.

  • JonnyMacJonnyMac Posts: 9,159
    edited 2022-10-04 15:03

    It took some hunting, but I found a copy of the source code archive.
    -- http://www.ic0nstrux.com/download/propc3/propc3_demo_software.zip

    The problem is in the docs; it has the SPI device clear and device clock pins reversed. Also, coding style used is visually "noisy" which I find hard to follow. The attached demo works. IMO (of course), the style is easier on the eyes which makes it easier to follow, understand, and update.

    Updated (04 OCT 2022)
    -- added pin names for all C3 IO
    -- added generic SPI transfer method (similar to demo code)

  • Here's an LA screen-cap of the signals (sans chip select) while reading channel 0 in single-ended mode.

  • Thanks so much! I did notice those formatting errors later on. I believe they were from copying and pasting from the PDF. The code looks good, and I’ll test it out as soon as I can. I’m a sophomore in high school and do this as a hobby, so I need all the help I can get! Thanks again for your help on this, and for the many great objects you have written and shared.

  • Good luck with your programming projects. Do try to keep your code tidy and orderly so that you and others will be able to pick it up later.

  • Thank you so much for the link to the source code archive! In the PDF an ftp link is mentioned a lot, but I could not get it to work. Access to the materials that are referenced in the PDF will make working with this board sooo much easier!

Sign In or Register to comment.