LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Controller programming

Hello everyone! 

 

I am trying to program the ESP 302 controller via LabVIEW 21. I want to do a simple thing: make every coordinate move in sequence. For that, I am using flat sequence and ESP interfaces. The first coordinate should move, and after the first stops, the second starts moving. And then the same for the third (see the screen below). 

My problem is that when I run the program and set a small velocity for the first axis, it starts moving, but the second one does not wait for the previous one to stop. For my purposes, it is a serious problem. I thought that the WS (wait to stop) command should have helped, but I still struggle with this problem. 

Does anyone have any idea how to fix this? 

 

 

0 Kudos
Message 1 of 8
(727 Views)

Please attach code (files with .VI and/or .CTL, or compress the entire Project via "Send to", "Zipped (compressed) Folder", and attach the .zip file) so we can really see (and possibly edit) your "code that doesn't run as you'd like".  Fortunately, I can read LabVIEW 2021 files ...

 

Bob Schor

Message 2 of 8
(685 Views)

A few general comments.

 

1. You should not need to keep opening and closing the instrument.  Create the object and connect once at the start and do not close until everything is done.

2. Look into using a State Machine.  It will dramatically help your coding.

3. Generally speaking, you should not be using a Sequence Structure.  Data Flow should be used as much as possible to dictate the order of things being done.

4. It would also help if you did a little diagram cleanup.  Avoid right-to-left wires.  Do not run wires under nodes.

5. Handle your errors.  I have a feeling you have an error coming out of your PA call that is forcing the WS to not run.  But you are not properly reporting your errors, so we cannot tell if there is an error.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 8
(681 Views)

Thank you for your reply! 

 

Here is my code

0 Kudos
Message 4 of 8
(676 Views)

Thank you for the reply! 

 

I did clean up a bit and added error strings. After WS it gives: "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond" Also I removed the sequences, but it made it worse I would say, because after making this first step it doesn't do anything and sometimes when I run the program again it just does nothing.

I looked into using a State Machine, but couldn't get into it, do you have any practical examples of using this? In addition, the next step of the program is array with subsequent movements. The .vi is attached.

0 Kudos
Message 5 of 8
(655 Views)

@This_Is_Mecco wrote:

I did clean up a bit and added error strings. After WS it gives: "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond"


So there is your main problem.  You need to debug that.  Start with a very small VI that does nothing but initialize, connect, move, and close.  This is the bare minimum test bench for figuring out your connection issues.

 


@This_Is_Mecco wrote:

In addition, the next step of the program is array with subsequent movements.


This is sounding what you probably actually need a just a simple FOR loop that iterates through an array of settings.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 8
(638 Views)

Wow.  I spent a lot of time removing all of the Frame sequences (completely unnecessary as you have the Error Line running through your code very nicely, which serializes everything), straightening wires, and trying to see where there might be a "mistake" (check out the axisNumber for the third set of codes to the ESP302).

 

And, of course, Crossrulz is correct -- you are doing (almost) the same thing six times, three to set up Angle, X, and Y (with a cluster of 3 parameters, Number, Velocity, and AP) and three to set up movement, with Angle, Y, and X (with a cluster of 2 parameters, Step and Velocity Step, with an extra "fiddle factor" for X that depends on the loop Index).  Your Block Diagram takes 4 1920 x 1080 monitors to show (and I only have 2), and mine takes "only" 2.7 (because I wrote it, as you did, as one really long Block Diagram).

 

I also notice that you "open" and "close" the references to the ESP302 between doing each set of commands.  Is this necessary, particularly if you aren't changing the "Open Instrument" parameters at all?

 

I've attached my Sequence-free version.  I also turned off "Icon View" of Front Panel controls to save even more space and make the Block Diagram easier to read.

 

Bob Schor

 

 

Message 7 of 8
(624 Views)

Thank you very much! This looks much less messy now! 

 

However the problem is still WS (wait to stop), which doesn't work properly, and I couldn't find a solution to make it work. I had to do it manually, using the "wait" command.

0 Kudos
Message 8 of 8
(573 Views)