Jump to content
swiftkid

Any C++/Arduino programmers on here?

Recommended Posts

Long shot but are there any C++ programmers out there or anyone with experience with Arduino/Seeed Canbus? Got a bit of a project I'm working on but I'm a complete novice and I'm getting pretty frustrated with it all! Hoping for a bit of assistance or maybe some pointers on where to get some info from.

Share this post


Link to post
Share on other sites

Well I've bought an arduino uno and a seeed canbus shield to try and communicate with the canbus system in the R32 engine. For now I've got a set of mk4 golf clocks I'm trying to control over the canbus via the seeed shield, there seems to be loads of people online that have done it but can I hell get it working or even make the dash do anything to even confirm I have it wired right.

 

The end goal is to wire it up to the R32 ECU and convert the CANbus messages to analogue signals to pass through to the Corrado clocks

Share this post


Link to post
Share on other sites

Sounds like an interesting project .. would like to get into that stuff some more myself, but have never had the time.

Share this post


Link to post
Share on other sites

I've not used an arduino and am not a C++ developer. But I used to be a Java developer. Are you writing the code yourself or simply trying to install, compile and run someone elses code? What is the actual issue you're facing (e.g. are you getting an error when compiling, etc?)

 

Whenever faced with issues like this in the past I'd try to write small test harnesses and test each part worked.

 

Sounds an interesting project.

Share this post


Link to post
Share on other sites

Yes it's a genuine arduino board.

 

I've been having a look and the things you can do with the arduino is awesome, some guy has been making a jarvis!

 

I'm trying to take it 1 step at a time so for now I'm just trying to figure out if I've got it wired right as u don't even know what the terminals do on the board or if when I'm trying to send signals I have to code it so it knows where to send from.

I'm sort of piecing together bits of code together, I have a piece of code that does rpm to a polo dash which I keep trying but nothing happening, no lights on board flash or anything.

 

When I send the initial signal to check canbus it comes back OK but it does that with or without the wires attached so I'm presuming it's just checking the canbus shield is there and not looking at the golf clocks I have attached to that.

Share this post


Link to post
Share on other sites

This is the code I have so far, anyone see any problems? Next step arduino/seeed forum I think, looking at it my problem seems quite specialised rather than just C++

 

// demo: CAN-BUS Shield, send data

#include

#include

 

MCP_CAN CAN(9); // Set CS to pin 10

 

int rpm_int;

 

void setup()

{

Serial.begin(115200);

 

START_INIT:

 

if(CAN_OK == CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k

{

Serial.println("CAN BUS Shield init ok!");

}

else

{

Serial.println("CAN BUS Shield init fail");

Serial.println("Init CAN BUS Shield again");

delay(100);

goto START_INIT;

}

}

 

void loop()

{

rpm_int = 250;

 

 

// send data: id = 0x00, standard flame, data len = 8, stmp: data buf

unsigned char stmp[] = {1,0,0,rpm_int};

CAN.sendMsgBuf(0x280, 0, 8, stmp);

delay(100); // send data per 100ms

}

 

/*********************************************************************************************************

END FILE

*********************************************************************************************************/

Share this post


Link to post
Share on other sites

Sorry slightly delayed reply from me. Work and the rest of my life is manic right now so not getting much time to come to the forum.

 

As I said I'm not a C++ or Arduino developer. But is the loop() function actually being called? I would have thought that there should be a call to it right after Serial.println("CAN BUS Shield init ok!"); such as below. I can't see it being called anywhere unless I have missed it:

 

if(CAN_OK == CAN.begin(CAN_500KBPS))                   // init can bus : baudrate = 500k
   {
       Serial.println("CAN BUS Shield init ok!");
[b]        //     I WOULD EXPECT A CALL TO LOOP() HERE?    [/b]
   }
   else
   {
       Serial.println("CAN BUS Shield init fail");
       Serial.println("Init CAN BUS Shield again");
       delay(100);
       goto START_INIT;
   }
}

 

It would also be worth adding some debugging statements around that area because that's where the statement to actually send the rpm speed seems to be. Not being a C++ developer I don't have anythign installed to compile it but I'd suggest somethign like this may help:

 


// demo: CAN-BUS Shield, send data
#include 
#include 

MCP_CAN CAN(9);                                      // Set CS to pin 10

int rpm_int;

