Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

controlling a power supply through serial (USB)

Hey Everyone,
 
i am pretty new to LabView, and am trying to use LabView to control a High Voltage (HV) power supply through the USB port. The driver for it is installed and it is emulating COM3 port, which LabView can see. I am just trying to test the commanding by using the Basic Serial Write and Read.vi from the tutorial.
 
The power supply that i'm using states the following in the manual:
Serial communications will use the following protocol:
<STX><CMD><,>ARG><,><CSUM><ETX>
Where:
<STX> = 1 ASCII 0x02 Start of Text character
<CMD> = 2 ASCII characters representing the command ID
<,> = 1 ASCII 0x2C character
<ARG> = Command Argument
<,> = 1 ASCII 0x2C character
<CSUM> = Checksum (see section 6.3 for details)
<ETX> = 1 ASCII 0x03 End of Text character
 

6.3 CHECKSUMS

The checksum is computed as follows:

Add the <CMD>, <,>, and <ARG> bytes into a 16 bit (or larger) word.
The bytes are added as unsigned integers.
Take the 1’s compliment (negate it).
Truncate the result down to the eight least significant bits.
Clear the most significant bit (bit 7) of the resultant byte, (bitwise AND with 0x7F).
Set the next most significant bit (bit 6) of the resultant byte (bitwise OR with 0x40).
Using this method, the checksum is always a number between 0x40 and 0x7F.
The checksum can never be confused with the <STX> or <ETX> control
characters, since these have non-overlapping ASCII values.

so this means if i try to use command #14 for example, with argument 100, then i would write

<STX>14,100,<CSUM><ETX> (this is shown in an example of the manual)

adding 14, 44(ascii comma), 100 together = 158, so 10011110, then complement it i get 01100001

if i clear the most significant bit, i assume that means delete it?: 1100001
then set the most significant remaining bit, that means make it a 1? so i get 1100001 (dec:97 hex:61)

now to translate this to the string that labview wants, do i enter
\214\2C100\2C\61\3                 ?
 
if anyone has experience with this or recognizes the command structure i would appreciate any help
thanks in advance!
 
0 Kudos
Message 1 of 5
(3,320 Views)

also forgot to add, when i run that line into the sample program, i get the following error:

http://img215.imageshack.us/img215/5486/visaerrormz3.jpg

This error is different if i unplug the power supply, so that means that the LabView is at least seeing the powersupply on COM3, which is good. but what i did above definately doesnt work 🙂

0 Kudos
Message 2 of 5
(3,319 Views)

Hi Estomax,

I had the same problem with my USB-RS232 devices. Solution: Add the buffer function after the configuration function and I think your problem is solved.

btw. you posted at the wrong board, this board is for instrument control.



Message Edited by K C on 04-25-2008 08:29 AM
0 Kudos
Message 3 of 5
(3,303 Views)
thanks KC for pointing that out. I am actually not modifying my VI's at all. I am using the example VI, so i'm not sure what you mean by adding the buffer function after the configuration functions.
0 Kudos
Message 4 of 5
(3,286 Views)

Hi,

In a start VI there is a configuration for the COM port. After this configuration you should at the buffer function.

It is not in the standard VI's so you have to modify it. The buffer function can be found at the standard serial pallette. You can also use the help to find it.

0 Kudos
Message 5 of 5
(3,278 Views)