Help with CanBUS/GPS Shield?

I'm just finding my feet with Arduino but have just bought the new CAN-Bus/GPS Shield from SK Pang together with the Serial LCD and OBDII cable.

The supplied example GPS and ECU sketches are great and work as far as they go but I'd like to combine the two and use the on-board joystick with a menu system to select CanBUS or GPS data and log all the data to a MicroSD card.

This is well over my head though, aside from the shield having a joystick and MicroSD card slot the examples do not use either and so I'm at a loss where to start.

Can anyone guide me?

I'm just finding my feet with Arduino but have just bought the new CAN-Bus/GPS Shield from SK Pang together with the Serial LCD and OBDII cable.

I'd say, with that list, you've jumped in at the deep end! :wink:

Can anyone guide me?

Some general advice...

  • The more work you do designing, the less work you do coding (by a factor of 10) and the less work you do debugging (by a factor of 100)
  • Pick ONE thing (like the joystick) and get it working as closely as possible to what you want in the final version then move on to the next thing

Good advice!

As it is now, I can set up the sketch to report my chosen engine parameters and run it in CanBUS mode.

Or I can load the GPS Sketch and get Lat/Lon on the serial LCD.

So it's at least of some use as is.

I'll do what you suggest and get the joystick working with some simple text on the LCD and work from there.

It's great fun but coming at this as a newbie I may have bitten off rather too much, I have zero C or any other coding experience so lots of it, even with the tutorials, is as yet making no sense :-/

For reference, this is the shield, a very neat device.

There are many internet tutorials available for someone in your shoes.

Or, you may find these useful to get you started with programming...
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1247637768
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1270229972

Thanks, I've been working through the Earthshine .pdf book albeit not always understanding what is going on! I've also bought "Getting Started with Arduino" and "Practical Arduino".

My started kit is from Oomlout and that comes with a starter booklet and guide.

What I will do is trace back the joystick pins on the schematic and start slowly by working to be able to detect a movement in one plane say 'Joystick UP' and build from there.

Once I've understood that I can then get the joystick to trigger a change in the data displayed.

All sounds so simple but I guess this is the best way to understand it all. I managed to get a Sparkfun RTC module working thanks to some posts on this forum which was a major victory for me and I'm loving the whole Arduino thing.

Any pointers on the Joystick and any caveats/routines welcomed.

I'm not going to be any help on joystick. Maybe someone else can give you some hints.

Quick and dirty Joystick demo:

/* Define Joystick connection */
#define UP     15
#define DOWN   17
#define LEFT   16
#define RIGHT  19
#define CLICK  18


void setup() {
  
  pinMode(UP,INPUT);
  pinMode(DOWN,INPUT);
  pinMode(LEFT,INPUT);
  pinMode(RIGHT,INPUT);
  pinMode(CLICK,INPUT);
 
  Serial.begin(9600);
  Serial.println("Joystick demo");

}

void loop() {
  
   if (digitalRead(UP) == 0) {
     Serial.println("Up pressed");}
      
   if (digitalRead(DOWN) == 0) {
      Serial.println("Down pressed");}
      
   if (digitalRead(LEFT) == 0) {
       Serial.println("Left pressed");}
   
   if (digitalRead(RIGHT) == 0) {
       Serial.println("Right pressed");}

   if (digitalRead(CLICK) == 0) {
       Serial.println("Click pressed");}      
       delay(100);
}

Use the Serial Monitor to see what key is pressed.

Thanks. I'de already got the basics of the Joystick working but your code has confused me a little!

Your schematic shows the joystick on Analog pins 1 - 5. So I was using AnalogPIN and reading the values as 1023 = OFF and any other value as ON.

Your sketch references digital 15 - 19. Does that then mean that A0 thru 5 are also D14 - 19?

That makes life a lot easier ::slight_smile:

Yes, the Analog pins can also be use as digital inputs.
Extract from : http://arduino.cc/en/Tutorial/AnalogInputPins

A/D converter

The Atmega controllers used for the Arduino contain an onboard 6 channel analog-to-digital (A/D) converter. The converter has 10 bit resolution, returning integers from 0 to 1023. While the main function of the analog pins for most Arduino users is to read analog sensors, the analog pins also have all the functionality of general purpose input/output (GPIO) pins (the same as digital pins 0 - 13).

Consequently, if a user needs more general purpose input output pins, and all the analog pins are not in use, the analog pins may be used for GPIO.

Pin mapping

The Arduino pin numbers corresponding to the analog pins are 14 through 19. Note that these are Arduino pin numbers, and do not correspond to the physical pin numbers on the Atmega chips. The analog pins can be used identically to the digital pins, so for example, the code would look like this to set analog pin 0 to an output, and to set it HIGH:

pinMode(14, OUTPUT);
digitalWrite(14, HIGH);

Excellent, thank you for taking the time to help. Not simple but great fun!

Great, now have the joystick input sorted and understood. Able to parse joystick inputs and display on the serial LCD.

Now I have to try and shoehorn the CanBUS and GPS sketches together and toggle the outputs via the LCD/Joystick.

Does all this get easier? The code grows so fast that I soon find myself losing the plot and getting lost :slight_smile:

How about using the data from CanBus and GPS storing it on the SD card, then using Google Earth to plot the route along with engine parameters?

Indeed, that would be the plan. But before I get that far the hurdle will be to get the data onto the storage card!