Home Creators Posts Import Register Favorites Logout
haven't archived this post yet. have a subscription? use the importer!

Content

Happy New Year to everyone. Thanks for your ongoing support for my channel and projects!

I decided not to post videos for a couple of weeks over the Holiday season, but I've still been busy. Some CAN Bus testing has been taking place. See:  https://en.wikipedia.org/wiki/CAN_bus 

I'm using three Teensy 3.1 and 3.2, and one Teensy 3.6. Although Teensy 3.2+ supports CAN Bus directly you still need a CAN Bus transceiver to transmit the data over long distances. This makes a differential signal which means that if noise occurs on the transmission line, it occurs on both pairs of cable, but the difference between them is still the same. 

This principle is the same as RS485 (which is what DMX uses), but RS485 is only half duplex which makes managing sending and receiving data a little more tricky. CAN Bus is 'Multi-Master', so any node can transmit or receive at any time and the CAN protocol sorts it out. 

Each node has an ID which gives it a priority, but provided I leave a 1ms delays in my transmitting loop then all my data gets through from all three nodes that are transmitting. If I remove the delay then the highest priority always wins, but running at 1000Hz is fine for me. Otherwise I'd need to implement a system of polling each node in turn and waiting for that node to reply, which is what you'd have to do with RS485, but it appears that probably isn't necessary for most applications.

I found there are lots of forks of the FlexCAN library for Teensy, the only one I could make work is:  https://github.com/tonton81/IFCT  . My transceivers are based on the SN65HVD230 / PCA82C250  apparently - I just got them from eBay in a five-pack for £6.99.

The only limiting factor is that the library only allows sending 8-bit variables, but the bits can be split and combined with various Arduino functions at each end to make 16-bit or higher variables. Looks like it'll run up to 1Mbit. 

I waved the wires next to the openDog while the motors were powered up and everything seems good. I should be using twisted pairs really, for now the transmission wires are just close to each other.

So this definitely has a place in multiple projects. openDog is the obvious one since that's where I left off in the last video. However any project that needs distributed sensors and uses brushless motors would benefit.  In fact I have another project for early 2020 which will be using ODrives/Brushless motors and also the same load cells as openDog, so this will probably be the first candidate.

I'm considering a dedicated video about this CAN Bus setup, although I may just combine it with the next openDog video.

Files

Previews only

Comments

Steve Martin

A separate video focusing on this is a great idea

Steve Martin

I'd also like you to do a video on your remote system, components and code for a basic system which you then build from

XRobots

I still need to do some work on that one - I never got data transmission in both directions that ran fast enough. It's the NRF24L01 I'm using though.

Simon

Just a small note: Usually for CAN one ID is used per message type and not per node. The anti-lock braking system controller sends both the current speed and braking data. The data is sent under different identification numbers.

Simon

Oh and usually CAN allows 8 times 8 bits = 64bits of data.

John N Nelson

Very interesting. I've worked with RS-485 in the electric power grid monitoring. I look forward to learning more about CAN Bus.

Neil Devonshire

Happy New Year James. You could use Cat-6 cable as it's twisted and screened, I know cars are very noisy environments for EMI/RFI where most systems in the car are not screened and radiate all over the place, where the CAN bus is very reliable. Your system will be stable with CAN unless it's the receiving/transmitting equipment inducing the noise. Looking forward to your projects in 2020

ingmar meins

Cool stuff James. Happy New Year from (currently) the 2nd worst air quality in the world here in Canberra. Surrounded by huge bush fires all along the east coast of Australia.

XRobots

That makes sense. The library uses an array of 8-bit variables for the message.