Jump to content

postformac

Members
  • Posts

    40
  • Joined

  • Last visited

Everything posted by postformac

  1. I am distributing an exe and looking to provide the end user with the ability to set-up their own input channels to read through a cDaq / cRIO. I know that I can distribute MAX with my installer which gives the end user the ability to configure their own channels. What I can't figure out is how to deal with this in my program to be able to read the samples as I don't know what the channels are in advance. I have been experimenting with the DAQmx property nodes and can read the available tasks / channels / channel types from the attached hardware, however I'm not sure how to deal with the various sample rates etc to get a read on all of the channels. Two questions - Is there a simpler way to just "sample all available channels" or do you have to do this manually per channel through the property nodes? If doing it manually through property nodes, could someone advise me on how to deal with the differing sample rates from different tasks? For example, I have one task set at the moment for a number of thermocouple inputs that are all at 10Hz and a separate task for a counter input that is only running at 2Hz. If I try to use a 10Hz loop to read each one in turn I get a big delay every time it samples from the counter task as it is not ready yet. If I was hard coding it I would just have two loops running at different rates but I can't figure out how to do this if I don't know it is needed in advance. Any help would be appreciated, thanks.
  2. Ok I get it, I think your way is better as it means I don't have to hard code all of the IDs in advance, it will just populate as it goes and generate a new cluster for whatever messages are on the bus. I have never used clusters before but they are looking pretty useful right about now, I will have to play with them some more... Thanks very much for your help!
  3. Oh no, I see what you mean. You mean to create my own lookup table just using an array or whatever, like this right? Thanks Sorting array-2.vi
  4. Ok, I think I understand what you have done. Basically you have created an array of clusters, with one cluster for each ID where each cluster contains a 1D array that specifies the row number(s) that the ID occurs on and a count of how many times that ID occurs in total. Then you use that to extract the information again at the end from the original array to create another array containing clusters of 2D arrays.... An array of clusters of arrays, why didn't I think of that ha ha. Seriously though that works really well, I would never have thought of it myself so thanks for your help. When you say in your note to create a lookup table if the IDs are not concurrent (which in reality they aren't) is there actually such a thing as a lookup table in labview or do you just mean to go through the array one row at a time and replace the IDs with pre-determined values manually (such as via a case statement)? Thanks, Mark
  5. Thanks very much for the replies guys. I have had a look at the example you posted Ned and its got lots of stuff in it I have never seen before so it might take me a while to digest! It does sound like a good way to do it though so I will have a go at repeating what you have done. Thanks
  6. I am having difficulty figuring out how to sort an array according to one of the columns, I'm sure there's a really easy way to do it but I can't think of a nice solution that doesn't use loads of memory! I have a large array that contains data from a CAN bus. Each line has the message identifier and 8 bytes of data. All I want to do is to split the array up so I end up with separate arrays each with all of the data for one individual message identifier. I have attached a quick VI that demonstrates the principle. This VI works fine and does what I am intending, but the actual files of CAN data are thousands of lines long and could contain upto around 30 different identifiers depending on how many nodes are active on the bus and what messages are present. That would mean that I would need to pass 30 arrays back around every iteration of my loop, some of which may contain thousands of lines of data depending on how active the ID is. It ends up being quite slow, I assume because I am sending so much data round and round my loop on each iteration. I would prefer to just terminate all of the possible array lines at auto-indexed tunnels at the edge of my loop so that I'm not passing that data back and forth. I can't work out how to make it operate like this though as I still need some output to send to every tunnel on each iteration, not just the tunnel of the identifier that the current line being examined refers to. I could output some kind of constant to all the other tunnels but then I have to go back through and remove all of the unwanted constants from each array afterwards. I'm sure there must be a better way to do this, could anyone suggest anything? Thanks Sorting array.vi
  7. Ok I got it to work with supressing alerts after following what is happening in the Save Workbook.vi as you suggested. I had to alter one if the VIs to give me the correct refnum as an output though, I couldn't put the reference that is currently output from all of the Excel VIs straight into my property node as it is an "excel object reference" and I needed an "Excel. _Application" reference. I don't really get the difference so I'm not sure if I have done the right thing there, it seems to work fine so its not really a problem but I just thought I would ask if there is a better way to do it like convert the reference or something. Thanks
  8. Hi ooth, Thats brilliant, thank you very much for your help and time. I had noticed the problem with leaving references open and ending the program half way through, so I have added the destroy all references vi at the beginning of my vi as you suggest. One thing with the delete sheet vi, at the end of my program I am left with an open copy of excel that has a message window asking the user to confirm the deletion of the sheet(s). My program stays running until the user either confirms or cancels the delete operation. Is this correct? Its not a big problem obviously. Thanks
  9. Thanks very much for the reply, I have re-arranged your program a bit to make it better suit my existing program that I am adding it into but basically you have given me exactly what I needed. The Excel VIs give all of the functionality I need without the hassle of having to do the ActiveX stuff myself, much easier! The only thing I can't find a VI for is to delete a specific worksheet, is there another way to do that? I just want to remove the blank original worksheets after I have finished adding all of my new ones. Are these VIs part of the NI report generation toolkit or where are they from? Thanks again for the help, I've been struggling with that whole ActiveX thing for a while!
  10. Hi, I know there have been a lot of posts on here relating to Excel and ActiveX but I couldn't find anything that showed exactly what I am looking for. Basically I am trying to write an array of data to an excel file but there are a number of steps that I want to go through first, I can open the reference to Excel, create a new workbook, create a new worksheet and write my data but what I can't manage to find is how to copy an existing worksheet to a new one and re-name my new worksheet. I have no concept of how ActiveX works, I have basically just copied what I have found in other posts and LabView examples so far.... What I want to do is the following: Open an existing workbook (template) Copy the first worksheet in that workbook (which will have a template layout and set calculations) Paste as a new worksheet with my array of data added in the correct place Rename the new worksheet to a name created in my program Repeat for a number of further worksheets with further arrays of data Save the workbook by a different name to preserve the template file In my VI at the moment I have tried to use the "copy" method for the "excel._worksheet" class which does copy the correct worksheet but then puts it in a new workbook instead of adding it to the existing one and my array is added to the existing worksheet rather than the copied one. I don't seem to be able to put any input into the "before" or "after" nodes on the _worksheet invoke node, any data type that I connect to it gives me an error message and stops the program from working. I have looked at the Excel object model map here http://msdn.microsof...y/bb332345.aspx but I have no idea what it means, is each column a subsiduary of the previous one or what? I don't get what I am looking at. I have attached my files so far, could someone give me some pointers on this or show me where to get further information on how the whole ActiveX thing works? Thanks Write Excel simple.vi Write Excel.vi Template.zip
  11. As another question on the same theme - I am basically using my table to display a 2D array of strings opened from an external file. If I want to use the row and column headers to simply number the rows and columns is there an immediate way to do this or do I need to create two 1D arrays that contain all of the necessary numbers? My 2D array of data will vary in size depending on which file is opened so there is not always the same number of rows or columns. I know I can check the dimensions of the array and then create the necessary 1D arrays of numbers using loops but I'm just wondering if there is a more direct way to do it? Thanks
  12. Oh I see, I had been creating the inputs manually I didn't realise you could do it like that. Problem solved, thank you very much for your help!
  13. Hi, I am using a property node to format the row and column headers in my tabe and I can't get the CellJustify property to work properly. The help documentation says the input should be an unsigned word Enum and the allowable values are Left, Center and Right. If I set an enum constant to Left then it works fine, if I change the same constant to Center or Right then I get a broken wire with the error "enumeration conflict". Could anyone please tell me why? Also I have coersion dots on my two ActiveCell inputs to the property node and I don't know why. I have followed the data types set in the help. I notice that the example program provided (linked from the help for the ActiveCell property) also has coersion dots on this input, is this how it should be? Thanks
  14. Thank you Francois, I will have a play with that. Dblk - I tried your file and although it may not be as quick as Francois method (still way quicker than mine!) it is useful in that it does not rely on fixed column widths. I tried a number of different configurations with the piece of equipment that is logging the data and actually the width of the first column is adjusted to suit however many samples you set as a maximum on the hardware. For this reason I think I will go with your method as it is more adaptable regardless of how the hardware is set up. Thanks both very much for your help!
  15. Hi, Thanks very much for the replies. Francois - I also noticed the columns were fixed width after I posted originally and I have since made a program that works in a similar way to yours (although not quite as neatly...). What is your item above where it says "each columns pre-determined width"? I have not seen that before but it looks useful! I did it as shown below where the file is first opened as a text file read by line and then re-shaped into a 2D array before being passed to my function to split the columns I want out of it. It seems to take a very long time to process the file though, is this because I am repeatedly passing so much data from one side of the loop to the other? The time is spent in the function that splits the strings up rather than the calling function. dblk - I don't have the openG VIs and had never heard of them, I am downloading them now though so I will look at your example when it has finished, thanks. Main.vi Split strings.vi
  16. Hi, I have a piece of equipment that is logging hex data to a text file and I'm having problems splitting the test file up into array data. The problem is that the text file uses a varying number of spaces as delimiters and I don't know how to handle this to get the file arranged properly in my array. I want to split each "visually obvious" column into a separate column in the array. I have tried doing this by using the import from spreadsheet file function using a single space as the delimiter which almost works (although it gives a load of blank columns that I could cut out) but it offsets the columns by 1 each time the logged counter goes up by a factopr of 10 (as this effectively removes one blank space between the data fields). Is there any way to use blank space in general as a delimiter without speciying how many spaces? I have attached a copy of a cut down file so you can see the format. Thanks! Data.txt
  17. Ok cheers, got it all working. I set the limits in a separate VI and then left the property nodes in the main VI as you suggest, all that would have been in the sub-VI was the decision for the limits and the property bit so I agree it is clearer to do it this way. Thanks
  18. Thanks for the reply, I have never seen that before, is that a "register for events" box? I'm not sure what I would need to do with it to have it affect a control, do I need to somehow connect it to the two controls? Oh ok, its a property node, I found it and got it to work thanks. Is it possible to put that function inside a sub-VI and still have it affect the controls on the front panel of my main VI?
  19. Hi, Is it possible to set the data entry limits for a control according to the value of another control? For example, I have a program that generates a number of sine waves and plots them on a graph. A number of attributes for the waveforms can be altered and one of those is relative phase. The user can enter the phase offset in degrees or radians and selects which is to be used via a drop box. I want to restrict the max phase offset to 90 degrees so I have set the data entry limits to between 0 and 90 deg. However, if the user has selected to enter the phase in radians this now means they can enter up to 90 radians. I want the limits on the control to be 0-90 when degrees is selected but only 0-1.5708 when radians is selected (= 90 degrees). Is that possible? Thanks
  20. Brilliant, thanks guys that works perfectly.
  21. Hi, I am collecting some data and saving it to a csv file for analysis in Excell, is there some way to set the default file extension that the data gets saved as? I can set it to save in csv format, but when I get the dialogue box asking where to save the file it always defaults to "All Files (*.*)" as the file type and you have to manually enter .csv on the file name. Thats not a problem as long as you know to do it but I want to make it so that it defaults to *.csv so that when other people use the program they won't get it wrong and end up with a file they can't open. Thanks!
  22. Brilliant, got it working perfectly, thanks for the help guys! I have put the column headings in at the time that the arrays are initialised, as suggested.
  23. Ok brilliant, I tried that and it works well. I have also moved the table output inside the loop so that it appears to update the table one line at a time as the program runs. I have made it output the data to a comma seperated file which also works, and shows all of the data correctly in notepad or excell. Is there any easy way to get it to add column headings for the output file, or do I need to do this manually by ensuring that the first item of data for each array is the column heading? Thanks very much for the help!
  24. My actual VI that I am working on has lots of extra stuff in it and requires the input from the instrument to have the data to put in the table, so I've made a quick example VI to show basically what I am trying to do: Download File:post-15022-1240590018.vi The VI runs a loop and just adds 1 to a value each iteration to simulate the data from the instrument. The values are collected together in arrays and this is built into a 2D array before being put into the table. I also collect a time stamp once per iteration and build them in a separate array which I have just output to an array indicator to show the contents. What I want to do is have all 3 arrays in the same table, one per column, so that on each row I have a time stamp and the 2 "measurement" values. Thanks
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.