Shop OBEX P1 Docs P2 Docs Learn Events
Sample code for MCP3204 ADC? — Parallax Forums

Sample code for MCP3204 ADC?

Martin HebelMartin Hebel Posts: 1,239
edited 2010-04-23 14:23 in Propeller 1
Can someone post some sample code to read the MCP3204 using the MCP3208 driver by Chip in the installed propeller tool?

I think we are using it right, but getting 0 out.

Thanks!

Martin

Comments

  • hover1hover1 Posts: 1,929
    edited 2010-04-23 13:39
    Martin, I came up with a couple demos for that chip over in the Object Exchange.

    ·http://obex.parallax.com/

    Jim

    OK..maybe one:
    http://obex.parallax.com/objects/488/


    Post Edited (hover1) : 4/23/2010 1:44:19 PM GMT
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2010-04-23 13:46
    Thanks, but that's a totally different driver than I want to use.
  • BeanBean Posts: 8,129
    edited 2010-04-23 14:02
    I don't know if this will help you, but here is the PropBasic code I use to read the MCP3204.
    TASK ReadADC ' Reads CH0 of ADC. Puts value in HUB long "EFCVal".
     
      Value  VAR LONG
    
     
      HIGH ADC_Cs
      LOW ADC_Clk
      PAUSE 5
      DO
        LOW ADC_Cs        ' Enable MCP3204
        PAUSEUS 100
        SHIFTOUT ADC_Din, ADC_Clk, MSBFIRST, %11000\5 ' Select CH0, Single-Ended
        SHIFTIN ADC_Dout, ADC_Clk, MSBPOST, Value\13  ' Read ADC
        HIGH ADC_Cs       ' Disable ADC
        LOW ADC_Clk
    
        WRLONG EFCVal, value
        PAUSE 1
      LOOP
    ENDTASK
    
    


    Bean


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Use BASIC on the Propeller with the speed of assembly language.
    PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

    March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There are two rules in life:
    · 1) Never divulge all information
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2010-04-23 14:23
    lol, thanks Bean, but no, doesn't help since it isn't spin and not using the driver we are using. Thanks though.

    -Martin
Sign In or Register to comment.