Renan Valente Posted June 22, 2020 Report Share Posted June 22, 2020 Hello Mates, need some advice from you. My data come from serial port as a big string and it is stored to a double array, I save the time stamp as string and them the whole DBL array as dynamic data, then I get this nice TDMS file which in excel looks like this: I only need to read the C and D columns, what is the best approach? Probably there is a better way to save the tdms, I willing to improve my code Quote Link to comment
hooovahh Posted June 23, 2020 Report Share Posted June 23, 2020 So there are plenty of improvements I can suggest for readability, but overall I think the code isn't bad. A few comments would help, and I'd prefer less feedback nodes, and instead code that calls it in a loop, but to be fair that might have just been what you did to demo it. I think all that is needed to to try to not use the dynamic data type. It can do unexpected things, and can hide some of what is going on, inside those functions that you need to open the configure dialog for. This can make the code less readable. So I'd get rid of the To Dynamic data, and instead use the Array Subset function on the 2D array of doubles. This should allow you to get just the two columns you want, and write that to the TDMS file. You may have to mess with the decimation, and possibly transpose the 2D array. I can never remember how the functions work, and so I'm often writing test code to see if the columns end up the way I want. This will mean of course that you also use the Array Subset on the 1D array of string which is the channel names. As for the time entry, it looks like it works, but might I suggest a different string format? Here is a post that shows how to use the Format Into String, with the timestamp input, which returns an ISO standard string format. More standard, and if a log is moved from one timezone to the next, it can still be clear when the log was made. Quote Link to comment
Renan Valente Posted June 26, 2020 Author Report Share Posted June 26, 2020 Hello Mr Hooovah, I really appreciate you answer, this is a subVI, the main loop runs in the main VI, which call all the function in a time frame loop, I think this is fine, right? As for the feedback loops, I'm still getting used to the concept of not having instaced variables and this whole wiring concept so, in a brief context: How should data be kept in a wire if not with feedback loops? Another thing, I'm only saving data when it has changed and this is a problem with the time marking, I would like to store is as a waveform of multiple channels, so the time mark could change and not having the very same sample rate, how should I implement this? Quote Link to comment
hooovahh Posted June 29, 2020 Report Share Posted June 29, 2020 I think we're at the point where to better help you need to post the actual VIs. I suspect lots of coding styles that are indicative of beginner LabVIEW programmers and I can't make blanket statements like "Don't do this" without being able to see more of what you are trying to do. Like my initial reaction is that timed loops shouldn't be used except on RT or FPGA platforms. I also see lots of booleans that I would suggest using an event structure for capturing their value change. Maybe putting them all into a single cluster and capturing that value change would be better. Other suggestions are to use a state machine, or queue message handler. This usually has a cluster of stuff to carry between cases and can be thought of as something akin to variables. 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.