LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with interface for serial port

hello!

I am a new user for LabView, and I met a problem with
interface for RS232 instrument to build.

It is for ventils to control ( ventil runs just as a small air pump), I want
to
do it by LabView programm.

it runs by:
9600 bau rate,
8 data bits,
1 stop bit,
no parity.
4 chanals.(it can control max. 4 ventils)

I set them up by the first step.

And then I wanted to give a command to test it. I got the information
from its manual: (open one ventil)

Byte1 Byte 2 Byte 3 Byte4
10010000 0000CCCC 00000nnn 0nnnnnnn


CCCC: the number of chanal (it is chanal 1 that i would test).
nnn nnnnnn (10bits in Byte3 and 4)) : the value of the pump (in %, i wanted
100%).

So by the se
cond step I wrote the string
"10010000 00000001 00000111 01111111"
directly in
Write.vi to be sent to COM2, and the next step I set up the Read.vi to get
the return signals.
But there is no action from this ventil, and the program doesn't show any
error code ,
by Read.vi it got only the singals "/00" .

I think maybe I should not set up the order just as the long string with 0
and 1 directly to
the Write.vi, but what should I write?

Could someone give me some details about how to build an interface just like
it correctly?

Le
0 Kudos
Message 1 of 4
(2,872 Views)
Perhaps use the VISA VIs.
First init and configure port.
Second write data to port. I suggest you send the data in four bit chunks,
not eight:
1001 0000 0000 0001 0000 0111 0111 1111

Also check timeout settings.

You can set these with VISA by using property nodes.

It takes some playing around to get the stuff talking.

Also remember that serial devices need the correct string terminators to
work.

Hope this helps,

James

> So by the second step I wrote the string
> "10010000 00000001 00000111 01111111"
> directly in
> Write.vi to be sent to COM2, and the next step I set up the Read.vi to
get
> the return signals.
> But there is no action from this ventil, and the program doesn't show any




[Attachment visa send example.vi, see below]
0 Kudos
Message 2 of 4
(2,872 Views)
Perhaps the instrument is looking for binary data and you are sending it an ASCII string? Try setting a string constant or control to display hex, right-click>>Hex Display, and type in your four bytes in hex (90 01 07 7F). Then connect that to the input of your write vi. This may be what your device is looking for, its hard to say without seeing it.

Hope this is some help!

Brian
0 Kudos
Message 3 of 4
(2,872 Views)
Garfield wrote:
>
> hello!
>
> I am a new user for LabView, and I met a problem with
> interface for RS232 instrument to build.
>
> It is for ventils to control ( ventil runs just as a small air pump), I want
> to
> do it by LabView programm.
>
> it runs by:
> 9600 bau rate,
> 8 data bits,
> 1 stop bit,
> no parity.
> 4 chanals.(it can control max. 4 ventils)
>
> I set them up by the first step.
>
> And then I wanted to give a command to test it. I got the information
> from its manual: (open one ventil)
>
> Byte1 Byte 2 Byte 3 Byte4
> 10010000 0000CCCC 00000nnn 0nnnnnnn
>
> CCCC: the number of chanal (it is chanal 1 that i would test).
> nnn nnnnnn (10bits in Byte3 and 4)) : the value of the pump (in %, i want
ed
> 100%).
>
> So by the second step I wrote the string
> "10010000 00000001 00000111 01111111"

I think that's the problem, you dont have do send a string of 35 bytes,
but
you have do send only four bytes !. Create the four bytes you want to
send
in an array and use the function "Byte Array to string" to create a
string
containing your bytes, then send this string of length four to your
device.

By the way, i made the experience that it is generally easier to deal
with
the serial port by using LabView VISA. When you have to check for
timeouts you need to write your own timeout loops when using the normal
serial port VIs. If you use the LAbView VISA-VIs you can specify a
timeout limit when you initialize the serial port and then the VISA-VIs
detect automatically timeout situations.

regards

Guenter
0 Kudos
Message 4 of 4
(2,872 Views)