MCP3208

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
JAW
Posts: 30
Joined: Tue Jun 16, 2009 2:25 pm
Been thanked: 4 times
Contact:

MCP3208

Post 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
Attachments
LCD SPI ADC REV 1.fcf
(16 KiB) Downloaded 1017 times

JAW
Posts: 30
Joined: Tue Jun 16, 2009 2:25 pm
Been thanked: 4 times
Contact:

Re: MCP3208

Post 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
Attachments
LCD SPI ADC REV 2.fcf
(16 KiB) Downloaded 1018 times

JAW
Posts: 30
Joined: Tue Jun 16, 2009 2:25 pm
Been thanked: 4 times
Contact:

Re: MCP3208

Post 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
Attachments
LCD SPI ADC REV 3.fcf
(16 KiB) Downloaded 1066 times

JAW
Posts: 30
Joined: Tue Jun 16, 2009 2:25 pm
Been thanked: 4 times
Contact:

Re: MCP3208

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: MCP3208

Post 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 1043 times

JAW
Posts: 30
Joined: Tue Jun 16, 2009 2:25 pm
Been thanked: 4 times
Contact:

Re: MCP3208

Post 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

JAW
Posts: 30
Joined: Tue Jun 16, 2009 2:25 pm
Been thanked: 4 times
Contact:

Re: MCP3208

Post 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
Attachments
MCP3208 TEST 20X4 LCD.fcf
(20.96 KiB) Downloaded 880 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: MCP3208

Post 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.

JAW
Posts: 30
Joined: Tue Jun 16, 2009 2:25 pm
Been thanked: 4 times
Contact:

Re: MCP3208

Post by JAW »

Just added your suggestion and as always, You are bang on the money!!

Many Thanks

James :D
Attachments
MCP3208 TEST 20X4 LCD NO SWITCH.fcf
(17.62 KiB) Downloaded 880 times

Post Reply