Jump to content
  • 0

LIFA does not wait until steps complete.


tsakitsan

Question

Hello community,

I am using LIFA to control a stepper motor. What I want to achieve is to insert a some steps and the motor has to go forward for X steps and then the same steps backwards.
I have connected 2 stepper write but it does not work as I want it. The motor goes forward only for a few steps and then backwards for the full value of steps.

What can I do?

digi.JPG

Link to comment
Share on other sites

20 answers to this question

Recommended Posts

James pointed out that the screenshot I posted is basically what you're doing your first post.  I was looking at the interactive movement section of you code (the case that came up when I opened it.  

I would try a simple example, that is just the 4 VIs I posted above with the LIFA open / close on either side and see if it does what you expect.  Remember to add error handling as well to see if there is an error somewhere.  Can you give that a shot, post your code and let us know what the results are.

Thanks!

-Kristoff

Link to comment
Share on other sites

On 7/12/2018 at 5:16 AM, tsakitsan said:

Ok no support whatsoever. So I wasted triple the time that an expert would and I solved my issue in a very unorthodox way.

See the file attaches. Now everything works fine, but slower. at least it works

solution.JPG

Do you still have the vi?

Link to comment
Share on other sites

I cannot replicate that experiment 2 today. Without closing the stepper and the arduino with the run continuously button, it runs fine.

I keep having issues when two event cases are present. Seems like when an event is queued, the stepper wait til steps complete is overridden.

Any solutions to that? 

*Update.. Again when trying to exhibit the operation to my tutor, I practiced 6 times... all ok.. He used it, he altered the acceleration on one of the event cases to max and then back to zero and.. boom motor went backwards..

Link to comment
Share on other sites

If one case of an event structure is executing while another event (or many events) occur those events will queue up and be handled int he order they occurred, so the behavior your describing sounds more like a symptom of the problem (ie the wait till complete VI not waiting) rather than something caused by the event structure.

Quote

2nd Experiment: Normal arduino initiation, stepper write +steps, stepper wait, stepper write -steps, stepper wait (nothing else).
Result: All good with run, but when running continuously the .vi ends before the stepper completes the steps, and the new stepper write takes over doing the steps all over again.

I would return to this experiment and try to determine the first VI to behave not as expected.  Can you post the code for this one?  Are you doing closing the stepper and the Arduino at the end?  If the Arduino is not reset it's possible memory is leaked in the firmware when allocating / deallocating steppers.

Link to comment
Share on other sites

16 hours ago, Kristoff said:

Firmware source code is here.

The code you posted looks like the your first test case.  Can you post the second test case?

Also, when you say 'Running Continuously' do you mean using the 'Run Continuously button' (as show in the image below) or are you running continuously by placing your code in a while loop?

image.png

Thanks!

-Kristoff

I was really trying to replicate the problem so yes I was running it continuously using the "run continuously button" but I know its not a good practice.
I am using only one stepper.

Today I felt more like "proper" problem solving and I remember that usually when the initial stated problem was happening was between two different event structures.
So I was clicking one event it was executing then another one, it was executing and then everything was going wrong.. So here you have, attached the problematic .vi

To recreate the problem, run the .vi > press event 1> wait until its complete > press event 1 again > and wait again, then
Press event 2 > wait >press event 2 again > wait, then,
press event 1 and before it finished press event 2 (you will see that one interrupt the other), then
do it again, then run event 2 and interrupt it by event 1

And there you have it! Which ever event you press now stepper moves only one way....

Really looking forward to resolve this issue and of course thanks for the previous replies

Ktest probz.vi

Link to comment
Share on other sites

There is a potential for issues when using 'Stepper Wait Till Steps Complete' with multiple steppers.  It looks like the firmware sums the distance remaining for all steppers and then the LabVIEW side checks if it's not equal to 0.  If one stepper has positive x steps to go and another stepper has negative x steps to go the VI would report that there are no steps remaining and the VI would unblock.

If you're only using a single stepper that shouldn't be a problem, but it is something to be aware of.

case 0x33:  // Stepper steps to go
        retVal = 0;
        for(int i=0; i<8; i++){
          retVal += steppers[i].distanceToGo();
        }
        Serial.write( (retVal & 0xFF) );
        Serial.write( (retVal >> 8) );

-Kristoff

Link to comment
Share on other sites

Firmware source code is here.

The code you posted looks like the your first test case.  Can you post the second test case?

Also, when you say 'Running Continuously' do you mean using the 'Run Continuously button' (as show in the image below) or are you running continuously by placing your code in a while loop?

image.png

Thanks!

