Pican Gps + Gyro +accelerometer User Guide V1.0
Pican Gps + Gyro +accelerometer User Guide V1.0
V1.0
Product name PiCAN GPS + Gyro + Accelerometer CAN-Bus Board for Raspberry Pi
Contents
Table of Contents
1. Introduction ............................................................................................................ 3
1.1. Features ................................................................................................................................................................ 3
2. Hardware Installation .............................................................................................. 4
1.2. Screw Terminal .................................................................................................................................................. 4
1.3. 120Ω Terminator ............................................................................................................................................. 4
1.4. LED1 ....................................................................................................................................................................... 4
1.5. LED2 ....................................................................................................................................................................... 4
1.6. Not Fitted Items ................................................................................................................................................. 5
1.7. External GPS Antenna and Backup Battery ........................................................................................... 5
1.8. GPS 1PPS (Pulse Per Second) ...................................................................................................................... 5
1.9. MPU-6050 I2C Address .................................................................................................................................. 5
3. Software Installation ............................................................................................... 6
1.10. MPU-6050 Test ............................................................................................................................................... 7
1.11. Basic GPS Test ................................................................................................................................................. 8
1.12. Using GPSD ........................................................................................................................................................ 9
1.13. External GPS Antenna ................................................................................................................................ 10
1.14. Bring Up the CAN Interface ...................................................................................................................... 11
4. Writing Your Own Software .................................................................................... 12
1.15. Application in Python ................................................................................................................................. 12
1.16. Application in C ............................................................................................................................................. 13
1. Introduction
This PiCAN GPS board provides CAN-Bus capability for the Raspberry Pi 2 and 3. It
uses the Microchip MCP2515 CAN controller. CAN connections are made via 4 way
screw terminal plug. GPS is provided by a 66 channels MTK3339 chipset module. An
onboard battery holder for a CR1220 cell. The backup power is for the real time clock
and help to reduce fix time. The GPS module has built in patch antenna but an external
active antenna can also be use via the uFL connector.
The MPU-6050 provides six axis gyro and accelerometer with an onboard Digital
Motion Processor™ (DMP™) capable of processing complex 9-axis MotionFusion
algorithms, the MPU-6050 does away with the cross-axis alignment problems that can
creep up on discrete parts.
Easy to install SocketCAN driver. Programming can be done in C or Python.
1.1. Features
• CAN v2.0B at 1 Mb/s
• High speed SPI Interface (10 MHz)
• Standard and extended data and remote frames
• CAN connection via screw terminal
• 120Ω terminator ready
• Serial LCD ready
• LED indicator
• Four fixing holes, comply with Pi Hat standard
• SocketCAN driver, appears as can0 to application
• Interrupt RX on GPIO25
• MTK3339 chipset
• -165 dBm sensitivity, 10 Hz updates, 66 channels
• RTC battery holder
• Fix status LED
• On board patch antenna
• uFL connector for external active antenna
• I2C Digital-output of 6 or 9-axis MotionFusion data in rotation matrix,
quaternion, Euler Angle, or raw data format
• Input Voltage: 2.3 - 3.4V
• Selectable Solder Jumpers on CLK, FSYNC and AD0
• Tri-Axis angular rate sensor (gyro) with a sensitivity up to 131 LSBs/dps and a
full-scale range of ±250, ±500, ±1000, and ±2000dps
• Tri-Axis accelerometer with a programmable full scale range of ±2g, ±4g, ±8g
and ±16g
• Digital Motion Processing™ (DMP™) engine offloads complex MotionFusion,
sensor timing synchronization and gesture detection
• Embedded algorithms for run-time bias and compass calibration. No user
intervention required
2. Hardware Installation
Before installing the board make sure the Raspberry is switched off. Carefully align
the 40way connector on top of the Pi. Use spacer and screw (optional items) to secure
the board.
1.2. Screw Terminal
The CAN connection can also be made via the 4 way screw terminal.
CAN0 (J3)
Pin number Function
1 n/c
2 GND
3 CAN_H
4 CAN_L
1.4. LED1
There is a red LEDs fitted to the board. This is connected to GPIO04. It can use as a
general purpose indicator.
1.5. LED2
The LED blinks at about 1Hz while it's searching for satellites and blinks once every
15 seconds when a fix is found.
3. Software Installation
The following procedure is for the Raspberry Pi 3.
It is best to start with a brand new Raspbian Jessie image. Download the latest from:
https://www.raspberrypi.org/downloads/raspbian/
After first time boot up, do an update and upgrade first.
sudo apt-get update
sudo reboot
dtparam=spi=on
enable_uart=1
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
dtoverlay=spi-bcm2835-overlay
Change
to
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2
rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
Reboot Pi:
sudo reboot
cd MPU-6050-examples
Tilt and shake the board, you should see the value changes.
If you see the data with lots of commas then it means the module has not got a fix yet.
Make sure the GPS module has a clear view of the sky. Alternatively connect an
external GPS antenna to the board and place the antenna outdoor.
You should see something like this:
gpsmon
1.13. External GPS Antenna
The PiCAN-GPS board has built in patch antenna which provides a -165dBm
sensitivity. However if your project is in a box and does not have a clear view of the
sky then an external antenna is more suitable.
The optional external antenna has a SMA connector and an uFL to SMA cable adapter
is required.
http://www.skpang.co.uk/dl/can-test_pi2.zip
Connect the PiCAN2 to your CAN network via screw terminal .
To send a CAN message on can0 (CAN B J4) use :
./cansend can0 7DF#0201050000000000
Connect the PiCAN to a CAN-bus network and monitor traffic by using command:
./candump can0
msg = can.Message(arbitration_id=0x7de,
extended_id=False)
bus.send(msg)
1.16. Application in C
Bring the CAN interface up if it is not already done:
sudo /sbin/ip link set can0 up type can bitrate 500000
Download the source code and example files by typing the following in the command
prompt:
wget http://skpang.co.uk/dl/cantest.tar
The example file is called cantest.c to edit this file, type the following in the command
prompt:
nano cantest.c
7DF is the message ID and 0201050000000000 is the data. Change the data to suit.
Press CTRL-X to exit.
To compile the program type:
make