Page 1 of 1

MCP3208

Posted: Thu Oct 08, 2015 11:04 am
by JAW
Hello all,

I'm currently trying to get data out of an MCP3208 8 channel SPI DAC. I can set the address for each channel and get data back but it is meaningless! I've attached a file of what I'm doing. From the datasheet I've ascertained that on reply from the DAC I get the MSB and then the LSB (page 18 of datasheet) I started to monitor the LSB and MSB values individually and they just don't make any sense. Any advice would greatly appreciated!

Regards

James

Re: MCP3208

Posted: Thu Oct 08, 2015 11:48 am
by JAW
I've made some progress. The new chart is giving a more stable reading but the MSB appears to be inverted. When I increment the pot I get the following on the MSB :-

10000000 128
01000000 64
11000000 192
00100000 32
10100000 160
01100000 96
11100000 224

If the bits were the other way round it would make sense! Any Ideas?

Regards

James

Re: MCP3208

Posted: Thu Oct 08, 2015 4:23 pm
by JAW
More progress but still not quite there!!! I've inverted the MSB using some code off the forum and altered the chars sent to the SPI. It works much better but still can't fathom the last bit, Any ideas ???

Cheers

James

Re: MCP3208

Posted: Tue Oct 20, 2015 9:55 am
by JAW
Has anyone got any help or advice to give?

This chip is driving me up the wall!!! I coming to the mind of finding a different ADC.

Regards

James

Re: MCP3208

Posted: Tue Oct 20, 2015 12:23 pm
by Benj
Hi James,

Wow your right that datasheet is not doing you any favours, seems very complicated.

Anyway here is my attempt at following the datasheet.

Have a look and see how you get on.
LCD SPI ADC REV 3.fcf
(16 KiB) Downloaded 1054 times

Re: MCP3208

Posted: Tue Oct 20, 2015 12:45 pm
by JAW
Hi Benj

It works!!

I have been banging my head against the wall for ages!!. I just need to sit down and understand what you have done differently. I notice you have done the comms in one send char as I did it in two as suggested in the datasheet.

Many Thanks

James

Re: MCP3208

Posted: Tue Nov 03, 2015 4:40 pm
by JAW
Hi All,

I've written a macro now so you can pass the channel number you want to read and it will return the reading of that channel. Took me a little while, with moving house and looking after children over half term! I've tested it and it works great. Saves a lot of time and memory space!

Regards

James :D

Re: MCP3208

Posted: Tue Nov 03, 2015 4:59 pm
by Benj
Hi James,

Looks very good, great job.

You could make the MCP3208_Read function slightly more efficient by replacing the large switch icon with this single icon.

SPI_Send_Char ( 0b00011000 | (ADC_CHANNEL & 7) )

This takes the selected ADC channel, ensures it it in the range 0-7 and combines with the ADC sample code 0b00011000 to give you 0b00011000 to 0b00011111.

Re: MCP3208

Posted: Wed Nov 04, 2015 9:54 am
by JAW
Just added your suggestion and as always, You are bang on the money!!

Many Thanks

James :D