I started posting some stuff about this in @Steel City 06 's SPAL electric fan thread but rather than hi-jacking it I figured I'd start a new thread for this, because it has more applications than just electric fan control.
For context, what I'm doing is making a fan controller for a variable speed cooling fan using a PWM signal based on information from non-OE sensors running straight to the Arduino as well as some values from the OBD2 bus. The control code (how much fan speed is needed for a given temperature) is the easy part, by far, and probably will comprise less than 10% of the total code required.
Other applications might include a torque converter lockup controller for a 32RH using a manual trans PCM for those that would rather not use the 42RLE. Lots of possibilities.
Anyway, to the meat and potatoes.
Getting Arduino to talk to your PCM
First things first - you have to get the Arduino to talk to the PCM. There are a number of OBD2 protocols but from what I can tell, the TJ PCM uses J1850 VPW, which I believe is common among Chrysler and GM vehicles pre-CAN.
I found an Arduino library for communicating directly using J1850VPW but it required some circuitry in between and the documentation isn't really detailed enough for me to understand it. C/C#/C++ is not my "native" programming language - I have a general understanding of the syntax but I don't have a lot of knowledge on the deeper stuff.
Most inexpensive OBD2 code readers are based on an "ELM327" chip. I found a couple of ELM327 libraries that I can understand well enough to try to implement - one called ELMo which is pretty simple, you just send commands like 01 05 which is a request for live data and and then you get a response like 41 05 38 which would tell you the coolant temperature is 96C 205F. The other one is called ELMduino which hides the inner workings and lets you ask for PIDS by name, which makes the library more complex but makes your work a lot easier.
With the software figured out, you need the hardware to get from the Arduino serial port to the communication pins on the ELM327. Most ELM327's come in the form of a $20 Amazon reader that is either Bluetooth or USB. There are some Arduino models that do Bluetooth but I don't want to have to figure that out nor do I want my radiator fan to depend on a bluetooth connection. The Arduino Due is the only board that can be a USB host, but it's a much bigger board and overkill for what we're doing, plus I'm not sure I want to invest the time in figuring out USB, either. I want as direct a link as possible.
I have a UART to OBD2 board on backorder from Sparkfun, which will interface directly to the Arduino's serial port. If that backorder seems to be going on indefinitely, I may buy a cheap USB model and un-solder the USB chip to solder in some conductors straight from the Arduino serial port.
Then I'll have to find a way to tie into the J1850VPW pins right before they go to the DLC connector, because I want to tie directly to the harness so that I still have use of the DLC for my Torque app, etc without having to unplug the lifeline to my cooling fan, because that would be stupid. I don't want to try to build something from scratch with a naked ELM327 chip because there's a bunch of electronics BS in between that I want to be already put together for me.
I'm gonna refrain from posting code until I have something that works, but when I get to that point I will be sure to update.
For context, what I'm doing is making a fan controller for a variable speed cooling fan using a PWM signal based on information from non-OE sensors running straight to the Arduino as well as some values from the OBD2 bus. The control code (how much fan speed is needed for a given temperature) is the easy part, by far, and probably will comprise less than 10% of the total code required.
Other applications might include a torque converter lockup controller for a 32RH using a manual trans PCM for those that would rather not use the 42RLE. Lots of possibilities.
Anyway, to the meat and potatoes.
Getting Arduino to talk to your PCM
First things first - you have to get the Arduino to talk to the PCM. There are a number of OBD2 protocols but from what I can tell, the TJ PCM uses J1850 VPW, which I believe is common among Chrysler and GM vehicles pre-CAN.
I found an Arduino library for communicating directly using J1850VPW but it required some circuitry in between and the documentation isn't really detailed enough for me to understand it. C/C#/C++ is not my "native" programming language - I have a general understanding of the syntax but I don't have a lot of knowledge on the deeper stuff.
Most inexpensive OBD2 code readers are based on an "ELM327" chip. I found a couple of ELM327 libraries that I can understand well enough to try to implement - one called ELMo which is pretty simple, you just send commands like 01 05 which is a request for live data and and then you get a response like 41 05 38 which would tell you the coolant temperature is 96C 205F. The other one is called ELMduino which hides the inner workings and lets you ask for PIDS by name, which makes the library more complex but makes your work a lot easier.
With the software figured out, you need the hardware to get from the Arduino serial port to the communication pins on the ELM327. Most ELM327's come in the form of a $20 Amazon reader that is either Bluetooth or USB. There are some Arduino models that do Bluetooth but I don't want to have to figure that out nor do I want my radiator fan to depend on a bluetooth connection. The Arduino Due is the only board that can be a USB host, but it's a much bigger board and overkill for what we're doing, plus I'm not sure I want to invest the time in figuring out USB, either. I want as direct a link as possible.
I have a UART to OBD2 board on backorder from Sparkfun, which will interface directly to the Arduino's serial port. If that backorder seems to be going on indefinitely, I may buy a cheap USB model and un-solder the USB chip to solder in some conductors straight from the Arduino serial port.
Then I'll have to find a way to tie into the J1850VPW pins right before they go to the DLC connector, because I want to tie directly to the harness so that I still have use of the DLC for my Torque app, etc without having to unplug the lifeline to my cooling fan, because that would be stupid. I don't want to try to build something from scratch with a naked ELM327 chip because there's a bunch of electronics BS in between that I want to be already put together for me.
I'm gonna refrain from posting code until I have something that works, but when I get to that point I will be sure to update.