LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

MEASURING FORCE ON BALANCE USING AN ELECTRONIC BALANCE FROM THE SERIAL PORT

Hi,

I am trying to measure FORCE using an electronic BALANCE from the serial port. My measurements are strange! The BALANCE sometimes give ZERO reading! Is it because of the sample rate, baud rate etc? I have attached the readings concerned.
Message 1 of 22
(4,003 Views)
Hi,

I am sending my VI for measuring force using the electronic balance. There are many other bugs in it! Is it possible to put BACK the sub VI's back into the VI program. Is there any LV command that I can use to PUT BACK the sub Vi's back into their proper place?
0 Kudos
Message 2 of 22
(3,998 Views)
I think your problem is due to the way you read the weight :
1/ask the balance to send the data
2/oversee the byte number on the serial port until it is constant
3/read the bytes received
4/convert to number

During step 2, you compare the bytes at serial port with the previous value. So far, you have been very lucky to be able to read something : the answer here is always ZERO since the readings occur BEFORE the balance has been able to send anything! means that your loop stops immediately (if you are not convinced, jujst add an indicator to display the loop index. However, since you added a wait (0.8 s), when going to step 3, the balance has had some time to send something. Here, you should not have read again the number of bytes at serial port, but that unwillingly corrects the previous error and you can read most of the received data...

You should modify completely your algorithm. Usually, a balance send the weight as a string with some terminator (RC or LF). Accordingly, the algorithm should be :
1/ask the balance to send the data
2/read the serial port, concatenating the received chars until a terminator char is received or a timeout has occured
3/convert to number

CC
Chilly Charly    (aka CC)
0 Kudos
Message 3 of 22
(3,987 Views)
I am trying to undrerstand your post but I am a novice at labview. Can you correct the VI concern. I have attached part of the VI. It is in LV. By the way is it possible to PUT BACK a SUBVI back into it's proper place? Or REXPAND back the SUBVI?
0 Kudos
Message 4 of 22
(3,983 Views)
Hello,

You can put back a subVI in it's place (ie. replace an existing subVI with a different, perhaps older, version) you can right click on it, choose replace, and then choose select a VI and navigate your directory sturcture to the VI you would like to place there as a subVI. If you meant you'd like to take some existing code ona block diagram and make it a subVI, an easy way to do that is to highlight the code you wish to be in the subVI, and then choose Edit -> Create SubVI (to go back from here type to undo, although you'll only have 8 undo's by default; you can change this using Tools -> Options... and selecting the Block Diagram category drop down, where you'll be able to uncheck the default and change the value to something between 0 and 99). To unexpand a subVI, you can simply open the subVI, highligh and copy the contents of the block diagram (excluding perhaps controls and indicators), then paste it into the block diagram and wire it in place of the subVI itself (where presumably you've deleted the subVI now).

In terms of reading from your instrument, you may be able to wrap the "overseeing until the byte count is constant" and reading into just a read if your instrument returns a termination character. That is, if termination is enabled for reads, you should be able to read until a termination character is seen and return automatically.

If you can post exactly what your receive for a read operation (the entire string received) I can help you do this!

Thank you,

Best Regards,

JLS
Best,
JLS
Sixclear
0 Kudos
Message 5 of 22
(3,961 Views)
Here is the entire file. Hope it helps!
0 Kudos
Message 6 of 22
(3,952 Views)
An "improved" version of your serial reading is attached. Without a balance, I had no possibility to test it ! 😉
So there is no garantee that it will work. Anyway, if you look at the code, you 'll find several ideas about managing strings received on a serial port...

CC
Chilly Charly    (aka CC)
0 Kudos
Message 7 of 22
(3,950 Views)
Your example is in LV7.1. Can you change it to LV7.0.

Thanks.
0 Kudos
Message 8 of 22
(3,926 Views)
Here it is...

CC
Chilly Charly    (aka CC)
0 Kudos
Message 9 of 22
(3,924 Views)
I have tried using your VI. However If I highlight the LV it shows the CORRECT reading going to almost the LAST stage. At the LAST stage it reverts to 0 and is displayed as 0. However if I change by clicking on the BUTTON and change it from CONTINUE IF TRUE to STOP IF TRUE, it works fine.

I have been trying to plot a GRAPH of FORCE READING vs TIME. TIME here is from the starting point of RUNNING the LV. However I have not been successful. Could you HELP!. The LV is attached. It is in LV 6.0.
0 Kudos
Message 10 of 22
(3,885 Views)