User Interface

From BitWizard Wiki
Revision as of 20:10, 3 February 2013 by Bronte (talk | contribs)
Jump to navigation Jump to search
The RPi_UI PCB
The RPi_UI PCB

This is the documentation page for the RPi_UI board.

Overview

Installation of the I2C Version

If you run your Pi on the standard raspian wheezy image (download) you will need to do modify some config files.

1.
/etc/modprobe.d/raspi-blacklist.conf
Comment the line blacklist i2c-bcm2708

The file should look like this afterwards:
blacklist spi-bcm2708
#blacklist i2c-bcm2708

2.
/etc/modules
Add i2c-dev at the end.

3.
Reboot the pi. You should be able to see the devices /dev/i2c-0 and /dev/i2c-1

Assembly instructions

Specifications

Possible Configurations

External resources

Datasheets

Additional software

Related projects

Pinout

The 26 pin gpio connector is described at elinux
The SPI connector has the same pinout as the atmel 6-pin ICSP connector and is documented here: SPI_connector_pinout.
The I2C connector is documented here: I2C_connector_pinout.
The UART connector is documented here: uart connector pinout.
The analog connector has the following pinout:

pin function
1 5V
2 Analog in
3 GND


Some people report they find it difficult to read the names of the connectors on the PCB. We'll fix that in a future version. In the meanwhile:

The RPi_UI PCB
The RPi_UI PCB

Note that for the 20x4 version of the board, the connectors are in the same order with the same pinout.

LEDs

The only LED is a power indicator.

jumper settings

There is one 2x2 pin jumper (JP1), which controls which SPI bus (actually which SPI chip-select line) is routed to the AVRs slave-select pin, and which is routed to the reset pin (to enable reprogramming of the AVR):
Left pads/pins connected: SPI0 connected to Slave-Select Right pads/pins connected: SPI1 connected to RESET Bottom pads/pins connected: SPI0 connected to RESET Top (near the LCD) pads/pins connected: SPI1 connected to Slave-Select

There is also one solder jumper, SJ1, which controls the supply voltage on the SPI, I2C, and UART connectors:
1-2: 5V (left)
2-3: 3V3 (right, near the PCB edge)

Protocol

To make the RPI_UI PCB do things, you need to send things over the SPI or I2C bus to the PCB. A comparison of the two protocols can be found here.

The general overview of the SPI protocol is here.

The software

Controlling the display works the same way as our SPI_LCD or I2C_LCD modules. Reading the pushbuttons is very much like the DIO module. The read and write ports are described below.

write ports

Some ports just set a single value. So writing more than one byte to such a port is redundant. Other ports are logically a stream of bytes. So writing more than one byte is encouraged.

The rpi_ui board defines several ports.

port function
0x00 display data.
0x01 write data as command to LCD.
0x10 any data clears the screen.
0x11 move the cursor to line l, position p.
l is the top 3 bits
p is the bottom 5 bits of the data.
0x12 set contrast.
0x13 set backlight.
0x14 reinit LCD.
0x70 .. 0x71 Select which i/o is coupled to which ADC channel
0x80 Set number of ADC channels to read
0x81 Set number of samples to add (we suggest using a power of 2) (two bytes) See: annoying bug
0x82 Set ammounts of bits to shift accumulated sample value
0xf0 change address.

read ports

The rpi_ui board supports several read ports:

port function
0x01 identification string. (terminated with 0).
0x02 read eeprom (serial number).
0x20 read button 1 (1 means NOT pushed, 0 means pushed)
0x21 read button 2 (1 means NOT pushed, 0 means pushed)
0x22 read button 3 (1 means NOT pushed, 0 means pushed)
0x23 read button 4 (1 means NOT pushed, 0 means pushed)
0x24 read button 5 (1 means NOT pushed, 0 means pushed)
0x25 read button 6 (1 means NOT pushed, 0 means pushed)
0x30 reports which buttons have been pushed since last read of this register

If you keep a button pushed, it will read out as 1 multiple times

0x31 reports which buttons have been pushed since last read of this register (V1.2 and up)

If you keep a button pushed, it will read out as 1 only once

