Shop OBEX P1 Docs P2 Docs Learn Events
Modify the MCP3208 Object...? — Parallax Forums

Modify the MCP3208 Object...?

jeff-ojeff-o Posts: 181
edited 2010-12-12 21:46 in Propeller 1
Hey everyone, I'd like to use the MCP3208 object from the OBEX (programmed by Chip himself!) The problem is that my custom board uses separate pins for DOUT and DIN, while the object uses a single pin for both. Is there any way to modify the code to use separate pins?

Here's the object: http://obex.parallax.com/objects/180/

Comments

  • ThricThric Posts: 109
    edited 2010-12-11 14:09
    this is what i found in the OBEX http://obex.parallax.com/objects/488/
    it uses different pins
  • Duane DegnDuane Degn Posts: 10,588
    edited 2010-12-11 14:54
    jeff-o,

    I tried hacking the object you refered to before I saw Thric's post. His is probably a better method of doing this.

    I made a very ugly hack of Chip's beautiful code. I haven't tried it myself, (famous last words) but my limited understanding of PASM is telling me it should work.

    Just change the number of left shifts of the variable dInOnly to the pin number of your data in pin.
    dInOnly                 long    1 << 4          ' change 4 to match your data in pin
    

    I'll try to find one of my MCP3208s to try this on.

    I feel like I just put a crayon mustache on the Mona Lisa.

    Duane
  • Duane DegnDuane Degn Posts: 10,588
    edited 2010-12-11 16:41
    The code I previously posted does NOT work.

    I wired up a MCP3208. It works fine with Chip's object but I get zeros with mine.

    If I get it to work, I'll post an update. But don't hold your breath.

    Duane
  • Duane DegnDuane Degn Posts: 10,588
    edited 2010-12-11 17:19
    Another correction.

    The code I posted does work! Wow, I'm a genius! (that was sarcasm)

    I had my data lines switched. The dInOnly pin is connected to the ADC data out pin. (How many times am I going to get rx and tx switched?)

    So if you're willing to hard code the pin number connected to the data out on the ACD then the code I posted should work.

    I'm so relieved to know I understand PASM as much as I thought I did.

    Duane
  • jeff-ojeff-o Posts: 181
    edited 2010-12-11 18:10
    Duane Degn wrote: »
    Another correction.

    The code I posted does work! Wow, I'm a genius! (that was sarcasm)

    I had my data lines switched. The dInOnly pin is connected to the ADC data out pin. (How many times am I going to get rx and tx switched?)

    So if you're willing to hard code the pin number connected to the data out on the ACD then the code I posted should work.

    I'm so relieved to know I understand PASM as much as I thought I did.

    Duane

    Fantastic! I'll take it for a spin right away and let you know how it goes.
  • jeff-ojeff-o Posts: 181
    edited 2010-12-12 21:46
    Hey everyone, so here's what I ended up doing. Duane's mod did work, but I ended up using the object Thric recommended. I had found that object myself, but didn't use it because I wasn't able to import it into 12blocks. The MCP3208 object worked though. In the end, I figured out how to modify the ADC_INPUT_DRIVER object to work with 12blocks, and used it because it had a frequency measurement tool which I needed anyway.
Sign In or Register to comment.