Carberry

From OpenGarages
Revision as of 19:38, 3 March 2016 by Scrambles (talk | contribs)
Jump to: navigation, search

Summary

The Carberry is designed as a drop in replacement for some dash controls. This page is dedicated to research into making it do more than the pre-designed usage.

Top down view of the Carberry, courtesy of Carberry.it

Hardware Specifications

Wiring Pinout

Carberrypinout.jpg

Pinout

Position Wire color Description
1 Red +12V Power Supply
2 Black Power Ground
3 Blu/Yellow +12V Ignition Input
4 Black/Orange +12V Ignition Output
5 White General Purpose Input #1
6 Black Signal Ground
7 White/Green General Purpose Input #2
8 Green CAN BUS High Channel #1
9 White CAN BUS Low Channel #1
10 Yellow/Green CAN BUS High Channel #2
11 Yellow/White CAN BUS Low Channel #2
12 Red/Green LIN BUS
13 Blu General Purpose Output #1
14 Blu/Green General Purpose Output #2
15 Pink Resistive Input Channel #1
16 Yellow Resistive Input Channel #2
17 Pink/Black Resistive Output Channel #1
18 Yellow/Black Resistive Output Channel #2
19 Gray GMLAN BUS Channel #1
20 Yellow/Gray GMLAN BUS Channel #2
21 Cyan External UART Output (TXD)
22 Cyan/White External UART Input (RXD)

Credit: http://carberry.it/wiki/start

Raspberry Pi Setup

Setting up the OS

Carberry.it provides multiple versions of the Carbian OS for download at Carberry Downloads. For Raspberry Pi 2 and above you must use the Carbian-Jessie distribution. This page also provides firmware updates, additional Carberry operating systems and Carberry daemons.

If you wish to use your own Raspbian distribution with Carberry Pi's daemons, follow the instructions at the below links.

To install the "Carberry" daemon on Raspbian follow the instructions at Carberry Daemon

To install the Carberry's "Shutdown" Daemon on Raspbian follow the instructions at Shutdown Daemon

To utilize UART with the Carberry, follow the instructions at UART. Raspbian "Jessie" does not have inittab as mentioned in this set of instructions, however, Raspbian "Wheezy" and earlier distributions do.

Connecting the Carberry

If testing functionality without a vehicle, connect your Carberry's +12v Power Supply and +12v Ignition Input (Carberry pins 1 and 3) to a +12v DC power source and Ground (Carberry pin 2) to ground. To use with a vehicle connect your Carberry's +12v Power Supply and +12v Ignition Input (Carberry pins 1 and 3) to a battery (pin 16 on OBD II ports), Ground (Pin 2 on Carberry) to Chassis Ground (Pin 4 on OBD II ports) and Signal Ground (Pin 6 on Carberry) to Signal Ground (Pin 5 on OBD II ports). Connect your Carberry's SWCAN or CAN ports to the applicable OBD II pins.

Updating Carberry Firmware

Communication via Raspberry Pi

Communication via USB

Setup on Windows

The Carberry can communicate with a PC via USB or UART. To use with Microsoft Windows download USB Drivers. Extract the files. Connect your Carberry via MicroUSB to your computer. Once connected, navigate to Device Manager, Ports (COM & LPT) and right click on your device. Select Update Driver Software and click "Browse my computer for driver software." Navigate to the files you previously extracted and click "Okay." Once you click "Next" your drivers should begin installing.
Make note of the COM port assigned to your Carberry for later use in serial communication. Install a suitable terminal application, such as PuTTY.

Connecting via PuTTY

Open PuTTY and choose "Serial" under connection type. Enter the COM port you obtained from your "Device Manager" under Serial Line. Leave the speed at 9600 (the speed should not matter when connected via USB, however, leaving at default presents no issues). Adjust any of the other settings as you please. When ready, press "Open" and your computer should connect to the Carberry. Type in "AT" and push enter. If setup properly, the Carberry should return with an "OK."

Setup on Linux

If Minicom is not installed on your distribution, follow the instructions at Minicom to install it. Linux should not require any additional drivers for communicating with the Carberry via USB. Connect the Carberry via MicroUSB to your computer's USB port. Once connected, open a terminal and "enter dmesg | grep tty" to determine your Carberry's serial port. It should look similar to ttyAMA0.
Plug a micro USB Cable into the Carberry's Micro USB port and the opposing end into your computer.

[ADDITIONAL INSTRUCTIONS]

Using the Carberry

Once connected to your Carberry, send the command AT to test communication with your Carberry. A response of OK indicates all is in working order. If you do not receive a response, double check your baud rate and COM ports. If you do not see your text as you type, send the command ECHO to display your commands as they're typed.

CAN Communication


Set CAN mode

To query the CAN mode enter CAN MODE. You should receive SERIES, PARALLEL or USER as a response.

To set the CAN mode enter CAN MODE <MODE>.

The available CAN Modes are SERIES, PARALLEL and USER. For the free reception of CAN messages, USER mode is recommended.

CAN bus free reception

When in user mode, you can manually open channels to allow for reception and transmission of CAN messages.

