Help with CAN

doobedoobedo
Posts: 258
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: Help with CAN

Post by doobedoobedo »

It looks like it's a bug in Ubuntu regarding the netbeans thing.

CAN id 601 is reserved for SDO, so I mapped syncofs to id 207 (I've been trying to get the mapping of canio on id 206 working too, also with no success). Still no change.

I'm spamming 206 with a single byte of 0x50 every 100ms from the arduino.

Code: Select all

can0       206   [1]  50                        'P'
get canio returns 0. setup with: can rx canio 206 0 5 32 exactly as per the wiki

arduino code (start and forward are true):

Code: Select all

if (millis() - lastSend >= 100){
    lastSend = millis();
    udio = 0;
    if (cruise){
      udio |= B10000000;
    }
    if (start){
      udio |= B01000000;
    }
    if (brake){
      udio |= B00100000;
    }
    if (forward){
      udio |= B00010000;
    }
    if (reverse){
      udio |= B00001000;
    }
    if (bms){
      udio |= B00000100;
    }
    CAN.beginPacket(0x206);
    CAN.write(udio);
    CAN.endPacket();
  }
If it's any help all I have hooked up to the brain board is a 12V supply and CAN.

display error memory shows:

Code: Select all

[6]: WARN - HICUROFS1
[6]: WARN - HICUROFS2
[6]: STOP - OVERVOLTAGE
if that makes any difference, I don't know why
doobedoobedo
Posts: 258
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: Help with CAN

Post by doobedoobedo »

\o/ sorted canio - reversed the bit order and padded to 8 bytes

also the can command:
can rx 206 0 5 32

I expected 206 to be interpreted as hex, but no - decimal! to get can id 0x206 you need
can rx 518 0 5 32

That's an easy trap to fall in to.

Code: Select all

  if (millis() - lastSend >= 100){
    lastSend = millis();
    udio = 0;
    if (cruise){
      udio |= B00000001;
    }
    if (start){
      udio |= B00000010;
    }
    if (brake){
      udio |= B00000100;
    }
    if (forward){
      udio |= B00001000;
    }
    if (reverse){
      udio |= B00010000;
    }
    if (bms){
      udio |= B00100000;
    }
    // send packet: id is 11 bits, packet can contain up to 8 bytes of data
    //Serial.print("Sending packet ... ");
    CAN.beginPacket(0x206);
    CAN.write(udio);
    CAN.write(0x00);
    CAN.write(0x00);
    CAN.write(0x00);
    CAN.write(0x00);
    CAN.write(0x00);
    CAN.write(0x00);
    CAN.write(0x00);
    CAN.endPacket();
  }
doobedoobedo
Posts: 258
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: Help with CAN

Post by doobedoobedo »

ok so I transmit syncofs with:
can tx syncofs 519 0 16 1

with I see:

Code: Select all

can0  207   [8]  C4 09 00 00 00 00 00 00   '........'
2500 is 0x09C4 so the first two bytes are swapped

can rx syncofs 519 0 16 32
allows it to be set, but again byte order is important

Code: Select all

cansend can0 207#C409000000000000
sets to 2500

Code: Select all

cansend can0 207#DC05000000000000
sets to 1500 (0x05DC)

This is solved for me, I found this http://vi-firmware.openxcplatform.com/e ... ering.html obviously a trap for young players when it comes to CAN :). It might be worth putting this in the wiki for us noobs.
User avatar
dima
Posts: 157
Joined: Sun Dec 09, 2018 9:35 pm
Location: Canada

Re: Help with CAN

Post by dima »

This is why GUI is for newbies ;) it doesn't happen with slcan and canable-app.
doobedoobedo
Posts: 258
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: Help with CAN

Post by doobedoobedo »

Haha it may well have all been hidden from me too if I'd picked a different arduino CAN library, and some of your comments nudged me in the right direction.

Wiki definitely needs to be explicit that the can ids need to be set as decimal though as I've not seen one that wasn't in hex in documentation.
Jack-Lee
Posts: 21
Joined: Mon Jun 24, 2019 8:32 pm
Location: Germany

Re: Help with CAN

Post by Jack-Lee »

Hello,
@ Dima: I can receive the CAN message, but interpret what I should say the number (see screenshot) I can not. For me, I see no connection with the value that should actually be transferred (V.4.7.0).

What would help me:
An exact example like me put the value "Version" on the CAN and how I interpret the value read there again.
An exact example like me can set the value "Direction" for direction selection with command "X" via CAN.
Unfortunately, I can not find such a simple example anywhere, either it explains the signal structure, or it is about complex things. How a CAN command from the controller board is placed on the bus and interpreted via sniffer is somehow missing.
With such an example, I could deduce the rest myself.

Greeting,
Patrick
PS."can tx version 001 0 16 1" be a C ++ command? I only use the web interface of the Tesla board, as well as a "CANUSB" sniffer ... I do not know what to do with your hint (entered into the web interface is the sniffer's read result "08 00 00 00 00 00 00 00 ", which has no connection to the" Version "Value for me.)
doobedoobedo
Posts: 258
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: Help with CAN

Post by doobedoobedo »

You put the command into the 'send custom command' box in the web interface, then click the button.

Version only transmits the major part (in my case 4) so to see it on CAN id 0x100 you'd use:
can tx version 256 0 8 1

The numbers in order, left to right, mean:
CAN id in decimal (256 = 0x100)
start bit (bit 0 of first byte)
length of the value in bits ( 8 = 1 byte)
multiplier (1 = send as-is)

This is how the message looks to me on my sniffer

Code: Select all

can0  100   [8]  04 00 00 00 00 00 00 00   '........'
Avoid using very low CAN ids as the precedence of the message depends on how close it is to zero, flooding the bus with id zero messages is a known attack.
User avatar
dima
Posts: 157
Joined: Sun Dec 09, 2018 9:35 pm
Location: Canada

Re: Help with CAN

Post by dima »

@Jack-Lee

To avoid everyone re-learning a lot of low level CAN programming. I'm putting together a web-interface GUI.

Need Windows testers :) https://github.com/dimecho/Huebner-Inve ... indows.zip
Screenshot_2.png
Screenshot_4.png
Screenshot_5.png
Jack-Lee
Posts: 21
Joined: Mon Jun 24, 2019 8:32 pm
Location: Germany

Re: Help with CAN

Post by Jack-Lee »

Hi,

great, this works. So i tried to send the "boostcalc" (Value = 2200). The CAN Massage says 98 08 00 00 00 00 00 00 '........'
The "dir" equals "00 00 00 00 00 00 00 00". Is there a Table that show what a bit means in such situation?

But ive could controll the "pot" for Regen over CAN :)

Greetings,
Patrick

PS. Thanks for your help :)

@Dima : but how i install this? :P
I'm a mechanical engineer with a bit of electrical engineering experience. Of interface communication and programming, unfortunately, I have almost no idea. But i try to learn this too :)
Post Reply