GraemeJ Posted May 22, 2008 Report Share Posted May 22, 2008 I am fairly new to Labview and am in trouble with the attached vi. The purpose of the vi (part of a larger scheme) is to let the user measure a series of chemical standards, and then derive a calibration equation from the data. The user would enter data in a table, edit the data and then store in a file. The problems I am aware of (and I imagine forum members can find plenty of others) are: - Write to Text File: data is correctly written to the file when LV is first started and the vi run, but even this is not consistent. Sometimes the file remains blank. Having run the vi once, on later runs the file is not cleared and new data has not been able to be subsequently written to the file, even though the new data and the path are present at 'Write to Text File' on each occassion. - Run time shortcut menu: a custom menu for the table, made up from application items, has been saved as a file in the same directory as the vi. When running, the menu appears, but no action occurs when a menu item is selected. I had assumed that no further code was required. If code is necessary I would appreciate some help in getting started. Any advice would be very much appreciated. Regards. Sorry, wrong attachment: try again Quote Link to comment
jgcode Posted May 22, 2008 Report Share Posted May 22, 2008 For your menu questions. Yes you need to handle the event. Using the Event structure is one way way to handle FP RTSM selections and it is quite easy. Add a case called Shortcut Menu Selection (User) or Shortcut Menu Selection (App) for the control and handle the Item-Tag string in a case structure. Use (User) for custom items, use (App) for Application items (you cannot edit item name/tag of application items) Also I prefer not to execute code in the Event Structure but to queue it out to a consumer loop. Quote Link to comment
orko Posted May 22, 2008 Report Share Posted May 22, 2008 QUOTE (GraemeJ @ May 20 2008, 06:08 PM) - Write to Text File: data is correctly written to the file when LV is first started and the vi run, but even this is not consistent. Sometimes the file remains blank. Having run the vi once, on later runs the file is not cleared and new data has not been able to be subsequently written to the file, even though the new data and the path are present at 'Write to Text File' on each occassion. For boolean events, I have much better luck using the "NewVal" event input value vs. the actual terminal, because the value of the terminal inside the case structure can get confusing depending on the mechanical action of the switch. The NewVal value will be whatever the control's value was when the event fired (when it's value changed), and doesn't depend on when the button latches. This code worked more consistently for me: Download File:post-3266-1211398763.vi Also, I noticed an oddity in the code here... will this ever be false? Quote Link to comment
GraemeJ Posted May 23, 2008 Author Report Share Posted May 23, 2008 Thanks Orko, Your suggestions worked fine! Regards, GraemeJ Quote Link to comment
GraemeJ Posted May 25, 2008 Author Report Share Posted May 25, 2008 Hello jgcode, Re: Runtime Shortcut Menu Thanks for your advice. I have got it partially running, but am still in trouble. For "copy" and "description and tip" each case operates correctly. When either if these is selected in the RTSM, a probe on the selector terminal for these cases within the event structure shows the correct Item_tag, and the case is then processed. For all other Application Items eg. 'empty table' or 'delete row', the Item_tags do not appear in the Event structure. I have not been able to figure out how to step through this bit of the code to see what is happening. Any further advice would be much appreciated. Regards, GraemeJ Quote Link to comment
jgcode Posted May 25, 2008 Report Share Posted May 25, 2008 QUOTE (GraemeJ @ May 24 2008, 09:09 AM) Hello jgcode,Re: Runtime Shortcut Menu Thanks for your advice. I have got it partially running, but am still in trouble. For "copy" and "description and tip" each case operates correctly. When either if these is selected in the RTSM, a probe on the selector terminal for these cases within the event structure shows the correct Item_tag, and the case is then processed. For all other Application Items eg. 'empty table' or 'delete row', the Item_tags do not appear in the Event structure. I have not been able to figure out how to step through this bit of the code to see what is happening. Any further advice would be much appreciated. Regards, GraemeJ Hi Graeme, no probs. Are you handling your custom items with event: Shorcut Menu Selection (User) And LabVIEW application shortcuts with event: Shortcut Menu Selection (App) ?? Even if you have a overall custom menu, it can be made up of App and Custom tags so you need to use both events? If this does not help please post up your new code. Quote Link to comment
GraemeJ Posted May 27, 2008 Author Report Share Posted May 27, 2008 Thanks jgcode, Still in trouble. I have not understood what LV is trying to achieve with the RTSM: with the default menu, eg. 'empty table' seems an unambiguous requirement which would have had prewritten code, as is the case for much of LV. However, 'empty table' is also a custom app. which requires code to be written. Attached is my current code. As always, would appreciate any help. GraemeJ Quote Link to comment
jgcode Posted May 27, 2008 Report Share Posted May 27, 2008 QUOTE (GraemeJ @ May 26 2008, 09:49 AM) Thanks jgcode,Still in trouble. I have not understood what LV is trying to achieve with the RTSM: with the default menu, eg. 'empty table' seems an unambiguous requirement which would have had prewritten code, as is the case for much of LV. However, 'empty table' is also a custom app. which requires code to be written. Attached is my current code. As always, would appreciate any help. GraemeJ Sorry I may have been a bit vague before - LV will perform code for SRTM App Events, but if you need to capture these events for other reasons then you need to use Shortcut Menu Selection (App) not Shortcut Menu Selection (User). Now in your code the table is an indicator and it can't access these methods (empty table etc..), it needs to be a control. Therefore one solution is to use a control and write to (update) the table using a local variable. If you probe the item tags in the new code it will be picking up these events now. The only problem I can think of is that the user can enter in values. But if you keep your data private in the application and only use the local variable to write to the screen (as opposed to read at any time) this should not be a problem aside from making the table a little ugly if the user types something in. You can't disable the table because then you can't access the SRTM. One way to handle this is to use a value change event to load the private data back into the table if the user did change it. May be overkill in your case? I code in LV8.5, I saved this down to LV8.0, if you only have LV7.0, please follow the .PNG. Download File:post-10325-1211770620.vi Code is in LV8.0 Quote Link to comment
GraemeJ Posted May 27, 2008 Author Report Share Posted May 27, 2008 Sorry I may have been a bit vague before - LV will perform code for SRTM App Events, but if you need to capture these events for other reasons then you need to use Shortcut Menu Selection (App) not Shortcut Menu Selection (User). Many thanks indeed jgcode, that solved the problem and I am most grateful for your help. The user being able to enter data in the table is an issue and I will use your suggested solution. Thanks again, GraemeJ Quote Link to comment
hakannn Posted May 27, 2008 Report Share Posted May 27, 2008 hi everybody, i'm a student to istanbul. i'm not good to Labview. i wanna read the AI and write to text. i read the AI but i can't write to text. My program's is writing to text just one time. pls help me i hope u can understand my problem look forward your reply Code is in LV8.0 Quote Link to comment
jgcode Posted May 27, 2008 Report Share Posted May 27, 2008 QUOTE (hakannn @ May 26 2008, 04:05 PM) hi everybody, i'm a student to istanbul. i'm not good to Labview. i wanna read the AI and write to text. i read the AI but i can't write to text. My program's is writing to text just one time. pls help me i hope u can understand my problem look forward your reply Code is in LV8.0 Hi Hakannn I couldn't run your download as a VI was missing (calysan.vi) however, I have had a look. Please find a basic example attached of one way to collect software timed DAQ and stream it to file. I have a few pointers on your code as well with the main thing being you need to continually poll the DAQ Read VI in a timed loop (whether this is hardware or software timed) and read the output [array] and write it to disk. Please check Help>>Find Examples for more DAQ and File IO examples. Enjoy! Download File:post-10325-1211808458.vi Code is in LV8.0. Quote Link to comment
hakannn Posted May 27, 2008 Report Share Posted May 27, 2008 firstly, thanks for your concern i'm trying your suggestion. i send to "calisan.VI" thanks for everything... hakan hi again, i opened your example but i don't know what can i write the "physical channells". i writed dev1/ai0 bc i'm using "AI0". but i can't read the AI pls help again. thanks for everything hakan Quote Link to comment
jgcode Posted May 27, 2008 Report Share Posted May 27, 2008 QUOTE (hakannn @ May 26 2008, 10:26 PM) firstly, thanks for your concerni'm trying your suggestion. i send to "calisan.VI" thanks for everything... hakan hi again, i opened your example but i don't know what can i write the "physical channells". i writed dev1/ai0 bc i'm using "AI0". but i can't read the AI pls help again. thanks for everything hakan http://lavag.org/old_files/monthly_05_2008/post-10325-1211814136.png' target="_blank"> No worries You need to make sure you have the FULL correct physical channel name e.g. Dev2/ai0 (PCI, USB etc..) e.g. cDAQ1/Mod2/ai0 (Compact DAQ chassis) not just "ai0" Go into MAX and make sure you are selecting the correct device. Green is "installed and is plugged in" Yellow is "simulated" White with red cross is "has been installed but currently not found" For your real device make sure has a green icon and that the device name is correct. Quote Link to comment
crelf Posted May 27, 2008 Report Share Posted May 27, 2008 QUOTE (jgcode @ May 26 2008, 11:11 AM) You need to make sure you have the FULL correct physical channel name Right. I suggest you also check out your "Data Neighborhood" - you can define more user-friendly names for individual channels, as well as define tasks (grouping similar channels into groups that share timing information). Quote Link to comment
hakannn Posted May 27, 2008 Report Share Posted May 27, 2008 i'm using usb 6009 and i acquainted it to pc. i'm choosing dev1/ai0. i sent the pic from my pc. pls help me thanks hakan Quote Link to comment
hakannn Posted May 28, 2008 Report Share Posted May 28, 2008 thanks everybody, i can read data and write to text finally, how can i write to read the data time. i can write just value but i wanna show when i read the data. last question, i use the "write to text file" in Lab 8.0 but i can't find it in Lab 7.1. can i write the same program in Lab 7.1?? thanks again that's my program. i hope it will use by someone hakan Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.