PDA

View Full Version : MCP3208 problems SOLVED THANKS :)



Basil
09-14-2007, 10:12 AM
Hi All,

I have a problem :)

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 :)





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[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
(http://our.rocketryplanet.com/profile/basil4j)
Post Edited (Basil) : 9/14/2007 11:13:24 PM GMT

Basil
09-14-2007, 12:37 PM
Just changed mode to '$FF' rather than just '1'.

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

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

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

My our page
(http://our.rocketryplanet.com/profile/basil4j)

Beau Schwabe
09-14-2007, 02:17 PM
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 (mailto:bschwabe@parallax.com)

IC Layout Engineer
Parallax, Inc.

parsko
09-14-2007, 03:54 PM
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 George
09-14-2007, 09:09 PM
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 Hawkins
09-14-2007, 10:51 PM
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

mynet43
09-14-2007, 11:43 PM
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

Basil
09-15-2007, 07:10 AM
Hi Jim,

Just got your email :) Its works! Silly parameters :P

Thanks guys for all the suggestions :)

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

My our page
(http://our.rocketryplanet.com/profile/basil4j)