LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

instruction visa rs232

Hello,
I try to drive a K8056 Velleman relay card under labview 8 via serial (rs232) connexion. The user manual gives poor information about the syntax of commands (http://www.velleman.be/download/manuals/?id=351282).
The test software given on Velleman website is running well, but I didn't manage to drive the card with labview.
I'm using the VISA serial VIs. I think there is a problem of syntax for the instructions or maybe i'm wrong with the checksum.

I'm trying to toggle the first relay :
chr$(13)
1
T
1
checksum : 255-(13+49+84+49)+1=61

Here are the bytes i send, but I'm not sure for the separation and end characters.
Could anyone help me to find the right syntax ?
Thanks for your help !!
0 Kudos
Message 1 of 15
(6,571 Views)
I certainly looks like you are assembling the command string correctly. Are you sure the address and port settings are correct? (2400/8/N/1)

I also found the following comment:
  • For wired operation, the instruction sequence needs to be sent at least twice.
This might be the problem. Try sending the command string end-to-end a few times with no break.

Mike...

PS: the assembly instructions are funny - I especially like where it tells yo to be sure to use "raisin-core" solder...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 15
(6,542 Views)
Hi,
i always sent 3 or 4 times the same comand.
I'm sure of the port adress.

I open a visa session, i configure the port for 2400 (normally, the other parameters are default settings), send a string via VisaWrite, and i close the visa session.
I try that sort of string : "chr$(13)\chr$(1)\T1\109\n" reapeted several times but it does not work.
0 Kudos
Message 3 of 15
(6,522 Views)

Are you including the chr$ bit? If so that is not correct. Also don't include the linefeed "\n" at the end. The protocol said nothing about that so don't include it. The entire command string should only be 5 characters long.

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 15
(6,505 Views)
I'm a little confused about what is actually being sent. You mention the string 'chr$(13) etc. Surely you are not sending the characters 'chr$(13) etc. are you?
0 Kudos
Message 5 of 15
(6,502 Views)
Yes, i send exactely what i wrote. I'm sure there is a problem with that, but i have no idea of what to send.
The instruction "chr$(13)" is given in the user manual of velleman.

I know that the port effectively send bytes but i suppose that labview translate from ascii to bytes ?? Am i wrong ?
0 Kudos
Message 6 of 15
(6,493 Views)

In text based programming languages, the chr$() function will return the ASCII character specified by the value inside (). chr$(13) is the carriage return character. There are numerous ASCII tables available on the web that you find and use as a reference. Decimal 13 is hex 0D and in LabVIEW, you can specify hex characters by right clicking on the string control/constant and selecting Hex Display. You can also select '\' Codes display. The '\' code for a carriage return is \r. In your example of sending a CR, 1, T,1, and the 105 checksum, with hex display you would send 0D31 5431 6C. The type cast and Byte Array to String functions can be used to create the correct string. Shown below is a U8 array and the Byte Array to String. One byte array is set for hex display and one for decimal. They both create the same data.

Message Edited by Dennis Knutson on 06-20-2007 11:17 AM

Message 7 of 15
(6,485 Views)
thanks, i'll try that.
how do you get the cheksum ??

Thanks a lot

Message Edité par Matthieu42 le 06-20-2007 12:27 PM

0 Kudos
Message 8 of 15
(6,480 Views)
LV does no conversion of the data. It sends exactly what you give it. In this case it would have sent the character "c" followed by the characters "h", "r", "$" and so on...
  • First, the character with the ASCII value of 13 (decimal) is the carriage return.
  • Second is the card address this is a U8 value between 1 and 255.
  • Third is a single ASCII character - In this case the character "T" (84 decimal)
  • The fourth byte is interpreted in one of two ways. Depending upon the command it can be either a U8 value (1..255) OR an ASCII value between 49 and 57 (which corresponds to the characters "1" through "9".  For the command "T" it expects the ASCII values.
  • Finally comes the checksum.
In total, exactly 5 bytes - no more no less.

The attached VI generates a command string for the T command... When using this code wire the output of the command formatter directly to the input of the serial write. Do not try to copy and paste the output of this VI unless you set the string control you are pasting into to "Hex Display".

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Download All
0 Kudos
Message 9 of 15
(6,472 Views)
I didn't actually calculate the checksum. I just used the 109 value you had posted (and copied it wrong and used 108). In the first post of yours, the decimal 61 seems correct and Mike's example matches that.
0 Kudos
Message 10 of 15
(6,469 Views)