LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronously Get and manuplate Data

Solved!
Go to solution

Dear All,

I am new member in this community. And just started learning Labview. I need your help.

I wanted to command a device first (Command string is {M00), and then get data from the same device continously untill desired value achieved. Compare both values continously untill become same. The problem is that, it accepts the command but afterwards it does not display me the current values, and so it never reaches. I tried many things, but all in vain.

 

Kindly help. Waiting for your kind reply.

 

Thanks in Advance

Download All
0 Kudos
Message 1 of 14
(1,704 Views)

Hi zahid,

 

THINK DATAFLOW! is the main thing you need to learn when using LabVIEW!

 

get data from the same device continously untill desired value achieved

You should program it this way: do something more than once (aka "in a loop") until a condition is met…

Ever tried to debug your VI and watch the DATAFLOW using highlight-debugging?

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 2 of 14
(1,699 Views)

Dear GerdW,

 

Thanks for your kind reply. I tried getting and commanding in a while loop with some delay but still i don't get any value (from Huber Temp). If i run individually and put a loop, it works. like this:

 

temploop.JPG

 

But when i combined both of giving command and getting data, it does not works.

I am little bit confused.

Kindly help

0 Kudos
Message 3 of 14
(1,687 Views)

Hi zahid,

 

THINK DATAFLOW!

- Putting "string" control outside the loop seems wrong to me: either put it inside or use a string constant…

- using a 10s wait seems wrong to me

- using BytesAtPort is mostly wrong: you either use a TermChar with an arbitrary high number of bytes to read - or you use a known message length to read…

- using a sequence is just Rube-Goldberg here…

- remove coercion dots in your VI

- the whole string to number conversion looks overcomplicated to me…

 

Do you get error messages?

Did you debug your VI? Do you receive any string data at all?

 

 

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
Message 4 of 14
(1,666 Views)

Some (other) comments on getting data from your instrument:

  • Have you "played with your device" using MAX?  One of the first things to do, particularly with a VISA device, is to open it in MAX and start sending commands and reading responses.  When you set up MAX for VISA, you'll notice that you can tell VISA whether the Device uses a Termination Character (typically <LF>, 10, Hex A), so MAX usually configures Reads as 1024 points, then when you do a read, it tells you how many bytes were read.  Your code should do the same (and you should initialize your VISA appropriately).
  • You don't need to concatenate <CR> and <LF> -- there is a <CR/LF> constant.
  • You almost never need a Frame Sequence.  Your code works just fine without it, as you (properly) wire the VISA Reference and Error Line to serialize the code.
  • The first point above means don't set Bytes to Read, use 1024 instead (but do initialize the VISA Ref, which you've presumably already done).
  • Your question about "Giving command and getting data" will be answered when you "play with your device" using MAX.  If you think your command starts your device "spitting out data", just give it a "Write", a "Read", and then another "Read" to see if the second Read succeeds (if you get MAX to throw a TimeOut error, you'll know that the command you gave it only returns a single value).

Bob Schor

Message 5 of 14
(1,658 Views)

Dear GerdW,

Thankyou again for your reply. The VI is provided by the vender listed below. They also provide us string codes to command desired value to device or getting current value from device. This VI Works perfect.

a.JPG

When i need to command some value change, i use following conversion. and Give the key string as {M00.

b.JPG

This individually also works fine. And device accepts my custom Temperature.

Another thing is that, when i need to read current temperature, i use following program. With the string input as {M07****. Means to read something. It gives me value in 2 decimal digits. like 12.24. The VI is as follows.

c.JPG

 

But when i combine these, to do a comparison, as shown in my first origional post... it does not works. I just want to make them work in combination.

I hope you'll understand my point.

 

Thanks for your help. Waiting for a positive reply.

 

Regards,

 

Zahid

 

 

 

0 Kudos
Message 6 of 14
(1,642 Views)

Hi Zahid,

 

But when i combine these, to do a comparison, as shown in my first origional post... it does not works. I just want to make them work in combination.

In your original post you completely missed THINK DATAFLOW!

And you did not answer my question from message #4

 

What exactly "does not work"?

Which errors do you get?

Did you debug your VI?

 

Hints:

- When those VIs are "vendor supplied" you should use them as subVIs in your MainVI.

- You should not try to read from and write to your device in parallel as been shown in your first post!

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 7 of 14
(1,631 Views)

Zahid,

 

     You ask for help, and both GerdW and I offer suggestions and advice.  You ignore what we suggest (you still are using Sequences, you still use <CR> and <LF> constants instead of <CR/LF>, you still use Bytes at Port property, and I am guessing that you also have not tested your own device, which neither of us can do, with MAX), and then ask for more help.

 

     Why don't you take a half hour and incorporate our suggestions?  Who knows, you might go a long way to (a) improving your code and (b) solving your problems.  At least we would know that you are listening.

 

Bob Schor

0 Kudos
Message 8 of 14
(1,630 Views)

Dear Bob Schor,

 

Thanks for your reply. Sorry for so much questioning. Actually i don't know about MAX. I am a new user of labview. Now i am studying this. I am also trying to implement your's and GerdW's Suggestions. When i end up with these, i will be in touch if i got some trouble.

Thanks for your help and support.

 

Regards,

 

Zahid

0 Kudos
Message 9 of 14
(1,616 Views)

Dear GerdW,

Thanks for your reply.

I want to Run the first command just once (In order to give device a required setpoint of temperature). After that i need to get/Read temperature from device continous basis. And then compare setpoint and actual current temperature. When both are equal, i need a notification. That is all i needed.

Unbenannt111.jpg

 

When i run these commands individually, i didn't get errors. But when i combine these, Either device does not update the set point or the current temperature command gives value=0. Still i didn't get any error.

I am trying to do it from last few days. But not yet done. I am also following your suggestions...

Regards,

 

M. Zahid Khan.

0 Kudos
Message 10 of 14
(1,611 Views)