Tuesday, 7 July 2015

Connect 2 Custard Pi 3's to a Raspberry Pi and get 16 analogue inputs

The Custard Pi 3 plugs into the Raspberry Pi GPIO (A, B, B+ and 2) and provides 8 analogue inputs using the SPI bus. This post shows how you can connect 2 x Custard Pi 3 to a Raspberry Pi and get 16 inputs. (There is soldering required).

The Custard Pi 3 uses the SPI bus. The connections are shown below.

J1-24 is the chip enable (CE0) output from the GPIO which is used to address the AtoD chip - MCP3208. The other pins are

J1_19:  MOSI - data out from the GPIO (input to MCP3208)
J1_21: MISO - data into the GPIO  (output from MCP3208)
J1_23: SCLK - used to clock data in and out.

The GPIO has a second chip enable (CE1) provided on pin J1_26. On the second Custard Pi 3 board, cut the connection from pin 10 of the IC (U1) to pin 24 of J1 and connect pin 10 of IC (U1) to pin 26 of J1 instead.

The 2 Custard Pi 3 baords can be stacked on top of each other as they both have stackable GPIO connectors.

Now all one has to do is to modify the Python code to address the second Custard Pi 3 board which has been modified to be eneabled from CE1 (Pin 26 of J1).

In the downloads tab of the SF Innovations website (http://www.sf-innovations.co.uk/downloads.html) the mods required to "Function for reading analogue inputs (Projects 11,& 14)" are shown below.

1.  In section below change 2nd line to " GPIO.setup(26, GPIO.OUT) #pin 26 is chip enable"


GPIO.setup(24, GPIO.OUT)    #pin 24 is chip enable
GPIO.setup(23, GPIO.OUT)    #pin 23 is clock 
2. In section below change 2nd line to "GPIO.output(26, True)"
#set pins to default state
GPIO.output(24, True)       
GPIO.output(23, False)
GPIO.output(19, True) 

3. In section below change first line to "GPIO.output(26, False)  #enable chip"

    GPIO.output(24, False)  #enable chip
    anip=0  #clear variable
4.  In section below change 2nd line to "GPIO.output(26, True) #disable chip"
        #print (bit,value,anip)    
    GPIO.output(24, True)       #disable chip 

5.  Now save this file with a different name.

6.   Call the original file for a reading from the unmodified Custard Pi 3 and call the modified 
file for a reading from the modified Custard Pi 3.


This is a method for connecting 2 Custard Pi 3's to the Raspberry Pi to get 16 analogue inputs.


No comments:

Post a Comment