can bus library for atmega 32u4

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So I have been implementing a bit-banging protocol to control my house lights, blinds and ventilation.  arduino micro's send one's and zero's over one wire to the basement, where an uno is shift registered to controll solid state relays.  This to the point I am now looking into a more 'stable' protocol with more error-checking and adressing/prioritizing. 

 

After lots of research, the CAN-bus protocol is the perfect candidate, as it would neatly and seamlessly be integrated with the protocol I have at the moment.   Problem and question: my house is filled with arduino micro atmege 32u4 processors and there is no way I want to install or plug in another shield.  So I would like to have these micro's talk 'CAN' themselves.  Does the CAN-bus library protocol already exists for these puppies, or do I need to write this myself.

 

funny enough, google sends me round in 1.5million result circles.  What's with that!?

 

* Wrong forum. Moved. *

Last Edited: Wed. Nov 13, 2019 - 06:49 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

To do CAN you really need micros with CAN peripherals. While Atmel have a few AVR that include CAN the 32U4 does not number among these (look at things like AT90CAN128 etc).

 

In this IoT age I kind of wonder why you'd want to run cables all over houses anyway? Why not link things with WiFi or Bluetooth or Zigbee or one of the small radio modules specifically suited to micros such as NRF24L01 etc.

 

If they are Arduinos you will easily get radio module shields to attach to them. (having said that there are probably CAN shields too that contain a standalone CAN controller to interface to the AVR).

 

EDIT: yup there are CAN shields out there:

 

http://wiki.seeedstudio.com/CAN-BUS_Shield_V2.0/

https://store.arduino.cc/mkr-can-shield

 

(these all seem to use MPC chips for the CAN)

 

Still think radio is more "2019" than a Car Area Network.

 

(actually CAN is losing popularity in the place where it's traditionally been used too - there is too much data flow in modern cars for the limited bandwidth of CAN to cope so it is superceded by things like Fibex/Flexray and data over automotive ethernet (Broadreach etc) - it may be the case that in localised areas of the car some sensor/actuator connections are still on CAN but it will very quiclky pass oever a CAN/Fibex or AN/Ethernet routing bridge onto the main backbone of the car).

Last Edited: Tue. Nov 12, 2019 - 04:27 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Have you looked at S.N.A.P protocol?  Here: http://www.hth.com/snap/

 

An arduino lib is also available: https://github.com/PHaroZ/arduin...

 

This should meet your needs and uses serial, but you could bit bang it if you want to.

 

Jim

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

this is not an arduino question!! wrong decision to move it as such

 

* Well it sure didn't belong in the forum meant for discussing projects already submitted in the Projects forum for guidance of others. *

Last Edited: Wed. Nov 13, 2019 - 10:05 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hewi wrote:
arduino micro's send one's and zero's over one wire to the basement,

hewi wrote:
this is not an arduino question

No need to blow your top, most arduino's are just AVR's anyway, no one said you had to use the Arduino IDE or such, but the topic may be of interest to other Arduino users.

Good luck with your project.

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

In this IoT age I kind of wonder why you'd want to run cables all over houses anyway? Why not link things with WiFi or Bluetooth or Zigbee or one of the small radio modules specifically suited to micros such as NRF24L01 etc.

 

because all the house is already wired and plugged with AVR atmega32u4's, whom are bit-banging data to the basement, I do not want to start adding shields or extra/different hardware to implement yet another protocol.  I only need a CAN-bus lib for the atmega32u4's, but that does not seem to exist :(

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You would need CAN bus transceivers as well. One normally wouldn’t bit bang CAN unless you had a very fast processor., even then there’s plenty of micros with CAN built in. All but one chip I’m aware of requires external transceiver ics.
Bit banging a port pin connected to a significant length of wire without some form of driver/ receiver is not a good idea anyways.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
You would need CAN bus transceivers as well.
Exactly.

 

CAN is not just a packeting protocol - it's a network infrastructure - think "poor man's ethernet". It (Car Area Network) was designed specifically to set up a network inside an automobile so that all the sensors and actuators could communicate with each other and with some central ECU (Electronic Control Unit).

 

If you are saying the devices are already all cabled and connected (How? UART/SPI/I2C/LIN/oneWire/other??) then presumably what you are looking for is not an electrical interfacing mechanism (such as CAN is) but a data packeting/transport protocol to carry the data over the wires? (think "TCP/IP over Ethernet for example"!)

 

TCP/IP is probably overkill so there's a lot of simpler protocols for micros, Jim mentioned SNAP in #3 - that's a good candidate - you might also want to explore "Modbus" too.

 

Of course those are just two from quite a long list...  https://en.wikipedia.org/wiki/List_of_automation_protocols