06-24-2019 10:43 PM
I want to use Canopen to control muti-axis,by using Canopen example code "CANopen Read Write CAN Frame",one axis is driven successfully.When I add for loop to input an array data,for loop in the WHILE loop is not function.Does anyone know the reason? or How to contorl muti-axis by canopen with NI9881?
Solved! Go to Solution.
06-24-2019 11:08 PM
Your incoming arrays are empty. When you auto-index on an empty array, there are no elements for the For Loop to act on. Thus it executes zero times.
Put some data in your arrays and try again.
06-24-2019 11:22 PM
I use NI9881 connected moter driver(load is no problom,There is nothing wrong with the wiring),and input the control word to command moter to my expect position,data stream still not work in the for loop.if there is no for loop,moter will respond.but I can't control two moter at once.that's very frustrate me.
06-25-2019 07:25 AM
Did you look at the pictures you attached to your message?
You had highlight execution turned on. The array wires going into your For Loop have the notation "#0" on them. That means your arrays have ZERO elements in them. When a For Loop is set to auto-index on an array such as that, it will iterate ZERO times.
Why are those arrays empty?
06-25-2019 08:26 AM
sorry that I didn't make myself clear.
the picture I upload that is empty arrays ,yes.Because I was debug my code without load.
But I really add numbers in arrays tried agian.
This time I wire my load and Filled with numbers and the LOOP situation is still exists.
Thank you and look forward to your reply.
06-25-2019 08:38 AM
You still have 3 arrays in there with no elements. Those wires that appear to hold references for the CAN bus.
06-25-2019 07:15 PM
AAAAA~ The problem seems to be here.
When I run my code with load,NI9881'LED is enlighted that's means NI9881(Canopen module is good running ).
Why the CAN bus signal cann't run normal on the wire? That's pretty strange!!!
06-25-2019 10:06 PM
@ytm1056147860 wrote:
AAAAA~ The problem seems to be here.
When I run my code with load,NI9881'LED is enlighted that's means NI9881(Canopen module is good running ).
Why the CAN bus signal cann't run normal on the wire? That's pretty strange!!!
"AAAA~" What does that mean?
"enlighted" Not an English word. A bad translation from Japanese/Chinese? I guess you mean "lit up".
"Why the CAN bus signal cann't run normal on the wire?" I have no idea what you mean here either.
Did you investigate the problem I pointed out about empty arrays?
06-25-2019 10:45 PM
I delete FOR LOOP before WHILE LOOP ,and CANopen wires is not empty,even though I still can't control muti-axis at once,but the empty LOOP problem is solved.
THANKYOU agian!
06-25-2019 11:18 PM
Did you have any elements in your array called "NodeID". With that empty, the 3 For Loops in series would have run 0 times causing all of those reference arrays to be empty. And that would cause the For Loop in the While Loop to run 0 times.