juanpaexpedite
Posts: 15
Joined: Fri May 15, 2015 10:27 am

SPI Channel 1 with MCP3002 in Windows 10 IoT

Tue Jun 02, 2015 9:29 am

I am learning SPI with the RPi2 and after the first great test with CH0 now I want to make the following steps, but I have several doubts:

Image

1.-What is the use of the pin 26 [SPI0 CS1]? That means that there are ADCs with two channel select signal? Any example?

2.- To use the channel 0 I have no issue, but to use the channel 1 I have:
return new SpiConnectionSettings(ChipSelect0)
{
ClockFrequency = 500000,
Mode = SpiMode.Mode0
};


Where ChipSelect == 0. simple.

Do I have to change something in the Writebuffer from:

public byte[] WriteBuffer = new byte[2] { 0x68, 0x00 };

to another writebuffer to read from the other channel?

Berndt73
Posts: 11
Joined: Tue Jun 02, 2015 11:13 am

Re: SPI Channel 1 with MCP3002 in Windows 10 IoT

Tue Jun 02, 2015 11:20 am

Hi,

I played around with the MCP3008 last weekend, so I was also puzzled what the wiriteBuffer means, which I figured out by looking at the datasheet.So, look at the DataSheet for the MCP3002 in TABLE 5-1 you will find the description for setting the bits...

http://pdf1.alldatasheet.com/datasheet- ... P3002.html
Sidenote: I was not able to use channel1 on the MCP3008, I think there is a small glitch in the API

HTH,

Berndt Hamboecxk

texy
Forum Moderator
Forum Moderator
Posts: 5157
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: SPI Channel 1 with MCP3002 in Windows 10 IoT

Tue Jun 02, 2015 12:07 pm

juanpaexpedite wrote:1.-What is the use of the pin 26 [SPI0 CS1]? That means that there are ADCs with two channel select signal? Any example?
It doesn't mean that the ADC would necessarily have 2 channels, but that 2 devices can be used. For example, many SPI-driven touch screens use both channels - one for the display controller, the other for the touch panel controller. I suspect that multi-channel ADC's will use software registers to select channels.
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

juanpaexpedite
Posts: 15
Joined: Fri May 15, 2015 10:27 am

Re: SPI Channel 1 with MCP3002 in Windows 10 IoT

Tue Jun 02, 2015 1:46 pm

Berndt73 wrote:Hi,

I played around with the MCP3008 last weekend, so I was also puzzled what the wiriteBuffer means, which I figured out by looking at the datasheet.So, look at the DataSheet for the MCP3002 in TABLE 5-1 you will find the description for setting the bits...

http://pdf1.alldatasheet.com/datasheet- ... P3002.html
Sidenote: I was not able to use channel1 on the MCP3008, I think there is a small glitch in the API

HTH,

Berndt Hamboecxk
And have you found what can be the bytes for the buffer, watching python I think is 0X01, 0XC0 but I am not sure the code I am reading.

Berndt73
Posts: 11
Joined: Tue Jun 02, 2015 11:13 am

Re: SPI Channel 1 with MCP3002 in Windows 10 IoT

Wed Jun 03, 2015 8:47 am

I have no idea, why 0x68 is used, I would try 0x6C (set the 3rd bit), because

channel = 0 sends 0000 0001 1000 0000 0000 0000
channel = 1 sends 0000 0001 1100 0000 0000 0000

I've applied the reference voltage of +3.33V to the input of the MCP and I received a value of 1023 when the setup was correct, so I tried all (useful) combinations on the MCP3008 mentioned in the datasheet...

juanpaexpedite
Posts: 15
Joined: Fri May 15, 2015 10:27 am

Re: SPI Channel 1 with MCP3002 in Windows 10 IoT

Thu Jun 04, 2015 12:35 pm

Finally digging in to the specifications and testing, to use the channel 1 you need to use
new byte[2] {0x70,0x00}.


It would be great if someone post the bytes for the MCP3008. At this moment I do not have any so I will test when I get one.

With that can be used to sensors with the SPI0 directly.

Berndt73
Posts: 11
Joined: Tue Jun 02, 2015 11:13 am

Re: SPI Channel 1 with MCP3002 in Windows 10 IoT

Thu Jun 04, 2015 1:15 pm

You find the datasheet here:
https://www.adafruit.com/datasheets/MCP3008.pdf
Table 5.2 is what you need...

When I playd around with it I was successful with these values:
0x08 was CH0
0x09 was CH2
0x0A was CH4
0x0B was CH6

Return to “Windows 10 for IoT”