LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

step up - wait - step down

Dear All

 

I have a loading machine, that I can now control sending some strings, to put it moving or stop.

With a new test that I have to do (please see the attach picture) I need to:

1- apply a 20mm/min on a sample to compress it (that it is easy, only send the string corresponding to 20 mm/min speed).

2 - when reaching a force of 30kN, i need to stop the machine and maintain the 30kN for 1 min.

The problem is that the load decreases, I need to control (ON/OFF) until 1 min

3 - after that apply a negative displacement of -20mm/min for discharge to 0 kN.

 

My need of help is basically in the connection between ramps and the waiting part.

I can send a command to be true until F>30kN

Then I dont know how to start 1 min time in control ON/OFF (control on /off seems easy)

Then after 1 min how to change again for a new ramp.

 

Best

cpalka

 

 

 

0 Kudos
Message 1 of 10
(3,670 Views)

Attach the VI (as a .vi file, not as a picture, please) so we can see what you are doing and get some idea about "what you know".  Have you looked at the functions or Express VIs in the Timing Palette?  You can use one of them to answer the question "Has my Time elapsed?".

 

Bob Schor

0 Kudos
Message 2 of 10
(3,636 Views)

You are describing something that can be implemented as a simple state machine. Basically, you have a loop that runs at a reasonable rate, reads the force sensor with every iteration and outputs compression as a function of force reading, time, and "state".

 

The solution is independent of programming language, but since you posted in the LabVIEW forum, we can probably assume that you are looking for a LabVIEW solution.

 

What have you done so far? Can your program reliably communicate with the hardware? How far did you get and where did you get stuck? Can you show us some code?

0 Kudos
Message 3 of 10
(3,619 Views)

Hi cpalka,

 

You might also like to take a look at this thread where the OP wants to build a simple on/off controller to aim for a setpoint.

As RavensFan said, you probably need something like a State Machine to control the behaviour of your application, although other designs are possible if for some reason you really didn't want a State Machine...

 

Depending on the necessary accuracy of the 1 minute, you might measure the starting tick count and then keep checking until you reach a number 60000 greater than your starting value, or you could simply count iterations if you have a defined loop rate (e.g. if your loop runs every 0.5 seconds, you need 120 iterations - a For loop could also work for this). Note that in the latter case, any unexpected delays (e.g. your loop actually takes 0.6 seconds) will mess up the total time, in that situation becoming 72 seconds...


GCentral
0 Kudos
Message 4 of 10
(3,586 Views)

Hi cbutcher and friends

 

Many thanks for your contribution.

 

I only have a code that actually only communicate with loading machine (i found the strings with rs sniffer).

Sending a command to put machine loading ate 20mm/min until F>30kN, after that send a string to stop seems easy.

Maybe a case struture, the State Machines seems good idea.

The duration of 1 min is aprox, and keeping the 30kN during this, i accept an error of +-0.5kN (during this I will make a On/OFF control, I need only to loading at a lower speed until F>30kN then stop, then when F<29.5kN turns ON again.

After that send a speed of -20mm/min for decrease. my problem is in the midle during 1 min.

But i will make a first version

PS: I am not an expert in Labview, but I want to learn more and more...the problem is that my projects are not at all related.

So today I want control a machine with labview (because their own software is too limited) other days I use NI hardware, other time, other hardware...sometimes visa communications, etc....

 

Hope you understand

best

cpalka

 

 

0 Kudos
Message 5 of 10
(3,419 Views)

Dear All

 

Here is the first VI that I made some months ago to see if I could control the machine and I have success.

Now I need to change it for the ramps.

 

cpalka

0 Kudos
Message 6 of 10
(3,355 Views)

Don't split your VISA wire into two.  It is a serial port connection.  Now you've lost control over which writes and reads occur first.  When dealing with a serial port, remember to keep it in "series".

0 Kudos
Message 7 of 10
(3,290 Views)

Hi Ravens

 

Sorry for the mistake, I remember some time ago that you or a colleague advise me the same.

It is not so easy doing the code in serial, every time that I use a Write block I need to add allays a Read block?

The For Loop can work here? It is possible in first for loop put inside it the speed of 20mm/min and the target Force=30kN, after that change for second loop and inside I put a small condition to maintain the 30kN force and target here 60s.

The third and last inside the decrease speed -22mm/min and target F=0  kN. I never use the for loop.

 

Best 

cpalka

0 Kudos
Message 8 of 10
(3,037 Views)

Hi cpalka,

 


@cpalka wrote:

It is not so easy doing the code in serial, every time that I use a Write block I need to add allays a Read block?


That depends - does the instrument require you to read something? Probably if you don't read, the response will build up in the buffer, which may cause problems, so best to read in that case.

 

Note that for the parsing, you can use the Scan from String node for more than one at the same time:

Example_VI.png


@cpalka wrote:

The For Loop can work here? It is possible in first for loop put inside it the speed of 20mm/min and the target Force=30kN, after that change for second loop and inside I put a small condition to maintain the 30kN force and target here 60s.

The third and last inside the decrease speed -22mm/min and target F=0  kN. I never use the for loop.


I think you'll be better using the described plans for a state machine.

Since you have specific bits of code to set the motor in the positive and negative directions, I'd suggest making those into a subVI (or pair of subVIs).

 

I notice that the string you're sending includes "79" or "-79", so if you can specify the speed, you only need one subVI - have it take the VISA Resource as an input and provide it back as an output, then also a pair of error wires and the speed as a numeric value (probably double).

That could look something like this:

Example_VI.png

Take care with the formatting of the number! Your manual probably has detailed information about the formatting of the values to provide.

 

Then you can easily call this VI in your main VI when you want to change the speed, for example in your hypothetically created State Machine whilst aiming for the correct speed.

 

You could also make a similar VI with a boolean input for the $IDE {0,1} command to open and close the port, if you wanted. The Append True/False String node might be particularly helpful for this.


GCentral
0 Kudos
Message 9 of 10
(3,030 Views)

Hi cbutcher

 

Thanks for new information about reading values from strings.

 

Maybe may solution could be with use of sub VIs, honestly I still do not know how can do the sequence of the ramp with stage (1min) and down ramp.

I need to do a simple example maybe with a signal simulator

 

Best cpalka

0 Kudos
Message 10 of 10
(3,023 Views)