Recieve CAN BUS signal from M150

Support forum for users of the M1 Build

Recieve CAN BUS signal from M150

Postby Prince on Sat Feb 25, 2023 12:08 am

Hello, I'm trying to send Torque data from Arduino to M150. Arduino is sending the data via CAN BUS by a CAN module. The data is 16 bits and sent as 2*8 bits chunks. In order to recieve the data in M150, I've created a DBC file in vector CANdb as below:

https://ibb.co/wNVM1Sf
https://ibb.co/Tkrm2VN
https://ibb.co/R7c517y
https://ibb.co/9qnBgyt


Then I exported the DBC to motec:

https://ibb.co/smJQB6Q

On the objects tab, I've created channel, functions and parameter:

https://ibb.co/N7qR37n

I don't know what to write in the scheduled function in order to recieve CAN BUS data. Can anyone guide me?

Thank you.
Prince
 
Posts: 9
Joined: Thu Feb 23, 2023 7:03 pm

Re: Recieve CAN BUS signal from M150

Postby adrian on Mon Feb 27, 2023 11:14 am

Firstly, is there a reason you are splitting the channel into 2 8bit channels? It's much easier to just have the 'Torque' channel in the dbc as a 16bit channel and read it directly into the M1.

Below is a document on how to write the dbc import code.
Attachments
MoTeC M1 Build Tutorial - DBC Import.pdf
(1.66 MiB) Downloaded 230 times
adrian
MoTeC
 
Posts: 718
Joined: Mon Apr 13, 2015 5:16 pm

Re: Recieve CAN BUS signal from M150

Postby Prince on Thu Mar 02, 2023 7:03 pm

I thought I could only send 8 bits per signal (because of CAN BUS 8-bit limit) but appearently the software finds a way to handle 16 bit data automatically, I've updated the dbc as below:

https://ibb.co/0fMzGG3

I decided to use the default CAN module to recieve CAN BUS so I imported "MoTeC Comms" and "MoTeC Types" into the project. Now my Object tab and recieve script which is implemented from the presentation you've given me look like this:

https://ibb.co/B4s97CN

Obviously the code I've written is not valid thus I got these errors:

https://ibb.co/7VB7pkY

I moved to the "Schedule" tab on "Partner Project Base - GPA(M150)" but couldn't access the CAN BUS update code, can you help me write mine? Thanks.
Prince
 
Posts: 9
Joined: Thu Feb 23, 2023 7:03 pm

Re: Recieve CAN BUS signal from M150

Postby adrian on Mon Mar 06, 2023 9:11 am

A CAN message has 8 bytes, so 64bits. You can send a single 64bit channel in a CAN message if you want (if you have a device that can receive them).

Have a close look at the Receive Message example on page 13 of that document, it details exactly what you should be doing. You want to be checking if you have received the CAN message, not the channel within the message.
adrian
MoTeC
 
Posts: 718
Joined: Mon Apr 13, 2015 5:16 pm

Re: Recieve CAN BUS signal from M150

Postby Prince on Tue Mar 07, 2023 9:09 pm

Oh it's my bad, okay I understood the messsage max size. So after I've reread the presentation I managed to get zero errors out of M1 build as below:

https://ibb.co/09ydD2V

Then I've built the firmware and opened in M1 Tune as below:

https://ibb.co/7N6Xhyg

Although the CAN message is being recieved in USB CANalyst software , the torque value doesn't update in Tune as I expected. My hardware is as below:

https://ibb.co/dWNNZVy

Canalyst, m150 and arduino (with mcp2515 shield) are on the same network, yourdyno is irrelevant to CAN BUS, you can see the loadcell I'm working on. I'm using D17 and D18 pins and selected "CAN BUS 1" as input bus in M1 Build properties window.

Do I need to configure anything else on M1 Tune or Build? Can you identify the problem? Or is there any way to see the raw CAN BUS signal reaching to M150?

Thank you for help.
Prince
 
Posts: 9
Joined: Thu Feb 23, 2023 7:03 pm

Re: Recieve CAN BUS signal from M150

Postby adrian on Wed Mar 08, 2023 3:07 pm

"Torque CAN Bus 1 Diagnostic" is 'Not In Use'. What do you have "Torque CAN Bus 1 Mode" set to?

If you download the Utilities package from our website here: https://www.motec.com.au/filedownload.p ... docid=3739 there is a program included called CAN Inspector. This allows you to view and log the CAN bus using the M1.

For more information on using M1 Build you can download our seminar training notes from here: https://www.motec.com.au/filedownload.p ... docid=5083
adrian
MoTeC
 
Posts: 718
Joined: Mon Apr 13, 2015 5:16 pm

Re: Recieve CAN BUS signal from M150

Postby Prince on Wed Mar 08, 2023 11:42 pm

CAN Bus 1 / Mode is set as below:

https://ibb.co/jGRLnrb

But I suppose the reason why diagnostic isn't in use is because I've unchecked the "Diagnostic Logging" box. And I've done it because it was causing an error saying: 'Diagnostic Logging condition' is not set.

To be honest, even though I've read the diagnostics and logging paragraphs of m1 build manuals I still can't comprehend fully what they are. I guess there is a channel with data type: logging mode which can get values as "run" or "stop" and it triggers a logging system to start or stop logging some variables to M1 Tune at spesific frequencies. If I am correct, this is irrelevant to my problem which is to display CAN BUS signal in M1 Tune in a meaningful way.

I tried to log CAN BUS state but failed, I won't chase that problem for now.

I've checked the CAN BUS signal with "CAN Inspector" and it gave identical values to "USB CANalyst" so what is the problem?
Prince
 
Posts: 9
Joined: Thu Feb 23, 2023 7:03 pm

Re: Recieve CAN BUS signal from M150

Postby adrian on Thu Mar 09, 2023 8:34 am

The diagnostic channel is giving you information about the CAN bus, the diagnostic logging is a completely different thing and won't have any effect on the CAN bus working or not.

You have the input object for "Torque CAN Bus 1 Mode" configured as a parameter. What do you have that parameter set to in M1 Tune?

CAN Bus Diag.png
CAN Bus Diag.png (23.75 KiB) Viewed 3428 times


In M1 Tune, on the worksheet add a calibrate window and tick 'All Items' so that you can see everything in your package. Make sure the CAN Bus Mode is set to the baud rate of your CAN bus.
adrian
MoTeC
 
Posts: 718
Joined: Mon Apr 13, 2015 5:16 pm

Re: Recieve CAN BUS signal from M150

Postby Prince on Fri Mar 10, 2023 1:18 am

I've added the calibrate window then set the baud rate and CAN BUS mode. I managed to read torque data. Thank you very much. :D
Prince
 
Posts: 9
Joined: Thu Feb 23, 2023 7:03 pm


Return to M1 Build

Who is online

Users browsing this forum: No registered users and 1 guest