I'm using WiringPi library (in c++) to interface a MCP3008 ACD via SPI, but i need to read 24 analog inputs so i have to be able to interface 3 different MCP3008. i don't how to manage 3 different slaves with tthe WiringPi library.
ANSWER: (Idon't have enough reputation to answer my own question so i leave it here in case it could be useful for someone)
Using the mcp3004 library you can use the SPI interface to communicate with de AD converter.
You just have to conect the MISO, MOSI, SCLK and CE0 in the corresponding slave's pins. The main problem was tha i needed to use 3 different slaves, but the solution is simple. All the slaves need to have the same MOSI, MISO, SCLK so you should connect those pins all to the MOSI, MISO and SCLK pins of the raspberry.
Now you have to make the CE0 raspberry pin to be connected to the slave you want to use, and the other slaves CS pin have to be pulled HIGH (because it is Active-low and you want them to be INACTIVE). The way that i find to do this is to use OR-GATES (2 inpust) so i use one gate for each slave. One of the inputs would be the CE0 raspberry pin (the same for the others slaves), the other input would be a GPIO pin (one different for each slave) and the OR-GATE output would be connected to the slave selection pin (same for the other slaves).
The idea is that if you want to use the slave 1 you should pull the pin1 LOW by digitalWrite(Pin1,LOW);
and the others HIGH by digitalWrite(Pin2,HIGH); digitalWrite(PINn,HIGH)
. Doing this you make the first slave CS pin to have the value of de CE0 and the others to have a HIGH (so the first slave is selected and the others are unselected).
you cant simply pull LOW the one you want to select and HIGH the other because the SPI pulls up and down the CS pin with a particular timming
Expecial thanks to @Ptaq666, @Jespe Juhl and the others who read the question and help me with it.
If I understand correctly that your problem is: "How to use one SPI master device connected to 3 slave devices", here is the solution:
void digitalWrite (int pin, int value);
for that.In the Internet there is A LOT of schematics, diagrams, tutorials on this topic. SPI on RPi is no different than any other SPI.
Should you encounter any software problems with the configuration, communication, whatever --> post some code in your question to show what you have already tried.