Many automotive enthusiasts and DIY mechanics are drawn to the world of On-Board Diagnostics II (OBD-II) for its wealth of real-time vehicle data. Interfacing with your car’s computer opens up possibilities for performance monitoring, diagnostics, and custom projects. For those using Arduino and modules like the Sparkfun OBD-II UART, accessing this data seems within reach. However, challenges can arise, particularly when dealing with specific communication protocols like J1850 PWM.
This post delves into a common issue faced by those attempting to read OBD-II data over PWM (Pulse Width Modulation) protocol, specifically focusing on troubleshooting inaccurate data readings and offering insights for a more successful DIY experience. We’ll explore the scenario presented by a user encountering difficulties with their Ford Focus and using Arduino to decipher J1850 PWM.
Understanding J1850 PWM Protocol in OBD-II
J1850 PWM is one of the older OBD-II communication protocols, prevalent in many Ford and some General Motors vehicles, particularly from the late 1990s to mid-2000s. Unlike CAN (Controller Area Network) which is dominant in modern cars, PWM uses voltage pulses of varying widths to transmit data. This difference is crucial because the initialization and data request methods differ significantly from other OBD-II protocols.
When working with an OBD-II UART module, it’s essential to correctly configure it for the protocol your vehicle uses. Automatic protocol detection, like the “ATDPN” command mentioned in the original user’s code, is a good starting point. However, verifying the detected protocol and ensuring your subsequent commands are appropriate for PWM is vital.
Diagnosing Inaccurate Data: Speed and RPM Fluctuations
The user in the forum post describes a frustrating situation: after successfully initializing communication and confirming the J1850 PWM protocol, they encounter wildly inaccurate readings for vehicle speed and RPM. Speed jumps erratically between 0 and 13 km/h, while RPM values are inconsistent and often nonsensical, even when the engine is off.
These symptoms point towards a few potential issues:
- Incorrect Data Interpretation: Even if the OBD-II UART module is correctly receiving data, the Arduino code might be misinterpreting the raw data bytes. PWM data, like other OBD-II protocols, sends data in hexadecimal format, and proper conversion is crucial. The provided code snippet uses
strtol(&rxData[6],0,16)
for conversion, which is generally correct, but issues could arise if the expected data format from the PWM protocol is not perfectly aligned with this conversion. - Timing and Request Issues: PWM protocol communication can be sensitive to timing. Sending requests too quickly or not handling response times correctly could lead to data corruption or misreads. The
delay()
functions in the provided code are basic, and in some cases, more precise timing control might be needed. - Protocol Specific Nuances: J1850 PWM might have specific initialization sequences or data request PIDs (Parameter IDs) that differ slightly from generic OBD-II examples often found online, which might be geared towards CAN or ISO protocols.
- Hardware or Wiring Problems: Although less likely if initial communication is established, loose wiring or issues with the OBD-II UART module itself could contribute to data errors.
Troubleshooting Steps for PWM Transmit OBDII Data
To address the issue of inaccurate data when working with Pwm Transmit Obdii and Arduino, consider these troubleshooting steps:
- Verify Protocol Detection: Double-check that the “ATDPN” command indeed returns ‘1’ or ‘2’ indicating PWM (J1850 PWM or J1850 VPW). If the protocol detection is incorrect, the subsequent commands will be inappropriate. Consult your vehicle’s documentation or reliable online resources to confirm the correct OBD-II protocol for your specific car model and year.
- Examine Data Request PIDs: The code uses “010D” for speed and “010C” for RPM. While these are standard OBD-II PIDs, it’s worth verifying if they are the correct PIDs for J1850 PWM in a 2002 Ford Focus. Some manufacturers might use slightly different PIDs or data formats even within the OBD-II standard. Resources like the Wikipedia list of OBD-II PIDs can be helpful, but vehicle-specific documentation is ideal.
- Analyze Raw Data: Modify the Arduino code to print the raw
rxData
buffer directly to the serial monitor before any conversion. This will show exactly what the OBD-II UART module is receiving. Examine this raw data for patterns or errors. Compare the raw data with the expected data format for J1850 PWM responses. Look for consistent headers or delimiters that might be misinterpreted by the current parsing logic. - Review PWM Specific ELM327 Commands: The ELM327 chip is commonly used in OBD-II UART modules. Consult the ELM327 datasheet for commands specifically related to J1850 PWM. There might be specific initialization commands or settings recommended for optimal PWM communication beyond the generic “AT” commands used in the provided code.
- Consider Protocol Headers (if applicable): J1850 PWM sometimes uses specific header bytes in data transmissions. If the raw data analysis reveals such headers, the Arduino code needs to be adjusted to correctly skip or interpret these header bytes before extracting the actual data values. The “ATSHE410F1” command in the initialization suggests an attempt to set a header, but verifying its correctness for PWM and the specific ECU is important.
- Test with a Known Working OBD-II Scanner: Before diving deep into code modifications, it’s beneficial to test your vehicle with a commercially available OBD-II scanner that explicitly supports J1850 PWM. If a professional scanner reads data correctly, it confirms that the issue lies within the Arduino setup and not a fundamental problem with the car’s OBD-II system. Autel offers a range of OBD-II scanners that are compatible with various protocols, including J1850 PWM, which could be used for comparison and verification.
- Wiring and Module Check: Although less likely, re-examine the wiring connections between the Arduino, OBD-II UART module, and the car’s OBD-II port. Ensure secure and correct connections. If possible, try a different OBD-II UART module to rule out hardware failure.
Moving Forward with OBD-II PWM Data
Decoding OBD-II PWM transmissions with Arduino can be a rewarding project, but it requires careful attention to protocol details and troubleshooting. By systematically verifying each aspect of the communication chain, from protocol detection to data interpretation, and using the troubleshooting steps outlined above, you can increase your chances of successfully accessing accurate data from your J1850 PWM equipped vehicle. Remember to consult vehicle-specific resources and the ELM327 datasheet for protocol-specific guidance. For more advanced diagnostics and robust OBD-II solutions, consider exploring dedicated automotive diagnostic tools from manufacturers like Autel, which offer comprehensive protocol support and reliable data acquisition.