g2 icon indicating copy to clipboard operation
g2 copied to clipboard

CAN GPIO

Open mawildoer opened this issue 7 years ago • 14 comments

Less an issue rather than the best forum I can find for this information, but I have recently developed a CAN GPIO network that I've implemented on my machine using the controller built into the DUE.

CAN is a fantastically noise resistant and capable of handling thousands of inputs using very little wire. We're currently working on boards with standard RJ45 jacks to use CAT6 Ethernet Cables to join the nodes together. These cables also carry the power for the peripheral network.

So far, I've implemented digital inputs which may be configured the same way as any other di pin.

Currently I'm working on adding heartbeats for the bus to guarantee it's running during operation.

Later we also plan to use the bus to communicate with our wireless probe and control the ATC.

I'm planning to commit the additions here soon, but it'd be great to gauge everyone's interest.

Here's a video of my machine using a probe (crudely) connected over CAN and a laser tool height setter connected the same way: Video of it probing - Youtube

Up next... closed loop, 240v servo control over SPI. I'll keep you posted ;) Photos of the PCB

mawildoer avatar Nov 11 '17 08:11 mawildoer

Excellent! Personally, I've been meaning to take a look at CAN stuff (in general), to get a better understanding of how it could be useful for us.

With the CAN GPIO bit you've been working on, is that using the g2core code as a basis or something, or is it new code which might one day be kinda useful to incorporate? :smile:

Went looking through your GitHub repositories (https://github.com/mawildoer?tab=repositories) but not seeing anything obvious there. :wink:

justinclift avatar Apr 12 '18 16:04 justinclift

Wow! Somehow I missed this issue coming in. I'd love to hear more. In particular how you're incorporating the CAN into the system.

giseburt avatar Apr 12 '18 16:04 giseburt

Both are fantastic news. This would get g2core to a whole new Level.

Keep it Up!

hurr1k4ne avatar Apr 12 '18 16:04 hurr1k4ne

Thanks guys! I'm glad there's some interest in it. I will have to make the code public now.

I actually rebuilt the GPIO section of the g2core code. It's now more OO based which is convenient given the possibility for SO many IOs that CAN opens. I've added a CAN header and modified the compiler scripts accordingly. It was based on an arduino DUE CAN library which I gutted and re-referenced the headers.

Thankfully, the CAN network seems to be extremely robust. The PSoCs we've been using as nodes have some really nice built in noise filtering making for really reliable noise free limits and laser tool height setter (as you can see in the background of the video).

Unfortunately, the project has effectively been scraped as a friend and I deffered uni to start a company based on a machining center we were developing, however I'm happy to post most of the code.

As for the servos, they worked quite well actually. They're based on Ti's Instaspin-Motion packages and the drivers we made were able to run the standard cheap Chinese servo motors pulg-n-play with awesome accuracy. We never got to the point of actually putting them on a machine though.

mawildoer avatar Apr 13 '18 00:04 mawildoer

That would be very cool. Even if it doesn’t merge with current code then we could at least utilize some of the CAN code. I’m in the middle of a GPIO refactor as well, so there may be some work merging them in but it’ll be god to see it done from a different perspective.

And whenever possible we’ll use actual commits so you get credit in the git log. Failing that accreditation in the changelog.

Thank you! -Rob

giseburt avatar Apr 13 '18 01:04 giseburt

I'm glad there's some interest in it. I will have to make the code public now.

Definitely, please do. :smile:

justinclift avatar Apr 13 '18 13:04 justinclift

They're based on Ti's Instaspin-Motion packages and the drivers we made were able to run the standard cheap Chinese servo motors pulg-n-play with awesome accuracy. We never got to the point of actually putting them on a machine though.

As a thought, it there any chance you'd throw the design for the drivers you made, online somewhere under an Open Source license of some variety? Just thinking it might be useful, so the next person wanting to do stuff in this area has a potentially easier time of it. :smile:

justinclift avatar Apr 13 '18 13:04 justinclift

@mawildoer Reminder ping. :smile:

justinclift avatar Apr 19 '18 17:04 justinclift

Thanks guys, I've made the repo for all our work on g2core public. I'm sorry about the mess it's in, but it shouldn't take long to get the structure in. A few commits ago, there was work on a major revision and it may be wise to go a few back for the most stable work.

https://github.com/geratech/controller

As for the servos, certainly nothing special going on there. All the schematics are available from Ti for free, all we did was re-lay them out suitable for a higher voltage.

mawildoer avatar Apr 22 '18 10:04 mawildoer

That's Awesome @mawildoer, thanks heaps! :smile:

No worries at all about the state it's in. Some of my dev code is all kinds of interesting (not the good sort) while I'm trying to figure something out. Shouldn't be a problem. :wink:

A few commits ago, there was work on a major revision and it may be wise to go a few back for the most stable work.

With the branches there, the two main ones with work in them appear to be the can_ths one and master. Err... could you point out the commit where the (potentially unstable) work on a major revision started? Just to know where to draw an initial imaginary line in the sand. :smile:

justinclift avatar Apr 22 '18 12:04 justinclift

I reckon the first working (obviously the simplest) is called "CAN fucking works now. woop woop. THS on pin 9" -- It was around 3am I believe

Tracking through those master commits, it looks like I did a better job than I remembered keeping master clean enough.

mawildoer avatar Apr 23 '18 10:04 mawildoer

Thanks @mawildoer. :smile:

justinclift avatar Apr 23 '18 13:04 justinclift

Just as potentially useful reference info for anyone else looking into the CAN side of things with the Arduino Due, this site has plenty of Due relevant info:

  • http://copperhilltech.com/blog/arduino-due-can-bus-controller-area-network-interfaces/

Saying that after reading way too much about CAN today. Most CAN stuff around isn't Due specific, and the above website (copperhilltech.com) has lots that is. Including CAN transceiver shields for the Due.

justinclift avatar Apr 26 '18 00:04 justinclift

Thanks for the reference Justin. That's actually where I got started with it as well. Great reference and useful for debugging as well

mawildoer avatar Apr 26 '18 02:04 mawildoer