DIY Electric Car Forums banner
1 - 20 of 21 Posts

·
Registered
Joined
·
14 Posts
Discussion Starter · #1 ·
I'm in over my head with the c++..total moron when it comes to coding... does anybody know of a version of damiens code that works on an arduino uno? The amount of "xxxx does not name a type" error codes I'm getting is astronomical. The internet isn't too much help, as I'm unable to equate non automotive coding to this application.

 

·
Registered
Joined
·
14 Posts
Discussion Starter · #3 ·
What hostility! That wasn't meant to be taken as sarcasm. It awesome. The possibilities are endless. I'm not just going to jump into a forum guns blazing, very bad form. I do know it was mostly (if not entirely) written by a gentleman named Perttu Ahola.
I shall reiterate. Some of us aren't programmers. We are the nuts and bolt greaseballs that cut our teeth on small block chevies and Hondas. Was wondering if anyone has done this themselves, and if they know of a "refined" version of the sketch floating around. One that zips over as easily as the "blink" sketch. I'll figure it out eventually I suppose but the programming community as a whole doesn't do well with code out of context, which is pretty understandable.
Sober up my friend, re-read my original post and hopefully you will come to the conclusion that what we have here is a noob needing help, with no ill intentions.
 

·
Registered
Joined
·
14 Posts
Discussion Starter · #6 ·
You clearly don't understand the bullshit Damien has gone through from this community -- to the point where he shut down support for Model X/S component development. Pull his name off this posting before he gets driven to a "fuckit" state of mind.

If you want software development or get coding advice, you should be on openinverter contributing to their work, trading their sweat for yours. Opensource means ANY development you do on their codebase gets thrown back jnto the pot.
This is literally the reasons forums exist. That will be the last thing I ever say to you, good sir.
 

·
Registered
Joined
·
14 Posts
Discussion Starter · #7 ·
I'm not familiar with that code, but I can take a stab at it for funzies. Which file(s) are you compiling ?
This one. And the apparent 99,000 libraries that go with it:ROFLMAO:

 

·
Registered
Joined
·
786 Posts
This one. And the apparent 99,000 libraries that go with it:ROFLMAO:

Well, that's the link to the repo... I took a quick glance at it, and I see a few "ino" files under the Software folder, I thought you were compiling one of those. Yes, it is of course expected that there will be a million libraries, and some libraries may not be available on some Arduino models. Either way, I can try to take a look if you give me more solid directions :)
 

·
Registered
Joined
·
14 Posts
Discussion Starter · #9 ·
Well, that's the link to the repo... I took a quick glance at it, and I see a few "ino" files under the Software folder, I thought you were compiling one of those. Yes, it is of course expected that there will be a million libraries, and some libraries may not be available on some Arduino models. Either way, I can try to take a look if you give me more solid directions :)
OK. Bear with me here, I'm a moron and don't know what I'm doing.
So I grabbed the entire thing in zip form, and unzipped it to my ide. Hit compile and hit with multiple errors. The library files seem fairly easy, I was able to zip most of those off of github. Once those were out of the way, it seems to be mostly syntax? (The last time I did anything resembling coding was qbasic in jr.high, so forgive my terminology)
Errors like "expected , or ;" ( place one of those in front...compile, seems to move past it but it feels like a bandaid)
"So and so doesn't name a type" Googling shows I need to type "void int xxxxx". Once again it moves past it but it doesn't feel right.
Anyhow, plan here was to eventually make it work and then upload the entire thing to github so the next carburetor guy has a shot at this. Taking no credit, obviously. Unless someone had already done it, then I'm certainly not to proud to copy/paste and get my car running that much faster.
If you are willing to just take a look and point me in the correct direction, I've been on this off and on for about a month and I'm not expecting anyone to edit the entire thing for me.
I hope that made sense. I'm not even sure it made sense to me at this point.
 

·
Registered
Joined
·
786 Posts
For personal projects I use Eclipse with Arduino plugin. It is a bit convoluted for beginner use though.

Which library did you use for twi ? I get a compilation error due to missing twi.h when targetting Uno. Compiles fine for Due.

