pinout.vvzero.com/draft/overlay/mdb2pi-hat.md

142 lines
4.2 KiB
Markdown
Raw Normal View History

2017-01-12 00:28:40 +08:00
<!--
---
name: MDB2Pi HAT
class: board
type: IO,Power
formfactor: HAT
manufacturer: Abrantix
description: Multi-Drop-Bus MDB Converter Board for the Raspberry Pi
url: http://www.abrantix.com/MDBConverter.html
buy: http://blog.abrantix.com/webshop/
image: 'mdb2pi-hat.png'
pincount: 40
eeprom: yes
power:
'1':
'2':
'4':
'17':
ground:
'6':
'9':
'14':
'20':
'25':
'30':
'34':
'39':
pin:
2017-03-28 16:04:56 +08:00
'3':
mode: i2c
'5':
mode: i2c
2017-01-12 00:28:40 +08:00
'8':
mode: UART
'10':
mode: UART
'27':
mode: i2c
'28':
mode: i2c
i2c:
'0x50':
2017-03-28 16:04:56 +08:00
name: HAT EEPROM on I2C0
2017-01-12 00:28:40 +08:00
device: 24C32
2017-03-28 16:04:56 +08:00
'0x51':
name: RTC on I2C1
device: PCF8563
2017-01-12 00:28:40 +08:00
-->
2017-03-28 16:05:49 +08:00
# MDB2Pi HAT
2017-01-12 00:28:40 +08:00
2017-11-14 22:52:08 +08:00
The MDB2Pi is a Raspberry Pi HAT which can serve as a MDB master (VMC), as MDB cashless peripheral, or as tracer for MDB Vending Machines. It takes care of the MDB specific 9-bit format, electrical and timing constraints. It forwards the MDB payload to the Raspberry Pi UART using a simple serial protocol. The MDB2Pi is powered through the MDB bus (10...42V regulated or unregulated supply) and back-powers the Raspberry Pi with up to 2.5A at 5V. Therefore, no separate power supply is required. Furthermore, the MDB2Pi contains a Real Time Clock (RTC), buffered by a super capacitor.
A housing for the MDB2Pi (and the MDB2Pi itself) is available at the Abrantix Web Shop: http://blog.abrantix.com/webshop/product/mdb-to-raspberrypi/. Alternatively, you can download a free 3D model here: http://www.thingiverse.com/thing:2209661
2017-01-12 00:28:40 +08:00
2017-03-28 21:10:23 +08:00
2017-03-28 16:05:49 +08:00
## Configuration
2017-03-27 23:16:06 +08:00
Enable UART and RTC by adding the following lines to /boot/config.txt:
2017-01-12 00:28:40 +08:00
```bash
enable_uart=1
2017-03-27 23:16:06 +08:00
dtoverlay=i2c-rtc,pcf8563
2017-01-12 00:28:40 +08:00
```
2017-02-02 23:15:22 +08:00
disable serial console output:
2017-01-12 00:28:40 +08:00
```bash
sudo nano /boot/cmdline.txt
```
--> remove the "console=..." parameter
2017-03-28 16:05:49 +08:00
## MDB Master and Cashless Device Demo:
2017-02-02 23:15:22 +08:00
Install mono runtime:
2017-01-12 00:28:40 +08:00
```bash
sudo apt-get install mono-runtime
```
2017-02-02 23:15:22 +08:00
Get the Demo code:
2017-01-12 00:28:40 +08:00
```bash
2017-02-02 23:12:42 +08:00
wget https://secure.abrantix.com/downloads/MDBConverter/MDBConverter.zip
unzip MDBConverter.zip
2017-01-12 00:28:40 +08:00
```
2017-02-02 23:12:42 +08:00
How to run the Master Demo:
2017-02-03 17:21:44 +08:00
2017-01-12 00:28:40 +08:00
```bash
2017-02-02 23:12:42 +08:00
cd MDBConverter
2017-01-12 00:28:40 +08:00
mono MDBMasterSimulatorConsole.exe /dev/serial0 115200
```
2017-02-03 17:22:33 +08:00
-> For master operation, please make sure to set the DIP Switch to ON-OFF-OFF-ON-ON
2017-02-02 23:12:42 +08:00
How to run the Cashless Device Demo:
```bash
cd MDBConverter
mono MDBCashlessDeviceSimulatorConsole.exe /dev/serial0 115200
```
2017-02-03 17:22:33 +08:00
-> For slave operation, please make sure to set the DIP Switch to OFF-ON-ON-OFF-OFF
2017-02-02 23:12:42 +08:00
2017-01-12 00:28:40 +08:00
Hint: On newer raspbian releases, the serial port is available as /dev/serial0 - older releases may use dev/ttyAMA0.
2017-05-04 14:42:49 +08:00
## RTC
2017-11-14 22:52:08 +08:00
A PCF8563 I2C chip in conjunction with a SuperCapacitor is used for Real-Time-Clock capability (no battery required). This allows buffering of the time up to 7 days when fully charged (or even more, depending on environment temperature and chip/capacitor variance).
2017-01-12 00:28:40 +08:00
2017-05-04 14:42:49 +08:00
Read the RTC:
```bash
pi@raspberrypi:~ $ sudo hwclock -r
Thu 04 May 2017 06:22:13 UTC -0.310218 seconds
```
Write the RTC:
```bash
pi@raspberrypi:~ $ sudo hwclock -w
```
RTC Troubleshooting:
Check if the chip responds over I2C:
```bash
pi@raspberrypi:~ $ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
```
Check dmesg for RTC
```bash
pi@raspberrypi:~ $ dmesg | grep rtc
[ 2.937443] rtc-pcf8563 1-0051: chip found, driver version 0.4.4
[ 2.943665] rtc-pcf8563 1-0051: rtc core: registered rtc-pcf8563 as rtc0
```
Hint: In case that the SuperCap has fully discharged, the daemon might be unable to talk to the RTC at first startup:
2017-01-12 00:28:40 +08:00
2017-05-04 14:42:49 +08:00
```bash
pi@raspberrypi:~ $ dmesg | grep rtc
[ 2.900119] rtc-pcf8563 1-0051: chip found, driver version 0.4.4
[ 2.900403] rtc-pcf8563 1-0051: pcf8563_write_block_data: err=-5 addr=0e, data=03
[ 2.900428] rtc-pcf8563 1-0051: pcf8563_probe: write error
[ 2.900459] rtc-pcf8563: probe of 1-0051 failed with error -5
```
2017-11-14 22:52:08 +08:00
In this case, please wait a few minutes to let the SuperCap recharge, then restart your pi so the RTC daemon can detect the chip again.