Custard pi 7 user information

1,530 views
1,408 views

Published on

The Custard Pi 7 provides Raspberry Pi hardware hackers with a handy board that is packed with features.

Published in: Business, Technology
1 Comment
0 Likes
Statistics
Notes
  • Be the first to like this

No Downloads
Views
Total views
1,530
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
1
Likes
0
Embeds 0
No embeds

No notes for slide

Custard pi 7 user information

  1. 1. CUSTARD PI 7 USER INFORMATION The Industrial Control Interface for the Raspberry Pi 9th November 2014 SF Innovations
  2. 2. www.sf-innovations.co.uk
  3. 3. www.sf-innovations.co.uk OVERVIEW OF FEATURES 2 Relay outputs 4 Open Collector outputs 2 Built in Switches 8 General Purpose Digital I/O 4 Analogue inputs 1 Analogue output 16 pin LCD Interface LED indication on most ports Screw terminal connection on most ports Flexible Power Supply Board can be powered from Raspberry Pi Board and Rpi can be powered from 5V supply Board and Rpi can be powered by 2 separate 5V supplies LED indication of 5VPi, 5V and 3V3 supplies Fused 5V and 3V3 available on screw terminals Prototyping area with pads for 14-pin SMT IC Ribbon Connector (26 way) to the Raspberry Pi GPIO Second Connector (26 way) to daisy chain a second Custard Pi -7
  4. 4. www.sf-innovations.co.uk LAYOUT OF COMPONENTS This PCB board size 15cm x 11 cm
  5. 5. www.sf-innovations.co.uk PROTOTYPING AREA
  6. 6. www.sf-innovations.co.uk RELAY AND OPEN COLLECTOR OUTPUTS This is provided using the MCP23008 8-port I/O expander which works on the I2C bus. This is followed by the Darlington Driver, the ULN2801 which drives the relays and provides the 4 Open Collector Outputs. There are 6 LEDs which indicate the status of these outputs. The 2 spare pins of the MCP23008 are used for the 2 key inputs from the on board switches.
  7. 7. www.sf-innovations.co.uk RELAY AND OPEN COLLECTOR OUTPUTS These are shown on the picture below. There are 2 sets of screw terminals provided with the relays with access to the 3 terminals (common, normally closed and normally open) of each relay. Screw terminals are also provided for the 4 Open Collector outputs and the 2 keypad inputs.
  8. 8. www.sf-innovations.co.uk RELAY AND OPEN COLLECTOR OUTPUTS This is provided using the MCP23008 8-port I/O expander which works on the I2C bus. This is followed by the Darlington Driver, the ULN2801 which drives the relays and provides the 4 Open Collector Outputs. There are 6 LEDs which indicate the status of these outputs. The 2 spare pins of the MCP23008 are used for the 2 key inputs from the on board switches. The functions to control these are provided in cpi7x.py. Download from here and change from .txt to .py. Default I2C address is 0x27 (add7) The 4 Open Collector outputs are switched on and off using the following settings. ONoc1 and OFFoc1, ONoc2 and OFFoc2, ONoc3 and OFFoc3, ONoc4 and OFFoc4
  9. 9. www.sf-innovations.co.uk RELAY AND OPEN COLLECTOR OUTPUTS The 2 relays are switched on and off using the following settings. ONrl1 and OFFrl1, ONrl2 and OFFrl2. The actual function to set them ON and OFF is: setbit (address , setting) & clrbit (address, setting) In readbit (address, bit) function allows the user to read the status of the the 2 keypad inputs. In addition the setinandout (address) function sets the MCP23008 chip to use 6 of the pins as outputs and 2 as inputs.
  10. 10. www.sf-innovations.co.uk RELAY AND OPEN COLLECTOR OUTPUTS #1/usr/bin/env python import time import cpi7x #start program board1=cpi7x.add7 cpi7x.setinandout(board1) cpi7x.alloff(board1) while True: cpi7x.setbit(board1, cpi7x.ONoc1) time.sleep (0.2) cpi7x.setbit(board1, cpi7x.ONoc2) time.sleep (0.2) cpi7x.setbit(board1, cpi7x.ONoc3) time.sleep (0.2) cpi7x.setbit(board1, cpi7x.ONoc4) time.sleep (0.2) cpi7x.setbit(board1, cpi7x.ONrl2) time.sleep (0.2) cpi7x.setbit(board1, cpi7x.ONrl1) time.sleep (0.5) Listing of sample program to switch relays and open collector outputs on and off and read keypad inputs. Download from here and change from .txt to .py Cpi7ocrelkp.py
  11. 11. www.sf-innovations.co.uk RELAY AND OPEN COLLECTOR OUTPUTS cpi7x.clrbit(board1, cpi7x.OFFoc1) cpi7x.clrbit(board1, cpi7x.OFFoc2) cpi7x.clrbit(board1, cpi7x.OFFoc3) cpi7x.clrbit(board1, cpi7x.OFFoc4) cpi7x.clrbit(board1, cpi7x.OFFrl2) cpi7x.clrbit(board1, cpi7x.OFFrl1) time.sleep (0.5) kp2 = (cpi7x.readbit (board1, 0x01)) kp1 = (cpi7x.readbit (board1, 0x02)) if kp1 == 0: print "kp1 pressed" if kp2 == 0: print "kp2 pressed" import sys sys.exit()
  12. 12. www.sf-innovations.co.uk LCD INTERFACE This is provided using the MCP23008 8-port I/O expander which works on the I2C bus (default address 0x25) A 2 x 16 character display has a 16pin connector on a 0.1 inch pitch and can easily be connected to the Custard Pi 7 with a ribbon connector. The functions to drive the display are provided in cpi7lcd.py. Download from here and change from .txt to .py.
  13. 13. www.sf-innovations.co.uk LCD INTERFACE Here is a ribbon cable connecting the LCD to the Custard Pi 7. (You will need to solder a 16 way connector to the LCD.)
  14. 14. www.sf-innovations.co.uk LCD INTERFACE #1/usr/bin/env python import time import cpi7lcd lcd = cpi7lcd lcd.lcdinit(0x25) while True: lcd.lcd_clear time.sleep (0.5) lcd.lcd_puts("LCD line 1 test",1) #display text on line 1 time.sleep (0.5) lcd.lcd_clear lcd.lcd_puts("LCD line 2 test",2) #display text on line 2 time.sleep (0.5) lcd.lcdinit(0x25) import sys sys.exit() Listing of sample program to write to a 2 line display. Download from here and change from .txt to .py testlcd.py
  15. 15. www.sf-innovations.co.uk 8 GENERAL PURPOSE DIGITAL I/O This is provided using the MCP23008 8-port I/O expander which works on the I2C bus (default address 0x26). The functions to control these I/O is provided in cpi7y.py. Download from here and change from .txt to .py.
  16. 16. www.sf-innovations.co.uk 8 GENERAL PURPOSE DIGITAL I/O The functions to control these I/O is provided in cpi7y.py. Download from here and change from .txt to .py. This works very similarly to the Relay and Open Collector controls. For this example 4 of the bits are set as outputs and 4 as inputs. The settings to control the outputs are: ONbit4, ONbit5, ONbit6, ONbit7 and OFFbit4, OFFbit5, OFFbit6, OFFbit7. The functions available are: setbit To switch outputs high clrbit To switch outputs low readbit Read inputs setinandout To set 4 bits as outputs and 4 as inputs setpullups 100k pullups on input pins alloff set all outputs to lo
  17. 17. www.sf-innovations.co.uk 8 GENERAL PURPOSE DIGITAL I/O The MCP23008 is a very versatile input output device. It allows the user set All 8 pins as inputs, outputs or a mix of inputs and outputs. The inputs can be set to have pull-ups and also generate an interrupt on change of status. There is more info on the registers on the datasheet.
  18. 18. www.sf-innovations.co.uk 8 GENERAL PURPOSE DIGITAL I/O #1/usr/bin/env python import time import cpi7y import pylcdlibseg board1=cpi7y.add6 cpi7y.setinandout(board1) cpi7y.setpullups(board1) cpi7y.alloff(board1) while True: cpi7y.setbit(board1, cpi7y.ONbit4) time.sleep (0.2) cpi7y.setbit(board1, cpi7y.ONbit5) time.sleep (0.2) cpi7y.setbit(board1, cpi7y.ONbit6) time.sleep (0.2) cpi7y.setbit(board1, cpi7y.ONbit7) time.sleep (0.5) cpi7y.clrbit(board1, cpi7y.OFFbit4) cpi7y.clrbit(board1, cpi7y.OFFbit5) cpi7y.clrbit(board1, cpi7y.OFFbit6) cpi7y.clrbit(board1, cpi7y.OFFbit7) time.sleep (0.5) Listing of sample program to switch the 4 outputs high and low and read the 4 inputs. Download from here and change from .txt to .py Cpi7gpio.py To test: Connect a resistor and LED from bit4 to GND and see it flash. Then test bit5, bit6 and bit7.
  19. 19. www.sf-innovations.co.uk 8 GENERAL PURPOSE DIGITAL I/O bit0 = (cpi7y.readbit (board1, 0x01)) bit1 = (cpi7y.readbit (board1, 0x02)) bit2 = (cpi7y.readbit (board1, 0x04)) bit3 = (cpi7y.readbit (board1, 0x08)) if bit0 == 0: print "bit0 low" else: print "bit0 high“ if bit1 == 0: print "bit1 low" else: print "bit1 high“ if bit2 == 0: print "bit2 low" else: print "bit2 high“ if bit3 == 0: print "bit3 low" else: print "bit3 high" print "***************************" import sys sys.exit() To test: Connect a link from bit0 to GND and check that the program detects this. Then test bit3, bit2 and bit 1.
  20. 20. www.sf-innovations.co.uk 4 ANALOGUE INPUTS AND ANALOGUE OUTPUT This is provided using the PCF8591 8-bit A to D D to A convertor which works on the I2C bus (default address 0x4F).
  21. 21. www.sf-innovations.co.uk 4 ANALOGUE INPUTS AND ANALOGUE OUTPUT This is provided using the PCF8591 8-bit A to D D to A convertor which works on the I2C bus (default address 0x4F).
  22. 22. www.sf-innovations.co.uk 4 ANALOGUE INPUTS AND ANALOGUE OUTPUT #1/usr/bin/env python import time import smbus #******************************************** # Custard Pi 7 8591 25th Oct 2013 #I2C addresses add= 0x4F bus=smbus.SMBus(1) #DtoA channel select ch0= 0x00 ch1= 0x01 ch2= 0x02 ch3= 0x03 def readanalog(add): analog=bus.read_byte(add) return analog def writedtoa(add,value): bus.write_byte_data (add, 0x44, value) #****************************************** Listing of sample program to output an analogue voltage and read the voltage on the 4 analogue inputs. Download from here and change from .txt to .py cp8591.py To test: Loop back the ANOUT back to ANIN0, ANIN1 etc in turn and see that the analogue output is being read correctly.
  23. 23. www.sf-innovations.co.uk 4 ANALOGUE INPUTS AND ANALOGUE OUTPUT while True: value=0x00 for x in range (0,255): writedtoa(add,value) print value time.sleep(0.5) value=value+1 an0 = readanalog(add) an0 = readanalog(add) print "ch0=", (an0) an1 = readanalog(add) print "ch1=", (an1) an2 = readanalog(add) print "ch2=", (an2) an3 = readanalog(add) print "ch3=", (an3) print "*****“ time.sleep(0.5)
  24. 24. www.sf-innovations.co.uk POWER MANAGEMENT There are 3 powering options. #1 The Rpi and the Custard Pi 7 can both be powered from the Rpi 5V supply. In this case jumper J14 is on the left hand side and the board 5V and the Rpi 5VPI are both connected together. Make sure that only the Rpi 5V supply is connected. #2 Both can be powered from the board 5V. Same as above but make sure that only the board 5V is plugged in. #3 Both are independently powered. In this case make sure that jumper on J14 is on right hand side (or not plugged in).
  25. 25. www.sf-innovations.co.uk POWER CONNECTORS There is a 3-way ground connector provided. The 3V3 and 5V supply outputs on the screw terminal are fused at 100mA to prevent users from taking too much power from these rails.
  26. 26. www.sf-innovations.co.uk MULTIPLE CUSTARD PI 7 BOARDS Because the Custard Pi 7 uses the I2C interface to interface to the various functional blocks it is possible to daisychaining 2 or more Custard Pi 7s. The user has to pay attention to the I2C addressing to make sure that the devices on the various cards have different I2C addresses. There are also resistor positions available on the PCB to do this. One needs to pay particular attention to the power requirements.
  27. 27. www.sf-innovations.co.uk SETTING UP THE I2C BUS – STEP 1 At the command prompt type: sudo nano /etc/modules This uses the nano editor to make some changes to the modules file. Add the following two lines to this file i2c-bcm2708 i2c-dev Then save and exit the file using CTRL-x and Y.
  28. 28. www.sf-innovations.co.uk SETTING UP THE I2C BUS – STEP 2 Make sure that you have the I2C utilities installed by executing the following two commands. The Pi will need to be connected to the Internet for this. sudo apt-get install python-smbus sudo apt-get install i2c-tools If you get a 404 error do an update first: sudo apt-get update Note : The installation could take a few minutes to do, depend on how busy the server is. Now add a new user to the i2c group: sudo adduser pi i2c
  29. 29. www.sf-innovations.co.uk SETTING UP THE I2C BUS – STEP 3 On the Raspberry Pi, the I2C and the SPI buses are usually disabled. This is done in the /etc/modprobe.d/raspi-blacklist.conf file. If this file is not present then there is nothing to be done. Otherwise edit the file by typing the following at the command prompt. sudo nano /etc/modprobe.d/raspi-blacklist.conf If the I2C and the SPI is blacklisted, you will see the following commands. blacklist spi-bcm2708 blacklist i2c-bcm2708 Insert a # in front of these to comment them out. Then save and exit the file using CTRL-x and Y. After editing the file, you will need to reboot for the changes to take effect.
  30. 30. www.sf-innovations.co.uk SETTING UP THE I2C BUS – STEP 4 Now we need to test if the I2C bus is working correctly. Connect up the Custard Pi 6 board (or any other I2C bus device) and run the following command. sudo i2cdetect -y 1 (for Rev 2 boards which uses port 1) Or sudo i2cdetect -y 0 (for Rev 1 boards which uses port 0) If everything is OK, then the I2C address of the device will be shown as on the following slide.
  31. 31. www.sf-innovations.co.uk SETTING UP THE I2C BUS – STEP 4 I2C devices with address 40 and 70 present on the bus.
  32. 32. www.sf-innovations.co.uk SUMMARY The Custard Pi 7 provides Raspberry Pi hardware hackers with a handy board that is packed with features. Make sure you refer to the www.sf-innovations.co.uk website for the latest user information. Further information Blog dedicated to electronics & Raspberry Pi

×