Page 1 of 1

MCP3008 / SPI

Posted: Tue Jul 29, 2014 1:31 am
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

Re: MCP3008 / SPI

Posted: Tue Jul 29, 2014 9:12 am
by Benj
Hello,

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

Re: MCP3008 / SPI

Posted: Wed Jul 30, 2014 3:13 am
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

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

Posted: Wed Jul 30, 2014 11:19 pm
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