MCP3008 / SPI

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
henker
Posts: 45
Joined: Mon Dec 22, 2008 11:22 pm
Location: Prospect, NS, Canada
Has thanked: 7 times
Been thanked: 2 times
Contact:

MCP3008 / SPI

Post by henker »

Hello,
Has anyone used the analog to SPI converter MCP3008.
I'm trying to make this work with an 18F4685 but no luck.

I'm using the SPI component sending byte 0x01 and then a byte containing 0x08.
This is the start byte and the byte requesting data from channel 0

The problem is that the data I'm getting back is garbage.
I have attached a snapshot of the communication protocol.
It looks like that the 10 bit is returned starting the the byte that you send requesting the data...

Hopefully someone can push me in the correct direction.


Thanks for the help
henk
Attachments
Capture.JPG
Capture.JPG (93.82 KiB) Viewed 4668 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: MCP3008 / SPI

Post by Benj »

Hello,

Please can you post your program so far so we can try and find what's going wrong.

henker
Posts: 45
Joined: Mon Dec 22, 2008 11:22 pm
Location: Prospect, NS, Canada
Has thanked: 7 times
Been thanked: 2 times
Contact:

Re: MCP3008 / SPI

Post by henker »

Ben,

Attached is the FC5 code.
When connecting the Analog 0 pin to Ground the SPI gives 0, with that pin to +5V, the SPI provides 1023.
So far so good. When giving 1V, the SPI should give about 200, however this is not the case; The value is all over the place...
I'm afraid it has something to do with the fact that the second byte contains both SPI in and SPI out.
Thanks for you help.
Henk
Attachments
MCP3008.fcf
(12 KiB) Downloaded 276 times

henker
Posts: 45
Joined: Mon Dec 22, 2008 11:22 pm
Location: Prospect, NS, Canada
Has thanked: 7 times
Been thanked: 2 times
Contact:

Re: MCP3008 / SPI ->>> Please read IMPORTANT

Post by henker »

All,
The MCP3008 - PIC interfacing is solved. Attached is the code. All straight forward.

The actual problem why I had inconstant readings was caused by the grounding of my breadboard.
In the passed I had experienced this before and again I had this issue.
Because the backplate of the breadboard is made from steel is seems to react like a capacitor.
To solve this, connect a wire from the back plate to the 0 of your supply voltage.

This might be common knowledge but if you don't know this it can cost you lots of hair (or have it turn grey)

Thanks
Henk
Attachments
MCP3008.fcf
(11.5 KiB) Downloaded 320 times

Post Reply