(software continued)
Ford ACP
At first I had hoped it was a simple 'if this wire has any signal that means do something' but, alas, it is more complicated than that. Our cars use the Ford Audio Control Protocol (pin 1 and 7). This is a serial communications protocol based on the rs485 spec , kind of like the old rs232 (those old small 8 pin D ports on your computer that you never used).
Some specs about the protocol:
1 start bit
9 data bits
no parity
1 stop bit
9600 baud.
Standard UART stuff. We'll need a chip to translate the wire signal to the computer. Something similar to the max485 will be used and hooked up to a raspberry pi.
Communication (from andrew hammonds)
* a delay of 1642us (16 Bit times) will indicate a start of new message
* the 9th bit in a byte must be set in the last byte of message to indicate
the end of message
* Acknowledge is given with 0x06
Byte 0 – Medium/Priority, should be 0x71
Byte 1 – Changer functional address, should be 0x9A or 0x9B
Byte 2 – Head unit address, 0x80 on receive, 0x82 on transmit
Byte 3 – Command control byte
0xE0 – Handshake 1, byte 4 should be 0x04
0xFC – Handshake 2, byte 4 must be the same for transmit and receive
0xC8 – Handshake 3, byte 4 must be the same for transmit and receive
9xFF – Current disc status in byte 4
Byte 4 – 0x00 Disk OK
Byte 4 – 0x01 No disc in current slot
Byte 4 – 0x02 No disc at all
Byte 4 – 0x03 Check current disk
Byte 4 – 0x04 Check all disc
0xC2 and 0xD0 – Change or request current disc
Byte 1 – 0x9A – command to change disc
Byte 1 – not 0x9A – request current disc
Byte 4 – disc number
0xC1 – Control command
Byte 4
Bit 0 – Fast search
Bit 1
Bit 3
Bit 4 – change Random status
Bit 5 – change Loudness status
Bit 6 – change Play/Stop status
Bit 7
Send back byte 4 with actual mode
0xC3 – Next track
Byte 4 – Track number
0x43 – Previous track
Byte 4 – Track number
The last byte in all message is a checksum of all previous bytes. Simply add
all bytes of message to calculate the checksum.
Message examples
To display current play time, disc and track number:
Byte
0 1 2 3 4 5 6 7 8
0x71 0x9B 0x82 0xD0 Disc No Track No Minutes Seconds Checksum
No disc message:
Byte 0 1 2 3 4 5
0x71 0x9B 0x82 0xFF 0x01 Checksum
(/andy)
There is a problem here in that this is a 9 bit uart but the raspberry pi only supports 8 bit uart. now what?
More complications of course!
OBD
I'm using the library from here: https://github.com/brendan-w/python-OBD. It works pretty well. Be sure to use the async connection or it will hang the program.
Our cars protocol is:
SAE J1850 PWM (pulse-width modulation — 41.6 kbit/s, standard of the Ford Motor Company) (protocol 01)
pin 2: Bus+
pin 10: Bus–
High voltage is +5 V
Message length is restricted to 12 bytes, including CRC
Employs a multi-master arbitration scheme called 'Carrier Sense Multiple Access with Non-Destructive Arbitration' (CSMA/NDA)
Checking PID 00h and 20h shows the following PIDS are supported
PIDS_A: 101111111111111110111001100100 01
PIDS_B: 100000000000000000000000000000 00
00 PIDS_A Supported PIDs [01-20] bitarray
01 STATUS Status since DTCs cleared special
02 FREEZE_DTC DTC that triggered the freeze frame special While this one is labeled as not support, I'm pretty sure it only toggles on when a code is thrown. I'll need to test it.
03 FUEL_STATUS Fuel System Status (string, string)
04 ENGINE_LOAD Calculated Engine Load Unit.percent
05 COOLANT_TEMP Engine Coolant Temperature Unit.celsius
06 SHORT_FUEL_TRIM_1 Short Term Fuel Trim - Bank 1 Unit.percent
07 LONG_FUEL_TRIM_1 Long Term Fuel Trim - Bank 1 Unit.percent
08 SHORT_FUEL_TRIM_2 Short Term Fuel Trim - Bank 2 Unit.percent
09 LONG_FUEL_TRIM_2 Long Term Fuel Trim - Bank 2 Unit.percent
0A FUEL_PRESSURE Fuel Pressure Unit.kilopascal
0B INTAKE_PRESSURE Intake Manifold Pressure Unit.kilopascal
0C RPM Engine RPM Unit.rpm
0D SPEED Vehicle Speed Unit.kph
0E TIMING_ADVANCE Timing Advance Unit.degree
0F INTAKE_TEMP Intake Air Temp Unit.celsius
10 MAF Air Flow Rate (MAF) Unit.grams_per_second
11 THROTTLE_POS Throttle Position Unit.percent
12 AIR_STATUS Secondary Air Status string
13 O2_SENSORS O2 Sensors Present special
14 O2_B1S1 O2: Bank 1 - Sensor 1 Voltage Unit.volt
15 O2_B1S2 O2: Bank 1 - Sensor 2 Voltage Unit.volt
16 O2_B1S3 O2: Bank 1 - Sensor 3 Voltage Unit.volt
17 O2_B1S4 O2: Bank 1 - Sensor 4 Voltage Unit.volt
18 O2_B2S1 O2: Bank 2 - Sensor 1 Voltage Unit.volt
19 O2_B2S2 O2: Bank 2 - Sensor 2 Voltage Unit.volt
1A O2_B2S3 O2: Bank 2 - Sensor 3 Voltage Unit.volt
1B O2_B2S4 O2: Bank 2 - Sensor 4 Voltage Unit.volt
1C OBD_COMPLIANCE OBD Standards Compliance string
1D O2_SENSORS_ALT O2 Sensors Present (alternate) special
1E AUX_INPUT_STATUS Auxiliary input status (power take off) boolean
1F RUN_TIME Engine Run Time Unit.second
20 PIDS_B Supported PIDs [21-40] bitarray
21 DISTANCE_W_MIL Distance Traveled with MIL on Unit.kilometer
22 FUEL_RAIL_PRESSURE_VAC Fuel Rail Pressure (relative to vacuum) Unit.kilopascal
23 FUEL_RAIL_PRESSURE_DIRECT Fuel Rail Pressure (direct inject) Unit.kilopascal
24 O2_S1_WR_VOLTAGE 02 Sensor 1 WR Lambda Voltage Unit.volt
25 O2_S2_WR_VOLTAGE 02 Sensor 2 WR Lambda Voltage Unit.volt
26 O2_S3_WR_VOLTAGE 02 Sensor 3 WR Lambda Voltage Unit.volt
27 O2_S4_WR_VOLTAGE 02 Sensor 4 WR Lambda Voltage Unit.volt
28 O2_S5_WR_VOLTAGE 02 Sensor 5 WR Lambda Voltage Unit.volt
29 O2_S6_WR_VOLTAGE 02 Sensor 6 WR Lambda Voltage Unit.volt
2A O2_S7_WR_VOLTAGE 02 Sensor 7 WR Lambda Voltage Unit.volt
2B O2_S8_WR_VOLTAGE 02 Sensor 8 WR Lambda Voltage Unit.volt
2C COMMANDED_EGR Commanded EGR Unit.percent
2D EGR_ERROR EGR Error Unit.percent
2E EVAPORATIVE_PURGE Commanded Evaporative Purge Unit.percent
2F FUEL_LEVEL Fuel Level Input Unit.percent
30 WARMUPS_SINCE_DTC_CLEAR Number of warm-ups since codes cleared Unit.count
31 DISTANCE_SINCE_DTC_CLEAR Distance traveled since codes cleared Unit.kilometer
32 EVAP_VAPOR_PRESSURE Evaporative system vapor pressure Unit.pascal
33 BAROMETRIC_PRESSURE Barometric Pressure Unit.kilopascal
34 O2_S1_WR_CURRENT 02 Sensor 1 WR Lambda Current Unit.milliampere
35 O2_S2_WR_CURRENT 02 Sensor 2 WR Lambda Current Unit.milliampere
36 O2_S3_WR_CURRENT 02 Sensor 3 WR Lambda Current Unit.milliampere
37 O2_S4_WR_CURRENT 02 Sensor 4 WR Lambda Current Unit.milliampere
38 O2_S5_WR_CURRENT 02 Sensor 5 WR Lambda Current Unit.milliampere
39 O2_S6_WR_CURRENT 02 Sensor 6 WR Lambda Current Unit.milliampere
3A O2_S7_WR_CURRENT 02 Sensor 7 WR Lambda Current Unit.milliampere
3B O2_S8_WR_CURRENT 02 Sensor 8 WR Lambda Current Unit.milliampere
3C CATALYST_TEMP_B1S1 Catalyst Temperature: Bank 1 - Sensor 1 Unit.celsius
3D CATALYST_TEMP_B2S1 Catalyst Temperature: Bank 2 - Sensor 1 Unit.celsius
3E CATALYST_TEMP_B1S2 Catalyst Temperature: Bank 1 - Sensor 2 Unit.celsius
3F CATALYST_TEMP_B2S2 Catalyst Temperature: Bank 2 - Sensor 2 Unit.celsius
40 PIDS_C Supported PIDs [41-60] bitarray
PID check calls to PIDS_D through PIDS_G just throw out of range errors.
These are just the standard pids. Every manufactuer uses tons of non-standard PIDs. Something like FORscan can read them but I'm not sure how to yet.
My rear O2s are off so ymmv
Raspberry pi
Using a method called bit banging we can use this software pigpio to translate 8 to 9 bit. Playing with software serial communications is like eating glass. getting everything to sync up like this will be...fun.
the raspberry pi uses linux as it os. Instead of using hardware encoder chips we will offload the decoding work onto the OS. this will allow us to play nearly anything as long as their is software available on Linux that does the job.
The audio program we will use is mpd which will be fed commands from its command line (mpc). so we take the apc command, translate it to music command. done! Just that easy!
steps so far:
1) format micro sd card. if it is over 32gb you must use fat32format. The card must be in fat format.
2) Download pi's NOOBS image. copy the contents on to the card.
3) plug in mouse,kb, network, audio, hdmi, and finally power (5v 2amp micro usb)
4) install raspbian, install mpd, install mpc
5) copy music into mpds music dir, run mpc add all command (it is in the manual)
6) force audio through the jack (instead of hdmi) with raspi-config
7) mpc play 1 to test.
updated pigpio to 56. noobs has 50 by default.
First thing you need to do is get a micro sd card. There are differnet classifications and each size uses a slight different scheme. Be sure to check what they mean here. and what the PI likes here. I thought mine was too slow but then I checked the datasheet for it and it turns out to be fine. double check that!
I decided not to use archphile distro. I'll be working on this section now as I wait for other hardware bits to show up.