10-30-2009 09:51 AM
VeeJay wrote:Hi Guys,
I seem to have made some progress in figuring out the codes behind the buttons. Now, I have a list of commands and their corresponding ACK's that I have to program on LabVIEW. How do I go about doing that?
What do you mean? You previously indicated in post#22 that you are using 2 computers, and that you were able to "issue a command using LabVIEW to accept that there is a connection". Whatever that means. Does this mean that LabVIEW was simulating the software or the treadmill? Are you trying to simulate the treadmill with LabVIEW, the software, or both? I'm still not clear on this particular part. How do you have the computers connected together? Through a null modem cable? If you're trying to simulate the treadmill then your LabVIEW program basically has to sit in a loop monitoring the serial port. When it sees a command it recognizes, it responds. Fairly simple.
It is equivalent to programming "bytes" (that are commands) on a processor. Thanks!
I have no idea what you are asking with this, as it's a meaningless statement.
I have one more question. How do you convert a string that you obtain from the Serial read Buffer into a hexadecimal number? The information that the port is reading is basically hex codes but they are in string format. How do I convert then into Hex number or decimal so that I can use them directly in Case structures as case A0 or case A1 to do the corresponding operation.
It depends on whether you get the string as hex values or as characters that respresent hex numbers or as just letters. In other words, if you get the character "A" (ASCII 65), does this represent the letter A or the string representation of the hex value A?
10-30-2009 10:04 AM
What do you mean? You previously indicated in post#22 that you are using 2 computers, and that you were able to "issue a command using LabVIEW to accept that there is a connection". Whatever that means. Does this mean that LabVIEW was simulating the software or the treadmill? Are you trying to simulate the treadmill with LabVIEW, the software, or both? I'm still not clear on this particular part. How do you have the computers connected together? Through a null modem cable? If you're trying to simulate the treadmill then your LabVIEW program basically has to sit in a loop monitoring the serial port. When it sees a command it recognizes, it responds. Fairly simple.
__________________________________________________________________________________________________________________
I have the software installed on one comp and Labview on another. I have them connected by RS232 cable Rx->Tx, Tx->Rx and Gnd->Gnd . When the software asks for ACK in search for a treadmill, i send the appropriate ACK to the software from Labview to simulate a connection. Yeah, I figured it out last night as well. I have to loop through to keep monitoring the port. And I am thinking of using case statements to perform an action corresponding to the input command received.
It is equivalent to programming "bytes" (that are commands) on a processor. Thanks!
I have no idea what you are asking with this, as it's a meaningless statement.
____________________________________________________________________________________________________________________________________________________________
Reading it now, I see that it made no sense. 🙂 Sorry! . It was a long day that day. I wanted to know how to use these codes to perform the actions. But I guess that has been answered with the previous response.
_______________________________________________________________________________________________________________
It depends on whether you get the string as hex values or as characters that respresent hex numbers or as just letters. In other words, if you get the character "A" (ASCII 65), does this represent the letter A or the string representation of the hex value A?
________________________________________________________________________________________________________________
The format of Read buffer in VISA Read is String. Now, what it reads are hex codes like A0 or A1 etc in hex "string" format. I need them to be A0 or A1 in hex "number" format.
Thanks a ton!!
V
10-30-2009 12:56 PM
________________________________________________________________________________________________________________
The format of Read buffer in VISA Read is String. Now, what it reads are hex codes like A0 or A1 etc in hex "string" format. I need them to be A0 or A1 in hex "number" format.
In that case, if you have your string indicator set to "Hex Display" and you see A0, then to convert it to a number you just need a Type Cast. If you're expecting multiple values, then String to Byte Array can be used as an alternative.
10-30-2009 02:16 PM
10-30-2009 04:46 PM
A Person wrote:
You can also use the Hexadecimal String to Number function if you can use the decimal representation of your value from the VISA Read function.
That would only work if he's getting the character/letter "A", followed by the character "0". That's 2 bytes, not 1.
11-04-2009 05:17 PM
Hi Guys,
I am making quite some progress in this project, Thanks to you guys. I have a question though. When a command (1byte) is followed by 4bytes of data, how do I read the 4 bytes of data? Do I read the command first using VISA read and setting "bytes read" to 1 and then reading again using VISA READ by setting "bytes read" to 4? I am trying to display the 4 data bytes on an indicator but for some reason, it just displays 1 byte.
eg. #A4 followed by #30 #30 #30 #30
It just displays only one 30 even though I have read them all. But, on PortMon, I can see that A4 is followed by 30 30 30 30.
ANy help would be Kudoseeddddd!!!! 🙂
V
11-04-2009 11:00 PM
11-05-2009 04:01 PM
Hi,
Sorry for the late response. My PC was taken over by the Admin for Malware scan. Anyway, here are the answers to your questions.
_________________________________________________________________
Is the command being echoed?
No the command is not being echoed. There is a command byte and 4 data bytes.
____________________________________________________________________
Are you saying that the "return count" output of the VISA Read says 4? What kind of indicator are you using?
Yes, return count of VISA read is 4. String Indicator shows 4 bytes in string ASCII. Trying to convert it to numeric indicator as shown in the screenshot, I get just 1 byte.
eg. 4 bytes read are 0000 (30 30 30 30 hex) or 0100 ( 30 31 30 30 hex) or 0120 (30 31 32 30 hex)etc
string indicator shows then as such 0000 or 0100 or 0120 on normal display or (30 30 30 30 hex ) etc as above
the numeric indicator (elevation) shows just one byte 30 in hex. But I want it as above in hex numeric
___________________________________________________________________________________________________
Do you have a string indicator connected directly to the VISA Read output? If so, which display mode are you using for the indicator?
Yes String Indicator is on Hex mode. (I also tried normal mode but for now it is hex mode)
_______________________________________________________________________________________________________
What I want is the four data bytes inside the case structure in Hex numeric mode. Typecast is hex mode. U32 elevation is set to hex display. THanks! Please let me know if I was clear enough.
V
11-05-2009 06:50 PM
11-06-2009 11:20 AM
Thanks smercurio_fc,
Now that I have each byte in an array position, how do I use them as a "single" value? The four bytes together represent a value. I need to use that for my further calculations. Thanks!
V