question

vassilis-bourdakis avatar image
vassilis-bourdakis asked

two CAN bus devices on rpi: NMEA2000 (250kb/s) and diyBMS (500kb/s) - can0 and can1, How?

good evening,


don't think I manage to fit the whole question in the title, so bear with me:

Got a rpi running 2.80Large with a Waveshare HAT connected to N2K bus. Works fine, data streamed via signalK to server, all's perfect.

Now preparing my custom diy LifePO4 bank and built a diyBMS that now supports VenusOS. Tried that on another rpi4 running also 2.80 with a PCAN-USB IPEH-002021 interface. Also works fine (have to admit on first go to my amazement!)

Now for the boat I want the Waveshare HAT and the PCAN-USB to work together in one rpi.

thing is both seem to run on can0.

Q is how do I configure one of the two to shift to can1.

For the record on the gui interface they both appear as can(1), so one should move to can(2).


PCAN-USB dbus-spy with the diyBMS comes up with this:

com.victronenergy.adc
com.victronenergy.battery.socketcan_can0                            DIYBMS-004CE8AC
com.victronenergy.fronius
com.victronenergy.logger
com.victronenergy.modbusclient.tcp
com.victronenergy.modbustcp
com.victronenergy.qwacs
com.victronenergy.settings
com.victronenergy.system


WAVESHARE HAT dbus-spy with N2K connection shows:

                 
  1. Services
  2. com.victronenergy.fronius com.victronenergy.logger com.victronenergy.modbusclient.tcp com.victronenergy.modbustcp com.victronenergy.qwacs com.victronenergy.settings com.victronenergy.system com.victronenergy.vecan.can0

getting them both in the one rpi doesn't get me far as I only see one CAN-bus(1) on the gui and if I configure it at 250kbit/s N2K works fine, if I configure it at 500 I get nothing (ok, not really surprisingly...)

Edited to note that when both, PCAN-USB light doesn't flash red as when operating alone, but stays simply on all the time.

Any ideas on how I configure the USB CAN to the other can? Haven't figure out where this thing is configured!

cheers


V.

BMSVE.CanNMEA 2000 - N2K
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

3 Answers
bathnm avatar image
bathnm answered ·

Have you looked at the output of ifconfig -a, does it display two can interface? If so then take a look at https://github.com/kwindrem/VeCanSetup

There is some configuration needed to get both can interfaces up and running. Unfortunately on an RPI it is not plug and play.




1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

vassilis-bourdakis avatar image vassilis-bourdakis commented ·

thanks,

had completely forgotten ifconfig :-)

right, system was reporting only can0. A rerun of the VeCanSetup I configured both afresh. Now both can0 and can1 are configured in config.txt and as a result ifconfig -a reports this:

can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          UP RUNNING NOARP  MTU:16  Metric:1
          RX packets:115 errors:12 dropped:0 overruns:0 frame:12
          TX packets:843 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:720 (720.0 B)  TX bytes:6439 (6.2 KiB)


can1      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          UP RUNNING NOARP  MTU:16  Metric:1
          RX packets:1790 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:12384 (12.0 KiB)  TX bytes:0 (0.0 B)


can0 is N2K, works fine, can1 is BMS receives packets (wont sent anyway!) BUT something's going on and the data are NOT used by VenusOS and wont show up on the gui...

Anyway, one step at a time, I do have two can interfaces now on the system, need to figure out why system wont use the data coming in from the bms.

It's interesting to note that on the rpi4 BMS works with PCAN-USB with no can info written on config.txt. Seems that the USB interface alone works with no config. But when can hat is on the rpi, config.txt needs to be setup for it to work.

To support that, I configured ONLY can1 for the waveshare on config.txt, and nothing for can0, rebooted and surprisingly ifconfig -a only reports can0 with the can1 data (tx and rx from the N2K bus) but in the gui I get two can interfaces, can0 comes up with the BMS (working properly!), can1 with N2K (but with no data...)

Seems that what is on can0 gets to broadcast to the gui (either N2K or BMS) but second can is somehow lost on the way...

odd, more suggestions gladly welcomed!


cheers

V.


0 Likes 0 ·
vassilis-bourdakis avatar image
vassilis-bourdakis answered ·

well, turns out it's a matter or ordering...

Steps I took with PCAN-USB and Waveshare HAT connected and both can0 and can1 appearing in the gui (it's not obvious how to achieve that but I'll bypass that for now...)

So with both showing on gui, I went and disabled both in the gui (Settings->Services->can0 can1) by simply changing the CAN-bus profile to each one.

Then configured in config.txt ONLY can0 for the N2K bus Waveshare HAT as per normal.

Rebooted.

With both still disabled in gui, nothing was working.

Enabled the can0 - which in the gui shows as CAN-bus (1) CAN-bus profile:

VE.Can & CAN-bus BMS (250kbit/s)

and can1 CAN-bus (2) CAN-bus profile:

CAN-bus BMS (500kbit/s)

now both N2K and diyBMS work on the same rpi3B+.

dbus-spy shows all needed:

Services
com.victronenergy.adc
com.victronenergy.battery.socketcan_can1                                   DIYBMS-004CE8AC
com.victronenergy.ble
com.victronenergy.fronius
com.victronenergy.logger
com.victronenergy.modbusclient.tcp
com.victronenergy.modbustcp
com.victronenergy.qwacs
com.victronenergy.settings
com.victronenergy.system
com.victronenergy.vecan.can0

ifconfig -a shows both can0 and can1

root@raspberrypi2:~# ifconfig -a
can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          UP RUNNING NOARP  MTU:16  Metric:1
          RX packets:38374 errors:2154 dropped:0 overruns:0 frame:2154
          TX packets:9907 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:306892 (299.6 KiB)  TX bytes:78411 (76.5 KiB)


can1      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          UP RUNNING NOARP  MTU:16  Metric:1
          RX packets:16919 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3380 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:117128 (114.3 KiB)  TX bytes:27040 (26.4 KiB)

and candump -x can0 and can1 are both happy. And I'm happier as I can now view on my Garmins the basic BMS data like: V, A, C and W!

so looks like it's sorted. I'll try booting back 2.73 Large and configure it there as well without having them messed up that much on 2.80.


cheers

V.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

andyalford avatar image
andyalford answered ·

Not sure if this helps, but I was having problems with VeCanSetup not initialising my CANbus REC-BMS. When I dug around in the files, I found that if /etc/venus/canbus_ports was a little sensitive to content. In my case, I needed to have just "can0" and a Carriage Return, and then it initialised on boot. I will be trying a dual CAN installation in a few weeks, so I will be able to test this further soon!!

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Related Resources

Additional resources still need to be added for this topic