Sunday, March 2, 2014

Dashboard Computer

Everything almost works..

It all started with a desire to have a full color graphic display as the primary interface to the car's electronics.  The first version was a Arduino Uno with 16x2 character display.  Worked well, but 32 characters may be enough for a Tweet, but not to quickly convey to the driver useful information about the status of the motor.

This is the new larger Arduino Mega 2560 R3 from SAIN SMART with the full color 3.2" 320x240 touch display.

The other advantage over the Uno is this MEGA has 4x the program memory space using the AVR2560 processor.  Physically it is not much larger than the Uno, a bit longer.  The middle board's schematic is available at this link.

The following is a detailed account of integrating this with the SEEED Studio CAN Bus Shield, which was working great on the Uno at 1 Mbit/S
  1. SPI Bus - The 2560 moves the SPI Interface to different pins on the board in addition to the Arduino standard 6-pin ICSP header in the middle of the board.
  2. The SEEED Studio CAN BUS board (WIKI & schematic) does not use the ICSP header to access the MOSI MISO SCK signals which would have been logical.  Ironically, it passes through this header but does not actually have traces to these signals, but connects to the peripheral headers for digital I/O signals 10, 11, 12, 13.  The table in the connections section here shows the mapping.  Note the SD Card interface on the TFT board uses the same chip-select (Pin 53) so this will be inoperable if it is shared with CAN-BUS as a chip select.   The SD Card could be useful to store bit-maps for displays and possibly performance log data.   Schematic for the LCD & SD Interface Board.
  3. So after adding these jumpers to move the 3 signals from the peripheral headers  to the ICSP header on the CAN shield and the ChipSelect (it has several names: CS or SS or SPICS or SPI_CS) to I/O 53 on the Mega's extended I/O connector (2x18) the controller was able to initialize the CAN shield controller.  SPICS (SPI Chip Select) signal also had to be changed in the mcp_can_dfs.h file to define this to signal 53 (Mega) from signal 10 (Uno). 
  4. However, as soon as the the Kelly Controller was connected to Jane's CAN bus, the interrupt indicator on the shield illuminated and no data was be read from the shield.  It "appeared" to be sending data onto the CAN bus, but nothing was being read back.  Since the TX, RX and INT indicators were illuminating, it seems like data was available, just the MEGA was not reading it.  The CAN Shield uses an interrupt to signal the MEGA that data is available.  By default it uses INT0 (Interrupt 0 Uno I/O 2, pin 3 on the header) which is attached to the ISR (interrupt service routine) with the attachedInterrrupt function as interrupt 0.  This page also shows the differences between the UNO and MEGA interrupt.
  5. The SAIN SMART LCD Shield for the MEGA also uses INT0 (maybe for the touch-screen) and has a 10K pull-up resistor on it.   So it appears that the interrupt from the CAN Shield needed to move.  The MEGA has several as shown on this schematic.  Interrupt 4 (which may be labeled as (RXD1/INT2)PD2 on the Mega schematic/pin-out) was selected and it appears on I/O pin #19.  It is "mis"-labeled on this schematic as INT2 and there are several references on the web to this being INT2 but don't be fooled, it is attached in SW as INT4.  
    Dashboard Display
  6. After all of this the MEGA with the large LCD is now talking CAN.
  7. Mechanically, this also required some adapting.  Since the CAN shield is not designed for the MEGA platform, it does not have a header-pass through for the Extended I/O of the Mega.  Two layers of trimmed stackable headers passed the signals up to the LCD adapter. 

  1. Next steps - Mount the display and work on speeding up the refresh rate.   Creating an isolated communication link to the fuel gauge Arduino will permit this display to be the primary interface and allow the Fuel Gauge Arduino to live in the boot.

No comments: