CanBerry V2.0 Datasheet

Transcription

CanBerry V2.0 Datasheet
i
i
“industrialberry_datasheet” — 2015/3/21 — 10:25 — page i — #3
i
i
CanBerry PI V 2.0
INDUSTRIAL
BERRY
www.industrialberry.com
March 2015
i
i
i
i
i
i
“industrialberry_datasheet” — 2015/3/21 — 10:25 — page iii — #5
i
i
Contents
1 License
1.1 Disclaimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
1
2 Introduction
3
3 Hardware implementation
5
4 Software implementation
4.1 Real Time Clock . . . . . . . . . . . . . . . . . . . . . . . . . .
4.1.1 RTC with shell . . . . . . . . . . . . . . . . . . . . . . .
4.2 LED Control . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11
12
12
13
5 Components list
15
Bibliography
17
iii
i
i
i
i
i
i
“industrialberry_datasheet” — 2015/3/21 — 10:25 — page v — #7
i
i
List of Figures
2.1
2.2
CanBerry V2.0 on Raspberry PI . . . . . . . . . . . . . . . . .
CanBerry V2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . .
4
4
3.1
3.2
3.3
3.4
3.5
Electric diagram of CanBus block . . . . . . . . . . . . . . . . .
Electric diagram of RTC block . . . . . . . . . . . . . . . . . .
CanBerry Connector . . . . . . . . . . . . . . . . . . . . . . . .
Raspberry HAT Eeprom . . . . . . . . . . . . . . . . . . . . . .
CAN Bus example, image from http://en.wikipedia.org/wiki/
File:CAN-Bus_Elektrische_Zweidrahtleitung . . . . . . . .
CANH Bus monitoring . . . . . . . . . . . . . . . . . . . . . . .
6
7
7
8
3.6
8
9
v
i
i
i
i
i
i
“industrialberry_datasheet” — 2015/3/21 — 10:25 — page vii — #9
i
i
List of Tables
5.1
CanBerry Pi V 2.0 . . . . . . . . . . . . . . . . . . . . . . . . .
16
vii
i
i
i
i
i
i
“industrialberry_datasheet” — 2015/3/21 — 10:25 — page 1 — #11
i
i
Chapter 1
License
Open-source hardware shares much of the principles and approach of free and
open-source software. In particular, we believe that people should be able
to study our hardware to understand how it works, make changes to it, and
share those changes. To facilitate this, we release all of the original design files
(Eagle CAD) for the IndustrialBerry hardware. These files are licensed under
a Creative Commons Attribution Share-Alike license, which allows for both
personal and commercial derivative works, as long as they credit IndustrialBerry and release their designs under the same license. The IndustrialBerry
software/firmware is also open-source.
1.1 Disclaimer
In no event shall Industrialberry be liable to the buyer or to any third party
for any indirect, incidental, special, consequential, punitive or exemplary damages (including without limitation lost profits, lost savings, or loss of business
opportunity) arising out of or relating to any product or service provided or to
be provided by Industrialberry, or the use or inability to use the same, even if
Industrialberry has been advised of the possibility of such damages.
1
i
i
i
i
i
i
“industrialberry_datasheet” — 2015/3/21 — 10:25 — page 2 — #12
i
i
i
i
i
i
i
i
“industrialberry_datasheet” — 2015/3/21 — 10:25 — page 3 — #13
i
i
Chapter 2
Introduction
CanBerry Pi V 2.0 is an extension board for RaspBerry Pi. It is an Open
Hardware Design. It has two functionalities: a can bus module and an onboard
Real Time clock powered by a 12 mm battery. In fig 2.1 is shown the Board on
Raspberry PI B+. The CanBus is based on MCP2515 [1] SPI controller and
the MCP2551 [2] tranceiver. All functionalities are full integrated in standard
linux kernel, so, they can be avaible on fly, or at last recompiling linux kernel
to add canbus functionalities. The real time clock is based on DS3231 [3](with
internal oscillator ) or DS1307Z [4] I2C controller. It is full compatible with
linux too. Using I2C Kernel module, and standard kernel functions, date and
hour can be set/get by simple commands. On the bottom side is located an on
board battery to guarantee a data autonomy more than 20 years. In chapter
hardware there are all informations on principal components, schematics to
rebuild and modify RaspBerry PI board. In chapter Software is reported how
all hardware can be used: as recompile kernel, build simple user space function
to set and get I2C data, etc... In chapter application is reported a typical
example of how to use the board.
3
i
i
i
i
i
i
“industrialberry_datasheet” — 2015/3/21 — 10:25 — page 4 — #14
i
i
Chapter 2 Introduction
Figure 2.1: CanBerry V2.0 on Raspberry PI
Figure 2.2: CanBerry V2.0
4
i
i
i
i
i
i
“industrialberry_datasheet” — 2015/3/21 — 10:25 — page 5 — #15
i
i
Chapter 3
Hardware implementation
CanBerry PI 2.0 is composed by two blocks: a CanBus Module shown in Fig.
3.1 and a Real Time Clock shown in 3.2 The SMD Jumper JP2 must be used
to connect the RTC Int pin to Raspberry GPIO7.
MCP2515 is a stand alone SPI canbus controller full integrated in linux
kernel. At the start, the driver was implemented as a block device. Recently it
is assumed to be a network module into the kernel. It is supplied by 3.3V from
raspberry connector (fig 3.3 ). MCP2551 is supplied by 5V from Raspberry
connector insted. So, to match voltage physical level between the two chips, a
voltage matching made by R3 and R4 has been used. The SMD Jumper JP3
must be used for the first and the last device of CAN Bus, this jumper provides
the 120 Ω termination (see fig 3.5).
The Raspberry Pi B+ has been designed specifically with add-on boards in
mind and today we are introducing HATs (Hardware Attached on Top). A
significant feature of HATs is the inclusion of a system that allows the B+ to
identify a connected HAT and automatically configure the GPIOs and drivers
for the board, making life for the end user much easier! The automatic configuration is achieved using 2 dedicated pins (ID SD and ID SC) on the 40W
B GPIO header that are reserved for an I2C EEPROM CAT24C32WI. The
EEPROM (see fig 3.4).
You can see in fig.3.6 the signal on pin CANH
5
i
i
i
i
i
i
“industrialberry_datasheet” — 2015/3/21 — 10:25 — page 6 — #16
i
i
Chapter 3 Hardware implementation
Figure 3.1: Electric diagram of CanBus block
6
i
i
i
i
i
i
“industrialberry_datasheet” — 2015/3/21 — 10:25 — page 7 — #17
i
i
Figure 3.2: Electric diagram of RTC block
Figure 3.3: CanBerry Connector
7
i
i
i
i
i
i
“industrialberry_datasheet” — 2015/3/21 — 10:25 — page 8 — #18
i
i
Chapter 3 Hardware implementation
Figure 3.4: Raspberry HAT Eeprom
Figure 3.5: CAN Bus example, image from http://en.wikipedia.org/wiki/
File:CAN-Bus_Elektrische_Zweidrahtleitung
8
i
i
i
i
i
i
“industrialberry_datasheet” — 2015/3/21 — 10:25 — page 9 — #19
i
i
Figure 3.6: CANH Bus monitoring
9
i
i
i
i
i
i
“industrialberry_datasheet” — 2015/3/21 — 10:25 — page 10 — #20
i
i
i
i
i
i
i
i
“industrialberry_datasheet” — 2015/3/21 — 10:25 — page 11 — #21
i
i
Chapter 4
Software implementation
How to prepare a SD Card with CAN kernel modules
Download Wheezy raspbian 2014-09-09
After your raspberry has been booted, go to home directory:
cd /home/pi/
nano can-start.sh
add these lines to the script
#!/bin/sh
#Can
insmod /lib/modules/3.12.28+/kernel/drivers/spi/spi-bcm2708.ko
insmod /lib/modules/3.12.28+/kernel/net/can/can.ko
insmod /lib/modules/3.12.28+/kernel/drivers/net/can/can-dev.ko
insmod /lib/modules/3.12.28+/kernel/net/can/can-raw.ko
insmod /lib/modules/3.12.28+/kernel/net/can/can-bcm.ko
insmod /lib/modules/3.12.28+/extra/spi-config.ko
devices=\bus=0:cs=0:modalias=mcp2515:speed=10000000:gpioirq=25:pd=20:pds32-0=16000000:pdu32-4=
insmod /lib/modules/3.12.28+/kernel/drivers/net/can/mcp251x.ko
ip link set can0 up type can bitrate 1000000
Run the script:
sudo sh can-start.sh
So the system is ready, then you can use standard canbus command to use
the peripheral:
candump can0 -> to monitoring can bus traffic
cansend can0 7DF#0201050000000000 -> to send canbus commands
11
i
i
i
i
i
i
“industrialberry_datasheet” — 2015/3/21 — 10:25 — page 12 — #22
i
i
Chapter 4 Software implementation
4.1 Real Time Clock
It is possible use the RTC IC with the terminal or with a compiled program.
The DS1307Z is a device I2C, and then we must install i2c-tool
sudo aptitude install i2c-tool
and libi2c-dev before use it.
sudo aptitude install libi2c-dev
4.1.1 RTC with shell
The following code allow the management of the RTC with the i2c-tool directly
from the shell. Verify the DS1307Z address 0x68 with
sudo i2cdetect -y 0
for Raspberry Rev 1 or
sudo i2cdetect -y 1
for Rev 2 and B+, because the I2C bus address changed from 0 to 1.
Run the scripts as root:
modpro be rtc-ds1307
Then, run
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device (if you have
a Rev 1 Pi)
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device (if you have
a Rev 2 Pi)
Set RTC with
hwclock -w
Read RTC with
hwclock -r
12
i
i
i
i
i
i
“industrialberry_datasheet” — 2015/3/21 — 10:25 — page 13 — #23
i
i
4.2 LED Control
4.2 LED Control
Go to home directory:
cd /home/pi/
nano gpio_on.sh
add these lines to the script
#!/bin/sh
# Set up GPIO 27 and set to output
echo "27" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio27/direction
# Set up GPIO 4 and set to output
echo "4" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio4/direction
# Write output
#Led1 On
echo "1" > /sys/class/gpio/gpio27/value
#Led2 On
echo "1" > /sys/class/gpio/gpio4/value
# Clean up
echo "27" > /sys/class/gpio/unexport
echo "4" > /sys/class/gpio/unexport
nano gpio_off.sh
add these lines to the script
#!/bin/sh
# Set up GPIO 27 and set to output
echo "27" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio27/direction
# Set up GPIO 4 and set to output
echo "4" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio4/direction
13
i
i
i
i
i
i
“industrialberry_datasheet” — 2015/3/21 — 10:25 — page 14 — #24
i
i
Chapter 4 Software implementation
# Write output
#Led1 Off
echo "0" > /sys/class/gpio/gpio27/value
#Led2 Off
echo "0" > /sys/class/gpio/gpio4/value
# Clean up
echo "27" > /sys/class/gpio/unexport
echo "4" > /sys/class/gpio/unexport
Run the scripts as root:
sh gpio_on.sh
sh gpio_off.sh
14
i
i
i
i
i
i
“industrialberry_datasheet” — 2015/3/21 — 10:25 — page 15 — #25
i
i
Chapter 5
Components list
In the table 5.1 we can see the Bill of Material for the board, all the components
are available on-line. For simplicity, every component has a DigiKey order code
(www.digikey.com).
15
i
i
i
i
i
“industrialberry_datasheet” — 2015/3/21 — 10:25 — page 16 — #26
i
Quantity
2
1
2
5
4
1
2
4
1
1
1
1
1
1
1
1
1
1
Value
Yellow
120 Ω
499 Ω
4.7 kΩ
10 kΩ
18 kΩ
22pf
100nf
1uf
16MHz
MCP2551
MCP2515
DS3231
CAT24C32WI-GT3
RETAINER COIN 12MM
TERMINAL-3-PCB
Header 40 pos
Package
1206
0603
0603
0603
0603
0603
0603
0603
0603
HC49/US
SOIC8
SOIC18
SOIC16
SOIC8
3 X 3.5mm
2 X 20
Parts
LED1, LED2
R10
R13, R14
R1, R2, R3, R6, R7
R5, R8, R11, R15
R4
C5, C7
C1,C2, C4, C8
C9
Q1
IC1
IC2
IC4
IC5
BAT100
X1
Digikey-cod
754-1144-1-ND
RMCF0603JT120RCT-ND
RMCF0603FT499RCT-ND
RMCF0603JT4K70CT-ND
P10KGCT-ND
P18KGCT-ND
445-1273-1-ND
445-1316-1-ND
445-1322-1-ND
535-10226-1-ND
MCP2551-I/SN-ND
MCP2515-I/SO-ND
DS3231S-ND
CAT24C32WI-GT3CT-ND
BAT-HLD-012-SMT-ND
277-8807-ND
SAM1086-20-ND
PCB
Table 5.1: CanBerry Pi V 2.0
Unit Price $
0,21
0,02
0,04
0,02
0,10
0,10
0,10
0,10
0,10
0,41
1,12
1,98
8.35
0.57
0,27
0,37
3.30
3.20
Total
0,42
0,02
0,08
0,10
0,40
0,10
0,20
0,40
0,10
0,41
1,12
1,98
8.35
0.57
0,27
0,37
3.30
3.20
21.39
i
i
i
i
Chapter 5 Components list
16
i
i
i
i
“industrialberry_datasheet” — 2015/3/21 — 10:25 — page 17 — #27
i
i
Bibliography
[1] Microchip. MCP2515 Datasheet. http://ww1.microchip.com/downloads/en/
devicedoc/21801e.pdf.
[2] Microchip. MCP2551 Datasheet. http://ww1.microchip.com/downloads/en/
devicedoc/21667d.pdf.
[3] Maxim. DS3231 Datasheet. http://datasheets.maximintegrated.com/en/
ds/DS3231-DS3231S.pdf.
[4] Maxim. DS1307Z Datasheet. http://datasheets.maximintegrated.com/en/
ds/DS1307.pdf.
17
i
i
i
i