CANOpen + MicroBasic simultaneously?

2 weeks 1 day ago - 2 weeks 12 hours ago #29535081 by Peter Degen-Portnoy
The goal is to have an Arduino drive the Motor Control Unit (SBLM2360T) via CAN and I've selected CANOpen because "Practically all of the controller’s real-time queries and real-time commands that can be accessed via Serial/USB communication can also be accessed via CANopen". 

Test Setup:
* Solderless breadboard using the power lines to simulate a CAN bus, 100 Ohm resistors at each end
-- Shouldn't need them on something so short & didn't have 120 ohm in my supply cabinet
-- I do have 120 ohm resistors coming, but again, the "CAN bus" is only a few inches long, so they may not be needed at all according the my research.
* 2 @ Arduino w/ Seeed CAN-BUS Shield
-- One is the master, generating a CANOpen query for the motor amps
-- One is a CAN sniffer just reading traffic on the CAN bus
* MCU configured for CANOpen, ID #2 running a MicroBasic script that looks for CAN frames and prints them (script below)
* Everyone one is at 500 KBS, CAN Standard (11 bit frame)

The CAN sniffer can successfully see what the master is generating:
* Message ID: 0x602
* unsigned char stmp[8] = {0x44, 0x20, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00}; 

But I never see the MCU detect any CAN traffic. I've also got an oscilloscope connected to the bus configured to decode the traffic, but it isn't detecting the frames. So, I'm concerned that I don't have independent verification via the scope that the CAN bus is set up correctly other than the two Arduino's are exchanging information. 

Should I expect to be able to see CAN frames with a MicroBasic script while using CANOpen? The MCU *does* support CAN and USB simultaneously; correct? If that is correct, then is it reasonable to use the Roborun+ console to view CAN activity in the MCU?

I would greatly appreciate any thoughts on where I should look next for debugging. 

Thanks,

pdp

MicroBasic script:
`top:
`  if (getvalue(_CF, 1) > 0 ) then ' If one or more frame is received`
`   header = getvalue(_CAN, 1)`
`   byte_count = getvalue(_CAN, 2)`
`   byte_1 = getvalue(_CAN, 3)`
`   byte_2 = getvalue(_CAN, 4)`
`   print(header, "\t", byte_count, "\t", byte_1, "\t", byte_2, "\r")`
`  end if`
` wait(10)`
`goto top`

Please Log in or Create an account to join the conversation.

2 weeks 14 hours ago - 2 weeks 14 hours ago #29535084 by Athanasios
Hi Peter,
you can use script and CAN  communication at the same time.
In the manual page 213 "CF-Read Raw CAN received frames count"
you need to configure the CAN mode to RawCAN in order the _CF command to work. 
I tried your script using RawCAN and listen node ID 0 and it works fine.

Please Log in or Create an account to join the conversation.

2 weeks 12 hours ago #29535085 by Peter Degen-Portnoy
Thanks Athanisios,

Thanks for your response.

I apologize if I wasn't sufficiently clear; the goal is to use CANOpen because I am under the impression that I then do not need to write MicroBasic for motor control, but can concentrate all the logic in the Arduino code. That seems to be a more efficient development process. I'd like to be able to use the SDO 0x600 Command/Query to 0x580 Response cycle without any MicroBasic code although I may want to use TPDO message to broadcast basic motor stats and I understand one uses MicroBasic to write the stats to specific variables for transmission.

At this point, I am trying to use CANOpen with MicroBasic to confirm CANOpen messages are being received and recognized and was wondering if that was possible. Perhaps there are different CAN commands in MicroBasic for reading CANOpen or perhaps MicroBasic is ignored when CANOpen SDO's and PDO's are received. I'm just not clear on the relationship between the two.

Thanks,

pdp

Please Log in or Create an account to join the conversation.

2 weeks 9 hours ago #29535086 by Athanasios
"
I'd like to be able to use the SDO 0x600 Command/Query to 0x580 Response cycle without any MicroBasic code
"
You don't need any script for the CANopen to work. you just need to configure it correctly and then int works. SDO works without any need for a script.
just send the correct message.


although I may want to use TPDO message to broadcast basic motor stats and I understand one uses MicroBasic to write the stats to specific variables for transmission.
"
this can be done with script. You just write the value you need to transmit to the variables that are already mapped for the TPDO you are using.
Though it seems better to  remap the TPDOs to send whatever data you need.
"
At this point, I am trying to use CANOpen with MicroBasic to confirm CANOpen messages are being received and recognized and was wondering if that was possible.
"
you don't need a script for this. Just send the SDO and see the response you get 

"
Perhaps there are different CAN commands in MicroBasic for reading CANOpen or perhaps MicroBasic is ignored when CANOpen SDO's and PDO's are received. I'm just not clear on the relationship between the two.
"
SDOs and Microbasic script are irrelevant. They work independently.
You send the command and the firmware replies. 

use the script you made in RAW can to see if messages arrive at the controller. As they shuld.

This way you can debag your arduino code.
I hope this answer your questions 

Please Log in or Create an account to join the conversation.

2 weeks 5 hours ago #29535088 by Peter Degen-Portnoy
Thank you so very much, this is very helpful!

Please Log in or Create an account to join the conversation.

Moderators: tonysantoni
Time to create page: 0.096 seconds