How to structure CAN message for Simulink+Arduino to Tinymovr communication? #329
-
IntentionI want to build Simulink Code to be run on Arduino Hardware. The Arduino is equipped with a CAN shield, which is used to connect it to the Tinymovr. I have run the Arduino examples from the website to confirm the connection is working. The Simulink code should enable the Arduino to receive position information from the Tinymovr, use it in a PID, and send back a velocity command to the Tinymovr. QuestionI am wondering how I should structure the message for the velocity command for the Tinymovr to understand it. In the screenshot below are the options that I have in Simulink. Could someone help me with how I should structure my CAN message?I am looking for information similar to the following image, about how many bits of which part of the message I should put where. Additional InformationFrom the Simulink documentation about the CAN pack block it seems CAN ID of the Tinymovr and message ID should be combined and put into the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Please take a look here: Tinymovr/studio/Python/tinymovr/channel.py Line 102 in 76b6051 These two functions pack and unpack node IDs, endpoint IDs and a hash value corresponding to the protocol version to and from CAN arbitration IDs that can be used in your messages. You will need to structure your arbitration IDs like this. For the protocol version, you can use zeros as a starting point, it is accepted. With respect to the Data Field, it is always the first n bytes, and the size n is determined by the data type. For instance, an uint8 has a size of 1 byte. An IEEE754 float has a size of 4 bytes. For messages that you send to retrieve data, the RTR bit needs to be set, and the Data Field should be empty (DLC==0) |
Beta Was this translation helpful? Give feedback.
-
As the Tinymovr periodically sends a heartbeat frame, it is possible that the limited buffers of the MCP2515 capture the heartbeat and present this when querying the input buffer. I'd suggest looking at the Arduino library and especially this code: Where the correct filter to throw away the heartbeat message is shown. Apart from that I cannot see any other reason why the message is not received, especially given that the cangaroo receives it. Regarding available command line options, including bitrate configuration, please check |
Beta Was this translation helpful? Give feedback.
Please take a look here:
Tinymovr/studio/Python/tinymovr/channel.py
Line 102 in 76b6051
These two functions pack and unpack node IDs, endpoint IDs and a hash value corresponding to the protocol version to and from CAN arbitration IDs that can be used in your messages. You will need to structure your arbitration IDs like this. For the protocol version, you can use zeros as a starting point, it is accepted.
With respect to the Data Field, it is always the first n bytes, and the size n is determined by the data type. For instance, an uint8 has a size of 1 byte. An IEEE754 float has a size of 4 bytes.
For messages that you send to re…