0x40 read button 1 (1 means pushed, 0 means NOT pushed) (V1.1 and up)
0x41 read button 2 (1 means pushed, 0 means NOT pushed) (V1.1 and up)
0x42 read button 3 (1 means pushed, 0 means NOT pushed) (V1.1 and up)
0x43 read button 4 (1 means pushed, 0 means NOT pushed) (V1.1 and up)
0x44 read button 5 (1 means pushed, 0 means NOT pushed) (V1.1 and up)
0x45 read button 6 (1 means pushed, 0 means NOT pushed) (V1.1 and up)
0x60.. 0x61 Return analog value (2 bytes)
0x68 .. 0x69 Return added and bitshifted analog value (2 bytes)
0x70 .. 0x71 Return which i/o is coupled to which ADC channel
0x80 Return number of ADC channels to read
0x81 Return number of samples to add (two bytes)
0x82 Return ammounts of bits to shift accumulated sample value

Using the analog inputs

Please see this chapter on the page explaining the DIO protocol. There are two major differences:

  • The internal reference voltage needs to be configured in a different way
  • The mapping of the analog inputs; please use the following table instead:
IO pin value
temp 0xC7 (Vref=1V1) OR 0x47 (Vref=Vcc=~5V)
ext 0xC6 (Vref=1V1) OR 0x46 (Vref=Vcc=~5V)

Example

Setup the ADC (only needed once after reboot):

bw_tool -a 94 -w 70:c7 //Set ADC channel 0 to temperature sensor, and internal 1V1 reference
bw_tool -a 94 -w 80:01 //Set number of channels to sample to 1

Read the value:

bw_tool -a 94 -R 60:s // Read the result, output in hex

Using the temperature sensor

The temperature sensor is a MCP9700. It's output voltage depends on the temperature. For more information, please see the MCP9700 datasheet.

An initialization and readout script are available on the Temperature sensor example page.

Using the RTC

The User Interface can be equipped with either an SPI RTC or an I2C RTC.

I2C

The I2C RTC has a Linux driver, which is available in the standard kernels delivered with raspian. (and probably others too).

Just issue:

modprobe i2c:mcp7941x
echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-0/device/new_device

and the module is loaded and detects the RTC.

You can then set the RTC with: "hwclock -w". This will write the unix clock to the RTC. Put a "hwclock -s" somewhere in your startup scripts to initialize the unix clock from the RTC.

SPI

We are not aware of a device driver for the SPI version of the RTC. We can read/write the RTC with bw_tool from the commandline using the raw SPI bytes commandline option "--hex". The CPU on the board has to enable the CS line for the SPI RTC. This limits the speed of the SPI transactions a bit (50 kHz works, I haven't really tested what the limit is).

 bw_tool -s 50000 --hex 96 12 20 1 2 34 5 6 7 89

will write (0x12) the test-bytes 1 2 34 5 6 7 89 to the RAM at location 0x20 in the RAM.

 bw_tool -s 50000 --hex 96 13 20 0 0 0 0 0 0 0 0

will read them back.

Refer to the datasheet of the MCP79522 for information on the registers of the chip http://ww1.microchip.com/downloads/en/DeviceDoc/22300A.pdf

examples

read identification

read the identification string of the board.

data sent data recieved explanation
0x95 xx select destination with address 0x94 for READ.
0x01 xx identify
xx 0x73 's'
xx 0x70 'p'
xx 0x69 'i'
xx ... etc.

Send text to display

Display the string "Hello World!" (only the first 5 bytes of the string shown).

data sent data recieved explanation
0x94 xx select destination with address 0x94 for WRITE
0x00 xx datastream
0x48 xx 'H'
0x65 xx 'e'
0x6c xx 'l'
0x6c xx 'l'
0x6f xx 'o'
xx ... etc.

set cursor position

move to line 1, character 5:

data sent data recieved explanation
0x94 xx select destination with address 0x94 for WRITE
0x11 xx port 0x11 = set cursor position.
0x25 xx 0x25 = 001 00101 = line 1 position 5.

Default operation

Future hardware enhancements

Future software enhancements

Changelog

1.0

  • Initial public release