Dual CANbus monitor and instrumentation cluster
Eagle Schematic and Board design
/media/uploads/TickTock/canaryr5.zip
Parts List
Assembly
1) LCD Displays
I found ribbon cable is a nice way to organize the wires to the displays. You'll need 12 conductors and I connected them in the following order:
1 | LED+ |
2 | LED- |
3 | RSTB |
4 | MOSI |
5 | SCLK |
6 | CSB |
7 | X+ |
8 | X- |
9 | Y+ |
10 | Y- |
11 | VDD |
12 | GND |
First I connected all the GND connections (IM0, IM1, IM3, & 2 GND). Do not connect the bottom GND until you have the ribbon cable connected. After making all the ribbon cable connections (connecting the GND of the ribbon cable to the bottom GND pad), solder the GND bar from the previous step to the back of the bottom GND connection. Finally, make a connection from the back side 3.3V pin to IM2. Take a break and repeat for the second display. Once the two displays are complete combine all wires except CS0, CS1, X+, X-, Y+, and Y-. Connect X- of the left display to X+ of the right. Similarly connect Y- of the left display to Y+ of the right. Insulate any exposed wires.
2) PCB
Refer to the schematics to place all the components on the board. If you plan to install into the CANary 3D enclosure, DO NOT install the battery holder or the socket for the mbed and, instead, connect two wires to the VB and GND pads nearby. You will have to install the battery holder against the back wall to avoid interfering with the right-hand display and the mbed will have to be directly soldered. I have not found a socket with a low enough profile to fit in the space provided (depth of enclosure is limited by the space behind the center console). Also, I recommend keeping as much lead as possible on the Zener diode (bending it as shown to clear the back wall). Although it is operating well within parameters, the Zener gets quite hot during extended operation and the leads help dissipate the heat and keep it away from the PCB and other components.
Once the PCB is populated, solder the LCDs to the PCB. CS0 connects to the right display and CS1 connects to the left.
3) Testing
1) | First step is to buzz out all connections from the LCDs to the pins in the main board |
2) | Next check the touch screen connections. On the main board, place an Ohm meter across X+ and X-. You should read 700 Ohms. Repeat for Y+ and Y-. Then test the resistance from X+ to Y+. With nothing touching the screens, it should read >100K Ohms and <1K when touching either screen. |
3) | When all connections are checked, solder in the mbed. Download and install the touch2 program http://mbed.org/users/TickTock/code/touch2/ to test the basic operation of the mbed and touch screens. |
tips: | |
Touch screen is sensitive - excess flux on X+,X-,Y+,Y- connection on mbed can result in flakey operation | |
If touch is not working, double-check the LCD0_CS and LCD1_CS are not swapped. LCD0_CS must connect to the CS of the LCD that has X- & Y- connected to the mbed. LCD1_CS must connect to the CS of the LCD that has X+ & Y+ connected to the mbed. | |
4) | Once touch2 works, it is time to connect to the OBD connector. I highly recommend double checking all connections from the OBD to the PCB with the cable in place before connecting to the Leaf. Buzz out all the pins in the OBS to make sure none are shorting to each other, Check that the 12V goes to the Zener (and nothing else) and the switched 12V to the resistor divider (and nothing else). Test the ground connection properly connects to ground and nothing else. |
5) | Once you are confident there are no shorts or wrong connections from the OBD connector, take a deep breath and plug it into your leaf. Touch2 program should come up and function. Unplug and install the latest CANary firmware. Test all features before installing into the enclosure (gids, cellpair, menu system, logging) since installing and removing from the enclosure is a PITA. |
4) Enclosure
The 3D printer leaves a lot of powder behind - I used a strong spray of water to get it out of all the cracks. The enclosure comes with a rather rough finish. I recommend convincing yourself you like it, then simply lightly sand then paint before assembly. Sanding is very difficult - the nylon is very nicely fused and doesn't want to sand. I tried sandblasting and that didn't work either. I had some limited success with filler and then sanding, but only on the outside - it is too difficult to sand the face.
5) Final Assembly
Diff: main.cpp
- Revision:
- 41:8d4609ea7259
- Parent:
- 40:0e6e71a7323f
- Child:
- 42:4533b13b297d
--- a/main.cpp Sun Mar 31 17:45:05 2013 +0000 +++ b/main.cpp Sun Mar 31 18:57:36 2013 +0000 @@ -1,14 +1,11 @@ // main.cpp //To Do: -// * Use timestamp for mWs but override with playbackInt based calc in playback -// * Log file playback (to enable testing of new passive display modes without having to drive around) // * USB device detect // * Ability to update binary from the thumb-drive (requires file timestamp) // * Cellpair histogram // * Audible friction brake feedback // * User-configurable watchpoint -// * Immediately turn off when car is turned off and logging // * Better graphical DTE display with historic efficiency information considered and displayed // * Add 50% charge option // * Tire Pressure Sensor display @@ -67,7 +64,7 @@ volatile bool userIdle; bool touched=false; //flag to read touchscreen char counter = 0; -unsigned char dMode[2] = {dteScreen,brakeScreen}; //display mode +unsigned char dMode[2] = {mainScreen,brakeScreen}; //display mode unsigned char sMode = 0; // setup mode unsigned char lastDMode[2] = {0,0}; //last screen mode unsigned char dtMode = 6; @@ -87,7 +84,8 @@ float scale12V = 16.2; // R1:R2 ratio signed long mWs_x4 = 0; unsigned short numWsamples = 0; -unsigned long miles = 0; +unsigned short numSsamples = 0; +float kW = 0; float mpkWh = 0; float accV = 0; bool playbackEn = false; @@ -96,6 +94,8 @@ bool step = false; char header[5]; char data[8]; +signed long motorRPM; +float MPH = 0; int main() { int readPointer=0; @@ -454,8 +454,7 @@ } if(tick){ // Executes once a second - accV=floor(mon12V*scale12V*10+0.5)/10; - //accV=mon12V*scale12V; + accV=floor(mon12V*scale12V*10+0.5)/10; //Round to nearest 10th accOn=(accV>5)?true:false; if(!accOn&&!logEn&&userIdle&&!playbackEn){ //sprintf(sTemp,"Display Off %4.2f\n",accV); @@ -466,13 +465,18 @@ }else{ dled = ledLo; } - //if(mWs_x4>0){ - if(numWsamples>0){ - mpkWh= ((float) mWs_x4)/numWsamples/4e3; // just kW for now + if(numSsamples>0){ // Avoid div0 + MPH=((float) motorRPM)/numSsamples/215; // Empirically derived - may change car to car }else{ - mpkWh=99; + MPH=0; } - miles=0; + if(numWsamples>0){ // Avoid div0 + kW=((float) mWs_x4)/numWsamples/4e3; + mpkWh=floor(MPH*10/kW+0.5)/10; // Round to nearest 10th + }else{ + kW=0; + } motorRPM=0; + numSsamples=0; mWs_x4=0; numWsamples=0; if(logCP) @@ -487,19 +491,14 @@ sendCPreq(); // send cellpair data request. wait_ms(16); sendTreq(); //send temperature request - //wait_ms(16); - //showCP=true; pollCP=false; } if(step){ // playback if(playbackOpen&&playbackEn){ - //sprintf(sTemp,"step\n"); - //logMsg(sTemp); for(i=0;i<120;i++){ if(!feof(file)){ fscanf(file,"%5c%8c",&header,&data); - //pbts=(header[1]<<8)|header[2]; logCan(header[0],CANMessage(0x7ff&((header[4]<<8)+header[3]), data, 8)); }else{ fclose(file); // restart