Moto Hawk Training CAN Controller Area Network 1
- Slides: 33
Moto. Hawk Training CAN Controller Area Network 1
OUTLINE • CAN Introduction • CAN Physical Network • CAN Message Format • Moto. Hawk Block Walk Through • Moto. Hawk “Post Office” • Moto. Hawk Advanced CAN Blocks • CAN Protocol Overview 2
INTRODUCTION • CAN = Controller Area Network § Communication specification implemented for automotive applications in the 1980 s • Often, the term “CAN” is misused § CAN is a hardware definition for interoperability between modules § CAN specification does not state the data content of a given message § Protocols built on top of CAN state the data content (ex. J 1939, GMLAN) • Moto. Hawk doesn’t define a protocol, but allows access to the CAN hardware to implement a protocol • By itself, CAN is not difficult (I mean it) 3
OUTLINE • CAN Introduction • CAN Physical Network • CAN Message Format • Moto. Hawk Block Walk Through • Moto. Hawk “Post Office” • Moto. Hawk Advanced CAN Blocks • CAN Protocol Overview 4
PHYSICAL NETWORK • Two wire robust serial communication • Up to 1 Mbps data rate which is limited by wire length § 100 m @ 250 Kbps § 30 m @ 1 Mbps • Termination resistance required • Maximum bandwidth § 2000 messages per second @250 Kbps § 4000 messages per second @500 Kbps § 8000 messages per second @1 Mbps • Designed bandwidth should not exceed 70% of the maximum bandwidth 5 CAN - CAN + 120 Ω Wire Length
PHYSICAL NETWORK • Bus arbitration is handled with a simple strategy § All modules on the bus attempt to transmit a message at the same time § The message with the lowest address wins • This strategy is handled at the hardware level § Dominant Bits (0) vs. Recessive Bits (1) • Multiple modules on the same bus cannot transmit the same address at the same time Module 0 continues to transmit while Module 1 waits for next opportunity to transmit Module 0 Module 1 T 0 6 T 1 T 2 T 3
OUTLINE • CAN Introduction • CAN Physical Network • CAN Message Format • Moto. Hawk Block Walk Through • Moto. Hawk “Post Office” • Moto. Hawk Advanced CAN Blocks • CAN Protocol Overview 7
MESSAGE FORMAT • A CAN 2. 0 B Message can contain up to 131 bits • As application developers, 3 fields are important: § 4 bits determine the length of the data (aka payload) (Range : 0 -8) § Up to 64 bits of data depending on data length § ID Format • Extended IDs are 29 bits • Standard IDs are 11 bits • Extended and Standard IDs can exist on the same bus at the same time • Standard IDs have less message overhead (higher percentage of data per message) 8
OUTLINE • CAN Physical Network • CAN Message Format • Moto. Hawk Block Walk Through • Moto. Hawk “Post Office” • Moto. Hawk Advanced CAN Blocks • CAN Protocol Overview 9
CAN DEFINITION BLOCK • First, the CAN hardware needs to be initialized • Baud rate and transmit queue size configured • If the baud rate and/or Moto. Tune protocol settings are not configured properly, then Moto. Tune can’t talk to the module via CAN (and therefore programming cannot be performed via CAN) § Boot key sets CAN baud rate to 250 kbps 10
Send CAN Raw Block 11
CAN Exercise #1 • CAN Bus Test § Construct a calibratable CAN message transmitter § Use CANKing to monitor bus traffic System Diagram 12
OUTLINE • CAN Introduction • CAN Physical Network • CAN Message Format • Moto. Hawk Block Walk Through • Moto. Hawk “Post Office” • Moto. Hawk Advanced CAN Blocks • CAN Protocol Overview 14
POST OFFICE • CAN is the hardware layer, so how are transmitted messages sorted and filtered in Moto. Hawk? • A Post Office is the simplest analogy § Mailboxes § Letters § Addresses § Zip Codes 15
POST OFFICE • Many messages are transmitted on a bus at a given time, but a module may only be interested in a small subset § Similar to a post office where the messages are letters and the software dispatcher is the postman § A “mail box” in Moto. Hawk is called a “slot” 16
POST OFFICE • A “slot” has an address known as a CAN ID similar to the address on a mailbox • The Moto. Hawk post office needs to deliver messages to these slots • How does it happen? 17
POST OFFICE • Filtering is done with 2 masks § ID Mask : Filters a message by the address or the ID § Payload Mask : Filters a message by the data content • A mask is similar to assigning a “Don’t Care” or a “Do Care” to a particular number in the mask 18
Filtering • Filtering is done with 2 masks § ID Mask : Filters a message by the address or the ID § Payload Mask : Filters a message by the data content • A ‘ 1’ in the mask means that the data and the value must match exactly § For example, 19 • if ID mask = 0 x 7 F 0 (111 1111 0000) • and ID = 0 x 7 E 4 (111 1110 0100) • If incoming ID = 0 x 7 E 0, (111 1110 0000) message goes to mailbox • If incoming ID = 0 x 7 F 4, (111 1111 0100) x message is rejected by mailbox • If incoming ID = 0 x 7 E 1, (111 1110 0001) message goes to mailbox
READ CAN RAW BLOCK 20
POST OFFICE • The “Slot Name” is the name of the mailbox at the post office • The slot has default settings for the ID, ID Mask, Payload Value, and Payload Mask • This is the design time mailbox configuration 21
POST OFFICE • The properties of the mailboxes can be changed at run time • The filters determined at design time can be strengthened (more restrictive), but cannot be weakened • In Moto. Hawk, the CAN Receive Slot Properties Block allows the user to change the filters at run time 22
POST OFFICE • What happens if the postal worker rings your doorbell to deliver a message? § This is an asynchronous reception of a message § The advantage is that processing time can be saved by not periodically polling this message • How does Moto. Hawk handle this situation? § Asynchronous reception processed with CAN Receive Slot Trigger Block § Slot name in this block must match the slot name specified in Read CAN Raw block or Read CAN Message block 23
OUTLINE • CAN Introduction • CAN Physical Network • CAN Message Format • Moto. Hawk Basic Transmit Block § Exercise • Moto. Hawk “Post Office” • Moto. Hawk Advanced CAN Blocks • CAN Protocol Overview 24
MOTOHAWK ADVANCED CAN • The Read and Send CAN blocks are nice, but sometimes more advanced data parsing is necessary. Common questions: § I have 12 bit scaled data that spans across multiple bytes. How do I convert it into engineering units? § I have more data that can fit into 64 bits. How do I create multi-page messages? § I’m using a protocol that has a variable ID. How do I dynamically create the ID easily? • These are valid questions and there is an answer… 25
MOTOHAWK ADVANCED CAN • Moto. Hawk has 2 blocks – Read CAN Message and Send CAN Message (below) • These are very powerful blocks that allow users to set up multi-page documents and parse and scale both variables and IDs 26
MOTOHAWK ADVANCED CAN >> edit motohawk_can_example. m 27
LITTLE ENDIAN vs BIG ENDIAN • Terminology originates from “Gulliver’s Travels” • “Endianness” refers to the order in which bytes are stored in memory • This table shows the 4 byte storage for 1025 (0 x 41) 28 Address Big Endian Representation Little Endian Representation 00 0000 0001 01 0000 0100 02 0000 0100 0000 03 0000 0001 0000 • By default, the Moto. Hawk CAN scripts use Big Endian byte ordering…which can lead to confusion
LITTLE ENDIAN vs BIG ENDIAN Given this CAN definition byte ordering for a 4 byte variable: Big Endian Little Endian LSB 63. . . …. 56 MSB 55. . . …. 48 47. . . …. 40 MSB 39. . . …. 32 Now, go let’s back to the script definition… 29 LSB
OUTLINE • CAN Introduction • CAN Physical Network • CAN Message Format • Moto. Hawk Basic Transmit Block § Exercise • Moto. Hawk “Post Office” • Moto. Hawk Advanced CAN Blocks • CAN Protocol Overview 30
CLASS EXERCISE • Create a distributed control system to control the ETC over CAN Pedal Duty Cycle Analog signal from potentiometer CAN message send TPS % City ID 0 x 81 CAN message receive TPS % Analog signal from ECT Duty Cycle CAN message receive 31 TPS % CAN message send Duty Cycle PWM output City ID 0 x 0 B
CLASS EXERCISE Duty Cycle message definition CAN 1 ID Type : Standard (0) ID : 0 x 1 F 4 ID : 0 x 2 F 4 Data Length : 2 Bytes Data Length : 1 Byte Transmission Rate : 10 ms Transmission Rate : 15 ms Data Field Duty Cycle (SIGNED) Scale : 200/65, 535 Offset : 0 Start bit: 48 Size: 2 bytes 32 TPS Percent message definition TPS Percent (UNSIGNED) Scale : 100/255 Offset : 0 Start bit: 56 Size: 1 byte
PROTOCOL OVERVIEW • CAN gets complicated when protocols are considered § J 1939, Smart. Craft, CCP, GMLAN, etc. are all examples of protocols that adhere to strict rules • These protocols can be implemented using Simulink and/or Stateflow • Some message formats (J 1939) have already been implemented for other projects 33
Moto. Tron Control Solutions Production Controls in a Flash
- Controller area network training
- Moto moto
- Controller area network nedir
- Hawk roosting context
- Imaginary feelings i am poem
- Ozymandias explanation with quotations
- Kittyhawk
- Hawk roosting by ted hughes
- An analysis of evening hawk poem essay
- Marsh hawk trophic level
- Hawk d'onofrio
- Inference context clues examples
- Hawk roosting annotations
- Are bears secondary consumers
- Black hawk
- George catlin (political scientist)
- Hawk us
- Uihc billing
- Red hawk indian
- Food chain of robin worm and hawk
- Hawk router table
- Stud ip hawk
- Cody hawk
- H is for hawk structure
- Little hawk cartoon
- Earth resources kitty hawk
- "power factor correction"
- Incident at hawk's hill summary
- Prs registration
- Animal behavioral adaptations examples
- Con moto jelentése
- Accelerazione zanichelli
- Gravitazione zanichelli
- Origine