I'm waiting on an Elmscan OBDII scan tool for my car (to interface to the computer I intend to install and for troubleshooting my car) and it occured to me that I could use this info for the PIC RGB light controller I'm working on. (Modulate the lights with the RPMs instead among other things, maybe a Speakjet output too) I'm thinking that I could just use 2 serial ports one for the car to PIC and one for the PIC to OBDII. Off the top of my head, I'm thinking I'll need an additional external UART, (or maybe another PIC instead) and 2 MAX232s The data rate is quite low (9600 baud), but I also have a bunch of software PWMs I need to drive. Does this sound like the 16F877 will have enough capacity? Just looking for a guesstimate from someone with more PIC experience. I would think the biggest problem I would need to deal with is that the PC will be able to change what items are monitored and to deal with it appropriately if a desired sensor is disabled. Otherwise, I'm just parroting out the data strings from serialIN to serialOUT and vice-versa. Any thoughts would be appreciated.
The fun part about RS-232 is that it can transmit and recieve seperately. In other words, you can have the PC transmit to the PIC (wire the PC to the PICs RX line) and then have the PIC transmit to the OBDII (wiring that to the PICs TX line). The USART does not have to do hand-shaking or verification. Its just TX and RX. You can use the same MAX232 chip. The PWM signals will have to be firmware instead of hardware since the PIC only has one CCP module, but Im assuming you already know this.
Neat. Thanks. As far as the PWM, I already have it mostly done driving them out of TMR0. (I'm going to use the CCP module to control servos that all will be positioned to the same angle) I figured with all the features I want in the end, the 16F877 was the way to go.
I just got my OBDII box and had a thought. Won't I need another UART as I need to be read what the scantool is saying back?
Yeah, that could be a problem. If you need two-way transmission, then there is a solution. Use a 74HC4053 analog mux. This basically switches much like a relay in the sense that it allows voltage to pass through it either way. You select the line to talk to the PC first, then switch over to talk to the OBDII. Put this inbetween the PIC and the MAX chip. Get a MAX232 that has dual TX/RX pairs. Have the PIC select the channel the mux controls.
Just got my order today and as luck would have it, I ordered the wrong max232, I ordered the dual one.