https://bitwizard.nl/wiki/api.php?action=feedcontributions&user=Bronte&feedformat=atomBitWizard WIKI - User contributions [en]2024-03-29T06:43:41ZUser contributionsMediaWiki 1.27.0https://bitwizard.nl/wiki/index.php?title=Talk:User_Interface&diff=2495Talk:User Interface2013-02-03T19:29:04Z<p>Bronte: </p>
<hr />
<div>This article prolly needs some more examples. Maybe its also a good idea to move the I2C rasbian config things to a seperate I2C article. --Bronte</div>Brontehttps://bitwizard.nl/wiki/index.php?title=Talk:User_Interface&diff=2494Talk:User Interface2013-02-03T19:28:40Z<p>Bronte: Created page with "This article prolly needs some more examples. Maybe its also a good idea to move the I2C rasbian config things to a seperate I2C article."</p>
<hr />
<div>This article prolly needs some more examples. Maybe its also a good idea to move the I2C rasbian config things to a seperate I2C article.</div>Brontehttps://bitwizard.nl/wiki/index.php?title=User_Interface&diff=2493User Interface2013-02-03T19:26:14Z<p>Bronte: /* examples */</p>
<hr />
<div>[[File:RPi-UI.jpg|thumb|300px|alt=The RPi_UI PCB|The RPi_UI PCB]]<br />
<br />
This is the documentation page for the RPi_UI board.<br />
<br />
== Overview ==<br />
<br />
== Installation of the I2C Version ==<br />
<br />
If you run your Pi on the standard raspian wheezy image ([http://www.raspberrypi.org/downloads download]) you will need to do modify some config files.<br />
<br />
'''1.'''<br /><br />
''/etc/modprobe.d/raspi-blacklist.conf'' <br /><br />
Comment the line ''blacklist i2c-bcm2708'' <br /><br />
<br /><br />
The file should look like this afterwards: <br /><br />
<nowiki><br />
blacklist spi-bcm2708 </nowiki><br /><nowiki><br />
#blacklist i2c-bcm2708 </nowiki><br /><nowiki><br />
</nowiki><br />
<br /><br />
'''2.''' <br /><br />
''/etc/modules'' <br /><br />
Add ''i2c-dev'' at the end. <br /><br />
<br /><br />
'''3.''' <br /><br />
Reboot the pi. You should be able to see the devices ''/dev/i2c-0'' and ''/dev/i2c-1'' <br /><br />
<br />
== Assembly instructions ==<br />
<br />
== Specifications ==<br />
<br />
=== Possible Configurations ===<br />
<br />
== External resources ==<br />
<br />
<br />
=== Datasheets ===<br />
<br />
* [http://ww1.microchip.com/downloads/en/DeviceDoc/22266D.pdf MCP79412 (I2C RTC)]<br />
* [http://ww1.microchip.com/downloads/en/DeviceDoc/22300A.pdf MCP79522 (SPI RTC)]<br />
* [http://ww1.microchip.com/downloads/en/DeviceDoc/21942e.pdf MCP9700 thermistor]<br />
<br />
== Additional software ==<br />
<br />
The [[Bw_tool]] is meant to provide a basic commandline access to the bitwizard expansion boards<br />
<br />
=== Related projects ===<br />
<br />
== Pinout ==<br />
<br />
The 26 pin gpio connector is described at [http://elinux.org/RPi_Low-level_peripherals elinux]<br><br />
The SPI connector has the same pinout as the atmel 6-pin ICSP connector and is documented here: [[SPI_connector_pinout]].<br><br />
The I2C connector is documented here: [[I2C_connector_pinout]].<br><br />
The UART connector is documented here: [[uart connector pinout]].<br><br />
The analog connector has the following pinout:<br />
{| border=1<br />
! pin !! function <br />
|-<br />
| 1 || 5V<br />
|-<br />
| 2 || Analog in<br />
|-<br />
| 3 || GND<br />
|}<br />
<br />
<br />
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: <br />
[[File:Rpi_ui_docu.png|none|thumb|500px|alt=The RPi_UI PCB|The RPi_UI PCB]]<br />
<br />
Note that for the 20x4 version of the board, the connectors are in the same order with the same pinout. <br />
<br />
=== LEDs ===<br />
<br />
The only LED is a power indicator.<br />
<br />
== jumper settings ==<br />
<br />
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):<br><br />
Left pads/pins connected: SPI0 connected to Slave-Select<br />
Right pads/pins connected: SPI1 connected to RESET<br />
Bottom pads/pins connected: SPI0 connected to RESET<br />
Top (near the LCD) pads/pins connected: SPI1 connected to Slave-Select<br />
<br />
There is also one solder jumper, SJ1, which controls the supply voltage on the SPI, I2C, and UART connectors:<br><br />
1-2: 5V (left)<br><br />
2-3: 3V3 (right, near the PCB edge)<br />
<br />
== Protocol ==<br />
<br />
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 [[SPI_versus_I2C_protocols|here]].<br />
<br />
The general overview of the SPI protocol is [[General_SPI_protocol|here]]. <br />
<br />
== The software ==<br />
<br />
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.<br />
<br />
=== write ports ===<br />
<br />
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. <br />
<br />
The rpi_ui board defines several ports. <br />
{| border=1<br />
! port !! function <br />
|-<br />
| 0x00 || display data.<br />
|- <br />
| 0x01 || write data as command to LCD.<br />
|- <br />
| 0x10 || any data clears the screen. <br />
|- <br />
| 0x11 || move the cursor to line l, position p. <br>l is the top 3 bits<br>p is the bottom 5 bits of the data. <br />
|- <br />
| 0x12 || set contrast. <br />
|- <br />
| 0x13 || set backlight. <br />
|- <br />
| 0x14 || reinit LCD. <br />
|-<br />
| 0x70 .. 0x71 || Select which i/o is coupled to which ADC channel<br />
|-<br />
| 0x80 || Set number of ADC channels to read<br />
|-<br />
| 0x81 || Set number of samples to add (we suggest using a power of 2) (two bytes) See: [[annoying bug]]<br />
|-<br />
| 0x82 || Set ammounts of bits to shift accumulated sample value<br />
|-<br />
| 0xf0 || change address. <br />
|}<br />
<br />
=== read ports ===<br />
The rpi_ui board supports several read ports: <br />
<br />
{| border=1<br />
! port !! function <br />
|-<br />
| 0x01 || identification string. (terminated with 0).<br />
|-<br />
| 0x02 || read eeprom (serial number). <br />
|-<br />
| 0x20 || read button 1 (1 means NOT pushed, 0 means pushed)<br />
|-<br />
| 0x21 || read button 2 (1 means NOT pushed, 0 means pushed)<br />
|-<br />
| 0x22 || read button 3 (1 means NOT pushed, 0 means pushed)<br />
|-<br />
| 0x23 || read button 4 (1 means NOT pushed, 0 means pushed)<br />
|-<br />
| 0x24 || read button 5 (1 means NOT pushed, 0 means pushed)<br />
|-<br />
| 0x25 || read button 6 (1 means NOT pushed, 0 means pushed)<br />
|-<br />
| 0x30 || reports which buttons have been pushed since last read of this register<br><br />
If you keep a button pushed, it will read out as 1 multiple times<br />
|-<br />
| 0x31 || reports which buttons have been pushed since last read of this register (V1.2 and up)<br><br />
If you keep a button pushed, it will read out as 1 only once<br />
|-<br />
| 0x40 || read button 1 (1 means pushed, 0 means NOT pushed) (V1.1 and up)<br />
|-<br />
| 0x41 || read button 2 (1 means pushed, 0 means NOT pushed) (V1.1 and up)<br />
|-<br />
| 0x42 || read button 3 (1 means pushed, 0 means NOT pushed) (V1.1 and up)<br />
|-<br />
| 0x43 || read button 4 (1 means pushed, 0 means NOT pushed) (V1.1 and up)<br />
|-<br />
| 0x44 || read button 5 (1 means pushed, 0 means NOT pushed) (V1.1 and up)<br />
|-<br />
| 0x45 || read button 6 (1 means pushed, 0 means NOT pushed) (V1.1 and up)<br />
|-<br />
| 0x60.. 0x61 || Return analog value (2 bytes)<br />
|-<br />
| 0x68 .. 0x69 || Return added and bitshifted analog value (2 bytes)<br />
|-<br />
| 0x70 .. 0x71 || Return which i/o is coupled to which ADC channel<br />
|-<br />
| 0x80 || Return number of ADC channels to read<br />
|-<br />
| 0x81 || Return number of samples to add (two bytes)<br />
|-<br />
| 0x82 || Return ammounts of bits to shift accumulated sample value<br />
|}<br />
<br />
== Using the analog inputs ==<br />
<br />
Please see [[DIO_protocol#Using_the_analog_inputs|this]] chapter on the page explaining the DIO protocol. There are two major differences: <br />
* The internal reference voltage needs to be configured in a different way<br />
* The mapping of the analog inputs; please use the following table instead:<br />
<br />
{| border=1<br />
! IO pin !! value<br />
|-<br />
| temp || 0xC7 (Vref=1V1) OR 0x47 (Vref=Vcc=~5V)<br />
|-<br />
| ext || 0xC6 (Vref=1V1) OR 0x46 (Vref=Vcc=~5V)<br />
|}<br />
<br />
=== Example ===<br />
<br />
Setup the ADC (only needed once after reboot):<br />
bw_tool -a 94 -w 70:c7 //Set ADC channel 0 to temperature sensor, and internal 1V1 reference<br />
bw_tool -a 94 -w 80:01 //Set number of channels to sample to 1<br />
<br />
Read the value:<br />
bw_tool -a 94 -R 60:s // Read the result, output in hex<br />
<br />
== Using the temperature sensor ==<br />
<br />
The temperature sensor is a MCP9700. It's output voltage depends on the temperature. For more information, please see the [http://ww1.microchip.com/downloads/en/DeviceDoc/21942e.pdf MCP9700 datasheet].<br />
<br />
An initialization and readout script are available on the [[Temperature sensor example]] page.<br />
<br />
== Using the RTC ==<br />
<br />
<br />
The User Interface can be equipped with either an SPI RTC or an I2C RTC.<br />
<br />
=== I2C ===<br />
<br />
The I2C RTC has a Linux driver, which is available in the standard kernels delivered with raspian. (and probably others too). <br />
<br />
Just issue: <br />
modprobe i2c:mcp7941x<br />
echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-0/device/new_device<br />
and the module is loaded and detects the RTC. <br />
<br />
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.<br />
<br />
=== SPI ===<br />
<br />
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). <br />
<br />
bw_tool -s 50000 --hex 96 12 20 1 2 34 5 6 7 89<br />
<br />
will write (0x12) the test-bytes 1 2 34 5 6 7 89 to the RAM at location 0x20 in the RAM. <br />
<br />
bw_tool -s 50000 --hex 96 13 20 0 0 0 0 0 0 0 0<br />
<br />
will read them back. <br />
<br />
Refer to the datasheet of the MCP79522 for information on the registers of the chip http://ww1.microchip.com/downloads/en/DeviceDoc/22300A.pdf<br />
<br />
= examples =<br />
<br />
== read identification ==<br />
<br />
read the identification string of the board.<br />
{| border=1<br />
! data sent !! data recieved || explanation <br />
|-<br />
| 0x95 || xx || select destination with address 0x94 for READ. <br />
|-<br />
| 0x01 || xx || identify<br />
|-<br />
| xx || 0x73 || 's'<br />
|-<br />
| xx || 0x70 || 'p'<br />
|-<br />
| xx || 0x69 || 'i'<br />
|-<br />
| xx || ... || etc. <br />
|}<br />
<br />
== Send text to display ==<br />
Display the string "Hello World!" (only the first 5 bytes of the string shown). <br />
{| border=1<br />
! data sent !! data recieved || explanation <br />
|-<br />
| 0x94 || xx || select destination with address 0x94 for WRITE<br />
|-<br />
| 0x00 || xx || datastream<br />
|-<br />
| 0x48 || xx || 'H'<br />
|-<br />
| 0x65 || xx || 'e'<br />
|-<br />
| 0x6c || xx || 'l'<br />
|-<br />
| 0x6c || xx || 'l'<br />
|-<br />
| 0x6f || xx || 'o'<br />
|-<br />
| xx || ... || etc. <br />
|}<br />
<br />
== set cursor position ==<br />
move to line 1, character 5:<br />
{| border=1<br />
! data sent !! data recieved || explanation <br />
|-<br />
| 0x94 || xx || select destination with address 0x94 for WRITE<br />
|-<br />
| 0x11 || xx || port 0x11 = set cursor position. <br />
|-<br />
| 0x25 || xx || 0x25 = 001 00101 = line 1 position 5. <br />
|}<br />
<br />
== bash script to show system informations ==<br />
<br />
This bash script shows the current time and load averages of the cpu. The refresh is set to 5 seconds.<br />
<br />
#!/bin/bash<br />
<br />
#clean the display<br />
bw_tool -I -a 94 -r 16 -v 0<br />
<br />
while true; do<br />
#get cpu loads<br />
load=`top -bn1 | grep load | cut -d' ' -f13-`<br />
<br />
#print the current time <br />
bw_tool -I -a 94 -r 17 -v 0<br />
bw_tool -I -a 94 -t `date +%H:%M:%S`<br />
<br />
#print the load averages<br />
bw_tool -I -a 94 -r 17 -v 32<br />
bw_tool -I -a 94 -t $load<br />
<br />
#idle for 5 seconds<br />
sleep 5<br />
done<br />
<br />
== Default operation ==<br />
<br />
<br />
== Future hardware enhancements ==<br />
<br />
<br />
== Future software enhancements ==<br />
<br />
<br />
== Changelog ==<br />
<br />
<br />
=== 1.0 ===<br />
* Initial public release</div>Brontehttps://bitwizard.nl/wiki/index.php?title=User_Interface&diff=2492User Interface2013-02-03T19:20:56Z<p>Bronte: /* Additional software */</p>
<hr />
<div>[[File:RPi-UI.jpg|thumb|300px|alt=The RPi_UI PCB|The RPi_UI PCB]]<br />
<br />
This is the documentation page for the RPi_UI board.<br />
<br />
== Overview ==<br />
<br />
== Installation of the I2C Version ==<br />
<br />
If you run your Pi on the standard raspian wheezy image ([http://www.raspberrypi.org/downloads download]) you will need to do modify some config files.<br />
<br />
'''1.'''<br /><br />
''/etc/modprobe.d/raspi-blacklist.conf'' <br /><br />
Comment the line ''blacklist i2c-bcm2708'' <br /><br />
<br /><br />
The file should look like this afterwards: <br /><br />
<nowiki><br />
blacklist spi-bcm2708 </nowiki><br /><nowiki><br />
#blacklist i2c-bcm2708 </nowiki><br /><nowiki><br />
</nowiki><br />
<br /><br />
'''2.''' <br /><br />
''/etc/modules'' <br /><br />
Add ''i2c-dev'' at the end. <br /><br />
<br /><br />
'''3.''' <br /><br />
Reboot the pi. You should be able to see the devices ''/dev/i2c-0'' and ''/dev/i2c-1'' <br /><br />
<br />
== Assembly instructions ==<br />
<br />
== Specifications ==<br />
<br />
=== Possible Configurations ===<br />
<br />
== External resources ==<br />
<br />
<br />
=== Datasheets ===<br />
<br />
* [http://ww1.microchip.com/downloads/en/DeviceDoc/22266D.pdf MCP79412 (I2C RTC)]<br />
* [http://ww1.microchip.com/downloads/en/DeviceDoc/22300A.pdf MCP79522 (SPI RTC)]<br />
* [http://ww1.microchip.com/downloads/en/DeviceDoc/21942e.pdf MCP9700 thermistor]<br />
<br />
== Additional software ==<br />
<br />
The [[Bw_tool]] is meant to provide a basic commandline access to the bitwizard expansion boards<br />
<br />
=== Related projects ===<br />
<br />
== Pinout ==<br />
<br />
The 26 pin gpio connector is described at [http://elinux.org/RPi_Low-level_peripherals elinux]<br><br />
The SPI connector has the same pinout as the atmel 6-pin ICSP connector and is documented here: [[SPI_connector_pinout]].<br><br />
The I2C connector is documented here: [[I2C_connector_pinout]].<br><br />
The UART connector is documented here: [[uart connector pinout]].<br><br />
The analog connector has the following pinout:<br />
{| border=1<br />
! pin !! function <br />
|-<br />
| 1 || 5V<br />
|-<br />
| 2 || Analog in<br />
|-<br />
| 3 || GND<br />
|}<br />
<br />
<br />
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: <br />
[[File:Rpi_ui_docu.png|none|thumb|500px|alt=The RPi_UI PCB|The RPi_UI PCB]]<br />
<br />
Note that for the 20x4 version of the board, the connectors are in the same order with the same pinout. <br />
<br />
=== LEDs ===<br />
<br />
The only LED is a power indicator.<br />
<br />
== jumper settings ==<br />
<br />
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):<br><br />
Left pads/pins connected: SPI0 connected to Slave-Select<br />
Right pads/pins connected: SPI1 connected to RESET<br />
Bottom pads/pins connected: SPI0 connected to RESET<br />
Top (near the LCD) pads/pins connected: SPI1 connected to Slave-Select<br />
<br />
There is also one solder jumper, SJ1, which controls the supply voltage on the SPI, I2C, and UART connectors:<br><br />
1-2: 5V (left)<br><br />
2-3: 3V3 (right, near the PCB edge)<br />
<br />
== Protocol ==<br />
<br />
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 [[SPI_versus_I2C_protocols|here]].<br />
<br />
The general overview of the SPI protocol is [[General_SPI_protocol|here]]. <br />
<br />
== The software ==<br />
<br />
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.<br />
<br />
=== write ports ===<br />
<br />
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. <br />
<br />
The rpi_ui board defines several ports. <br />
{| border=1<br />
! port !! function <br />
|-<br />
| 0x00 || display data.<br />
|- <br />
| 0x01 || write data as command to LCD.<br />
|- <br />
| 0x10 || any data clears the screen. <br />
|- <br />
| 0x11 || move the cursor to line l, position p. <br>l is the top 3 bits<br>p is the bottom 5 bits of the data. <br />
|- <br />
| 0x12 || set contrast. <br />
|- <br />
| 0x13 || set backlight. <br />
|- <br />
| 0x14 || reinit LCD. <br />
|-<br />
| 0x70 .. 0x71 || Select which i/o is coupled to which ADC channel<br />
|-<br />
| 0x80 || Set number of ADC channels to read<br />
|-<br />
| 0x81 || Set number of samples to add (we suggest using a power of 2) (two bytes) See: [[annoying bug]]<br />
|-<br />
| 0x82 || Set ammounts of bits to shift accumulated sample value<br />
|-<br />
| 0xf0 || change address. <br />
|}<br />
<br />
=== read ports ===<br />
The rpi_ui board supports several read ports: <br />
<br />
{| border=1<br />
! port !! function <br />
|-<br />
| 0x01 || identification string. (terminated with 0).<br />
|-<br />
| 0x02 || read eeprom (serial number). <br />
|-<br />
| 0x20 || read button 1 (1 means NOT pushed, 0 means pushed)<br />
|-<br />
| 0x21 || read button 2 (1 means NOT pushed, 0 means pushed)<br />
|-<br />
| 0x22 || read button 3 (1 means NOT pushed, 0 means pushed)<br />
|-<br />
| 0x23 || read button 4 (1 means NOT pushed, 0 means pushed)<br />
|-<br />
| 0x24 || read button 5 (1 means NOT pushed, 0 means pushed)<br />
|-<br />
| 0x25 || read button 6 (1 means NOT pushed, 0 means pushed)<br />
|-<br />
| 0x30 || reports which buttons have been pushed since last read of this register<br><br />
If you keep a button pushed, it will read out as 1 multiple times<br />
|-<br />
| 0x31 || reports which buttons have been pushed since last read of this register (V1.2 and up)<br><br />
If you keep a button pushed, it will read out as 1 only once<br />
|-<br />
| 0x40 || read button 1 (1 means pushed, 0 means NOT pushed) (V1.1 and up)<br />
|-<br />
| 0x41 || read button 2 (1 means pushed, 0 means NOT pushed) (V1.1 and up)<br />
|-<br />
| 0x42 || read button 3 (1 means pushed, 0 means NOT pushed) (V1.1 and up)<br />
|-<br />
| 0x43 || read button 4 (1 means pushed, 0 means NOT pushed) (V1.1 and up)<br />
|-<br />
| 0x44 || read button 5 (1 means pushed, 0 means NOT pushed) (V1.1 and up)<br />
|-<br />
| 0x45 || read button 6 (1 means pushed, 0 means NOT pushed) (V1.1 and up)<br />
|-<br />
| 0x60.. 0x61 || Return analog value (2 bytes)<br />
|-<br />
| 0x68 .. 0x69 || Return added and bitshifted analog value (2 bytes)<br />
|-<br />
| 0x70 .. 0x71 || Return which i/o is coupled to which ADC channel<br />
|-<br />
| 0x80 || Return number of ADC channels to read<br />
|-<br />
| 0x81 || Return number of samples to add (two bytes)<br />
|-<br />
| 0x82 || Return ammounts of bits to shift accumulated sample value<br />
|}<br />
<br />
== Using the analog inputs ==<br />
<br />
Please see [[DIO_protocol#Using_the_analog_inputs|this]] chapter on the page explaining the DIO protocol. There are two major differences: <br />
* The internal reference voltage needs to be configured in a different way<br />
* The mapping of the analog inputs; please use the following table instead:<br />
<br />
{| border=1<br />
! IO pin !! value<br />
|-<br />
| temp || 0xC7 (Vref=1V1) OR 0x47 (Vref=Vcc=~5V)<br />
|-<br />
| ext || 0xC6 (Vref=1V1) OR 0x46 (Vref=Vcc=~5V)<br />
|}<br />
<br />
=== Example ===<br />
<br />
Setup the ADC (only needed once after reboot):<br />
bw_tool -a 94 -w 70:c7 //Set ADC channel 0 to temperature sensor, and internal 1V1 reference<br />
bw_tool -a 94 -w 80:01 //Set number of channels to sample to 1<br />
<br />
Read the value:<br />
bw_tool -a 94 -R 60:s // Read the result, output in hex<br />
<br />
== Using the temperature sensor ==<br />
<br />
The temperature sensor is a MCP9700. It's output voltage depends on the temperature. For more information, please see the [http://ww1.microchip.com/downloads/en/DeviceDoc/21942e.pdf MCP9700 datasheet].<br />
<br />
An initialization and readout script are available on the [[Temperature sensor example]] page.<br />
<br />
== Using the RTC ==<br />
<br />
<br />
The User Interface can be equipped with either an SPI RTC or an I2C RTC.<br />
<br />
=== I2C ===<br />
<br />
The I2C RTC has a Linux driver, which is available in the standard kernels delivered with raspian. (and probably others too). <br />
<br />
Just issue: <br />
modprobe i2c:mcp7941x<br />
echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-0/device/new_device<br />
and the module is loaded and detects the RTC. <br />
<br />
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.<br />
<br />
=== SPI ===<br />
<br />
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). <br />
<br />
bw_tool -s 50000 --hex 96 12 20 1 2 34 5 6 7 89<br />
<br />
will write (0x12) the test-bytes 1 2 34 5 6 7 89 to the RAM at location 0x20 in the RAM. <br />
<br />
bw_tool -s 50000 --hex 96 13 20 0 0 0 0 0 0 0 0<br />
<br />
will read them back. <br />
<br />
Refer to the datasheet of the MCP79522 for information on the registers of the chip http://ww1.microchip.com/downloads/en/DeviceDoc/22300A.pdf<br />
<br />
= examples =<br />
<br />
== read identification ==<br />
<br />
read the identification string of the board.<br />
{| border=1<br />
! data sent !! data recieved || explanation <br />
|-<br />
| 0x95 || xx || select destination with address 0x94 for READ. <br />
|-<br />
| 0x01 || xx || identify<br />
|-<br />
| xx || 0x73 || 's'<br />
|-<br />
| xx || 0x70 || 'p'<br />
|-<br />
| xx || 0x69 || 'i'<br />
|-<br />
| xx || ... || etc. <br />
|}<br />
<br />
== Send text to display ==<br />
Display the string "Hello World!" (only the first 5 bytes of the string shown). <br />
{| border=1<br />
! data sent !! data recieved || explanation <br />
|-<br />
| 0x94 || xx || select destination with address 0x94 for WRITE<br />
|-<br />
| 0x00 || xx || datastream<br />
|-<br />
| 0x48 || xx || 'H'<br />
|-<br />
| 0x65 || xx || 'e'<br />
|-<br />
| 0x6c || xx || 'l'<br />
|-<br />
| 0x6c || xx || 'l'<br />
|-<br />
| 0x6f || xx || 'o'<br />
|-<br />
| xx || ... || etc. <br />
|}<br />
<br />
== set cursor position ==<br />
move to line 1, character 5:<br />
{| border=1<br />
! data sent !! data recieved || explanation <br />
|-<br />
| 0x94 || xx || select destination with address 0x94 for WRITE<br />
|-<br />
| 0x11 || xx || port 0x11 = set cursor position. <br />
|-<br />
| 0x25 || xx || 0x25 = 001 00101 = line 1 position 5. <br />
|}<br />
<br />
== Default operation ==<br />
<br />
<br />
== Future hardware enhancements ==<br />
<br />
<br />
== Future software enhancements ==<br />
<br />
<br />
== Changelog ==<br />
<br />
<br />
=== 1.0 ===<br />
* Initial public release</div>Brontehttps://bitwizard.nl/wiki/index.php?title=Bw_tool&diff=2491Bw tool2013-02-03T19:16:24Z<p>Bronte: </p>
<hr />
<div>= intro =<br />
<br />
The bw_tool is meant to provide a basic commandline access to the bitwizard expansion boards. It was written for the raspberry pi, but has now been proven to work on other Linux platforms with an spidev device as well. <br />
<br />
= installation/compiling =<br />
<br />
You can download the bw_tool [https://github.com/rewolff/bw_rpi_tools here]. If you are using git just type <br />
''git clone https://github.com/rewolff/bw_rpi_tools.git'' <br />
<br />
Each folder contains a make file, so using the command <br />
''make'' <br />
should work fine.<br />
<br />
= basic example =<br />
<br />
The simplest invocation:<br />
<br />
bw_tool -t "Hello World!"<br />
<br />
will display the shown text on an SPI_LCD on the default SPI bus (SPI0). Options modify the defaults. <br />
<br />
= options =<br />
<br />
== options specifying the device ==<br />
<br />
The option <br />
-I <br />
will switch to I2C mode. <br />
<br />
The option <br />
-D <device> <br />
will use that device. Specify /dev/spidev0.1 for the second SPI bus on the raspberry pi for example. Or /dev/i2c-1 to specify the second I2C bus. This second i2c bus is the one that is broken out on the gpio's of rev2 raspberry pi's. <br />
<br />
The option<br />
-a <address> <br />
specifies the address of the device to use. Note that BitWizard uses the full 8 bits that are sent to the device. Add one for "read" operation. In some circles, notably I2C, it is customary to specify just those 7 bits. Thus when the I2C_LCD is at the default address of 0x82, i2cdetect will scan it at address 0x41. <br />
<br />
== options sending data ==<br />
<br />
the option <br />
-t "text" <br />
will send the text to the device, at port zero. The port cannot be changed, but all BitWizard PCBs that have the option of displaying text have the text port at port zero. <br />
<br />
The option<br />
-w <addr>:<byte> <br />
will write the byte to the port at addr. For LCD-equipped boards for example -w 12:50 will set the contrast to 0x50. <br />
<br />
The option<br />
-W <addr>:<short><br />
will write the 16-bit short to the port at addr. For example -W 81:1000 will write the value 0x1000 to the numsamples port on an analog-equipped board.<br />
<br />
== reading data ==<br />
<br />
The option <br />
-R <port>:<datasize><br />
reads the data at port from the device. Datasize can be 'b' for byte (default), 's' for short (16 bits), or 'i' for a 32-bit integer. <br />
<br />
== finer control ==<br />
<br />
To test sending data to SPI devices, there is the <br />
--hex [byte...]<br />
option. This simply sends the bytes specified, and reports back what was received. Note that bitwizard boards will not send any data until they have been selected, so the first byte received will represent whatever static is found on the bus.</div>Brontehttps://bitwizard.nl/wiki/index.php?title=User_Interface&diff=2490User Interface2013-02-03T19:10:16Z<p>Bronte: </p>
<hr />
<div>[[File:RPi-UI.jpg|thumb|300px|alt=The RPi_UI PCB|The RPi_UI PCB]]<br />
<br />
This is the documentation page for the RPi_UI board.<br />
<br />
== Overview ==<br />
<br />
== Installation of the I2C Version ==<br />
<br />
If you run your Pi on the standard raspian wheezy image ([http://www.raspberrypi.org/downloads download]) you will need to do modify some config files.<br />
<br />
'''1.'''<br /><br />
''/etc/modprobe.d/raspi-blacklist.conf'' <br /><br />
Comment the line ''blacklist i2c-bcm2708'' <br /><br />
<br /><br />
The file should look like this afterwards: <br /><br />
<nowiki><br />
blacklist spi-bcm2708 </nowiki><br /><nowiki><br />
#blacklist i2c-bcm2708 </nowiki><br /><nowiki><br />
</nowiki><br />
<br /><br />
'''2.''' <br /><br />
''/etc/modules'' <br /><br />
Add ''i2c-dev'' at the end. <br /><br />
<br /><br />
'''3.''' <br /><br />
Reboot the pi. You should be able to see the devices ''/dev/i2c-0'' and ''/dev/i2c-1'' <br /><br />
<br />
== Assembly instructions ==<br />
<br />
== Specifications ==<br />
<br />
=== Possible Configurations ===<br />
<br />
== External resources ==<br />
<br />
<br />
=== Datasheets ===<br />
<br />
* [http://ww1.microchip.com/downloads/en/DeviceDoc/22266D.pdf MCP79412 (I2C RTC)]<br />
* [http://ww1.microchip.com/downloads/en/DeviceDoc/22300A.pdf MCP79522 (SPI RTC)]<br />
* [http://ww1.microchip.com/downloads/en/DeviceDoc/21942e.pdf MCP9700 thermistor]<br />
<br />
== Additional software ==<br />
<br />
<br />
=== Related projects ===<br />
<br />
<br />
== Pinout ==<br />
<br />
The 26 pin gpio connector is described at [http://elinux.org/RPi_Low-level_peripherals elinux]<br><br />
The SPI connector has the same pinout as the atmel 6-pin ICSP connector and is documented here: [[SPI_connector_pinout]].<br><br />
The I2C connector is documented here: [[I2C_connector_pinout]].<br><br />
The UART connector is documented here: [[uart connector pinout]].<br><br />
The analog connector has the following pinout:<br />
{| border=1<br />
! pin !! function <br />
|-<br />
| 1 || 5V<br />
|-<br />
| 2 || Analog in<br />
|-<br />
| 3 || GND<br />
|}<br />
<br />
<br />
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: <br />
[[File:Rpi_ui_docu.png|none|thumb|500px|alt=The RPi_UI PCB|The RPi_UI PCB]]<br />
<br />
Note that for the 20x4 version of the board, the connectors are in the same order with the same pinout. <br />
<br />
=== LEDs ===<br />
<br />
The only LED is a power indicator.<br />
<br />
== jumper settings ==<br />
<br />
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):<br><br />
Left pads/pins connected: SPI0 connected to Slave-Select<br />
Right pads/pins connected: SPI1 connected to RESET<br />
Bottom pads/pins connected: SPI0 connected to RESET<br />
Top (near the LCD) pads/pins connected: SPI1 connected to Slave-Select<br />
<br />
There is also one solder jumper, SJ1, which controls the supply voltage on the SPI, I2C, and UART connectors:<br><br />
1-2: 5V (left)<br><br />
2-3: 3V3 (right, near the PCB edge)<br />
<br />
== Protocol ==<br />
<br />
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 [[SPI_versus_I2C_protocols|here]].<br />
<br />
The general overview of the SPI protocol is [[General_SPI_protocol|here]]. <br />
<br />
== The software ==<br />
<br />
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.<br />
<br />
=== write ports ===<br />
<br />
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. <br />
<br />
The rpi_ui board defines several ports. <br />
{| border=1<br />
! port !! function <br />
|-<br />
| 0x00 || display data.<br />
|- <br />
| 0x01 || write data as command to LCD.<br />
|- <br />
| 0x10 || any data clears the screen. <br />
|- <br />
| 0x11 || move the cursor to line l, position p. <br>l is the top 3 bits<br>p is the bottom 5 bits of the data. <br />
|- <br />
| 0x12 || set contrast. <br />
|- <br />
| 0x13 || set backlight. <br />
|- <br />
| 0x14 || reinit LCD. <br />
|-<br />
| 0x70 .. 0x71 || Select which i/o is coupled to which ADC channel<br />
|-<br />
| 0x80 || Set number of ADC channels to read<br />
|-<br />
| 0x81 || Set number of samples to add (we suggest using a power of 2) (two bytes) See: [[annoying bug]]<br />
|-<br />
| 0x82 || Set ammounts of bits to shift accumulated sample value<br />
|-<br />
| 0xf0 || change address. <br />
|}<br />
<br />
=== read ports ===<br />
The rpi_ui board supports several read ports: <br />
<br />
{| border=1<br />
! port !! function <br />
|-<br />
| 0x01 || identification string. (terminated with 0).<br />
|-<br />
| 0x02 || read eeprom (serial number). <br />
|-<br />
| 0x20 || read button 1 (1 means NOT pushed, 0 means pushed)<br />
|-<br />
| 0x21 || read button 2 (1 means NOT pushed, 0 means pushed)<br />
|-<br />
| 0x22 || read button 3 (1 means NOT pushed, 0 means pushed)<br />
|-<br />
| 0x23 || read button 4 (1 means NOT pushed, 0 means pushed)<br />
|-<br />
| 0x24 || read button 5 (1 means NOT pushed, 0 means pushed)<br />
|-<br />
| 0x25 || read button 6 (1 means NOT pushed, 0 means pushed)<br />
|-<br />
| 0x30 || reports which buttons have been pushed since last read of this register<br><br />
If you keep a button pushed, it will read out as 1 multiple times<br />
|-<br />
| 0x31 || reports which buttons have been pushed since last read of this register (V1.2 and up)<br><br />
If you keep a button pushed, it will read out as 1 only once<br />
|-<br />
| 0x40 || read button 1 (1 means pushed, 0 means NOT pushed) (V1.1 and up)<br />
|-<br />
| 0x41 || read button 2 (1 means pushed, 0 means NOT pushed) (V1.1 and up)<br />
|-<br />
| 0x42 || read button 3 (1 means pushed, 0 means NOT pushed) (V1.1 and up)<br />
|-<br />
| 0x43 || read button 4 (1 means pushed, 0 means NOT pushed) (V1.1 and up)<br />
|-<br />
| 0x44 || read button 5 (1 means pushed, 0 means NOT pushed) (V1.1 and up)<br />
|-<br />
| 0x45 || read button 6 (1 means pushed, 0 means NOT pushed) (V1.1 and up)<br />
|-<br />
| 0x60.. 0x61 || Return analog value (2 bytes)<br />
|-<br />
| 0x68 .. 0x69 || Return added and bitshifted analog value (2 bytes)<br />
|-<br />
| 0x70 .. 0x71 || Return which i/o is coupled to which ADC channel<br />
|-<br />
| 0x80 || Return number of ADC channels to read<br />
|-<br />
| 0x81 || Return number of samples to add (two bytes)<br />
|-<br />
| 0x82 || Return ammounts of bits to shift accumulated sample value<br />
|}<br />
<br />
== Using the analog inputs ==<br />
<br />
Please see [[DIO_protocol#Using_the_analog_inputs|this]] chapter on the page explaining the DIO protocol. There are two major differences: <br />
* The internal reference voltage needs to be configured in a different way<br />
* The mapping of the analog inputs; please use the following table instead:<br />
<br />
{| border=1<br />
! IO pin !! value<br />
|-<br />
| temp || 0xC7 (Vref=1V1) OR 0x47 (Vref=Vcc=~5V)<br />
|-<br />
| ext || 0xC6 (Vref=1V1) OR 0x46 (Vref=Vcc=~5V)<br />
|}<br />
<br />
=== Example ===<br />
<br />
Setup the ADC (only needed once after reboot):<br />
bw_tool -a 94 -w 70:c7 //Set ADC channel 0 to temperature sensor, and internal 1V1 reference<br />
bw_tool -a 94 -w 80:01 //Set number of channels to sample to 1<br />
<br />
Read the value:<br />
bw_tool -a 94 -R 60:s // Read the result, output in hex<br />
<br />
== Using the temperature sensor ==<br />
<br />
The temperature sensor is a MCP9700. It's output voltage depends on the temperature. For more information, please see the [http://ww1.microchip.com/downloads/en/DeviceDoc/21942e.pdf MCP9700 datasheet].<br />
<br />
An initialization and readout script are available on the [[Temperature sensor example]] page.<br />
<br />
== Using the RTC ==<br />
<br />
<br />
The User Interface can be equipped with either an SPI RTC or an I2C RTC.<br />
<br />
=== I2C ===<br />
<br />
The I2C RTC has a Linux driver, which is available in the standard kernels delivered with raspian. (and probably others too). <br />
<br />
Just issue: <br />
modprobe i2c:mcp7941x<br />
echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-0/device/new_device<br />
and the module is loaded and detects the RTC. <br />
<br />
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.<br />
<br />
=== SPI ===<br />
<br />
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). <br />
<br />
bw_tool -s 50000 --hex 96 12 20 1 2 34 5 6 7 89<br />
<br />
will write (0x12) the test-bytes 1 2 34 5 6 7 89 to the RAM at location 0x20 in the RAM. <br />
<br />
bw_tool -s 50000 --hex 96 13 20 0 0 0 0 0 0 0 0<br />
<br />
will read them back. <br />
<br />
Refer to the datasheet of the MCP79522 for information on the registers of the chip http://ww1.microchip.com/downloads/en/DeviceDoc/22300A.pdf<br />
<br />
= examples =<br />
<br />
== read identification ==<br />
<br />
read the identification string of the board.<br />
{| border=1<br />
! data sent !! data recieved || explanation <br />
|-<br />
| 0x95 || xx || select destination with address 0x94 for READ. <br />
|-<br />
| 0x01 || xx || identify<br />
|-<br />
| xx || 0x73 || 's'<br />
|-<br />
| xx || 0x70 || 'p'<br />
|-<br />
| xx || 0x69 || 'i'<br />
|-<br />
| xx || ... || etc. <br />
|}<br />
<br />
== Send text to display ==<br />
Display the string "Hello World!" (only the first 5 bytes of the string shown). <br />
{| border=1<br />
! data sent !! data recieved || explanation <br />
|-<br />
| 0x94 || xx || select destination with address 0x94 for WRITE<br />
|-<br />
| 0x00 || xx || datastream<br />
|-<br />
| 0x48 || xx || 'H'<br />
|-<br />
| 0x65 || xx || 'e'<br />
|-<br />
| 0x6c || xx || 'l'<br />
|-<br />
| 0x6c || xx || 'l'<br />
|-<br />
| 0x6f || xx || 'o'<br />
|-<br />
| xx || ... || etc. <br />
|}<br />
<br />
== set cursor position ==<br />
move to line 1, character 5:<br />
{| border=1<br />
! data sent !! data recieved || explanation <br />
|-<br />
| 0x94 || xx || select destination with address 0x94 for WRITE<br />
|-<br />
| 0x11 || xx || port 0x11 = set cursor position. <br />
|-<br />
| 0x25 || xx || 0x25 = 001 00101 = line 1 position 5. <br />
|}<br />
<br />
== Default operation ==<br />
<br />
<br />
== Future hardware enhancements ==<br />
<br />
<br />
== Future software enhancements ==<br />
<br />
<br />
== Changelog ==<br />
<br />
<br />
=== 1.0 ===<br />
* Initial public release</div>Bronte