pockey Posted March 1, 2007 Report Share Posted March 1, 2007 Hi, all I'm writing a program to test a board. And the front panel is shown as follows: http://forums.lavag.org/index.php?act=attach&type=post&id=5056 When I click the "Start ADC" button, the computer will send a command to the board and the board will return both the command and hex string with 50 values. As shown "0xC7CE0xC7CE0xC7CE0xC7CE0xC7CE0xC7CE0xC7CE0xC7CE0xC7CE0xC7CE0xC7CE0xC7CE0xC7CE...."(they're the same as a testing) My job now is to take out the 50 values and calculate the average of them. It seems there's a tool called "Hexstring to number", I think I could use it to take every element out(not include the "0x"). However, I could not get the "0xC7CE0xC7CE0xC7CE0xC7CE0xC7CE0xC7CE0xC7CE0xC7CE0xC7CE0xC7CE0xC7CE0xC7CE0xC7CE...." in that button event as shown in the right string indicator. Only the command "c a" was received at that stage. Below is the block diagram of the "Start ADC" event: http://forums.lavag.org/index.php?act=attach&type=post&id=5055 As I did not know how to get the hex string, I could do nothing to get the average value..... Anyone could give me some tips?? Thanks a lot! The original VI is aslo attached. Quote Link to comment
Albert Geven Posted March 1, 2007 Report Share Posted March 1, 2007 maybe have a look at this Quote Link to comment
Mellroth Posted March 1, 2007 Report Share Posted March 1, 2007 Here is the same thing as Albert gave you, but using "Spreadsheet string to array" to do the conversion. http://forums.lavag.org/index.php?act=attach&type=post&id=5060 /J Quote Link to comment
pockey Posted March 2, 2007 Author Report Share Posted March 2, 2007 Thank you for your help!! So now I know how to convert the string to an array. However, the first problem is still there...I don't know how to get the exact hex string. http://forums.lavag.org/index.php?act=attach&type=post&id=5071 As shown, I could only get the "c a" command. It seems the hex string value will be received until next Read from the COM Port. http://forums.lavag.org/index.php?act=attach&type=post&id=5072 And if I replace the SubVI with detailed write and read implementation, I still could only get the "c a" in String Indicator 2 http://forums.lavag.org/index.php?act=attach&type=post&id=5073 It's so difficult to get the desired string from the COM Port...... And without the string, I could do nothing:( Quote Link to comment
Ton Plomp Posted March 2, 2007 Report Share Posted March 2, 2007 Hi Pokey, could you show (in a label) what display type the command string has? What happens in hyperterminal? Tonn Quote Link to comment
Albert Geven Posted March 2, 2007 Report Share Posted March 2, 2007 Hi Are you having the endchar enabled in your write/read subvi? Could you post this also? You probably need to read twice. Once for the command and once for the data. Quote Link to comment
pockey Posted March 2, 2007 Author Report Share Posted March 2, 2007 http://forums.lavag.org/index.php?act=attach&type=post&id=5075 The hyperterminal is shown as above. However, I do not understand much about "display type".... I did not use the SubVI in this event so that I can get the string without previous information. And there's nothing shown in String Indicator 2 if I read the COM Port twice. http://forums.lavag.org/index.php?act=attach&type=post&id=5076 But it's strange that if I "Highlight Execution", the hex string what I want will be shown in the String Indicator 2. Why, why, why... I have no idea about "endchar enabled", the SubVI is also attached. Quote Link to comment
Ton Plomp Posted March 2, 2007 Report Share Posted March 2, 2007 Hi Pokey, remove the second read part, and make the wait longer (500 ms) Ton Quote Link to comment
pockey Posted March 3, 2007 Author Report Share Posted March 3, 2007 Even I change the Wait time to 1000ms, I still could only get the "c a" in String indicator 2.... With two read parts, I get nothing~~~~ Quote Link to comment
pockey Posted March 3, 2007 Author Report Share Posted March 3, 2007 Oh, the problem has been solved! I add wait time before the second read part and with enough wait time, I could get the desired string now!! http://forums.lavag.org/index.php?act=attach&type=post&id=5091 And now I want to calculate the average of the total 51 hex values, is there such function offered by LabVIEW? Quote Link to comment
Ton Plomp Posted March 3, 2007 Report Share Posted March 3, 2007 QUOTE(pockey @ Mar 2 2007, 03:44 AM) Oh, the problem has been solved! I add wait time before the second read part and with enough wait time, I could get the desired string now!!And now I want to calculate the average of the total 51 hex values, is there such function offered by LabVIEW? Why the two reads? Mean.vi? Ton Quote Link to comment
pockey Posted March 3, 2007 Author Report Share Posted March 3, 2007 I do know why there should be two reads.... However, the tests I do show such conclusion. 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.