LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Communication question

Solved!
Go to solution

Hello, I hope everyone who sees this is doing well! I am somewhat newer to Labview and have been looking all over the internet for answers to my Labview code and this is my last resort because I cannot find them anywhere.

 

I am trying to create a code that takes any excel spreadsheet into Labview and keeps all the numbers from each box but deletes all letters (the letters and numbers will not be in the same box in excel, either numbers or letters, so in one box can be the number 10 and another can be just the letter z but there wont be a box with 10z) , then once I have gotten rid of all the letters within the spreadsheet I am going to send those numbers to a serial comport to be read in putty. 

 

First, I have noticed within LabView that it likes to convert any letter in a spreadsheet into the number zero. I have created a code that deletes the number zero from my inputted spreadsheet and therefore all letters but if the actual number zero is in that spreadsheet I do not want that number zero to be deleted, just the letters. Does anyone know how to do this? 

 

Second, I am also wanting to read my excel spreadsheet one number (Each box from left to right in 1 row, and no columns) at a time instead of saving a file after I get rid of all the letters and then inputting that entire saved file into the serial communication part of my code. I don't want putty to read the entire spreadsheet of just numbers all at once, I want it to ideally read one number at a time (or each box within excel) from left to right in row 1 in live time until it finishes each box of numbers. So, if there was 100 boxes within row 1 in excel from 1 - 100 in increments of 1, I want the putty to read 1,2,3,4,5 ... until 100 instead of just spitting 1-100 all at once.  

 

I apologize if this is confusing, and I appreciate anyone's help in this matter since I cannot find any help online anywhere. I am here if anyone needs clarification and thanks again! I am attaching my current code to this thread. Also, in my code you put the Programming File.csv into the test data and put the BinaryPull.txt file into both the saving to and write buffer controls on the front panel. (The BinaryPull.txt can be any text file that is just what I called mine, it also isn't attaching to this thread for some reason as a heads up)

 

 

Download All
0 Kudos
Message 1 of 9
(1,286 Views)
Solution
Accepted by lucas.orwick

Hmm, loos like you need to break the two tasks up into two VIs. Have on VI that pulls the data and does any formatting. The have another VI that takes the formatted data and pushes it out on the serial port. 

 

Start with the reading and formatting VI. Check out the attached VI read ascii.vi. the CSV file is a text file so reading it in as an array of strings is ok, then convert to numbers as needed. 

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
Message 2 of 9
(1,244 Views)

I'll stick in a tip.  Since 0 is the default default value for any numeric you will get a 0 value when you cannot convert a string to a number.  BUT, all of the string to Number functions have an optional Default Value input! You could use that to set a sentinel value like -1 or NaN.

 

NaN is a wonderful sentinel value since you can just remove any element that is not equal.to itself or IsNaN outputs T (IsNaN actually is implemented as x!=x)


"Should be" isn't "Is" -Jay
Message 3 of 9
(1,229 Views)

Hello, thank you for sending me this it has helped me a lot and it does what I needed to. I did take some time before I sent this question looking into the "scan from string" section but I have never seen an "unbundle by name" function so I think that's where I messed up. 

 

Would it be alright if I asked you one more set of questions and I'll leave you alone? 

 

If so, now that we have the code set up to get rid of the letters z and e, is there a way to put into the code when those letters pop up that it waits a certain amount of time when each letter pops up? So like if the letter z popped up in the excel spreadsheet then when it is in the for loop it waits like 5 seconds and then when e pops up it waits I don't know like 10 seconds? I am creating a code that once certain letter inputs are read on LabView it will wait a certain amount of time for instructions and then continue onto the next set of numbers. 

 

And why do you think I should split my vi into 2 separate vi's for one dealing with the letter sequencing and another for the serial communication? (I am trying to figure out the best way to do this and I am newer to labview) Also, is there a way to make my vi take the data live into putty (serial communication) so after each number or letter gets ran through the for loop for letter removal it reads that number one by one instead of running through the entire for loop and then sending those 100 numbers all at once through the serial communication? (So ideally I want it to read like 1,2,3,4,5 and if a "Z" pops up it will wait 5 seconds and continue reading into putty the number after "Z", so it would continue 6,7,8,9,10 ...) 

 