-Kristoff

Link to comment
Share on other sites

On 6/4/2018 at 6:43 PM, Kristoff said:

James pointed out that the screenshot I posted is basically what you're doing your first post.  I was looking at the interactive movement section of you code (the case that came up when I opened it.  

I would try a simple example, that is just the 4 VIs I posted above with the LIFA open / close on either side and see if it does what you expect.  Remember to add error handling as well to see if there is an error somewhere.  Can you give that a shot, post your code and let us know what the results are.

Thanks!

-Kristoff

Hello guys sorry for the late reply, got jealous from Mr.Kristoff and went on some holidays.

Well well well, I got two experiments and two outcomes.

1st Experiment: Normal arduino initiation, stepper write +steps, Stepper wait, stepper write -steps, stepper wait, stepper close, arduino close, error handling.
Result: All good with run, and run continuously.

2nd Experiment: Normal arduino initiation, stepper write +steps, stepper wait, stepper write -steps, stepper wait (nothing else).
Result: All good with run, but when running continuously the .vi ends before the stepper completes the steps, and the new stepper write takes over doing the steps all over again.

The second experiment resembles the problem I had on my case where inside the while loop, and the event case the stepper wait didn't wait as much as it should before passing the action to the next stepper write.

How does the stepper wait till steps complete work? Can I easily modify it so it does actually wait until steps are complete, because by what I can see it looks like a simple delay?

To check the attached .vi with the problem simply disconnect the blocks after stepper wait.
Disclaimer: This is not how I use it in my .vi and of course I am using error handling , but that's just a simple experiment giving out the same problem like mine.
If you need my original .vi let me know

 

Best Regards

kristoff test.vi

Link to comment
Share on other sites

On 6/1/2018 at 11:34 PM, Kristoff said:

Hey,

The LIFA Stepper Write  VI is non blocking.  It tells the Arduino to go a certain number of steps, and the firmware on the Arduino generates the actual stepper output signals in the background.  This allows you to read/write other data while the stepper motor is running. 

 

In your first screenshot you are telling the stepper to go forward X steps, then immediately telling it to go backward X steps without giving it time to complete the forward steps.

If you want to wait for the forward steps to complete you'll have to explicitly do so in your code using the 'Stepper Wait Till Steps Complete' after your Stepper Write command.  The 'Stepper Wait Till Steps Complete' will block execution until the pending steps have been completed.

Let us know if you have any more questions about this.

Thanks!

-Kristoff

 

 

So I have to create a different event case with a different button to complete backward steps? Is there any other option where I can do a simple back and forth movement with one button on my front screen? 

Regards

Link to comment
Share on other sites

Hey,

The LIFA Stepper Write  VI is non blocking.  It tells the Arduino to go a certain number of steps, and the firmware on the Arduino generates the actual stepper output signals in the background.  This allows you to read/write other data while the stepper motor is running. 

 

In your first screenshot you are telling the stepper to go forward X steps, then immediately telling it to go backward X steps without giving it time to complete the forward steps.

If you want to wait for the forward steps to complete you'll have to explicitly do so in your code using the 'Stepper Wait Till Steps Complete' after your Stepper Write command.  The 'Stepper Wait Till Steps Complete' will block execution until the pending steps have been completed.

Let us know if you have any more questions about this.

Thanks!

-Kristoff

 

 

Link to comment
Share on other sites

On 5/29/2018 at 8:24 PM, Kristoff said:

I wrote LIFA :D

tsakitsan, it sounds like this is just a bug in your LabVIEW code.  Can you post a screen shot of the full block diagram and also attach the VI?

Thanks!

-Kristoff

 

 

Hello Kristoff, I knew it was going to be you, I have attached the vi. Please have a look

 

Link to comment
Share on other sites

On 5/22/2018 at 9:54 AM, jpeyron said:

I found out we have an engineer familiar with LIFA

I wrote LIFA :D

tsakitsan, it sounds like this is just a bug in your LabVIEW code.  Can you post a screen shot of the full block diagram and also attach the VI?

Thanks!

-Kristoff

 

 

Link to comment
Share on other sites

On 22/5/2018 at 5:54 PM, jpeyron said:

Hi @tsakitsan,

I found out we have an engineer familiar with LIFA, but that they are out of the office at the moment. I am waiting to hear back from them about your post.

thank you,

Jon

Thanks Jon, I will wait for his reply. I am trying to find answers on other forums as well with no much luck. It happened to me again, it was doing forwards and backwards steps fine and at the third time I actuate it boom.. small movement to the front and all the commanded steps to the back, crushing my actuator.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...