Shop OBEX P1 Docs P2 Docs Learn Events
MCP3208 problems SOLVED THANKS :) — Parallax Forums

MCP3208 problems SOLVED THANKS :)

BasilBasil Posts: 380
edited 2007-09-14 23:10 in Propeller 1
Hi All,

I have a problem [noparse]:)[/noparse]

I have a MCP3208 connected to the prop with Din and Dout tied together.
The values I am getting back do not seem to be right.

Nothing connected to the following:
Chan 0 returns 0
Chan 1 returns 0
Chan 2 returns 14
Chan 3 returns 0
Chan 6 returns 1
Chan 7 returns 0
These are all floating so the crazy value is not really a biggie.

Accelerometer on channel 4
Chan 4 returns 12, should be returning ~2048

Pressure sensor on channel 5
Chan 5 returns 0, should be returning ~3500

I have check the voltage output from the sensors and they are fine.

Heres my code [noparse]:)[/noparse]


CON
  _clkmode = xtal1 + pll16x
  _xinfreq = 4_000_000
  ADC_CLK       = 12 'Clock to ADC
  ADC_DIN       = 13 'Data to/from ADC
  ADC_CS        = 14 'CS to ADC

VAR

  long  Stack[noparse][[/noparse]150]
  long  Cog
  word  Temp
  
OBJ
  Num   :       "Numbers"
  TV    :       "PC_Text"
  ADC   :       "MCP3208"
  
PUB Main | i, ii, ok
  waitcnt(32_000_000*10 + cnt)            'Delay

  Num.Init                                    'Initialize Numbers   
  TV.Start(30)                                'Start TV Terminal    
  TV.Str(string("TV started "))         'then display it and  
  TV.Out(13)                                                                  

  ADC.start(ADC_DIN, ADC_CS, ADC_CLK, %1)
  TV.Str(string("ADC Cog started "))         'then display it and  
  TV.Out(13)                                                                  
                                                                              
  repeat 
    waitcnt(64_000_000 + cnt)
    TV.out($00)               
    repeat ii from 0 to 7 step 1
      Temp  := ADC.in(ii)
      TV.Str(Num.ToStr(ii, Num#DDEC))    
      TV.Str(string(" ADC = "))        
      TV.Str(Num.ToStr(Temp, Num#DDEC))        
      TV.Out(13)                                                             





Thanks for any help!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Alec

My our page

Post Edited (Basil) : 9/14/2007 11:13:24 PM GMT

Comments

  • BasilBasil Posts: 380
    edited 2007-09-14 04:37
    Just changed mode to '$FF' rather than just '1'.

    Now all results are reading '0'...better [noparse]:)[/noparse] Still not correct, but no crazy values now...just none [noparse]:)[/noparse]

    Should also mention, I have a 1K resistor between Data pins and prop.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    -Alec

    My our page
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2007-09-14 06:17
    Basil,

    Can you zip the entire project (excluding the IDE)? We can't tell much without looking at what is inside of the MCP3208 object.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • parskoparsko Posts: 501
    edited 2007-09-14 07:54
    Basil,

    I have worked with the MCP3002, quite successfully, which is almost the same thing as a 3208. But, I recall that Din and Dout needed to have a resistor between them should you choose to drive then from one common pin on the Prop. It sounds like you have them tied together without the resistor, is this true? I'll try to dig up a post where (if I recall) Mike Green states that it's okay to drive these from one pin. I think it was a 1k or 4.7k ohm......

    -Parsko

    PS - I attached my MCP3002 code, in assembly, pretty well documented. It is messy, so I'm sorry if it isn't helpful, but it might give you some ideas...
  • Chad GeorgeChad George Posts: 138
    edited 2007-09-14 13:09
    Basil,

    I've used the 3208 in several projects and I know more than one time I didn't have the reference voltage attached correctly and it behaved similar to what you described.

    -Chad
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-09-14 14:51
    Interesting chip. Here's the datasheet for those following along: http://ww1.microchip.com/downloads/en/DeviceDoc/21294C.pdf

    Post Edited (Fred Hawkins) : 9/14/2007 5:45:24 PM GMT
  • mynet43mynet43 Posts: 644
    edited 2007-09-14 15:43
    I sent him a separate email.

    The main problem is that he has the call parameters for CLK and CS reversed.

    I also told him to use $FF.

    Jim
  • BasilBasil Posts: 380
    edited 2007-09-14 23:10
    Hi Jim,

    Just got your email [noparse]:)[/noparse] Its works! Silly parameters :P

    Thanks guys for all the suggestions [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    -Alec

    My our page
Sign In or Register to comment.