Shop OBEX P1 Docs P2 Docs Learn Events
MCP3202-B 2-channel 12-bit A/D object posted — Parallax Forums

MCP3202-B 2-channel 12-bit A/D object posted

Ken GraceyKen Gracey Posts: 7,401
edited 2009-10-01 15:28 in Propeller 1
Hey there,

Posted tonight at http://obex.parallax.com/objects/515/ is the above object. Based on Chip's code for the 3208 and adapted specifically for the 3202 (thanks Chip!). Needed this for a simple application with my robot and couldn't find a MCP3202 object.

Analog inputs are from the #27800 Parallax Joystick. Data is displayed with Parallax Serial Terminal. Enjoyed using Andy's FullDuplexSerialPlus with the shortened serial command structure, too. Pretty handy to have the details tucked away. Will port it to TV next with a bit of luck and experimentation.

Just getting back into the swing of things so expect to see more of my silly questions posted right here on the Propeller forum.

Any and all input is both welcome and appreciated -- critical, constructive, or just plain funny!

Thanks,

Ken Gracey
Parallax Inc.

Post Edited (Ken Gracey (Parallax)) : 9/20/2009 4:25:52 AM GMT

Comments

  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2009-09-20 04:45
    Looks great. Lots of comments which is excellent. I may get to try it out in a month or so when I pick up some chips. yeah.gif I was wondering where you where getting the CarriageReturn from until I noticed that you were using
    FullDuplexSerialPlus and not FullDuplexSerial I don't remember seeing the FullDuplexSerialPlus around before. Looks like Andy added some nice features. jumpin.gif
  • edited 2009-09-20 14:03
    just tested and it works great - a very nice and simple to use object.
  • Greg LaPollaGreg LaPolla Posts: 323
    edited 2009-09-21 01:34
    I have a question about making this work with the 3204. I am not very well versed in Assembly. To make this work with 4 channels

    main_loop               mov     command,#%1001          'init command (start + msbf)
                            mov     t1,par                  'reset sample pointer
                            mov     t2,enables              'get enables
                            mov     t3,#2                   'ready 2 channels
    
    



    if the last line here is changed from #2 to #4 will that then give me 4 channels or is there more to it ?


    Greg
  • John AbshierJohn Abshier Posts: 1,116
    edited 2009-09-30 17:38
    Ken, I had lots of problems with this code. The demo code will only work if the clock pin = 0, since it overwrites the clock pin definition with the 0 value of dacmode. If you want to use the DAC mode, the assembly program reads 5 parameters but the Spin code only provides 4.

    I have attached my modifed MCP3202 driver. You and Chip can review and update the object as you think best.

    John Abshier

  • Ken GraceyKen Gracey Posts: 7,401
    edited 2009-09-30 17:52
    Hey John,

    Thanks! We'll take a look today and update as appropriate. I'll also try switching I/Os to duplicate the results you are seeing. Then we'll replace the OBEX post with your code if it addresses the errors.

    Sincerely,

    Ken Gracey
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2009-09-30 17:58
    Greg LaPolla said...
    I have a question about making this work with the 3204. I am not very well versed in Assembly. To make this work with 4 channels

    main_loop               mov     command,#%1001          'init command (start + msbf)
                            mov     t1,par                  'reset sample pointer
                            mov     t2,enables              'get enables
                            mov     t3,#2                   'ready 2 channels
    
    



    if the last line here is changed from #2 to #4 will that then give me 4 channels or is there more to it ?


    Greg

    I am pretty sure (can someone confirm) the 4 channel ADCs work on the same data scheme as the 8 channel ones. So it should work with the MCP3208 drivers on the Obex (like the one in my signature).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!

    Some of my objects:
    MCP3X08/4 ADC Driver - Programmable Schmitt inputs, frequency reading, and more!
    Simple Propeller-based Database - Making life easier and more readable for all your EEPROM storage needs.
    String Manipulation Library - Don't make strings the bane of the Propeller, bend them to your will!
  • PavelPavel Posts: 43
    edited 2009-10-01 15:28
    Bobb Fwed said...

    I am pretty sure (can someone confirm) the 4 channel ADCs work on the same data scheme as the 8 channel ones. So it should work with the MCP3208 drivers on the Obex (like the one in my signature).

    That's correct. The communication protocol is identical for both, but the D2 bit in the control byte is "don't care" for MCP3204. D2 controls upper/lower quad in channel selection.
Sign In or Register to comment.