I have a question regarding the VISA write section of my program. The Command i need to send to the scale for immediate scale reading recovery is: "SI"CrLf
Now, Since the Visa serial block at the beginning of the program has a CrLf connected to it, does that mean that any command sent by the program to the device has the CrLf attached to the end of it? If so, my command will be: "SI" only.
If thats not true then it will be: "SI"CrLf.
I am searching through the documentation on ways to switch the command modes ON. I will keep you guys updated.
I believe your statement (which I made bold) is absolutely correct!
Made some changes to the code, now I know that the scale is sending data but its not what I want. I basically changed the command i input to the scale, but for some reason it keeps sending a -0.1 or -0.2g value instead of the 50.0g thats on the display. I have tried playing around with different communication settings, Auto-print, Continuous, Dialog etc, no luck. Please check out the screenshots and the program below.
I am trying to figure out if it is sending a stable value before the scale was loaded by reading through the manuals, hopefully I will find something. I the mean time if someone has any ideas.........
This is what i did, I put a spanner on it of approx 50g. From time to time there is fluctuations in the first digit after the decimal point, but the scales set in factory settings and I have waited for 10 readings when its stable and it's almost like the READ indicator does not update itself.
But i will look into this lead in the manual and see if there is a setting such as a difference generator and keep you posted.
I think i figured out whats happenning. The program displays the first value it reads over and over again.
This is how i arrived at this conclusion:
Previous cases - The scale platform would be empty (so display reading -0.2g 0r -0.3g etc). Then after running the program, I would place a wrench or screwdriver on it and othing would happen.
Latest Case - Placed the screwdriver and other stuff first. Display read 194g. Started the program and got that reading, then started taking things off and no changes. The attached figure shows screenshot when I have taken everything off.
This sounds like a situation where you need to learn exactly how the instrument works. I have seen instruments which continue to return the old reading until explicilty commanded to take a new reading.
Read the manual carefully. Look at the detailed explanations of each of the commands which you think might be relevant. Make sure you understand the terminology used. A "reading" may refer to sending a value from a buffer or it might mean take a new measurement and send that. The results you get will be very different for the two definitions.
I do not think the problem is your program, except that you may need to send some additional or different commands.
You were right, I had the wrong command. I spent some time with the command manual yesterday and figured out which I needed to use. A screenshot of the new one is below.
Now, I have to figure out how to parse the readout. a pecularity is that the readout may be one of two things, "S S 50.0 g" or "S D 50.0 g". S S is for a stable reading, S D is for a dynamic (unstable) reading.
Is there a method through which I can specify for both cases in the formate specifier for scan for string. I tried %f and end up with Error 85 for scan for string, but do get a number on the indicator for its output. The number is the weigh scale reading but without decimal digits and unit indication (g).
Good news, I solved the format specifier issue I talked about in the previous post and am now getting the scale readings from both devices properly formatted and displayed in two waveform charts on LabView, please see the attached VI. I have two questions left;
1) I am now trying to tranfer said values from the waveform chart or Scan from string numeric value into two separate excel files. LabView 8.2 does not seem to have the "Export plot data to excel VI" which would have suited this application perfectly. Instead I can only find a vi called "Export data to spreadsheet". When I connect the numeric scale reading from Scan from String to this VI, I get an error. It does not allow me to connect the two components. How do I get around this?
2) Can I configure it in a way that I can suggest a file path for the new spreadsheet and if the file does not exist, will LabView create a file in that specified path folder.
PS: If export to excel is not possible, Can I tranfer data to a txt file and take it forward from there manually? Also, where is the VI clean-up option in 8.2 to make everything cleaner on my VI.
The easiest way to save data in a format readable by most spreadsheet programs is to use the Write to Spreadsheet File.vi in the File palette. This saves the data as a tab-delimited text file.
You can use the Chart History property node to get the data stored in the chart's internal buffer. Build Array can combine the data from the two charts into a single 2D array. Note that arrays in LV must be rectangular. So if the chart histories have different lengths, the shorter one will be padded with zeros when building the 2D array.
There are many functions in the File palette which will allow you to create paths, open, or create files and jsut about anything you might want to do with a file. Look through the palette and read the detailed help files for the functions which appear to be useful.
Export to Excel may be part of the Report Generation Toolkit.
I think the clean up tool was introduced in a later version of LV. It does not work all that well on VIs which are very messy. You are often better off learning to produce fairly neat code as you write it. The appropriate use of subVIs is helpful for appearance as well as code modularity.
I think I spoke too soon about my code working perfectly. It works perfectly fine when the delay time is set to zero, "real-time" data collection. Once I increase the delay time, the problem I encounter is; the program continues to display previous strings output from the scale, so if i put a delay time of 15 seconds, the next iteration when it sends data to the waveform chart, its a value immediately recieved after and not after 15 seconds.
As a remedy, I was planning to do one of two things,
1) move the Visa Write's outside of their respective while loops, not sure if that will work.
2) How about enclosing the entire VI inside a timed while loop and discard the time delays currently employed within the sub loops?
I am proceeding in the right direction? also, thank you for the help with write to spreadsheet, i will incorporate it into my VI.