Thank you for all your help, and I will attach my files again to this message! 

Download All
0 Kudos
Message 4 of 9
(1,197 Views)
Solution
Accepted by lucas.orwick

@lucas.orwick wrote:

Hello, thank you for sending me this it has helped me a lot and it does what I needed to. I did take some time before I sent this question looking into the "scan from string" section but I have never seen an "unbundle by name" function so I think that's where I messed up. 

 

Would it be alright if I asked you one more set of questions and I'll leave you alone? 

 

If so, now that we have the code set up to get rid of the letters z and e, is there a way to put into the code when those letters pop up that it waits a certain amount of time when each letter pops up? So like if the letter z popped up in the excel spreadsheet then when it is in the for loop it waits like 5 seconds and then when e pops up it waits I don't know like 10 seconds? I am creating a code that once certain letter inputs are read on LabView it will wait a certain amount of time for instructions and then continue onto the next set of numbers. 

 

And why do you think I should split my vi into 2 separate vi's for one dealing with the letter sequencing and another for the serial communication? (I am trying to figure out the best way to do this and I am newer to labview) Also, is there a way to make my vi take the data live into putty (serial communication) so after each number or letter gets ran through the for loop for letter removal it reads that number one by one instead of running through the entire for loop and then sending those 100 numbers all at once through the serial communication? (So ideally I want it to read like 1,2,3,4,5 and if a "Z" pops up it will wait 5 seconds and continue reading into putty the number after "Z", so it would continue 6,7,8,9,10 ...) 

 

Thank you for all your help, and I will attach my files again to this message! 


Good to hear it is starting to work out. Lets break the problem down into blocks. It is better to think of a VI as a function, not a program. You should use many VIs to make a program. A VI can be a stand alone program but it is not extensible and will cause you more trouble in the long run if you have a monster VI instead of a real program. This is not immediately apparent so I guess you will just have to take my word for it or learn the hard way. 

 

With the being said, lets break your problem up into block and solve each one of them in turn. Check out the updated read ascii VI, it might be just what you are looking for. 

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
Message 5 of 9
(1,182 Views)

Why do you need putty at all. Simply have LabVIEW communicate directly with the device. There should be no reason you need to have putty as part of your solution.

 

LabVIEW is a complete programming language. Yes, it can do everything that you are asking about. However, based on your messages your requirements for what your application needs to do seem very vague. It also seems like  you are trying to make LabVIEW behave exactly like some manual task including using putty to accomplish your task rather than stating explicitly what your task needs to do. There are probably much better solutions to your problem but in order to offer advice we would need a much clearer explanation of what you need to do. Don't worry about the how right now. Start with the what.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 6 of 9
(1,179 Views)

Hello again, okay this has fixed my issue and I appreciate all your time and help in my matter, I couldn't find anywhere on the internet (google, labview's website, youtube ...) to address my problems so you are a life saver! 

 

Have a good one,

Luke 

0 Kudos
Message 7 of 9
(1,146 Views)

@lucas.orwick wrote:

Hello again, okay this has fixed my issue and I appreciate all your time and help in my matter, I couldn't find anywhere on the internet (google, labview's website, youtube ...) to address my problems so you are a life saver! 

 

Have a good one,

Luke 


No problem, A good way to say thanks is to select the post that solved your issue as the solution. 

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
0 Kudos
Message 8 of 9
(1,141 Views)

@lucas.orwick wrote:

Hello again, okay this has fixed my issue and I appreciate all your time and help in my matter, I couldn't find anywhere on the internet (google, labview's website, youtube ...) to address my problems so you are a life saver! 

 

Have a good one,

Luke 


Most serial communication issues can be solved by watching this video: VIWeek 2020/Proper way to communicate over serial

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 9 of 9
(1,127 Views)