void setup()
{
   Serial.begin(115200);

START_INIT:

[b]//   SET TRANSMISSION RATE[/b]
if(CAN_OK == CAN.begin(CAN_500KBPS))                   // init can bus : baudrate = 500k
{
       Serial.println("CAN BUS Shield init ok!");
[b]        loop();  // Adding a call to loop which wasn't here before[/b]
}
else
{
           Serial.println("CAN BUS Shield init fail");
           Serial.println("Init CAN BUS Shield again");
           delay(100);
           goto START_INIT;
}
}

void loop()
{
   rpm_int = 250;


   // send data:  id = 0x00, standard flame, data len = 8, stmp: data buf
   unsigned char stmp[] = {1,0,0,rpm_int};
   [b]if(CAN_OK == CAN.begin CAN.sendMsgBuf(0x280, 0, 8, stmp))
    {
        Serial.println("Setting rpm was ok!");
       [b]loop();[/b]
    }
   else
   {
[b]         Serial.println("Setting rpm failed with :" + CAN_OK);  // I'm guessing this line so if it won't compile then just use [b][b]Serial.println("Setting rpm failed");[/b][/b][/b]
   }
[/b]
   delay(100);                       // send data per 100ms
}

/**************************************************  **************************************************  *****
 END FILE
**************************************************  **************************************************  *****/

Share this post


Link to post
Share on other sites

Well bit of an update for anyone interested, I managed to get the arduino reading the CANBUS messages so I bought an LCD display. After a LOT of trail and error, mostly error I managed to find some signals I wanted and as per video below (sorry I don't know how to embed it so its a link), I've managed to display the RPM on the LCD screen!

 

I only had it connected for a short time as my laptop battery lasts about 5 minutes, next step is trying to figure out how to run the Corrado clocks as I believe they are a 12v square wave signal and the arduino will only output 5v square wave.

 

But, its pretty exciting, all I need to do now is figure out what the data is and I can pretty much display any message the ECU sends over canbus, so MPG, sump oil temp, water temp, lambda etc etc.

 

th_20160416_144433_001_zpsl3dyibhu.mp4

Share this post


Link to post
Share on other sites

Awesome!

 

I'm no C++ developer either but I am a developer and this wets my whistle. Can you get a txt file populated with all the outputs. From that you can then know what you're dealing with. We can see RPM there but I'm sure there is a ton that is also coming back from the ECU.

 

Also if you can populate a txt file (sometimes referred to as a 'dump', yep. Taking a dump in a txt file) you can do a lot of the legwork without having to be in the car and use the data you have 'dumped' to pretend it is the ECU and display on the LCD.

 

Happy travels!

Share this post


Link to post
Share on other sites

I've saved the serial monitor output into an excel spreadsheet so I can analyse data unfortunately I've got the water pipes disconnected at the moment so can't run it fully up to temperature. Also I don't know how to timestamp so can't really see when actions are happening so until I can pull the car out the garage (hopefully this weekend) I can't really run it long enough to get full temp running data.

 

 

Sent from my SM-G900F using Tapatalk

Share this post


Link to post
Share on other sites

how to timestamp export into excel or get an arduino/ c++ timestamp? Do you set a timestamp on boot on the arduino?

 

 

Sent from my iPhone using Tapatalk

Share this post


Link to post
Share on other sites

Put a timestamp in the code, I tend to watch the data then copy paste it into excel. I didn't know if I could just send a message in the serial monitor when I'm doing things so when I'm looking at the data I can see when I did it... Eg unplug temp sensor, maf etc

 

Sent from my SM-G900F using Tapatalk

Share this post


Link to post
Share on other sites

Interesting project swift kid, not c++ developer but objective c (iPhone apps) currently gathering together equipment to make a double din to go in the Corrado should be able to do full multimedia and read obd stuff, also planning on chucking some stepper motors in to try and control the heater matrix cables as well, it's always trying to find the time though...

 

 

Sent from my iPad using Tapatalk

Share this post


Link to post
Share on other sites
Put a timestamp in the code, I tend to watch the data then copy paste it into excel. I didn't know if I could just send a message in the serial monitor when I'm doing things so when I'm looking at the data I can see when I did it... Eg unplug temp sensor, maf etc

 

Sent from my SM-G900F using Tapatalk

 

You should be able to get a timestamp by executing

 

now(); 

more variable reference here:

http://playground.arduino.cc/Code/Time

Share this post


Link to post
Share on other sites

Little update, mk1 one on right... Mk2 on left. Some parts just arrived so going to connect it up to corrado and try get dash running now!

 

03b6670d0970406880bd56a10342256a.jpg

 

Sent from my SM-G900F using Tapatalk

Share this post


Link to post
Share on other sites

×
×
  • Create New...