The Revision 2 main board supports CAN communication. The CAN bus can be used for configuration and for obtaining values like voltages, input states etc. The CAN messages are configurable and can be adjusted to be compatible with existing equipment.
Since firmware 3.75 throttle and digital inputs can be controlled via CAN.
Controlling throttle via CAN
If you want to send the throttle and regen magnitude commands via CAN rather then via analog inputs you have to set "potmode" to "CAN" (=2). Next you have to map a CAN message to pot and optionally pot2. So say you have a digital throttle that sends values from 0 to 1000 for 0 to 100% travel on CAN-Id 100 in the first two bytes.
- Configure potmin=0 and potmax=1000
- Map CAN message to pot: can rx pot 100 0 16 32
The last parameter, 32, tells the CAN module to apply the internal fixed point scaling.
CAN messages must be received every 500ms, otherwise throttle times out and is set to 0.
Controlling Digital IO via CAN
6 signals, namely cruise, start, brake, forward, backward and bms can be controlled via CAN. The CAN message is ORed to the physical inputs so you can have mixed signals also. Digital CAN IO doesn't need to be explicitely configured, it works as soon as you map a CAN message to "canio". "canio" is bit-encoded:
- Bit 0: cruise
- Bit 1: start
- Bit 2: brake
- Bit 3: forward
- Bit 4: reverse
- Bit 5: bms
So say you have a BMS that transmits an over/under voltage bit on CAN Id 200, 2nd data bit
can rx canio 200 2 1 1024
Note the 1024x gain that shifts the bit into the correct position (5 fraction bits plus 5th data bit). In this case all other IOs remain traditional, only BMS is controlled via CAN. Note that you cannot map multiple CAN messages onto "canio" as they would overwrite each other.
If you have a managed to mangle all 5 bits into one message, say CAN Id 300, first 5 bits the mapping is done like so
can rx canio 300 0 5 32
The same timeout mechanism is used as for throttle control, so after 500ms with no message the CAN-mapped inputs are assumed off. Traditional inputs remain unaffected.
Setting and reading parameters via SDO
The abbreviation SDO is taken from the CANOpen protocol. It assigns a certain meaning to the 8 data bits of a CAN frame.
|Purpose||CAN-Id||Byte 1 (Cmd)||Bytes 2-3 (Index)||Byte 4 (Subindex)||Bytes 5-8 (Data)|
|Set Value||0x601||0x40||0x2000||Value Index||Value x 32|
|Set Value Reply||0x581||0x23||0x2000||Value Index||Value x 32|
|Get Value||0x601||0x22||0x2000||Value Index||don't care|
|Get Value Reply||0x581||0x43||0x2000||Value Index||Value x 32|
|Map Value TX to COB ID yyy||0x601||0x40||0x3yyy||Value Index||Byte 5: bit offset, Byte 6: bit length, Bytes 7,8: scaling|
|Map Value RX to COB ID yyy||0x601||0x40||0x4yyy||Value Index||Byte 5: bit offset, Byte 6: bit length, Bytes 7,8: scaling|
|Abort - invalid index||0x581||0x80||Index of request||Value Index||Abort Code = 0x06020000|
|Abort - value out of range||0x581||0x80||Index of request||Value Index||Abort Code = 0x06090030|
The value index must be determined by counting the output of the list command. E.g. "boost" at the very top has index 0, potnom has index 77. The indexes can change over firmware versions as new parameters are added somewhere in between.
0x601 # 0x22 0x00 0x20 0x00 0 0 0 0 Get value of "boost"
0x601 # 0x40 0x00 0x20 0x01 0x80 0x0C 0 0 Set "fweak" to 100Hz (0xC80=3200 because scaled by 32)
0x601 # 0x40 0xAA 0x31 0x01 0x08 0x10 1 0 Map value of fweak to COB ID 0x1AA, starting at bit 8, stretching 16 bits, scaled by 1
Mapping values to arbitrary CAN messages
Values can be mapped into a certain bit range of the 64 payload bits of a CAN message. They can either be read from the message or sent via a message. To do so enter
can tx udc 123 0 16 10
This maps the value of udc to a CAN message with id 123 bits 0..15 (start at bit 0, span over 16 bits) with a gain of 10.
can tx din_forward 123 24 1 1
would map the pin state of the forward input to bit 24 of CAN message with id 123.
If you want to clear all messages, type
If you want to remove only a specific signal (starting version 4.18.R) type
can del <name>
To save your can map simply type "save".
- A maximum of 10 messages can be defined
- Per message a maximum of 8 values can be mapped
- a value can not span across the 32-bit boundary, i.e. it must be fully contained in the first or second 32 bits of the message. E.g. "can tx udc 123 16 32 10" is not allowed
- A value can span maximum 32 bits
CAN messages sent to, or received from the inverter are Little-endian.
If you are sending or receiving messages containing multi-byte values then the byte order must be taken into account.