Basically here is the deal... those code examples rely on some capabilities in Due board, such as interrupt-driven timers and two-wire interface, which are expected to be present for the CAN library. Now either those interfaces need to be emulated, or the CAN library can be swapped out for another one that will work on Uno. In addition, there will be some wiring differences.

So really if Uno is all you got, the only thing this code is useful for is as a reference of the frame structure / communication protocol.
 

·
Registered
Joined
·
14 Posts
Discussion Starter · #13 ·

It's absolutely wrong I'm sure but it got the compiler to calm down long enough for me to find the other issues.
On another sketch I just flat out deleted it. That's the big one. I'm not entirely sure if I'm going to need every inch of this code, as I'll be running different gouges and whatnot. I'm not entirely clear how important that library even is
For personal projects I use Eclipse with Arduino plugin. It is a bit convoluted for beginner use though.

Which library did you use for twi ? I get a compilation error due to missing twi.h when targetting Uno. Compiles fine for Due.

Basically here is the deal... those code examples rely on some capabilities in Due board, such as interrupt-driven timers and two-wire interface, which are expected to be present for the CAN library. Now either those interfaces need to be emulated, or the CAN library can be swapped out for another one that will work on Uno. In addition, there will be some wiring differences.

So really if Uno is all you got, the only thing this code is useful for is as a reference of the frame structure / communication protocol.
OK. So I have the two wire chip wired to my uno. There's plenty of can inferfaces on the web using that setup


I can't remember where I got my wiring diagram but that's a basic idea.

Is it possible I need two arduinos? One to run the can sketch (which I have as a library currently) and one to run not damiens code?
 

·
Registered
Joined
·
786 Posts
So that's what I was saying - you could use a different CAN library that will interface with MCP2515 from Uno, just not necessarily the one referenced in the code above. For example, in my projects I use Seeed Arduino CAN library. But switching out a CAN library will require quite a bit of code refactoring. If you have a hard time navigating it now, refactoring it to work with another library may be a non-starter. This is what I'm talking about :

void Msgs100ms() ////100ms messages here
{
digitalWrite(led, !digitalRead(led)); //toggle led everytime we fire the 100ms messages.

outFrame.id = 0x50b; // Set our transmission address ID
outFrame.length = 7; // Data payload 8 bytes
outFrame.extended = 0; // Extended addresses - 0=11-bit 1=29bit
outFrame.rtr=1; //No request
// Statistics from 2016 capture:
// 10 00000000000000
// 21 000002c0000000
// 122 000000c0000000
// 513 000006c0000000

// Let's just send the most common one all the time
// FIXME: This is a very sloppy implementation
// hex_to_data(outFrame.data.bytes, "00,00,06,c0,00,00,00");
outFrame.data.bytes[0]=0x00;
outFrame.data.bytes[1]=0x00;
outFrame.data.bytes[2]=0x06;
outFrame.data.bytes[3]=0xc0;
outFrame.data.bytes[4]=0x00;
outFrame.data.bytes[5]=0x00;
outFrame.data.bytes[6]=0x00;

/*CONSOLE.print(F("Sending "));
print_fancy_inFrame(inFrame);
CONSOLE.println();*/
Can0.sendFrame(outFrame);
}
That last line calls the CAN library to send the frame out. That will need to be replaced with whatever other library can do the same stuff on Uno given your other hardware. Of course it's often not that simple, given library calls may take different arguments, require different initialization style, etc, etc. I think if you don't have a lot of expertise, you should just get the Due board.
 

·
Registered
Joined
·
786 Posts
So what else are you intending to run on the Uno ? The only reason it's difficult to run Damien's code on Uno is the fact the code relies on hardware-optimized communication libraries written specifically for Due. If your other stuff is relatively hardware-intependent, it should work on Due.
 

·
Registered
Joined
·
14 Posts
Discussion Starter · #17 ·
So what else are you intending to run on the Uno ? The only reason it's difficult to run Damien's code on Uno is the fact the code relies on hardware-optimized communication libraries written specifically for Due. If your other stuff is relatively hardware-intependent, it should work on Due.

Ten four. I'll save the uno for some other task.
 
1 - 20 of 21 Posts
Top