| 1 | = CANbus Communication Specifications = |
| 2 | |
| 3 | == Data Link Specifications == |
| 4 | * 1Mbaud CANbus |
| 5 | * 8 time quanta per bit |
| 6 | * 75% sampling point |
| 7 | * Sync jump width = 1 time quanta (TQ) |
| 8 | * 11-bit MsgID (standard CAN) |
| 9 | * Proprietary protocol, not !DeviceNet or CANopen |
| 10 | * Recommended reading: Controller Area Network by Konrad Etschberger |
| 11 | |
| 12 | == CANbus Timing == |
| 13 | * 75μS to ask for position |
| 14 | * 75μS per puck to respond with the positions |
| 15 | * 125μS to send a packed torque to the lower 4DOF |
| 16 | * 125μS to send a packed torque to the wrist |
| 17 | * Control-side processing time on PC |
| 18 | |
| 19 | For the 4DOF, it is: 75+(4*75)+125+PC = 500μS + PC |
| 20 | For the 7DOF, it is: 75+(7*75)+(2*125)+PC = 850μS + PC |
| 21 | |
| 22 | These numbers are limited by the 1 Mbps CANbus. Each message has a 47-bit frame (47μS), plus payload data (3 bytes, 24μS typ). CANbus transceivers are not rated above 1 Mbps due to slew-rate limitations. |
| 23 | |
| 24 | == ID Specifications == |
| 25 | |
| 26 | === Message IDs === |
| 27 | * [GFFFFFTTTTT] (11 bits, binary) |
| 28 | * G: Group, 0 = Directed message, 1 = Group broadcast |
| 29 | * F: From ID, Host = 00000, Motor N = N |
| 30 | * T: To ID or group |
| 31 | |
| 32 | Examples: |
| 33 | * 00000000011 => Directed message from host to motor 3 (3 = 00011, binary) |
| 34 | * 10001100100 => Group broadcast from motor 3 to group 4 |
| 35 | |
| 36 | === Motor IDs and Groups === |
| 37 | Each motor in the robot has a unique communication ID, can be a part of any three groups (GRPA, GRPB, GRPC), and will listen for and process messages bound for its ID or any of its groups. There are a total of 32 possible groups (from 00000 to 11111). Motors 1 to 4 belong to groups 0, 1, and 4, motors 5 to 7 belong to groups 0, 2, and 5, and the host belongs to groups 3 and 6 by default. The default groups are: |
| 38 | * 0 = All actuators |
| 39 | * 1 = Lower arm torques (motors 1-4) |
| 40 | * 2 = Upper arm torques (motors 5-7) |
| 41 | * 3 = Position feedback |
| 42 | * 4 = Lower arm property |
| 43 | * 5 = Upper arm property |
| 44 | * 6 = Property feedback |
| 45 | |
| 46 | == CANbus Frame Data Payload == |
| 47 | |
| 48 | === Standard CANbus Message Format === |
| 49 | CAN specifies a maximum of 8 bytes/frame payload – our typical payload consists of 4-6 bytes: |
| 50 | [APPPPPPP] [00000000] [LLLLLLLL] [mmmmmmmm] [MMMMMMMM] [HHHHHHHH] |
| 51 | * A: Action, 0 = Get property, 1 = Set property |
| 52 | * P: Property (128 possible values, 0..127, 0000000..1111111), see Motor Controller Properties and Safety Module Properties below. |
| 53 | * 0: Second byte (almost) always set to zero (see exceptions below) |
| 54 | * L: Low byte of data value |
| 55 | * m: mid-low byte of data value |
| 56 | * If sending a 16-bit integer value, the following are not used: |
| 57 | * M: Mid-high byte of data value |
| 58 | * H: High byte of data value |
| 59 | |
| 60 | The CAN frame data length code (DLC) is set to the number of bytes being transmitted. |
| 61 | |
| 62 | === Exceptions === |
| 63 | 1. The Position property (P) is a 22-bit, 2's complement number. It is packed into a 3-byte frame payload [00MMMMMM] [mmmmmmmm] [LLLLLLLL]. It is always sent to Group 3. |
| 64 | |
| 65 | 1. Command torque can be sent as a set of four 14-bit, 2's complement numbers. It is sent to the motor controllers in 8 bytes (max): |
| 66 | |
| 67 | ||0||1||2||3||4||5||6||7 |
| 68 | ||APPPPPPP||BBBBBBbb||bbbbbbCC||CCCCcccc||ccccDDDD||DDdddddd||ddEEEEEE||eeeeeeee |
| 69 | |
| 70 | * A = Action |
| 71 | * P = Property |
| 72 | * B = Upper 6 bits of first value |
| 73 | * b = Lower 8 bits of first value |
| 74 | * C = Upper 6 bits of second value |
| 75 | * c = Lower 8 bits of second value |
| 76 | * D = Upper 6 bits of third value |
| 77 | * d = Lower 8 bits of third value |
| 78 | * E = Upper 6 bits of fourth value |
| 79 | * e = Lower 8 bits of fourth value |
| 80 | |
| 81 | Each motor has a property (PIDX: 1-4), which tells it which torque to use from the set of 4 |
| 82 | |
| 83 | == Full Communication Example == |
| 84 | This example contains: |
| 85 | * 3 motors with IDs of 5, 6, and 7 |
| 86 | * A host with an ID of 0 |
| 87 | |
| 88 | '''Host sends:''' |
| 89 | * MsgID [10000000000] → Group 0 |
| 90 | * Data [10000101] [00000000] [00000010] [0000000] → Set property 5 (STAT) to 2 (STATUS_READY) |
| 91 | * The motors start up with STAT = 0 (STATUS_RESET) |
| 92 | * Setting STAT to READY gets the motors ready to receive additional data |
| 93 | * Motors will only respond to STAT and VERS commands while in RESET (for safety) |
| 94 | |
| 95 | '''Host sends:''' |
| 96 | * MsgID [10000000000] → Group 0 |
| 97 | * Data [10001000] [00000000] [00000010] [00000000] → Set property 8 (MODE) to 2 (MODE_TORQUE) |
| 98 | * The motors default to MODE = 0 (MODE_IDLE) |
| 99 | * Setting MODE to MODE_TORQUE tells the motors to apply any torque sent to them |
| 100 | * When MODE = MODE_IDLE, motors will ignore any torque commands sent and apply braking |
| 101 | * When using a WAM, the safety system will set the MODE when you press the IDLE/ACTIVATE buttons |
| 102 | * Do not try to bypass the WAM’s safety system by setting the MODE directly, this will cause undesired operation. |
| 103 | |
| 104 | '''Host sends:''' |
| 105 | * MsgID [10000000000] → Group 0 |
| 106 | * Data [00110000] → Get property 48 (P) |
| 107 | |
| 108 | '''Motors send:''' |
| 109 | * MsgID [10010100011] → From ID 5 to Group 3 |
| 110 | * Data [00000000] [00000000] [0000010] → My position is 2 encoder counts |
| 111 | * MsgID [10011000011] → From ID 6 to Group 3 |
| 112 | * Data [00000000] [00000000] [0000111] → My position is 7 encoder counts |
| 113 | * MsgID [10011100011] → From ID 7 to Group 3 |
| 114 | * Data [00111111] [11111111] [11111110] → My position is -2 encoder counts |
| 115 | |
| 116 | Host uses these positions to calculate a torque. |
| 117 | |
| 118 | '''Host sends:''' |
| 119 | * MsgID [10000000010] → Group 2 |
| 120 | * Data [10101010] [AAAAAAaa] [aaaaaaBB] [BBBBbbbb] [bbbbCCCC] [CCcccccc] [cc000000] [00000000] |
| 121 | * Set torques to new values AAAAAAaaaaaaaa, etc. |