0
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
会员中心
创作中心
发布
  • 发文章

  • 发资料

  • 发帖

  • 提问

  • 发视频

创作活动
ELM327DSC

ELM327DSC

  • 厂商:

    ELM

  • 封装:

  • 描述:

    ELM327DSC - OBD to RS232 Interpreter - ELM Electronics

  • 数据手册
  • 价格&库存
ELM327DSC 数据手册
ELM327 OBD to RS232 Interpreter Description Almost all new automobiles produced today are required, by law, to provide an interface from which test equipment can obtain diagnostic information. The data transfer on these interfaces follow several standards, none of which are directly compatible with PCs or PDAs. The ELM327 is designed to act as a bridge between these On-Board Diagnostics (OBD) ports and standard RS232 ports. The ELM327 builds on improved versions of our proven ELM320, ELM322, and ELM323 interfaces by adding seven CAN protocols to them. The result is an IC that can automatically sense and convert the most common protocols in use today. There are a number of other improvements as well – a high speed RS232 option, battery voltage monitoring, and customizable features through programmable parameters, to name only a few. The ELM327 requires few external components to make a fully functioning circuit. The following pages discuss the interface details, and show how to use the IC to ‘talk’ to your vehicle, then concludes with two schematics to get you started. Features • Supports 12 protocols • Automatically searches for a protocol • Fully configurable with AT commands • RS232 baud rates to 500Kbps • Voltage input for battery monitoring • Low power CMOS design Connection Diagram PDIP and SOIC (top view) MCLR Vmeasure J1850 Volts J1850 Bus+ Memory Baud Rate LFmode VSS XT1 OBD Tx LED OBD Rx LED RS232 Tx LED RS232 Rx LED CAN Rx CAN Tx ISO L ISO K VDD VSS RS232 Rx RS232 Tx Busy RTS Applications • Diagnostic trouble code readers • Automotive scan tools • Teaching aids XT2 VPW In ISO In PWM In J1850 Bus- 4.00 MHz Block Diagram Memory 5 XT1 9 10 XT2 MCLR 1 Vmeasure 2 Baud Rate LFmode RS232Rx RS232Tx RTS Busy 18 17 6 7 RS232 Interface Command and Protocol Interpreter A/D Converter CAN ISO 15765-4 SAE J1939* ISO 9141-2 ISO 14230-4 SAE J1850 PWM & VPW 15 16 25 …28 23 24 21 22 12 3 4 14 13 11 status LEDs OBD interfaces *some support ELM327DSC Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 1 of 51 ELM327 Pin Descriptions MCLR (pin 1) A momentary logic low applied to this input will reset the IC. If unused, this pin should be connected to a logic high (VDD) level. Vmeasure (pin 2) This analog input is used to measure a 0 to 5V signal that is applied to it. Care must be taken to prevent the voltage from going outside of the supply levels of the ELM327, or damage may occur. If it is not used, this pin should be tied to either VDD or VSS. J1850 Volts (pin 3) This output can be used to control a voltage supply for the J1850 Bus+ output. The pin will output a logic high level when a nominal 8V is required (for J1850 VPW), and will output a low level when 5V is needed (as for J1850 PWM applications). If this switching capability is not required for your application, this output can be left open-circuited. J1850 Bus+ (pin 4) This active high output is used to drive the J1850 Bus+ Line to an active level. Note that this signal does not have to be used for the Bus- Line (as was the case for the ELM320), since a separate J1850 Bus- drive output is provided on pin 14. Memory (pin 5) This input controls the default state of the memory option. If this pin is at a high level during power-up or reset, the memory function will be enabled by default. If it is at a low level, then the default will be to have it disabled. Memory can always be enabled or disabled with the AT M1 and AT M0 commands. Baud Rate (pin 6) This input controls the baud rate of the RS232 interface. If it is at a high level during power-up or reset, the baud rate will be set to 38400 (or the rate that has been set by PP 0C). If at a low level, the baud rate will be 9600. LFmode (pin 7) This input is used to select the default linefeed mode to be used after a power-up or system reset. If it is at a high level, then by default messages sent by the ELM327 will be terminated with both a carriage return and a linefeed character. If it is at a low level, lines will be terminated by a carriage return only. This behaviour can always be modified by issuing an AT L1 or AT L0 command (see the section on AT Commands). VSS (pins 8 and 19) Circuit common must be connected to these pins. XT1 (pin 9) and XT2 (pin 10) A 4.000 MHz oscillator crystal is connected between these two pins. Loading capacitors as required by the crystal (typically 27pF each) will also need to be connected between each of these pins and circuit common (Vss). Note that this device has not been configured for operation with an external oscillator – it expects a crystal to be connected to these pins. Use of an external clock source is not recommended. VPW In (pin 11) This is the active high input for the J1850 VPW data signal. When at rest (bus recessive) this pin should be at a low logic level. This input has Schmitt trigger waveshaping, so no special amplification is required. All rights reserved. Copyright 2005, 2006, and 2007 by Elm Electronics Inc. Every effort is made to verify the accuracy of information provided in this document, but no representation or warranty can be given and no liability assumed by Elm Electronics with respect to the accuracy and/or use of any products or information described in this document. Elm Electronics will not be responsible for any patent infringements arising from the use of these products or information, and does not authorize or warrant the use of any Elm Electronics product in life support devices and/or systems. Elm Electronics reserves the right to make changes to the device(s) described in this document in order to improve reliability, function, or design. ELM327DSC Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 2 of 51 ELM327 Pin Descriptions (continued) ISO In (pin 12) This is the active low input for the ISO 9141 and ISO 14230 data signal. It is derived from the K Line, and should be at a high logic level when at rest (bus recessive). No special amplification is required, as this input has Schmitt trigger waveshaping. PWM In (pin 13) This is the active low input for the J1850 PWM data signal. It should normally be at a high level when at rest (ie. bus recessive). This input has Schmitt trigger waveshaping, so no special amplification is required. J1850 Bus- (pin 14) This active high output is used to drive the J1850 Bus- Line to an active (dominant) level for J1850 PWM applications. If unused, this output can be left open-circuited. RTS (pin 15) This active low “Request To Send” input can be used to interrupt the OBD processing in order to send a new command. Normally high, the line is brought low for attention, and should remain so until the Busy line (pin 16) indicates that the ELM327 is no longer busy. This input has Schmitt trigger waveshaping. Busy (pin 16) This active high output shows the current state of the ELM327. If it is at a low level, the processor is ready to receive ASCII commands and characters, but if it is at a high level, commands are being processed. RS232Tx (pin 17) This is the RS232 data transmit output. The signal level is compatible with most interface ICs (output is normally high), and there is sufficient current drive to allow interfacing using only a PNP transistor, if desired. RS232Rx (pin 18) This is the RS232 receive data input. The signal level is compatible with most interface ICs (when at idle, the level is normally high), but can be used with other interfaces as well, since the input has Schmitt trigger waveshaping. VDD (pin 20) This pin is the positive supply pin, and should always be the most positive point in the circuit. Internal circuitry connected to this pin is used to provide power on reset of the microprocessor, so an external reset signal is not required. Refer to the Electrical Characteristics section for further information. ISO K (pin 21) and ISO L (pin 22) These are the active high output signals which are used to drive the ISO 9141 and ISO 14230 buses to an active (dominant) level. Many new vehicles do not require the L Line – if yours does not, you can simply leave pin 22 open-circuited. CAN Tx (pin 23) and CAN Rx (pin 24) These are the two CAN interface signals that must be connected to a CAN transeiver IC for proper operation. If you are connecting to an existing CAN system, the integrity of the entire system might be jeopardized if a proper interface is not used. See the Example Applications section for more information. RS232 Rx LED (pin 25), RS232 Tx LED (pin 26), OBD Rx LED (pin 27) and OBD Tx LED (pin 28) These four output pins are normally high, and are driven to low levels when the ELM327 is transmitting or receiving data. Current capability is suitable for directly driving most LEDs through current limiting resistors, or interfacing to other logic for status reporting. If unused, these pins should be left opencircuited. Ordering Information These integrated circuits are 28 pin devices, available in either a 300 mil wide plastic (‘skinny’) DIP format or in a 300 mil SOIC surface mount type of package. To order, add the appropriate suffix to the part number: 300 mil 28 pin Plastic DIP.............................. ELM327P 300 mil 28 pin SOIC.................................... ELM327SM ELM327DSC Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 3 of 51 ELM327 Absolute Maximum Ratings Storage Temperature....................... -65°C to +150°C Ambient Temperature with Power Applied.................................... -40°C to +85°C Voltage on VDD with respect to VSS............ 0 to +7.5V Voltage on any other pin with respect to VSS........................... -0.3V to (VDD + 0.3V) Note: Stresses beyond those listed here will likely damage the device. These values are given as a design guideline only. The ability to operate to these levels is neither inferred nor recommended. Electrical Characteristics All values are for operation at 25°C and a 5V supply, unless otherwise noted. For further information, refer to note 1 below. Characteristic Supply voltage, VDD VDD rate of rise Average supply current, IDD Input threshold voltage Schmitt trigger input thresholds rising falling Output low voltage Output high voltage Brown-out reset voltage A/D conversion time Notes: Minimum 4.5 0.05 Typical 5.0 Maximum Units 5.5 V V/ms Conditions see note 2 see note 3 all except Schmitt inputs see note 4 9 1.0 2.9 1.0 1.5 0.3 4.6 4.07 4.2 7 4.59 1.3 4.0 mA V V V V V V msec current (sink) = 10 mA current (source) = 10 mA see note 5 1. This integrated circuit is produced with one of Microchip Technology Inc.’s PIC18F2x8x family of devices as the core embedded microcontroller. For further device specifications, and possibly clarification of those given, please refer to the appropriate Microchip documentation (available at http://www.microchip.com/). 2. This spec must be met in order to ensure that a correct power on reset occurs. It is quite easily achieved using most common types of supplies, but may be violated if one uses a slowly varying supply voltage, as may be obtained through direct connection to solar cells or some charge pump circuits. 3. Device only. Does not include any load currents. 4. Pins 1, 11, 12, 13, 15 and 18 (only) have internal Schmitt trigger waveshaping circuitry. All other inputs use standard CMOS circuitry. 5. The typical width of the Busy output pulse while the ELM327 interprets the command, measures the voltage, scales it and then transmits the result of a mid-range measurement, with the RS232 rate at 38400 baud. ELM327DSC Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 4 of 51 ELM327 Overview The following describes how to use the ELM327 to obtain information from your vehicle. We begin by discussing just how to “talk” to the IC using a PC, then explain how to change options using ‘AT’ commands, and finally we show how to use the ELM327 to obtain trouble codes (and reset them). For the more advanced experimenters, there are also sections on how to use some of the programmable features of this product as well. Using the ELM327 is not as daunting as it first seems. Many users will never need to issue an ‘AT’ command, adjust timeouts, or change the headers. For most, all that is required is a PC or a PDA with a terminal program (such as HyperTerminal or ZTerm), and knowledge of one or two OBD commands, which we will provide in the following sections… Communicating with the ELM327 The ELM327 expects to communicate with the host through an RS232 serial connection. Modern computers do not usually provide a physical connection such as this, but there are several ways in which a ‘virtual serial port’ can be created. The most common devices are USB to RS232 adapters, but there are several others such as ethernet to RS232 devices, or Bluetooth to serial adapters. No matter how you physically connect to the ELM327, you will need a way to send and receive characters. To do this, the simplest method is to use one of the many ‘terminal’ programs that are available (HyperTerminal, ZTerm, etc.), to allow typing the characters directly from your keyboard. To use a terminal program, you will need to make several settings. First, ensure that your software is set to use the proper ‘COM’ port, and that you have chosen the proper data rate - this will be either 9600 baud (if pin 6=0V at power up), or 38400 baud (if PP 0C has not been changed). If you select the wrong “COM” port, you will not be able to send or receive any data. If you select the wrong data rate, the information that you send and receive will be all garbled, and unreadable by you or the ELM327. Don’t forget to also set your connection for 8 data bits, no parity bits, and 1 stop bit, and to also set it for the proper “line end” mode. All of the responses from the ELM327 are terminated with a single carriage return character and, optionally, a linefeed character (depending on your settings). Properly connected and powered, the ELM327 will energize the four LED outputs in sequence (as a lamp test) and will then send the message: ELM327 v1.2 > In addition to identifying the version of this IC, receiving this string is a good way to confirm that the ELM327DSC computer connections and terminal software settings are correct (however, at this point no communications have taken place with the vehicle, so the state of that connection is still unknown). The ‘>’ character that is shown on the second line is the ELM327’s prompt character. It indicates that the device is in the idle state, ready to receive characters on the RS232 port. Characters sent from the computer can either be intended for the ELM327’s internal use, or for reformatting and passing on to the vehicle. The ELM327 can quickly determine where the received characters are to be directed by analyzing the entire string once the complete message has been received. Commands for the ELM327’s internal use will always begin with the characters ‘AT’, while OBD commands for the vehicle are only allowed to contain the ASCII codes for hexadecimal digits (0 to 9 and A to F). Whether an ‘AT’ type internal command or a hex string for the OBD bus, all messages to the ELM327 must be terminated with a carriage return character (hex ‘0D’) before it will be acted upon. The one exception is when an incomplete string is sent and no carriage return appears. In this case, an internal timer will automatically abort the incomplete message after about 20 seconds, and the ELM327 will print a single question mark (‘?’) to show that the input was not understood (and was not acted upon). Messages that are not understood by the ELM327 (syntax errors) will always be signalled by a single question mark. These include incomplete messages, incorrect AT commands, or invalid hexadecimal digit strings, but are not an indication of whether or not the message was understood by the vehicle. One must keep in mind that the ELM327 is a protocol interpreter that makes no attempt to assess the OBD messages for validity – it only ensures that an even number of hex digits were received, combined into bytes, then sent out the OBD port, and it does not know if the 5 of 51 Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com ELM327 Communicating with the ELM327 (continued) message sent to the vehicle was in error. While processing OBD commands, the ELM327 will continually monitor for an RTS input, or an RS232 input. Either one will interrupt the IC, quickly returning control to the user, and possibly aborting any initiation, etc. that was in progress. If you desire to interrupt the ELM327, that’s fine, but for normal orderly data transfer, users should always wait for either the prompt character (‘>’ or hex 3E), or a low level on the Busy output before beginning to send the next command. Finally, it should be noted that the ELM327 is not case-sensitive, so ‘ATZ’ is equivalent to ‘atz’, and to ‘AtZ’. Also, it ignores space characters and all control characters (tab, linefeed, etc.) in the input, so they can be inserted anywhere to improve readability. Another feature is that sending only a single carriage return character will always repeat the last command (making it easier to request updates on dynamic data such as engine rpm). AT Commands Several parameters within the ELM327 can be adjusted in order to modify its behaviour. These do not normally have to be changed before attempting to talk to the vehicle, but occasionally the user may wish to customize these settings – for example by turning the character echo off, adjusting a timeout value, or changing the header bytes. In order to do this, internal ‘AT’ commands must be issued. Those familiar with PC modems will immediately recognize AT commands as a standard way in which modems are internally configured. The ELM327 uses essentially the same method, always watching the data sent by the PC, looking for messages that begin with the character ‘A’ followed by the character ‘T’. If found, the next characters will be interpreted as internal configuration or ‘AT’ commands, and will be executed upon receipt of a terminating carriage return character. The ELM327 will usually reply with the characters ‘OK’ on the successful completion of a command, so the user knows that it has been executed. Some of the following commands allow passing numbers as arguments in order to set the internal values. These will always be hexadecimal numbers which must generally be provided in pairs. The hexadecimal conversion chart in the OBD Commands section may prove useful if you wish to interpret the values. Also, one should be aware that for the on/off types of commands, the second character is the number 1 or 0, the universal terms for on and off. The following is a description of all of the AT commands that are recognized by the current version of the ELM327. Since there are many, a summary page is provided after this section. AL [ Allow Long messages ] The standard OBDII protocols restrict the number of data bytes in a message to seven, which the ELM327 normally does as well (for both send and receive). If AL is selected, the ELM327 will allow long sends (eight data bytes) and long receives (unlimited in number). The default is AL off (and NL selected). AR [ Automatically set the Receive address ] Responses from the vehicle will be acknowledged and displayed by the ELM327, if its internally stored receive address matches the address that the ELM327DSC message is being sent to. With the auto receive mode in effect, the value used for the receive address will be chosen based on the current header bytes, and will automatically be updated whenever the header bytes are changed. The value that is used for the receive address is determined based on the contents of the first header byte. If it shows that the message uses physical addressing, the third header byte of the header is used for the receive address, otherwise (for functional addressing) the second header byte, increased in value by 1, will be used. Auto Receive is turned on by default, and is not used by the J1939 formatting. Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 6 of 51 ELM327 AT Commands (continued) AT0, AT1 and AT2 [ Adaptive Timing control ] BI [ Bypass the Initialization sequence ] When receiving responses from a vehicle, the ELM327 has traditionally waited the time set by the AT ST hh setting for a response. To ensure that the IC would work with a wide variety of vehicles, the default value was set to a conservative (slow) value. Although it was adjustable, many people did not have the equipment or experience to determine a better value. The new Adaptive Timing feature will automatically set the timeout value for you, based on the actual response times that your vehicle is responding in. As conditions such as bus loading, etc. change, the algorithm learns from them, and makes appropriate adjustments. Note that it always uses your AT ST hh setting as a maximum setting, however. With this new Adaptive Timing, sampling rates are often doubled or tripled from those typically experienced with prior versions. There are three adaptive timing settings that are available for use. By default, Adaptive Timing option 1 (AT1) is selected, and is the recommended setting. AT0 is used to disable Adaptive timing (usually used when experimenting), while AT2 is a more agressive version of AT1 (the effect is more noticeable for very slow connections – you may not see much difference with faster OBD systems). The J1939 protocol does not support Adaptive Timing – responses for J1939 use fixed timeouts as set in the standard. BD [ perform an OBD Buffer Dump ] This command should be used with caution. It allows an OBD protocol to be made active without requiring any sort of initiation or handshaking to occur. The initiation process is normally used to validate the protocol, and without it, results may be difficult to predict. It should not be used for routine OBD use, and has only been provided to allow the construction of ECU simulators and training demonstrators. BRD hh [ try Baud Rate Divisor hh ] All messages sent and received by the ELM327 are stored temporarily in a set of twelve memory storage locations called the OBD Buffer. Occasionally, it may be of use to view the contents of this buffer, perhaps to see why an initiation failed, to see the header bytes in the last message, or just to learn more of the structure of OBD messages. You can ask at any time for the contents of this buffer to be ‘dumped’ (printed) – when you do, the ELM327 sends a length byte (representing the length of the message in the buffer) followed by the contents of all twelve OBD buffer locations. The length byte represents the actual number of bytes received, whether they fit into the OBD buffer or not. This may be useful when viewing long data streams (with AT AL), as the number accurately represents the number of bytes received, mod 256. Note that only the first twelve bytes received are stored in the buffer. ELM327DSC This command is used to change the RS232 baud rate divisor to the hex value provided by hh. The actual baud rate (in kbps) will be 4000 divided by this divisor. For example, a setting of 115.2kbps would require a divisor of 4000/115.2 or 35. In hexadecimal notation, 35 is written as 23, so the actual command that needs to be sent would be AT BRD 23. Since the ELM327 may be able to operate at much higher rates than some interfaces can support, the BRD command allows requested rates to be tested before they are committed to (with automatic fall-back to the previous baud rate if there are problems). In use, the command is sent to request a change in the baud rate, and the ELM327 responds with the familiar “OK”. After that, an internal timer begins waiting, to ensure that the controlling computer has sufficient time to change their baud rate to the new rate. The ELM327 then sends the poweron message at the new baud rate, and begins waiting while the controlling computer assesses what has been received. If the AT I message was received without errors, the controlling computer sends a carriage return character, and if received by the ELM327, the rate will be retained. If the controlling computer sees errors (or worse, nothing), it provides no response, and switches back to the initial baud rate. If the ELM327 times out after receiving no response, or has received something that does not appear to be a carriage return character, it will revert back to the former baud rate. A more detailed discussion of this entire process is provided in the ‘Using Higher RS232 Baud Rates’ section. Any new baud rate that is set in this manner is retained across calls to set defaults (AT D), and for warm starts (AT WS), but will not survive a hardware reset (a power off/on or a call to AT Z). If you are in the habit of calling AT Z in your code, we advise using AT WS instead. 7 of 51 Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com ELM327 AT Commands (continued) BRT hh [ set Baud Rate Timeout to hh ] be inserted for you. Similarly, when sending a data request with formatting off, you must provide all of the required data bytes exactly as they are to be sent – the ELM327 will not perform any formatting for you other than to add some trailing 'padding' bytes to ensure that the required eight data bytes are sent. This allows operation in systems that do not use PCI bytes as ISO 15765-4 does. Note that turning the display of headers on (with AT H1) will override some of the CAF1 formatting of the received data frames, so that the received bytes will appear much like in the CAF0 mode (ie. as received). It is only the printing of the received data that will be affected when both CAF1 and H1 modes are enabled, though; when sending data, the PCI byte will still be created for you and padding bytes will still be added. Auto Formatting on (CAF1) is the default setting for the ELM327. CF hhh [ set the CAN ID Filter to hhh ] This command allows the timeout used for the Baud Rate handshake (AT BRD) to be varied. The time delay is given by hh x 5.0 msec, where hh is a hexadecimal value. The default value for this setting is 0F, providing 75msec. Note that a value of 00 does not result in 0 msec - it provides the maximum time of 256 x 5.0 msec. CAF0 and CAF1 [ CAN Auto Formatting off or on ] These commands determine whether the ELM327 assists you with the formatting of the CAN data that is sent and received. With CAN Automatic Formatting enabled (CAF1), the IC will automatically generate formatting (PCI) bytes for you when sending, and will remove them when receiving. This means that you can continue to issue OBD requests (01 00, etc.) as usual, without regard to these extra bytes that the CAN diagnostics systems require. With formatting on, the trailing (unused) data bytes that are received in a frame will be removed as well, and only the relevant ones will be shown. Beginning with v1.2 of the ELM327, lines with invalid PCI bytes are now ignored, rather than showing them as ‘7 byte) messages Automatically Receive Adaptive Timing Off, Auto1*, Auto2 perform a Buffer Dump Bypass the Initialization sequence Describe the current Protocol Describe the Protocol by Number Headers Off*, or On Monitor All Monitor for Receiver = hh Monitor for Transmitter = hh Normal Length messages* Protocol Close Responses Off, or On Set Header Set Header Set Protocol to h and save it Set Protocol to Auto, h and save it Set the Receive address Set Timeout to hh x 4 msec Try Protocol h Try Protocol h with Auto search * = default setting ELM327DSC Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 17 of 51 ELM327 Reading the Battery Voltage Before proceding to the OBD Commands, we will show an example of how to use an AT Command. We will assume that you have built (or purchased) a circuit which is similar to that of Figure 9 in the Example Applications section. This circuit provides a connection to read the vehicle’s battery voltage, which many will find very useful. If you look in the AT Command list, you will see there is one command that is listed as RV [Read the input Voltage]. This is the command which you will need to use. First, be sure that the prompt character is shown (that is the ‘ >’ character), then simply enter ‘AT’ followed by RV, and press return (or enter): >at rv 12.6V > Note that we did not use upper case characters in this example, mostly out of laziness. The ELM327 will accept upper case (AT RV) as well as lower case (at rv) or any combination of these (At rV). It does not matter to the ELM327. Also note that we have shown a space character (‘ ’) between the ‘at’ and the ‘rv’. This is only to separate the commands and make them more readable. You do not have to add spaces, or if you wish, you can add many spaces – it does not affect the internal interpretation of the command. As shipped from the factory, the ELM327 voltage reading circuitry will typically be accurate to about 2%. For many, this is all that is needed. Some people may want to calibrate the circuitry for more accurate readings, however, so we have provided a special ‘Calibrate Voltage’ command for this. To change the internal calibration constants, you will need to know the actual battery voltage to more accuracy than the ELM327 shows. Many quality digital multimeters can do this, but you should verify the accuracy before making too many changes. Perhaps in this case, you have connected your multimeter, and find that it reads 12.47V, and you would like the ELM327 to read the same. Simply calibrate it to that voltage using the CV command: >at cv 1247 OK At this point, the internal calibration values have been changed, and the ELM327 knows that the ELM327DSC voltage at the input is actually 12.47V. You should not provide the decimal point in the CV value, as the IC knows that it should be between the second and the third digits. To verify that the changes have taken place, simply read the voltage again: >at rv 12.5V > The ELM327 always rounds off the measurement to one decimal place, so the 12.47V actually appears as 12.5V. Note that the second decimal place is always maintained internally for accuracy and use in the calculations, but it is never displayed. The ELM327 can be calibrated with any reference voltage that you have available, but note that the CV command always expects to receive four characters representing the voltage at the input. If you used a 9V battery for your reference, and it is actually 9.32V, then you must add a leading zero to that when calibrating the IC: >at cv 0932 OK > The other AT Commands are used in the same manner. Simply type the letters A and T, follow that with the command you want to send, then any arguments that are required for that command, and press return (or enter, depending on your keyboard). You can place space characters as often as you wish if it improves the readability for you, as they are ignored by the ELM327. Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 18 of 51 ELM327 OBD Commands If the bytes that you send to the ELM327 do not begin with the letters ‘A’ and ‘T’, they are assumed to be OBD commands for the vehicle. Each pair of ASCII bytes will be tested to ensure that they are valid hexadecimal digits, and will then be combined into single data bytes for transmitting to the vehicle. OBD commands are actually sent to the vehicle embedded in a data packet. Most standards require that three header bytes and an error checksum byte be included with every OBD message, and the ELM327 adds these extra bytes to your command bytes automatically. The initial (default) values for these extra bytes are usually appropriate for most requests, but if you wish to change them, there is a method to do so (see the “Setting the Headers” section). Most OBD commands are only one or two bytes in length, but some can be longer. The ELM327 will limit the number of bytes that can be sent to the maximum number allowed by the standards (seven bytes or 14 hexadecimal digits). Attempts to send more bytes, or an odd number of hex digits, will result in a syntax error – the entire command is then ignored and a single question mark printed. Hexadecimal digits are used for all of the data exchange with the ELM327 because it is the data format used most often in the OBD standards. Most mode request listings use haxadecimal notation, and it is the format most frequently used when results are shown. With a little practice, it should not be very difficult to deal in hex numbers, but some people may want to use a table such as Figure 1, or keep a calculator nearby. All users will be required to manipulate the results in some way, though – combining bytes and dividing by 4 to obtain rpm, dividing by 2 to obtain degrees of advance, etc., and may find a software front-end to be of help. As an example of sending a command to the vehicle, assume that A6 (or decimal 166) is the command that is required to be sent. In this case, the user would type the letter A, then the number 6, then would press the return key. These three characters would be sent to the ELM327 by way of the RS232 port. The ELM327 would store the characters as they are received, and when the third character (the carriage return) was received, would begin to assess the other two. It would see that they are both valid hex digits, and would convert them to a one byte value (the decimal value is 166). The header bytes and a checksum byte would then be added, and a total of ELM327DSC five bytes would typically be sent to the vehicle. Note that the carriage return character is only a signal to the ELM327, and is not sent on to the vehicle. After sending the command, the ELM327 listens on the OBD bus for messages, looking for ones that are directed to it. If a message address matches, those received bytes will be sent on the RS232 port to the user, while messages received that do not have matching addresses will be ignored (but are often still available for viewing with the AT BD command). The ELM327 will continue to wait for messages addressed to it until there are none found in the time that was set by the AT ST command. As long as messages are received, the ELM327 will continue to reset this timer. Note that the IC will always respond with something, even if it is to say “NO DATA” (meaning that there were no messages found that were addressed to it). Hexadecimal Number 0 1 2 3 4 5 6 7 8 9 A B C D E F Decimal Equivalent 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Figure 1. Hex to Decimal Conversion Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 19 of 51 ELM327 Talking to the Vehicle The OBD standards specify that each request that is sent to the vehicle must adhere to a set format. The first byte (known as the ‘mode’) always describes the type of data being requested, while the second, third, etc. bytes specify the actual information required (given by a ‘parameter identification’ or PID number). These modes and PIDs are described in detail in documents such as the SAE J1979, or ISO 15031-5 standards, and may also be expanded on by the vehicle manufacturers. Normally, one is only concerned with the nine diagnostic test modes described by J1979 (although there is provision for more). All of these modes are not required to be supported by every vehicle, and are often not. These are the nine modes: 01 02 03 04 05 06 07 08 09 - show current data - show freeze frame data - show diagnostic trouble codes - clear trouble codes and stored values - test results, oxygen sensors - test results, non-continuously monitored - show ‘pending’ trouble codes - special control mode - request vehicle information (1=supported, 0=not). Although this information is not very useful for the casual user, it does prove that the connection is working. Another example requests the current engine coolant temperature (ECT). This is PID 05 in mode 01, and can be requested as follows: >01 05 The response will be of the form: 41 05 7B The 41 05 shows that this is a response to a mode 1 request for PID 05, while the 7B is the desired data. Converting the hexadecimal 7B to decimal, one gets 7 x 16 + 11 = 123. This represents the current temperature in degrees Celsius, but with the zero offset to allow for subzero temperatures. To convert to the actual coolant temperature, you need to subtract 40 from the value obtained. In this case, then, the coolant temperature is 123 - 40 or 83 °C. A final example shows a request for the engine rpm. This is PID 0C of mode 01, so at the prompt type: >01 0C A typical response would be: 41 0C 1A F8 The returned value (1A F8) is actually a two byte value that must be converted to a decimal value to be useful. Converting it, we get a value of 6904, which seems to be a very high value for engine rpm. That is because rpm is sent in increments of 1/4 rpm! To convert to the actual engine speed, we need to divide the 6904 by 4. In this case, then, the rpm is 1726, which is much more reasonable. Hopefully this has shown how typical requests proceed. It has not been meant to be a definitive guide on modes and PIDs – this information can be obtained from the manufacturer of your vehicle, the SAE (http://www.sae.org/), from ISO (http://www.iso.org/), or from various other sources on the web. Within each mode, PID 00 is normally reserved to show which PIDs are supported by that mode. Mode 01, PID 00 must be supported by all vehicles, and can be accessed as follows… Ensure that your ELM327 interface is properly connected to the vehicle, and powered. Most vehicles will not respond without the ignition key in the ON position, so turn the ignition to on, but do not start the engine. At the prompt, issue the mode 01 PID 00 command: >01 00 The first time the bus is accessed, you may see a bus initialization message, and then the response, which might typically be as follows: 41 00 BE 1F B8 10 The 41 signifies a response from a mode 01 request (01+40=41), while the second number (00) simply repeats the PID number requested. A mode 02, request is answered with a 42, a mode 03 with a 43, etc. The next four bytes (BE, 1F, B8, and 10) represent the requested data, in this case a bit pattern showing the PIDs supported by this mode ELM327DSC Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 20 of 51 ELM327 Interpreting Trouble Codes Likely the most common use that the ELM327 will be put to is in obtaining the current Diagnostic Trouble Codes (or DTCs). Minimally, this requires that a mode 03 request be made, but first one should determine how many trouble codes are presently stored. This is done with a mode 01 PID 01 request as follows: >01 01 To which a typical response might be: 41 01 81 07 65 04 The 41 01 signifies a response to the request, and the next data byte (81) is the number of current trouble codes. Clearly there would not be 81 (hex) or 129 (decimal) trouble codes present if the vehicle is at all operational. In fact, this byte does double duty, with the most significant bit being used to indicate that the malfunction indicator lamp (MIL, or ‘Check Engine Light’) has been turned on by one of this module’s codes (if there are more than one), while the other 7 bits of this byte provide the actual number of stored trouble codes. In order to calculate the number of stored codes when the MIL is on, simply subtract 128 (or 80 hex) from the number. The above response then indicates that there is one stored code, and it was the one that set the Check Engine Lamp or MIL on. The remaining bytes in the response provide information on the types of tests supported by that particular module (see the SAE document J1979 for further information). In this instance, there was only one line to the response, but if there were codes stored in other modules, they each could have provided a line of response. To determine which module is reporting the trouble code, one would have to turn the headers on (AT H1) and then look at the third byte of the three byte header for the address of the module that sent the information. Having determined the number of codes stored, the next step is to request the actual trouble codes with a mode 03 request (there is no PID needed): >03 A response to this could be: 43 01 33 00 00 00 00 The ‘43’ in the above response simply indicates that this is a response to a mode 03 request. The other ELM327DSC 6 bytes in the response have to be read in pairs to show the trouble codes (the above would be interpreted as 0133, 0000, and 0000). Note that the response has been padded with 00’s as required by the SAE standard for this mode – the 0000’s do not represent actual trouble codes. As was the case when requesting the number of stored codes, the most significant bits of each trouble code also contain additional information. It is easiest to use the following table to interpret the extra bits in the first digit as follows: If the first hex digit received is this, Replace it with these two characters 0 1 2 3 4 5 6 7 8 9 A B C D E F P0 P1 P2 P3 C0 C1 C2 C3 B0 B1 B2 B3 U0 U1 U2 U3 Powertrain Codes - SAE defined “ “ “ “ - manufacturer defined “ - SAE defined “ - jointly defined Chassis Codes - SAE defined “ “ “ “ - manufacturer defined “ - manufacturer defined “ - reserved for future Body Codes - SAE defined “ “ “ “ - manufacturer defined “ - manufacturer defined “ - reserved for future Network Codes - SAE defined “ “ “ “ - manufacturer defined “ - manufacturer defined “ - reserved for future Taking the example trouble code (0133), the first digit (0) would then be replaced with P0, and the 0133 reported would become P0133 (which is the code for an ‘oxygen sensor circuit slow response’). Note that the ISO 15765-4 (CAN) protocol is very similar, but it adds an extra data byte (in the second position), showing how many data items (DTCs) are to follow. To provide a few further examples, if the received code was D016, you would replace the D with U1, and the resulting trouble code would be U1016. Similarly, 1131 received would actually be for the code P1131. Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 21 of 51 ELM327 Resetting Trouble Codes The ELM327 is quite capable of resetting diagnostic trouble codes, as this only requires issuing a mode 04 command. The consequences should always be considered before sending it, however, as more than the MIL (or ‘Check Engine Light’) will be reset. In fact, issuing a mode 04 will: - reset the number of trouble codes - erase any diagnostic trouble codes - erase any stored freeze frame data - erase the DTC that initiated the freeze frame - erase all oxygen sensor test data - erase mode 06 and 07 information Clearing of all of this data is not unique to the ELM327 – it occurs whenever any scan tool is used to reset the codes. The biggest problem with losing this data is that your vehicle may run poorly for a short time, while it performs a recalibration. To avoid inadvertently erasing stored information, the SAE specifies that scan tools must verify that a mode 04 is intended (“Are you sure?”) before actually sending it to the vehicle, as all trouble code information is immediately lost when the mode is sent. Remember that the ELM327 does not monitor the content of the messages, so it will not know to ask for confirmation of the mode request – this would have to be the duty of a software interface if one is written. As stated, to actually erase diagnostic trouble codes, one need only issue a mode 04 command. A response of 44 from the vehicle indicates that the mode request has been carried out, the information erased, and the MIL turned off. Some vehicles may require a special condition to occur (eg. the ignition on but the engine not running) before they will respond to a mode 04 command. That is all there is to clearing trouble codes. Once again, do not accidentally send the 04 code! Quick Guide for Reading Trouble Codes If you do not use your ELM327 for some time, this entire data sheet may seem like quite a bit to review when your ‘Check Engine’ light eventually comes on, and you just want to know why. We offer this section as a quick guide to the basics that you will need. To get started, connect the ELM327 circuit to your PC or PDA and communicate with it using a terminal program such as HyperTerminal, ZTerm, ptelnet, or a similar program. It should normally be set to either 9600 or 38400 baud, with 8 data bits, and no parity or handshaking. The chart at the right provides a quick procedure on what to do next: Ignition Key to ON, but vehicle not running >0101 to see how many codes (2nd digit of the 3rd byte) >03 to see the codes (ignore the first byte and read the others in pairs) FIX THE VEHICLE! >04 to reset the codes ELM327DSC Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 22 of 51 ELM327 Bus Initiation Both the ISO 9141-2 and ISO 14230-4 (KWP2000) standards require that the vehicle’s OBD bus be initialized before any communications can take place. The ISO 9141 standard allows for only a slow (2 to 3 second) initiation process, while ISO 14230 allows for both a slow method, and a faster alternative. The ELM327 will perform this bus initiation for you, but not until your request needs to be sent. If the bus initiation occurs during the automatic search process, you will not see any status reporting, but if you have the Auto option off (and are set to protocols 3, 4, or 5), then you will see a message similar to this: BUS INIT: ... The three dots appear only as the slow initiation process is carried out – a fast initiation does not show them. This will be followed by either the expression ‘OK’ to say it was successful, or else an error message to indicate that there was a problem. (The most common error encountered is in forgetting to turn the vehicle’s key to ‘ON’ before attempting to talk to the vehicle.) Once the bus has been initiated, communications must take place regularly (typically at least once every five seconds), or the bus will revert to a low-power ‘sleep’ mode. If you are not sending data requests often enough, the ELM327 will generate requests for you to ensure that the bus stays ‘awake’. You will never see the responses to these, but you may see the transmit LED flash periodically when these are being sent. By default, the ELM327 ensures that these ‘wakeup’ or ‘idle’ messages are sent every 3 seconds, but this is adjustable with the AT SW command. The contents of the wakeup message are also user programmable with the AT WM command, if you should wish to change them. Users generally do not have to change either of the above though, as the default settings work well with almost all systems. Wakeup Messages After an ISO 9141 or ISO 14230 connection has been established, there needs to be periodic data transfers in order to maintain that connection, and prevent it from ‘going to sleep.’ If normal requests and responses are being sent, that is usually sufficient, but the ELM327 occasionally has to create its own messages to prevent the connecton from timing out. We term these periodic messages that are created the ‘Wakeup Messages’, as they keep the connection alive, and prevent the circuitry from going back to an idle or sleep mode. (Some texts refer to these messages simply as ‘idle messages.’) The ELM327 automatically creates and sends these for you if there appears to be no other activity – there is nothing that you need do to ensure that they occur. To see these, once a connection is made, simply monitor the OBD transmit LED – you will see the periodic ‘blips’ created when the ELM327 sends one. If you are curious as to the actual contents of the messages, you can then perform a Buffer Dump to see the bytes. Note that the ELM327 never obtains or prints a response to any of the wakeup messages. The standards state that if there is no activity at least every five seconds, the data connection may close. To ensure that this does not happen, and to ELM327DSC provide some margin, the ELM327 will send a wakeup message after three seconds of inactivity. This time interval is fully programmable, should you prefer a different setting (see the AT SW command). As with the ELM323, the ELM327 allows users to change the actual wakeup message that is sent. To do so, simply send the ELM327 a Wakeup Message command, telling it what you wish the message to be changed to. For example, if you would like to send the data bytes 44 55 with the header bytes set to 11 22 33, simply send the command: >AT WM 11 22 33 44 55 From that point forward, every wakeup message that the ELM327 sends will be as shown above. You can change these as often as you want, the only restriction being that every time you do, you must provide the complete message – the header bytes and the data bytes (the current version of the ELM327 only allows for messages of one to six bytes in length). You should not provide a checksum byte, as it will be automatically added for you. Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 23 of 51 ELM327 Selecting Protocols The ELM327 supports several different OBD protocols (see Figure 2 below). As a user, you may never have to choose which one it should use (since the factory settings cause an automatic search to be performed for you), but while experimenting, you may want to specify which protocol is used. For example, if you know that your vehicle uses the SAE J1850 VPW protocol, you may want the ELM327 to only try that protocol, and no others. If that is what you want, simply determine the protocol number (from the chart below), then use the ‘Set Protocol’ AT Command as follows: >AT SP 2 OK From this point on, the default protocol (used after every power-up or AT D command) will be protocol 2 (or whichever one that you have chosen). Verify this by asking the ELM327 to describe the current protocol: >AT DP SAE J1850 VPW Now what happens if your friend has a vehicle that uses ISO 9141-2? How do you use the ELM327 interface for that vehicle? There are a few choices... One possibility is to change your protocol selection to allow for the automatic searching for another protocol, on failure of the current one. This is done by putting an ‘A’ with the protocol number, as follows: >AT SP A2 OK >AT DP AUTO, SAE J1850 VPW Now, the ELM327 will begin by trying protocol 2, but will then automatically begin searching for another protocol should an attempt to connect with protocol 2 fail (as would happen when you try to connect to the friend’s vehicle). If you have the memory function enabled when you connect to your friend’s vehicle, their protocol will then be stored in memory as the new default protocol, but that is only a minor inconvenience as the next time you connect to your vehicle, it will try the friends protocol, fail, and search until it finds yours. Your protocol will then be resaved as the new default. Perhaps you have disabled the memory function (set pin 5 to 0V), and have used AT SP 2 to customize the IC for your vehicle only, and you don’t want it to search for others? (In effect, you have turned your ELM327 into an ELM322 type interface.) In this case, ELM327DSC you might want to use the ‘Try Protocol’ command for your friend’s vehicle, rather than setting it to something permanently. You can either say: >AT TP 3 OK if you already know that your friend’s vehicle uses protocol 3, or else you can say: >AT TP 0 OK which automatically tries all of the protocols (as allowed by PP 07) looking for one that responds. In general, users find that enabling the memory (setting pin 5 to 5V) and choosing the ‘Auto’ option (the easiest way is to say AT SP 0) works very well. After the initial search, the protocol used by your vehicle becomes the new default mode (so it is tried first every time), and if the interface is used on another vehicle, there is only a minor delay while it performs an automatic search. Protocol 0 1 2 3 4 5 6 7 8 9 A B C Description Automatic SAE J1850 PWM (41.6 Kbaud) SAE J1850 VPW (10.4 Kbaud) ISO 9141-2 (5 baud init) ISO 14230-4 KWP (5 baud init) ISO 14230-4 KWP (fast init) ISO 15765-4 CAN (11 bit ID, 500 Kbaud) ISO 15765-4 CAN (29 bit ID, 500 Kbaud) ISO 15765-4 CAN (11 bit ID, 250 Kbaud) ISO 15765-4 CAN (29 bit ID, 250 Kbaud) SAE J1939 CAN (29 bit ID, 250* Kbaud) User1 CAN (11* bit ID, 125* Kbaud) User2 CAN (11* bit ID, 50* Kbaud) *user adjustable Figure 2. ELM327 Protocol Numbers Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 24 of 51 ELM327 OBD Message Formats To this point we have only discussed the contents (data portion) of an OBD message, and made only passing mention of other parts such as headers and checksums, which all messages use to some extent. On Board Diagnostics systems are designed to be very flexible, providing a means for several devices to communicate with one another. In order for messages to be sent between devices, it is necessary to add information describing the type of information being sent, the device that it is being sent to, and perhaps which device is doing the sending. Additionally, the importance of the message becomes a concern as well – crankshaft position information is certainly of considerably more importance to a running engine than a request for the number of trouble codes stored. So to convey importance, messages are also assigned a priority. The information describing the priority, the intended recipient, and the transmitter are usually needed by the recipient even before they know the type of request that the message contains. To ensure that this information is obtained first, OBD systems transmit it at the start (or head) of the message. Since these bytes are at the head, they are usually referred to as header bytes. Figure 3 below shows a typical OBD message structure that is used by the SAE J1850, ISO 9141-2, and ISO 14230-4 standards. It uses 3 header bytes as shown, to provide details concerning the priority, the receiver, and the transmitter. Note that many texts refer to the receiver as the “Target Address” (TA), and the transmitter as the “Source Address” (SA). Another concern when sending any message is that errors might occur, and the received data may be falsely interpreted. To detect errors, the various protocols all provide some form of check on the received data, often as simple as a sum calculation (a ‘running total’ is maintained by the receiver as a message is being processed). This is compared to the ‘running total’ sent by the transmitter, and if they do not agree, an error has occured. The total is generally referred to as a ‘checksum’ or a ‘CRC byte’ and is usually sent at the end of a message. If an error is detected, the different protocols provide various ways of handling it. The OBD data bytes are thus normally encapsulated within a message, with ‘header’ bytes at the beginning, and a ‘checksum’ at the end. The J1850, ISO 9141-2, and ISO 14230-4 protocols all use essentially the same structure, with three header bytes, a maximum of seven data bytes and one checksum byte, as shown in Figure 3 below. The ISO 15765-4 (CAN) protocol uses a very similar structure, the main difference really only relating to the structure of the header. CAN header bytes are not referred to as that – they are called ‘ID bits’ instead. The initial CAN standard defined the ID bits as being 11 in number, and the more recent CAN TA priority receiver SA transmitter 3 header bytes up to 7 data bytes Figure 3. An OBD Message checksum ID bits (11 or 29) PCI 7 data bytes checksum Figure 4. A CAN OBD Message ELM327DSC Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 25 of 51 ELM327 OBD Message Formats (continued) standard now allows 29 in total. The ELM327 does not normally show any of these extra bytes unless you turn that feature on with the Headers On command (AT H1). Issuing that allows you to see the header bytes and the checksum byte (for the J1850, ISO 9141 and ISO 14230 protocols). For the CAN protocols, you will see the ID bits, and other items which are normally hidden such as the PCI byte for ISO 15765, or the data length codes (if they are enabled with PP 29). Note that the ELM327 is not able to display the checksum information for CAN systems, or the IFR bytes for J1850 systems. It is not necessary to ever have to set these header byes, or to perform a checksum calculation, as the ELM327 will always do this for you. The header bytes are adjustable however, should you wish to experiment by using advanced techniques such as physical addressing. The next section provides a discussion on how to do this… ELM327DSC Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 26 of 51 ELM327 Setting the Headers The emissions related diagnostic trouble codes that most people are familiar with are described in the SAE J1979 standard (ISO15031-5). They represent only a portion of the data that a vehicle may have available – much more can be obtained if you are able to direct the requests elsewhere. Accessing most OBDII diagnostics information requires that requests be made to what is known as a a ‘functional address.’ Any processor that supports the function will respond to the request (and theoretically, many different processors can respond to a single functional request). In addition, every processor (or ECU) will also respond to what is known as their physical address. It is the physical address that uniquely identifies each module in a vehicle, and permits you to direct more specific queries to only one particular module. To retrieve information beyond that of the OBDII requirements then, it will be necessary to direct your requests to either a different functional address, or to an ECU’s physical address. This is done by changing the data bytes in the message header. As an example of functional addressing, let us assume that you want to request that the processor responsible for Engine Coolant provide the current Fluid Temperature. You do not know its address, so you consult the SAE J2178 standard and determine that Engine Coolant is functional address 48. SAE standard J2178 also tells you that for your J1850 VPW vehicle, a priority byte of A8 is appropriate. Finally, knowing that a scan tool is normally address F1, you have enough information to specify the three header bytes (A8 48 and F1). To tell the ELM327 to use these new header bytes, all you need is the Set Header command: >AT SH A8 48 F1 OK The three header bytes assigned in this manner will stay in effect until changed by the next AT SH command, a reset, or an AT D. Having set the header bytes, you now need only send the secondary ID for fluid temperature (10) at the prompt. If the display of headers is turned off, the conversation could look like this: >10 10 2E The first byte in the response echos the request, as usual, while the data that we requested is the 2E ELM327DSC byte. You may find that some requests, being of a low priority, may not be answered immediately, possibly causing a “NO DATA” result. In these cases, you may want to adjust the timeout value, perhaps first trying the maximum (ie use AT ST FF). Many vehicles will simply not support these extra addressing modes. The other, and more common method of obtaining information is by physical addressing, in which you direct your request to a specific device, not to a functional group. To do this, you again need to construct a set of header bytes that direct your query to the physical address of the processor, or ECU. If you do not know the address, recall that the sender of information is usually shown in the third byte of the header. By monitoring your system for a time with the headers turned on (AT H1), you can quickly learn the main addresses of the senders. The SAE document J2178 assigns address ranges to these devices if you are unsure of which might be most appropriate. When you know the address that you wish to ‘speak to,’ simply use it for the second byte in the header (assume an address of 10 for this example). Combine that with your knowledge of SAE J2178 to choose a priority/type byte (assume a value of E4 for this example, as if the vehicle is J1850 PWM). Finally, you need to identify yourself to the target, so that responses can be returned to you. As is customary for diagnostic tools, we’ll use an address of F1. As before, these three bytes are then assigned to the header with the set header command: >AT SH E4 10 F1 OK From this point on, all messages that the ELM327 sends will use these three bytes for the header. All that needs to be done now is to request data from the vehicle. For physical addressing, this is often done using mode 22: >22 11 6B 62 11 6B 00 00 The response to this command is of the same format to those seen for ‘standard’ OBD requests. The request has been repeated (with 40 added to the mode value in order to show that this is a response), and this is followed by the actual data (0000 in this case). The PIDs used with mode 22 are usually proprietary to each manufacturer and are generally not published widely, so you may have difficulty in determining the ones to use with your vehicle. Elm 27 of 51 Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com ELM327 Setting the Headers (Cont’d) >AT CP vv >AT SH xx yy zz vv 5 bits only xx yy zz >AT SH xx yy zz xx vv xx yy 29 bit ID Figure 5. Setting a 29 bit CAN ID zz yy zz 11 bit ID Figure 6. Setting an 11 bit CAN ID Electronics does not maintain lists of this information, and cannot provide any further details for you. Mode 22 and others are described in more detail in SAE document J2190, “Enhanced E/E Diagnostic Test Modes”. The ISO14230-4 standard defines its’ header bytes a little differently. Advanced experimenters will be aware that for ISO 14230-4, the first header byte must always include the length of the data field, which varies from message to message. From that, one might assume that the you would need to redefine the header for every message that is to be sent – not so! The ELM327 always determines the number of bytes that you are sending, and inserts that length for you, in the proper place for the header that you are using. If you are using the standard ISO 14230-4 header, the length will be put into the first header byte, and you need only provide the two (most significant) bits of this byte when defining the header. What you place in the rest of the byte will be ignored by the ELM327 unless you set them all to 0’s. If they are all 0, it is assumed that you are experimenting with KWP four byte headers, and the ELM327 then creates the fourth header byte for you. Again, you do not need to provide any length to be put into this byte – it is done for you. Addressing within the CAN (ISO 15765-4) protocols is quite similar in many ways. First, consider the 29 bit standard. The ELM327 splits the 29 bits into a CAN Priority byte and the three header bytes that we are now familiar with. Figure 5 shows how these are combined for use by the ELM327. The CAN standard states that for diagnostics, the priority byte (‘vv’ in the diagram) will always be 1B (this ELM327DSC is the default value used by the ELM327). Since it is rarely changed, it is assigned separately from the other header bytes, using the CP command. Changing of this value is usually only required if experimenting with J1939 systems. The next byte (‘xx’) describes the type of message that this is, and is set to hex DB for functional addressing, and to DA if using physical addressing. The next two bytes are as defined previously for the other standards – ‘yy’ is the receiver (or Target Address), and ‘zz’ is the transmitter (or Source Address). For the functional diagnostic requests, the receiver is always 33, and the transmitter is F1, which is very similar to ISO 14230-4. Those that are familiar with the SAE J1939 standard will likely find this header structure to be very familiar (J1939 is a CAN standard for use by ‘heavyduty vehicles’ such as trucks and buses). We use slightly different terminology, but there is a direct parallel between the bytes used by J1939 for the headers and the grouping of the bytes in the ELM327. Refer to page 36 for a discussion of the J1939 support that is provided by the ELM327. The final header format to discuss is that used in 11 bit CAN systems. They also use a priority/address structure, but shorten it into roughly three nibbles rather than three bytes. The ELM327 uses the same commands to set these values as for other headers, except that it only uses the 11 least significant (‘rightmost’) bits of the provided header bytes, and ignores the others (as shown in Figure 6). It quickly becomes inconvenient to have to enter six digits when only three are required, so there is a special ‘short’ version of the 28 of 51 Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com ELM327 Setting the Headers (Cont’d) AT SH command that uses only three hex digits. It actually operates by simply adding the leading zeroes for you. The 11 bit CAN standard typically makes functional requests (ID/header = 7DF), but receives physical replies (7En). With headers turned on, it is a simple matter to learn the address of the module that is replying, then use that information to make physical requests if desired. For example, if the headers are on, and you send 01 00, you might see: >01 00 7E8 06 41 00 BE 3F B8 13 00 The 7E8 shows that ECU#1 was the one responding. In order to talk directly to that ECU, all you need do is to set the header to the appropriate value (it is 7E0 to talk to the 7E8 device – see ISO 15765-4 for more information). From that point on, you can ‘talk’ directly to the ECU using its physical address, as shown here: >AT SH 7E0 OK >01 05 7E8 03 41 05 46 00 00 00 00 Hopefully this has helped to get you started. As we often tell those that write – if you are planning to do some serious experimenting with OBD, you should buy the relevant standards. ELM327DSC Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 29 of 51 ELM327 Monitoring the Bus Some vehicles use the OBD bus for information transfer during normal vehicle operation, passing a great deal of information over it. A lot can be learned if you have the good fortune to connect to one of these vehicles, and are able to decipher the contents of the messages. To see how your vehicle uses the OBD bus, you can enter the ELM327’s ‘Monitor All’ mode, by sending the command AT MA from your terminal program. This will cause the IC to display any information that it sees on the OBD bus, regardless of transmitter or receiver addresses (it will show all). Note that the periodic ‘wakeup’ messages are not sent while in this mode, so if you have an ISO 9141 or ISO 14230 bus that had been initialized previously, it may ‘go to sleep’ while monitoring. The monitoring mode can be stopped by putting a logic low level on the RTS pin, or by sending a single RS232 character to the ELM327. Any convenient character can be used to interrupt the IC – there are no restrictions on whether it is printable, etc. Note that the character you send will be discarded, and will have no effect on any subsequent commands. The time it takes to respond to this interrupting character will depend on what the ELM327 is doing when the character is received. The IC will always finish a task that is in progress (printing a line, for example) before returning to wait for input, so you should always wait for the prompt character (‘>’), or the Busy line to go low, before beginning to send a command. One unexpected result may occur if you have the automatic protocol search feature enabled, and you tell the ELM327 to begin monitoring. If the bus is quiet, the ELM327 will begin searching for an active protocol, which may not be what you were expecting. Be aware also that the ISO 9141 and ISO 14230 protocols look identical when monitoring, so the ELM327 will likely stop searching at ISO 9141, even if the actual protocol is ISO 14230. With the Automatic searching enabled, this should correct itself, however, when the first OBD request is made. If the ‘Monitor All’ command provides too much information (it certainly does for most CAN systems!), then you can restrict the range of data that is to be displayed. Perhaps you only want to see messages that are being transmitted by the ECU with address 10. To do that, simply type: >AT MT 10 and all messages that contain 10 in the third byte of ELM327DSC the header will be displayed. Using this command with 11 bit CAN systems can be a little confusing at first. Recall the way in which all header bytes are stored within the ELM327. An 11 bit CAN ID is actually stored as the least significant 11 bits in the 3 byte ‘header storage’ location. It will be stored with 3 bits in the receiver’s address location, and the remaining 8 bits in the transmitter’s address location. For this example, we have requested that all messages created by transmitter ‘10’ be printed, so all 11 bit CAN IDs that end in 10 will be displayed (ie all that look like ‘x10’). The other monitoring command that is very useful is the AT MR command, which looks for specific addresses in the middle byte of the header. Using this command, you can look for all messages being sent to a particular address. For example, to use it to look for messages being sent to the ECU with address 10, simply send: >AT MR 10 and all messages that contain 10 in the second byte of the header will be displayed. Using this command with the 11 bit CAN systems will again need further explanation. It may be helpful to first picture the hex number ‘10’ in the above example as the binary number ‘0001 0000’. Recall from above that 11 bit CAN IDs are actually stored as the least significant 11 bits in the 3 byte ‘header storage’ locations, and only 3 bits are actually stored in the middle byte (receiver’s address) position. When comparing the received CAN ID to the address you provide with the MR command then, only the rightmost 3 bits of your MR address are considered and the other 5 bits are ignored. In this example, the AT MR 10 effectively becomes AT MR 0 for 11 bit CAN systems, and all messages that begin with ‘0’ as the first digit will actually be displayed. In order to use the AT MR command with CAN 11 bit identifiers, you should always try to use the format ‘AT MR 0x’, where ‘x’ is the digit that you want the identifiers to begin with. To look for all 2xx’s, use the command ‘AT MR 02’, and to see all of the 7xx’s, you should use ‘AT MR 07’. Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 30 of 51 ELM327 CAN Messages and Filtering The ELM327 monitoring commands (AT MA, MR and MT) usually work very well with the ‘slower’ protocols – J1850, ISO 9141 and ISO 14230. The CAN systems are a different story, however, as they often have an order of magnitude more information passing over them. The relatively small 256 byte buffer that the ELM327 uses for sending can quickly fill up when data is arriving at 500 Kbps and leaving at 38.4 Kbps, or even 115.2 Kbps. To help reduce the amount of information seen by the ELM327, the internal CAN module has a ‘filter’ that can be used to pass only messages with specific ID bits. A range of values can be passed when the filter is used with what is called a ‘mask’ to say which bits are relevant. As an example, consider an application where you are trying to monitor for 29 bit CAN diagnostic messages, exactly like the ELM327 does. By definition, these messages will be sent to the scan tool at address F1. From ISO 15765-4, you know then that the ID portion of the reply must be of the form: 18 DA F1 xx where xx is the address of the module that is sending the message. To use the filter, then, enter what you have into it, putting anything in for the unknown portion (you will see why in a moment). The command to set the CAN filter is AT CF… >AT CF 18 DA F1 00 How, you ask, do you tell the ELM327 to ignore those last two 0’s? You do that with the mask. The mask is a set of bits that tell the ELM327 which bits in the filter are relevant. If the mask bit is 1, that filter bit is relevant, and is required to match. If it is 0, then that filter bit will be ignored. All bits in the above message are relevant, except those of the last two digits. To set the mask for this example then, you would need to use the CAN Mask command, as follows: >AT CM 1F FF FF 00 If desired, you can convert the hexadecimal to binary to see what has been done. The 11 bit CAN IDs are treated in the same manner. Recall that they are stored internally in the right-most 11 bits of the locations used for 29 bit CAN, which must be considered when creating a filter or mask. As an example, assume that we wish to display all messages that have a 6 as the first digit of the 11 ELM327DSC bit ID. We need to set a filter to look for 6 in that digit: >AT CF 00 00 06 00 The 11 bit ID is stored in the last three locations, so the 6 would appear where it is shown. Now, to make that digit relevant, we create the mask: >AT CM 00 00 0F 00 The system only uses the 11 right-most bits in this case, so we can be lazy and enter the F as shown (the first bit of the F will be ignored, and it will be treated as if we had entered a 7). Clearly, this can be quite cumbersome if using 11 bit CAN systems routinely. To help with that, the ELM327 offers some shorter versions of the CF and CM commands. To use them for the example above, you need only enter three digit arguments: >AT CF 600 and >AT CM F00 As for the full eight digit versions, only the 11 least significant (right-most) digits are actually used, so you do not need to take special care with the first bit. With a little practice, these commands are fairly easy to master. Initially, try entering the filter and mask values, then use a command such as AT MA to see what the results are. The ELM327 knows that you are trying to filter, and combines the effects of both commands (it will do that for MR and MT as well). The MA, MR and MT commands all have the extra benefit that while they are in effect, the ELM327 will remain quiet, not sending acknowledgement or error signals, so anything you do while monitoring should not disrupt other devices that are on the bus. Note that if a filter has been set, it will be used for all CAN messages. Setting filters and masks may cause standard OBD requests to be ignored though, and you may begin seeing “NO DATA” responses. If this happens, and you are unsure of why, you may want to reset everything to their default values (AT D) and start over. Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 31 of 51 ELM327 Multiline Responses There are occasions when a vehicle must respond with more information than one ‘message’ is able to show. In these cases, it responds with several lines which must be assembled into one complete message. One example of this is a request for the serial number of the vehicle (mode 09, PID 02). This is often a multiline reply that needs to be joined. In these situations, you must take care to ensure that all of the reply has been received and it is in the correct order before assembling the message. The actual response usually has a byte that shows the sequence of the data, to help with this. Here is one example for a typical SAE J1850 vehicle: >0902 49 02 49 02 49 02 49 02 49 02 01 02 03 04 05 00 44 30 35 33 00 34 30 42 34 00 47 52 31 35 31 50 35 32 36 making the reading of the data easier. With formatting on, the sequence numbers are shown with a colon (‘:’) after each, so that they clearly stand out (0:, 1:, etc.). CAN systems add this hex digit (it goes from 0 to F then repeats), to aid in reassembling the data, just as the J1850 vehicle did. The first line of this response says that there are 014 bytes of information to follow. That is 14 in hexadecimal, or 20 in decimal terms, which agrees with the 6 + 7 + 7 bytes shown on the three lines. Serial numbers are generally 17 digits long however, so how do we assemble the number from 20 digits? The second line shown begins with the familiar 49 02, as this is a response to an 09 02 request. Clearly they are not part of the serial number. CAN will occasionally add a third byte to the response which we see next (the ‘01’), which shows the number of data items that are to follow (the vehicle can only have one VIN, so the response says there is only one data item). That third byte can be ignored, so this leaves 17 data bytes which are the serial number (purposely chosen to be identical to the those of the previous example). All that is needed is a conversion to ASCII, in order to read them, exactly as before. The following shows an example of a different type of multiline response that can occur when two or more ECUs respond to one request. Here is a typical response to an 01 00 request: >01 00 41 00 BE 3E B8 11 41 00 80 10 80 00 This is difficult to decipher without knowing a little more information. We need to turn the headers on to actually see ‘who’ is doing the talking: >AT H1 OK >01 00 48 6B 10 41 00 BE 3E B8 11 FA 48 6B 18 41 00 80 10 80 00 C0 Now, if you analyze the header, you can see that the third byte shows ECU 10 (the engine controller) and ECU 18 (the transmission) are both responding with a reply that is valid for them. This type of response occurs often, and you should be prepared for it. A final example shows how similar messages might occasionally be ‘mixed up’ in a CAN system. We Note that all OBD compliant vehicles do not necessarily provide this information. Many older ones do not, but as a rule the newer ones do. If your vehicle does not support this parameter, you will only see a “NO DATA” response. The first two bytes (49 and 02) on each line of the above response do not show any vehicle information. They only show that this is a response to an 09 02 request. The next byte on each line shows the order in which the data is to be assembled. Assembling the remainder of the data in that order, and ignoring the first few 00’s gives: 31 44 34 47 50 30 30 52 35 35 42 31 32 33 34 35 36 Using an ASCII table to convert these hex digits gives the following serial number for the vehicle: 1D4GP00R55B123456 CAN systems will display this information in a somewhat different fashion. Here is a typical response from a CAN vehicle: >0902 014 0: 49 02 01 31 44 34 1: 47 50 30 30 52 35 35 2: 42 31 32 33 34 35 36 CAN Formatting has been left on (the default), ELM327DSC Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 32 of 51 ELM327 Multiline Responses (Cont’d) ask the vehicle for the Calibration ID (09 04) and are presented with the following response: >09 04 013 0: 49 04 1: 32 38 013 0: 49 04 2: 00 00 1: 32 38 2: 00 00 their proper order. To do this, look at the byte following the CAN ID - it is what is known as the PCI byte, and is used to tell what type of data follows. In this case, the PCI byte begins with either a 1 (for a ‘First Frame’ message), or a 2 (for the ‘Consecutive Frames’). The second half of the PCI byte shows the order in which the information is to be assembled (ie. the segment number). In this case, the segment numbers are already in order, but if they had not been, it would have been necessary to rearrange the messages to place them in order. Each OBD standard has some minor peculiarities. Hopefully this has helped you with some of the more difficult ones. If you are still having trouble, we urge you to purchase the relevant standard, and study it. 01 35 36 30 39 34 39 41 43 01 00 39 00 35 00 35 00 36 00 34 00 30 00 31 41 43 00 00 which is quite confusing. The first group (the 013, 0:, 1: group) seems to make some sense, but the following group is very confusing. Why are there two segment twos? Which ECU do these belong to? The only way to tell is to turn on the headers, and repeat your request: >AT H1 OK >09 7E8 7E8 7E9 7E8 7E9 7E9 04 10 21 10 22 21 22 13 32 13 00 32 00 49 38 49 00 38 00 04 39 04 00 39 00 01 34 01 00 35 00 35 39 35 00 34 00 36 41 36 00 41 00 30 43 30 31 43 00 This time, the order appears to be the same, but be aware that it may not be – that is why the standard requires that sequence codes be transmitted with multiline responses. Looking at the first digits of these responses, you can see that some begin with 7E8, and some begin with 7E9. This is the special CAN IDs representing ECU#1 and ECU#2, respectively. Grouping the responses from the two ECUs gives: 7E8 10 13 49 04 01 35 36 30 7E8 21 32 38 39 34 39 41 43 7E8 22 00 00 00 00 00 00 31 and 7E9 10 13 49 04 01 35 36 30 7E9 21 32 38 39 35 34 41 43 7E9 22 00 00 00 00 00 00 00 From these, the messages can be assembled in ELM327DSC Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 33 of 51 ELM327 CAN Message Formats The ISO 15765-4 (CAN) standard defines several message types that are to be used with diagnostic systems. Currently, there are four main ones that may be used: SF FF CF FC the Single Frame the First Frame (of a multiframe message) the Consecutive Frame ( “ “ ) the Flow Control frame In this example, the line that begins with 0: is the First Frame message. The length (014) was actually extracted from the message by the ELM327 and printed on the separate line as shown. Following the First Frame line are two Consecutive Frames as shown (1: and 2:). To learn more details of the exact formatting, you may want to send a request such as the one above, then repeat the same request with the headers enabled (AT H1). This will show the PCI bytes that are actually used to send these components of the total message. The Flow Control frame is one that you do not normally have to deal with. When a First Frame message is sent as part of a reply, the ELM327 must tell the sender some technical things (such as how long to delay between Consecutive Frames, etc.) and does so by replying immediately with a Flow Control message. These are predefined by the ISO 15765-4 standard, so can be automatically inserted for you. If you wish to generate custom Flow Control messages, then refer to the next section. If a Flow Control frame is detected while monitoring, the line will be displayed with ‘FC: ’ before the data, to help you with decoding of the information. There is a final type of message that is occasionally reported, but is not supported by the diagnostics standard. The (Bosch) CAN standard allows for the transmission of a data request without sending any data in the requesting message. To ensure that the message is seen as such, the sender also sets a special flag in the message (the RTR bit), which is seen at each receiver. The ELM327 always looks for this flag, or for zero data bytes, and may report to you that an RTR was detected while monitoring. This is shown by the characters RTR where data would normally appear, but only if the CAN Auto Formatting is off, or headers are enabled. Often, when monitoring a CAN system with an incorrect baud rate chosen, RTRs may be seen. Note that the CAN system is quite robust with several error detecting methods in place, so that during normal data transmission you will rarely see any errors. When monitoring buses however, you may well see errors (especially if the ELM327 is set to an incorrect baud rate). As a diagnostic aid, when errors do occur, the ELM327 will print all bytes (no matter what CAF, etc., is set to), followed by the message ‘0902 014 0: 49 02 01 31 44 34 1: 47 50 30 30 52 35 35 2: 42 31 32 33 34 35 36 ELM327DSC Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 34 of 51 ELM327 Altering Flow Control Messages ISO 15765-4 (CAN) provides for only eight data bytes per frame of data. Of course, there are many cases where the data which needs to be sent is longer that 8 bytes and CAN has made provision for this, allowing data to be separated into segments, then recombined at the receiver. To send one of these multi-line messages, the transmitter in a CAN system will send a ‘First Frame’ message, and then wait for a reply from the receiver. This reply, called a ‘Flow Control’ message contains information concerning acceptable message timing, etc., and is required to be sent before the transmitter will send any more data. For ISO 15765-4, the type of response is well defined, and never changes. The ELM327 will automatically send this ISO 15765-4 Flow Control response for you as long as the CAN Flow Control option is enabled (CFC1), which it is by default. Several users have requested that we provide more flexibility over the data sent in the Flow Control message, and as of v1.1, we have provided a means to do this. In order to change how the ELM327 responds when it needs to send a Flow Control message, you need to change Flow Control ‘modes’. The default Flow Control mode is number ‘0’. At any time while you are experimenting, if you should wish to restore the automatic Flow Control responses (for ISO 15765-4), simply set the mode to 0: >AT FC SM 0 OK This will immediately restore the responses to their default settings. Mode 1 has been provided for those that need complete control over their Flow Control messages. To use it, simply define the CAN ID (header) and data bytes that you require be sent in response to a First Frame message. If you try to set the mode before defining these values, you will get an error: >AT FC SM 1 ? You must set the headers and data first: >AT FC SH 7E8 OK >AT FC SD 00 11 22 OK ELM327DSC then you can set the mode: >AT FC SM 1 OK From this point on, every First Frame message received will be responded to with your custom message. The final mode currently supported allows the user to set the data bytes which are to be sent, but not the ID bits. The ID bits (header bytes) in mode 2 are set to those which were received in the First Frame message, without change. To use this mode, first define your data bytes, then activate the mode: >AT FC SD 00 11 22 OK >AT FC SM 2 OK For most people, there will be little need to manipulate these ‘Flow Control’ messages, as the defaults are designed to work with the CAN OBD standards. If you wish to experiment, these special AT commands offer that control for you. Figure 7 summarizes the currently supported modes: FC Mode 0 ELM327 Provides ID Bits Data Bytes no values User Provides no values ID Bits Data Bytes Data Bytes 1 2 ID Bits Figure 7. Flow Control Mode Numbers Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 35 of 51 ELM327 J1939 Support The SAE J1939 CAN standard is a relatively new protocol that is being used in many types of heavy machinery – trucks, agricultural equipment, and busses, to name a few. It uses a standard CAN (ISO 11898) physical interface, and defines its own format for data transfer (although it is very similar to the ISO 15765 that is used for automobiles). The ELM327 offers some support for the J1939 standard in Protocol A. (Protocols B and C can be selected for J1939 formatting if needed, with Programmable Parameters 2C and 2E). Although this is not full support as dictated by the standards, the ELM327 implementation should at least allow you to begin experimenting. The default data rate for Protocol A has been set to 250 kbps, as set by the SAE J1939-11 standard. Should your application require a different speed, it is easily changed with PP 2B. J1939 messages use 29 bit CAN IDs, and up to 8 data bytes for each message (ISO 15765 always uses 8 bytes). Diagnostics on SAE J1939 are defined by the J1939-73 standard, and the actual data transfer protocol is described in J1939-21. If you are going to do a lot of work with J1939, it may be wise to purchase these standards documents from the Society of Automotive Engineers (SAE). The ELM327 handles the sending of messages with the J1939 protocol in the same way as any of the other protocols. The header bytes are predefined for you and all you need do is provide the data bytes that you wish to send. For example, assume that you wish to send a request for engine temperature (PGN 00FEEE). J1939 specifies a reverse order for the data bytes, so when you tell the ELM327 what to send, you need to switch the order of the data bytes, and then send them as you would any other request: >EE FE 00 The ELM327 then adds the required header (ID) bytes, etc. and sends the message for you. (It also configures itself correctly to be able to receive the response.) Note that the ELM327 sets the header bytes to EC FF F9 by default (for global requests from OBD service tool #1), so if you want something else, you will have to change the headers, using the AT SH command. All responses to a request are printed by the ELM327, whether they are a single CAN message transmission, or a multisegment transmission as ELM327DSC defined by the transport protocol (J1939-21). If the responses are multisegment, the ELM327 handles all of the negotiation for you (transparently - you won’t see it happen). If formatting is on (ie CAF1), the output will resemble the format used to print the ISO 15765-4 multiline responses. Note that if you provide three data bytes, the ELM327 will assume that you are sending a PGN, and will look for responses to that. If you send other than 3 data bytes, it will assume that you are making a general request, and will only look for responses to the Source Address (as given in the third byte of the header). The SAE J1939 standard predefines several Diagnostic Messages, and assigns ID values to them. The first of these (designated ‘DM1’) are reserved for trouble codes, which are periodically broadcast over the CAN network. Since these are commonly required, the ELM327 provides a special command to monitor for them (aptly named DM1). If you wish to monitor for all DM1 messages, simply issue: >AT DM1 and the ELM327 will print out all that it finds. The DM1 message is the only one that is presently predefined by the ELM327 for you. To monitor for any other diagnostic message, you need to know it’s PGN number (in hexadecimal), and monitor for that using the AT MP command. For example, the DM2 PGN number is 65227, or 00FECB in hexadecimal. The ELM327 requires hexadecimal, and assumes that all PGNs begin with 00 – so to monitor for DM2s, you need only send: >AT MP FECB and the IC will begin looking for all replies to DM2 requests. Please note that the ELM327’s support for the SAE J1939 standard is only basic (it does not support address negotiation as described in J1939-73, for example), and it has not undergone the extensive testing that our automotive protocols have. We simply have had a large number of requests for support of the protocol, and wanted to provide something for you to begin experimenting with. As always, we are quite open to your feedback and your suggestions for future upgrades. Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 36 of 51 ELM327 Restoring Order There may be times when it seems the ELM327 is out of control, and you will need to know how to restore order. Before we continue to discuss modifying too many parameters, this seems to be a good point to discuss how to ‘get back to the start’. Perhaps you have told the ELM327 to monitor all data, and there are screens and screens of data flying by. Perhaps the IC is now responding with ‘NO DATA’ when it did work previously. This is when a few tips may help. The ELM327 can always be interrupted from a task by a single keystroke from the keyboard. As part of its normal operation, checks are made for received characters, and if found the IC will stop what it is doing at the next opportunity. Often this means that it will continue to send the information on the current line, then stop, print a prompt character, and wait for your input. The stopping may not always seem immediate if the RS232 send buffer is almost full, though – you will not actually see the prompt character until the buffer has emptied, and your terminal program has finished printing what it has received. There are times when the problems seem more serious and you don’t remember just what you did to make them so bad. Perhaps you have ‘adjusted’ some of the timers, then experimented with the CAN filter, or perhaps tried to see what happens if the header bytes were changed. All of these can be reset by sending the ‘set to Defaults’ AT Command: >AT D OK This will often be sufficient to restore order, but it can occasionally bring unexpected results. One such surprise will occur if you are connected to a vehicle using one protocol, but the saved (default) protocol is a different one. In this case, the ELM327 will close the current session and then change the protocol to the default one, exactly as instructed. If the AT D does not bring the expected results, it may be necessary to do something more drastic - like resetting the entire IC. There are a few ways that this can be performed with the ELM327. One way is to simply remove the power and then reapply it. Another way that acts exactly the same way as a power off and then on is to send the full reset command: >AT Z It takes approximately one second for the IC to perform this reset, initialize everything and then test ELM327DSC the four status LEDs in sequence. A much quicker option is available with the ELM327, however, if the led test is not required – the ‘Warm Start’ command: >AT WS This new command performs a software reset, restoring exactly the same items as the AT Z does, but it omits the LED test, so it is considerably faster. Also, it does not affect any baud rates that have been set with the AT BRD command, so is essential if you are modifying baud rates with software. Any of the above methods should be effective in restoring order while experimenting. There is always the chance that you may have changed a Programmable Parameter, however, and are still having problems with your system. In this case, you may want to simply turn off all Programmable Parameters (which forces them to their default values). To do so, send the command: >AT PP FF OFF which should disable all of the changes that you have made. You can then start over with what is essentially a device with ‘factory settings’. There may be times when even this command is not recognized, however. If that is the case, you will need to use the hardware method of turning the PPs off (see the next section ‘Programmable Parameters’, for more details). Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 37 of 51 ELM327 Programmable Parameters The ELM327 contains several programmable memory locations that retain their data even after power is turned off. Every time the IC is powered up, these locations are read and used to change the default settings for such things as whether to display the headers, or how often to send ‘wakeup’ messages. The settings, or parameters, can be altered by the user at any time using a few simple commands. These Programmable Parameter commands are standard AT Commands, with one exception: each one requires a two-step process to complete. This extra step provides some security against random inputs that might try to make changes. The following pages list the currently supported Programmable Parameters for this version of the ELM327. As an example of how to use a Programmable Parameter, consider PP 01 (the printing of headers). If you are constantly powering your ELM327 and then using AT H1 to turn the headers on, you may want to change its default setting, so that they are always on by default. To do this, simply set the value of PP 01 to 00: >AT PP 01 SV 00 OK This changes the value associated with PP 01, but does not enabled it. To make the change effective, you must also type: >AT PP 01 ON OK At this point, you have changed the default setting for AT H1/H0, but you have not changed the actual value of the current AT H1/H0 setting. From the ‘Type’ column in the table on page 39, you can see that the change only becomes effective the next time that defaults are restored. This could be from a reset, a power off/on, or possibly an AT D command. It is occasionally difficult to know what changes you have made to the Programmable Parameters. To help with that, the ELM327 provides a Programmable Parameter Summary (PPS) command. This simply prints a list of all of the supported PPs, their current value, and whether they are on/enabled (N), or off/disabled (F). For an ELM327 v1.2 IC, with only the headers enabled (as discussed above), the summary table would look as follows: >AT PPS 00:FF F 04:01 F 08:FF F 0C:68 F 10:0D F 14:FF F 18:00 F 1C:FF F 20:FF F 24:00 F 28:FF F 2C:E0 F 01:00 05:FF 09:00 0D:0D 11:00 15:FF 19:FF 1D:FF 21:FF 25:00 29:FF 2D:04 N F F F F F F F F F F F 02:FF 06:F1 0A:0A 0E:FF 12:FF 16:FF 1A:FF 1E:FF 22:FF 26:00 2A:FF 2E:80 F F F F F F F F F F F F 03:32 07:09 0B:FF 0F:FF 13:32 17:92 1B:FF 1F:FF 23:FF 27:FF 2B:02 2F:0A F F F F F F F F F F F F You can see that PP 01 now shows a value of 00, and it is enabled (oN). Another example shows how you might change the CAN filler byte. Some systems use ‘AA’ as the value to put into unused CAN bytes, while the ELM327 uses ‘00’ by default. To change the ELM327’s behaviour, simply change PP 26: >AT PP 26 SV AA OK >AT PP 26 ON OK Again, PP 26 is of type ‘D’, so the above change will not actually take effect until the AT D command is issued, or the ELM327 is reset. The Programmable Parameters are a great way to customize your ELM327 for your own use, but you should do so with caution if using commercial software. Most software expects an ELM327 to respond in certain ways to commands, and may be confused if the headers are on when not expected, or if the CAN response shows data length codes, for example. If you make changes, it might be best to make small changes and then see the effect of each, so that it is easier to retrace your steps and ‘undo’ what you have done. If you get in too deeply, don’t forget the ‘all off’ command: >AT PP FF OFF No matter what software you use, you might get into more serious trouble, should you change the baud rate, or the Carriage Return character, for example, and forget what you have set them to. The Carriage Return value set by PP 0D is the only character that is recognized by the ELM327 as ending a command, so ELM327DSC Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 38 of 51 ELM327 Programmable Parameters (Cont’d) if you change its value, you may not be able to undo your change. In this case, your only recourse may be to force all of the PPs off with a hardware trick. When the ELM327 first powers up, it looks for a jumper from pin 28 (the OBD Tx LED) to circuit common (V DD). If a jumper is in place, it will turn off all of the PPs for you, restoring the IC to the factory defaults. To use this feature, simply connect a jumper to circuit common, then hold the other end of the jumper to pin 28 while turning the power on. As soon as you see the RS232 Rx LED begin to flash quickly, you can remove the jumper – the PPs are off. This feature should only be used when you get into trouble too deeply, and it’s your only choice (since putting jumpers into a live circuit might cause damage if you put it into the wrong place). As well, it is only available beginning with version 1.2 of the IC, and should not be used on any previous versions. The following is a summary of the currently implemented Programmable Parameters (ELM327 v1.2): PP 00 Description Perform AT MA after powerup or reset Values 00 = ON FF = OFF 00 = ON FF = OFF 00 = ON FF = OFF 00 to FF Default FF (OFF) Type R 01 Printing of header bytes (AT H default setting) FF (OFF) D 02 Allow long messages (AT AL default setting) FF (OFF) D 03 NO DATA timeout time (AT ST default setting) setting = value x 4.096 msec Default Adaptive Timing mode (AT AT setting) 32 (205 msec) D 04 00 to 02 01 D 06 OBD Source (Tester) Address. Not used for J1939 protocols. 00 to FF F1 R 07 Last Protocol to try during automatic searches 01 to 0C 09 D 09 Character echo (AT E default setting) 00 = ON FF = OFF 00 to FF 00 (ON) R 0A Linefeed Character 0A R 0C RS232 baud rate divisor when pin 6=1 The baud rate (in kbps) is given by 4000/(this value) For example, to obtain 500kbps, use a setting of 08 (4000/8 = 500) (Continued on the next page) 08 to FF 68 (38.4) P ELM327DSC Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 39 of 51 ELM327 Programmable Parameters (Cont’d) PP 0C (cont’d) Description Here are some example baud rates, and the divisor to be used for each: Baud Rate (kbps) 19.2 38.4 57.6 115.2 230.4 500 PP 0C value hex (dec) D0 (208) 68 (104) 45 (69) 23 (35) 11 (17) 08 (8) Values Default Type Note that the PP 0C value must be provided to the ELM327 as hex digits only. The decimal values that are shown above in brackets are for your convenience only. 0D Carriage Return Character 00 to FF 0D R 10 J1850 voltage settling time setting = value x 4.096 msec J1850 Break Signal monitor enable (reports BUS ERROR if break signal duration limits are exceeded) Auto search time delay between protocols 1 & 2 setting = value x 4.096 msec ISO baud rate (AT IB default setting) 00 to FF 0D (53 msec) I 11 00 = ON FF = OFF 00 to FF 00 (ON) D 13 32 (205 msec) I (see note 2) 16 00 = 96 FF = 10 00 to FF FF (10.4K) R 17 ISO wakeup message rate (AT SW default setting) setting = value x 20.48 msec Auto search time delay between protocols 4 & 5 setting = value x 4.096 msec CAN auto formatting (AT CAF default setting) 92 (2.99 sec) D 18 00 to FF 00 (no delay) I 24 00 = ON FF = OFF 00 = ON FF = OFF 00 to FF 00 (ON) D 25 CAN auto flow control (AT CFC default setting) 00 (ON) D 26 CAN filler byte (used to pad out messages) 00 D ELM327DSC Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 40 of 51 ELM327 Programmable Parameters (Cont’d) PP 29 Description Printing of the CAN data length (DLC) when printing header bytes Values 00 = ON FF = OFF 01 to 40 Default FF (OFF) Type D (see note 2) 2B Protocol A (SAE J1939) CAN baud rate divisor. The protocol A CAN baud rate is determined by this value (rate in kbps = 500/value). For example, setting this PP to 19 (ie. decimal 25) provides a baud rate of 500/25 = 20 kbps. 02 (250 Kbps) R 2C Protocol B (USER1) CAN protocol options. Each bit of this byte controls an option, as follows: b7: Transmit ID Length, 0=29 bit ID, 1=11 bit ID b6: Data Length, 0=fixed 8 byte, 1= Variable DLC b5: Receive ID Length, 0=as set by b7, 1=both 11 bit and 29 bit b4: reserved for future - leave set at 0 b3: reserved for future - leave set at 0. b2, b1, and b0 determine the data formatting options, as follows: b2 b1 b0 Data Format 0 0 0 none 0 0 1 ISO 15765-4 0 1 0 SAE J1939 Other combinations are reserved for future – results might be unpredictable if you should select one of them. Note that b7 is the msb, and b0 is the lsb. For example, the default value of E0 can be shown as 11100000 in binary, which has b7, b6 and b5 set to 1’s. This means that by default, 11 bit IDs will be sent, the data length will vary, and the ELM327 will receive messages with either 11 or 29 bit IDs. 00 to FF E0 (11100000) R 2D Protocol B (USER1) baud rate divisor. See PP 2B for a description. 01 to 40 04 (125 Kbps) R 2E Protocol C (USER2) CAN options. See PP 2C for a description. 00 to FF 80 (10000000) R 2F Protocol C (USER2) baud rate divisor. See PP 2B for a description. 01 to 40 0A (50 Kbps) R Notes: 1. The “Type” column indicates when changes to the Programmable Parameter take effect. Possible values are: I - the effect is immediate, D - takes effect after Defaults are restored (AT D, AT Z, AT WS or power off/on) R - will only become apparent after a Reset (AT Z, AT WS or power off/on) P - only takes effect after power off/on or AT Z. 2. These are changes since the last version of the IC. ELM327DSC Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 41 of 51 ELM327 Using Higher RS232 Baud Rates The RS232 serial interface has been maintained throughout the ELM OBD products, largely due to its’ versatility. Older computers and PDAs can use it directly, as can microprocessors. Newer computers generally do not have RS232 ports, but they do have USB and ethernet ports, both of which can be converted to RS232 with a simple adapter. Most people will build their ELM327 circuits with an RS232 interface, mainly because it is relatively easy and inexpensive to do so. A circuit such as the one shown in Figure 9 requires very few components and works extremely well at speeds up to 57600 bps. Depending on your computer’s RS232 voltages, your wiring practices, and your choice of components, it may also work well at speeds as high as 115200 bps. This is the approximate limit of such a circuit however, and anything operating at this speed should be thoroughly tested. Users that would like to operate at speeds in the range of 115200 bps (or higher) may wish to look at some of the single IC solutions that are available. These include devices such as the ADM232A from Analog Devices (http://www.analog.com/), or the popular MAX232 series of ICs from Maxim Integrated Products (http://www.maxim-ic.com/). These are all excellent devices that can be used for speeds of up to 115.2 Kbps. We do caution that many of these types of devices are only rated for operation up to 120 Kbps, however, so may not be suitable for higher data rates; be sure to check the manufacturers data sheet before committing to a design. An RS232 interface needs relatively large voltage swings, which are difficult to maintain at higher rates with large cable capacitances to contend with. (A typical interface is often limited to about 230400 bps under ideal conditions.) If you need to operate the ELM327 at these speeds or higher, it is recommended that you consider alternatives. One popular alternative is a USB data connection. The USB interface is capable of very high data transfer rates, certainly much higher than the 500 Kbps limit of the ELM327. Several manufacturers offer special ‘bridge’ circuits that simplify connecting an RS232 device (such as the ELM327) directly to the USB bus. Examples are the CP2102 from Silicon Labs (http://www.silabs.com/) or the FT232R from Future Technology Devices (http://www.ftdichip.com/). If planning to use the higher baud rates (ie up to 500 Kbaud), these interfaces are essential. We are often asked about the use of a direct ELM327DSC connection to microprocessor. That is certainly an option, and one that allows a full speed connection at essentially zero cost. If you are developing such a system, you can often simply connect the transmit output from your microprocessor to the ELM327’s receive, and the receive input to the ELM327’s transmit. Provided that they share the same power supplies, and you use good wiring practices between them, the connection should work well. You do not have to convert to RS232 voltage levels in order to use the RS232 signals. The default configuration for the ELM327 provides an RS232 data rate of either 9600 baud, or 38400 baud, depending on the level at pin 6 during power up or reset. While the 9600 baud rate is not adjustable, the 38400 one is (beginning with v1.2 of the IC). There are two ways that the rate can be changed – either permanently with a Programmable Parameter, or temporarily with an AT command. Programmable Parameter ‘0C’ has been provided to allow you to change the high speed baud rate to what works best for you. You can change the value several times if you wish, and each time that you do, that new value becomes your power on default setting. The type of storage used for this value is actually called ‘non-volatile’, as it is not affected by power cycles or resets. To change the setting requires only a write to the ELM327’s EEPROM, using the AT PP commands. If, for example, you would like to have the IC use a baud rate of 57.6K rather than the factory setting of 38.4K, simply change the value of PP 0C, and then enable it. PP 0C is actually an internal divisor that is stored in memory – the baud rate is calculated from 4000 divided by the value of the number that is stored. To obtain a setting of 57.6, a baud rate divisor of 69 is required (4000/69 is approximately 57.6). Since 69 in decimal is 45 in hexadecimal, you tell the ELM327 to set the value to 45: >AT PP 0C SV 45 then enable the new value for use: >AT PP 0C ON from that point on (until PP 0C is turned off), the ELM327 will communicate at the new baud rate. If you are designing your own circuitry, it is relatively easy to know what your circuit is capable of, and then write a value to PP 0C once. Software developers will not usually know what hardware is 42 of 51 Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com ELM327 Using Higher RS232 Baud Rates (Cont’d) connected to the ELM327 however, so will not know what the limitations are. For these users, we have provided the AT BRD command. The AT BRD command allows a new baud rate to be tested, and then accepted or rejected depending on the results of the test. See the chart at the right, which shows how the command works. As can be seen, the software first makes a request for a new baud rate divisor, using this command. For example, to try the 57600 baud rate that was previously discussed, the controlling PC would send the command: AT BRD 45 If the ELM327 is an older version, it will not support this command, and will return with the familiar ‘?’ character. If it does support the command, it will respond with ‘OK’, so the software knows whether to proceed or not. Having sent an ‘OK’, the ELM327 then switches to the new (proposed) baud rate, and then simply waits a predetermined time (nominally 75 msec). This period is to allow the PC sufficient time to change its baud rate. When the time is up, the ELM327 then sends the ID string (currently ‘ELM327 v1.2’) to the PC at the new baud rate, and then waits for a response. Knowing that it should receive the ELM327 ID string, the PC software compares what was actually received to what was expected. If they match, the PC responds with a carriage return character, but if there is a problem, the PC sends nothing. The ELM327 is meanwhile waiting for a valid carriage return character to arrive. If it does (within 75 msec), the proposed baud rate is retained, and the ELM327 says ‘OK’ at this new rate. If it does not, the baud rate then reverts back to the old rate. Note that the PC might correctly output the carriage return at this new rate, but the interface circuitry could corrupt the character, so that the ELM327 does not see a valid response. Your software must check for the ‘OK’ response before assuming that the new rate has been accepted. Using this method, a program can quickly try several baud rates, evaluating the connection each time, and settling on the fastest suitable one. The new baud rate will stay in effect until reset by an AT Z, or a Power Off/On. It is not affected by the AT WS (Warm Start) command. PC Request for a new baud rate divisor: AT BRD hh ELM327 ELM327 responds with ‘OK’ (if it is supported) Program switches to the new baud rate, and waits for input ELM327 waits for 75msec*, then sends the AT I string If the Rx is good, Program sends a carriage return Wait up to 75 msec* for a carriage return character yes CR received ? no Print ‘OK’ Revert to the old baud rate Print a prompt, then wait for the next command * Note that the 75msec time is adjustable (with the AT BRT hh command) ELM327DSC Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com 43 of 51 ELM327 Computer Control A common question we receive with our OBD interpreters is “Can I connect the ELM32x circuit directly to my own circuit, or must I use the RS232 interface shown?” Certainly you may connect directly to our ICs – you do not need to use an RS232 interface. The ELM327 does not use an inverted RS232 Rx input (as was the case with the ELM320, ELM322 and ELM323), so interfacing without RS232 levels is now even simpler. If you have a microprocessor that uses the same 5V supply as the ELM327, and has an internal UART, all you will generally need to do is connect your processor’s transmit output to the ELM327’s receive input, and then your receive input to the ELM327’s transmit output. Communications should work fine with this connection (and a correct baud rate setting). The ELM327 is a CMOS device that uses industry standard levels for all inputs and outputs, so is easily interfaced to almost any logic circuit. The ELM327 has a hand-shaking feature that may be very useful for some interfaces. There is a request to send (RTS) input, and a Busy output that can be used to interrupt the ELM327, and to see when it is ready to receive an input. To use them, set one of your port pins to normally provide a high output, and connect it to the RTS input. Use another port pin as an input to monitor the ELM327 Busy output. When you want to send a command, simply check the Busy output first. If it is at a logic high level, then bring your RTS line low and wait for the Busy line to go low (you might want to consider using an edge triggered interrupt for this, if one is available). When Busy does go low, restore your RTS line to a high level, and then send your command to the ELM327. No need to worry about the ELM327 becoming busy again after you raise the RTS line at this point – once Busy goes low, the ELM327 waits (indefinitely) for your command. If you do not use the RTS input on the ELM327, don’t forget to tie it to a high logic level. Error Messages When hardware or data problems occur, the ELM327 will respond with one of the following short messages. Some of the messages are suppressed during an automatic search for a protocol, and are only visible if not in the ‘auto’ mode. Here is a brief description of each: BUFFER FULL The ELM327 provides a 256 byte internal RS232 transmit buffer so that OBD messages can be received quickly, stored, and sent to the computer or PDA at a more constant rate. Occasionally (particularly with CAN systems) the buffer will fill at a faster rate than it is being ‘emptied.’ Eventually it may become full, and no more data can be stored (it is lost). If you are receiving BUFFER FULL messages, and are using a 9600 baud data rate, give serious consideration to changing your data rate to 38400 baud. If you still receive BUFFER FULL messages after that, consider some of the filtering options (the MR, MT, CF and CM AT Commands). BUS BUSY The ELM327 tried to send the message, or tried to initialize the bus, and detected too much activity to do so (it needs a pause in activity in order to insert the message). Although this could be because the bus was in fact very busy, it is most often due a wiring problem that is giving a continuously active input. If this is an initial trial with your ELM327 circuit, check all of the voltage levels at the offending OBD input – this error is very likely due to a wiring problem. BUS ERROR A generic problem has occured. This is most often from an invalid signal being detected (a pulse that is longer than a Break signal, etc.) on the bus, but could 44 of 51 ELM327DSC Elm Electronics – Circuits for the Hobbyist www.elmelectronics.com ELM327 Error Messages (Cont’d) be from a wiring error. Note that some vehicles may generate long pulses as part of their startup process, so you may see this message as part of a normal vehicle startup while ‘monitoring all.’ CAN ERROR The CAN system had difficulty initializing, sending, or receiving. Often this is simply from not being connected to a CAN system when you attempt to send a message, but it may be because you have set the system to an incorrect protocol, or to a rate that does not match the actual data rate. As with BUS ERRORs, the CAN ERROR might also be the result of a wiring problem, so if this is the first time using your ELM327 circuit, review all of your CAN interface circuitry before proceeding. FB ERROR When an OBD output is energized, a check is always made to ensure that the signal also appears at the respective input. If there is a problem, and no active input is detected, the IC turns the output off and declares that there was a problem with the FeedBack (FB) of the signal. If this is an initial trial with your ELM327, this is almost certainly a wiring problem. Check your wiring before proceeding. DATA ERROR There was a response from the vehicle, but the information was incorrect or could not be recovered.
ELM327DSC 价格&库存

很抱歉,暂时无法提供与“ELM327DSC”相匹配的价格&库存,您可以联系我们找货

免费人工找货