DPC-CAN/PROTOCOL/ENG

From HITEC_HELP
Jump to navigation Jump to search

What is DPC-CAN ?

  • DPC-CAN is setup and test Interface for HiTEC RCD CAN Servo.
  • Serial Communication via CP2xxx
  • CAN 2.0B Interface
    • CAN 2.0A message, 2.0B message
  • USB connector.
  • 3 pin power connector.
    • GND, POWER+, NC
  • 4 pin CAN connector.
    • GND, POWER+, CANL, CANH
  • You can use CANL, CANH without GND, POWER+.
    • We recommand use GND with CANL/H.

Packet

<Start Flag>, <Msg: n byte>, <Add Checksum of Msg>, <MsgLen = n>, <End Flag>
  • You must use packet form to send Msg or parsing Msg.
    • Except FIXED FORMAT.
    • ex) Write n bytes: xxxxx
  • Host -> DPC-CAN
    • Start Flag = STX = 2, End Flag = ETX = 3
  • DPC-CAN -> Host
    • if CAN Recv Msg, Start Flag = STX+2 = 4, End Flag = ETX+2 = 5
    • if Error Msg, Start Flag = STX+4 = 6, End Flag = ETX+4 = 7

Connect

  • Connect DPC-CAN to PC.
  • Open Serial Port
    • 115200 bps, 8, n, 1
  • Write: 6 bytes: ':', 'A', ':', 'A', ':', 'A'
  • Wait 500 msec
  • Write: 4 bytes: 2, 'X', 'X', 3
  • Wait 100 msec
  • Clear recv buffer
  • Write: 8 bytes: 2, 'V', 'S', 0, 0, 0, 0, 3
  • Wait 500 msec
  • Read all recv bytes
    • Find Value 4
    • get next 2 bytes
    • format = 4, <VER H>, <VER L>
  • Check Version of DPC-CAN
  • Init DPC-CAN
  • Now You can send or recv CAN 2.0A, 2.0B messages.
  • Connect Servo to DPC-CAN
  • Power On Servo

Version

  • VER H
    • bit 7..4:
      • 0 or 1 = Bootloader Type 1 = B1
      • 2 = Bootloader Type 2 = B2
    • bit 3..0:
      • 0 or 1 = DPC-CAN FW V1
      • 2 = DPC-CAN FW V2
  • VER L
    • Firmware Version
    • ex) 23 -> Ver 2.3
  • YOU MUST CHECK DPC-CAN FW V2, Ver 2.2+

Disconnect

  • Close Serial Port

Init

'S' - set baudrate, sample point

'S', <speed index>, <sampling point index>
  • ex) 'S', 0, 0 --> 1000 kbps, 50%
  • speed table
    • 0 = 1000
    • 1 = 800
    • 2 = 750
    • 3 = 500
    • 4 = 400
    • 5 = 250
    • 6 = 200
    • 7 = 150
    • 8 = 125
  • sampling point
    • 0 = 50%
    • 1 = 87.5% (recommanded)

'T' - set default target can id

'T', <CAN ID byte 0>, <CAN ID byte 1>, <CAN ID byte 2>, <CAN ID byte 3>
  • You can send 'M' Msg, after this setting.
  • CAN ID
    • little endian
    • if CAN ID byte 3, bit 7 is 1, this is 2.0B CAN ID.

'?' - get configuration

  • You can get CAN baudrate and DEFAULT TARGET CAN ID.
  • SEND
    • Write 3 bytes: 2, '?', 3 --> THIS IS NOT PACKET FORM
  • RETURN
'U', <can speed index>, <can sample point index>, <ID byte 0>, <ID byte 1>, <ID byte 2>, <ID byte 3>

send can message

  • You must use packet form
    • Start Flag = STX, End Flag = ETX

'M' - send CAN message with default target can id

'M', < data byte 0 >, ..., < data byte n-1 >
  • Msg length is 1 ~ 9 bytes.
  • ex) send CAN 2.0A message "HELLO" with default can id
    • 'M', 'H', 'E', 'L', 'L', 'O'

'A', 'C' - send CAN 2.0A message

'A', <CAN ID byte 0>, <CAN ID byte 1>, <data byte 0>, ..., <data byte n-1>
  • Msg length is 3 ~ 11 bytes.
  • ex) send CAN 2.0A message "HELLO" with CAN ID 0x123
    • 'A', 0x23, 0x01, 'H', 'E', 'L', 'L', 'O'
  • if you use 'C' instead of 'A', default target can id will be changed.

'B', 'D' - send CAN 2.0B message

'B', <CAN ID byte 0>, <CAN ID byte 1>, <CAN ID byte 2>, <CAN ID byte 3>, <data byte 0>, ..., <data byte n-1>
  • Msg length is 5 ~ 13 bytes.
  • ex) send CAN 2.0B message "HELLO" with CAN ID 0x12345678
    • 'B', 0x78, 0x56, 0x34, 0x12, 'H', 'E', 'L', 'L', 'O'
  • if you use 'D' instead of 'B', default target can id will be changed.

read messages

  • if DPC-CAN recv normal CAN message from CAN network, DPC-CAN send CAN Data in packet form to PC.
    • Start Flag = STX+2 = 4, End Flag = ETX+2 = 5
  • if DPC-CAN detect error, DPC-DPC send error Msg in packet form to PC.
    • Start Flag = STX+4 = 6, End Flag = ETX+4 = 7

error messages

  • "SET" message
    • You need setup baudrate and sample point to send any packet.
  • "ID" message
    • You need setup default target can id to send 'M' Msg.

recv CAN message

  • only One format
<CAN ID byte 0>, <CAN ID byte 1>, <CAN ID byte 2>, <CAN ID byte 3>, <data byte 0>, ..., <data byte n-1>
  • Msg Length is 4 ~ 12 bytes.
  • CAN ID is 4 byte fixed.
  • if CAN ID byte 3 bit 7 is 1, this is CAN 2.0B message.
  • ex) 0x78, 0x56, 0x34, 0x92, 0x99
    • CAN 2.0B Message, ID = 0x12345678, Data Len = 1, Data = 0x99