To set the CAN mode enter CAN USER OPEN CH<1|2> <500K|250K|125K|100K|95K2|83K3|50K|33K3|AUTO> [GMLAN]

For example, to open channel 1 with baud rate detection:
CAN USER OPEN CH1 AUTO
Please wait for timing result
Baud rate = 250K (250Kbps)

To enable GMLAN (SWCAN) on channel 2 type:

CAN USER OPEN CH2 AUTO GMLAN
Please wait for timing result
Baud rate = 33k3(33.3Kbps)
or
CAN USER OPEN CH2 33K3 GMLAN
OK

Reception filters & masks

To receive CAN frames you must set at least one reception filter on your open channel(s) and you may also set a reception mask. A filter combined with a mask can dictate whether you receive one specific frame, or a range of frames. A reception mask dictates which bits of CAN frames must match the CAN filter bits. The default reception mask for the Carberry is 0000:00000, which will accept any message, regardless of the active reception filter.

Masks

To set a reception mask enter CAN USER MASK CH<1|2> <MASK>. The mask can use a standard CAN ID of 0000 to FFE0 or an extended CAN ID of 0000:000000-FFFFC0.

For example, to set a mask of FFE0:FFFFC0 on CH1 enter:
CAN USER MASK CH1 FFE0:FFFFC0
OK

Filters

All CAN filters are disabled by default, but you may enable up to 32 filters per channel. To set a filter enter CAN USER FILTER CH<1|2> <filter number(1-32)> <FILTER>. The filter can use a standard CAN ID of 0000 to FFE0 or an extended CAN ID of 0000:000000-FFFFC0.

For example, to set a filter of 8040 on CH1 enter:
CAN USER MASK CH1 27 8040
OK

How filters & masks work together

To understand how masks and filters work together, you must convert them to binary. Masks are simply bitmasks, common to networking or other forms of coding. If you want to receive a range of CAN ID's with only one filter, it is best to convert your requirements to binary and determine which filters/masks to enable. In the table below, any 1 in the mask means the bit in the same position of incoming CAN ID's must match the filter you've set. Any 0 means the condition of the bit in the same position of incoming CAN ID's does not matter.


EXAMPLE 1 EXAMPLE 2 EXAMPLE 3
MASK 07FF 0F00 1000
FILTER 100A 0700 1900
MASK BINARY 0000 0111 1111 1111 0000 1111 0000 0000 0001 0000 0000 0000
FILTER BINARY 0001 0000 0000 1010 0000 0111 0000 0000 0001 1001 0000 0000
RESULTS Any frame matching bits 1 thru 11 Any frame matching bits 9 thru 12 Any frame matching bit 13

CAN Connection Modes

CAN alignment

Convert (default) left aligned CAN ID to proper ID

The following Ruby code will convert the CAN ID to the correct format (courtesy of Craig Smith):

carb = "carb_var".split(":") x = ((carb[0].hex >> 5) << 18) + (carb[1].hex >> 6) puts x.to_s(16)

Replace the carb_var with the mislabeled CAN ID.

Convert right aligned CAN ID to proper ID

The following Python script will convert a right aligned CAN ID to the correct format:

rightid=input('Enter your right aligned CAN ID XXXX:XXXXXX: ')
sid, eid=(rightid.split(':',2))
sid=int(sid, 16)
eid=int(eid, 16)
converted=hex(int("{0:b}".format(sid)+"{0:b}".format(eid),2))
print (converted)

GMLAN communication example

AT
OK
ECHO
OK
CAN MODE USER
OK
CAN USER OPEN CH1 AUTO GMLAN
Please wait for timing result
. baud rate = 33K3 (33.3 Kbps)
OK
CAN USER MASK CH1 0000
OK
CAN USER FILTER CH1 0 100A
RX1 8000:302000-0180
RX1 8140:282000-0000
RX1 7FE0:F82000
RX1 8140:282000-0000
RX1 7FE0:F82000
RX1 8140:282000-0000
RX1 7FE0:F82000
RX1 8140:282000-0000
RX1 7FE0:F82000
+++ (suspends reception)
ATO (resume reception)
RX1 8000:302000-0180
RX1 8140:282000-0000
RX1 7FE0:F82000
RX1 8140:282000-0000
RX1 7FE0:F82000
RX1 8140:282000-0000
RX1 7FE0:F82000
RX1 8140:282000-0000
RX1 7FE0:F82000

Command Index

Management Commands

Command Expected Response Purpose
AT OK Tests communication with Carberry
ECHO OFF or ON Echo the commands typed by the user
VERSION Version number Display current Carberry firmware and hardware version
REBOOT OK System reboot (only reboots Carberry, not the Pi)
+++ Suspends message reception
ATO Resumes message reception

CAN Connection Modes

Command Expected Response Purpose
CAN MODE Informs the user of the current CAN mode
CAN MODE PARALLEL OK Sets the Carberry's CAN channels into parallel mode
CAN MODE SERIES OK Sets the Carberry's CAN channels into series mode
CAN MODE USER OK Provides the user full control over RX and TX of both CAN channels

API

Known Issues

Other issues