Skip to content
Baldanos edited this page Sep 29, 2018 · 18 revisions

HydraFW Bus CAN (Controller Area Network)

Bus: CAN
Connections: two pins (RX/TX) and ground.
Output types: 3.3volt normal output, or open drain
(pull-up/pull-down resistors integrated in MCU or external).
Pull-up resistors: required for open collector output mode (2K – 10K).
Maximum Voltage: 5.5volts (5volt safe).

This guide is updated towards firmware release HydraFW v0.9 Beta

For hardware shield supported see https://github.com/smillier/HydraLINCAN

Protocol configuration syntax description:

  • show Show CAN parameters or show pins Show pins used in this mode

  • device with parameter 1 or 2 to choose CAN device (1 or 2)

  • speed with integer bitrate value (support k, m suffix or no suffix)

    • speed up to 2Mb/s
  • id with value specifies the frame identifier to be set

  • ts1 with value specifies the Time sequence 1 value

  • ts2 with value specifies the Time sequence 2 value

  • sjw with value specifies the resynchronization jump width value

  • slcan switch to LAWICEL/SLCAN mode

  • exit to exit CAN mode

Note default value for device 1 or 2: 
For device 1 (CAN1):
> can device 1
Device: CAN1
Speed: 500000 bps


For device 2 (CAN2):
> can device 2
Device: CAN2
Speed: 500000 bps

Configuration options:

Timing requirements

CAN bus operation depend on timing parameters which determine the accuracy of the bus sampling, but also when the node (Hydrabus) must send the ACK bit. Wrong settings in the timing parameters can lead to a bus malfunction and perturbate all other nodes on the bus.

To mitigate the impact on the bus, the CAN mode initially starts in silent mode, which allows to read frames but does not send ACK bit. As soon as the first frame must be sent, the controller is set to normal mode for the rest of the session.

To get more information about CAN bus timings, please see https://vector.com/portal/medien/cmc/application_notes/AN-AND-1-106_Basic_CAN_Bit_Timing.pdf

Hardware Informations:

can1> show pins 
TX: PB9
RX: PB8

can2> show pins 
TX: PB13
RX: PB12

Protocol interaction syntax description:

For writing, all data is split by 8 bytes (max frame data size). for example, writing ten bytes will result in sending a frame with the first eight bytes and a second with the last two bytes.

r or read Read one packet. (r:1…255 for bulk reads)

w or write Followed by values to write byte(s). (w:1…255 for bulk writes)

0 Write this Octal value. Format is prefixed by a 0 (values from 000 to 077)

0b Write this binary value. Format is 0b00000000 for a byte, but partial bytes are also fine: 0b1001.

0x Write this HEX value. Format is 0x01. Partial bytes are fine: 0xA. A-F can be lower-case or capital letters.

0-255 Write this decimal value. Any number not preceded by 0x, or 0b is interpreted as a decimal value.

" Write an ASCII-encoded string

Write support optional repeat : (eg.: 10:1…255 for repeated write of same value 10 in this example)

space Value delimiter. Use a space to separate numbers/commands. Any combination is fine, delimiter is required between each number/command, Example: 0x1 0xff 0 10 0b11 077

~ Write a random byte. (~:10 repeats the same random byte 10 times)

SLCAN

Since da84d5085a6307558bb004a9232f140f6e7b05a7, it is also possible to write packets using the LAWICEL/SLCAN format :

txxxyzz... Send a standard CAN frame using xxx as ID, y as data length and zz as data

Txxxxxxxxyzz... Send a standard CAN frame using xxx as extended ID, y as data length and zz as data

rxxxyzz... Send a RTR CAN frame using xxx as ID, y as data length and zz as data

Rxxxxxxxxyzz... Send a RTR CAN frame using xxx as extended ID, y as data length and zz as data

Example :

t1230 Sends a standard CAN frame with 0x123 as ID and no data length

T12345678411223344 Sends a standard CAN frame with extended ID of 0x12345678, with 4 bytes of data of value 0x11223344

If the value cannot be interpreted as a valid LAWICEL command, the data will be sent as an ASCII string in CAN frames

Protocol interaction example usage CAN1 write:

TBD

Additional informations about CAN bus

To be used with a real CAN bus, a CAN transceiver mus be used. See HydraLINCAN shield : https://github.com/smillier/HydraLINCAN

Before to select CAN Device to use (and init the CAN Bus) the CAN Bus shall be connected with the target CAN Bus else the init will returns bsp_can_init() error 3 which means HAL_TIMEOUT because no transceiver is connected or maybe there is a bus fault.

For more details on CAN bus see: https://en.wikipedia.org/wiki/CAN_bus

How to Flash/Use HydraFW

How to Build/Flash/Use HydraFW

Developer Getting-Started with HydraBus and STM32CubeIDE

Hardware

Firmware (hydrafw) performances

Firmware (hydrafw) Application guides

Firmware (hydrafw) guides

How to Help

Clone this wiki locally