Rain Lei wrote:
> Dear Gentlemen,
>
> Thanks for reading this at first.
>
> I need to use Labview to connect two instruments to my MACINTOSH. Both the
> instruments offer standard 9-pin RS232C interface. ( So, the first question
> is how to convert 9-pin setting to 8-pin? )
Someone with MAC experience will have to help here. There are really only a few
line
required for RS232. Check to see if you can find a converter at your local PC /
Hardware sttore.
>
>
> An example code of BASIC comes with one instrument is as follows:
>
> 10 PEN "COM1:600,N,7,2,RS,CS,DS,CD" AS #2
My knowldge of BASIC is years old but here goes. This line (10)
sets up the serial port (COM1 is the 1st serial port) to 600 baud, no parity, 7
data bits, 2 stop bits.
The RS (ready to send), CS (clear to send), DS (not sure about this one), and CD
(carrier detect, or signal present)
are control lines that determine when to Tx, Rx data. The #2 tells what data
type (integer, float etc) to use.
Check the BASIC manual to find out. Setting these command bits puts them into
some state (I'm guessing high)
>
> 20 A$="D"
This looks like the command that you send to the equipment
>
> 30 PRINT #2,A$
This sends the "D" to the gear
>
> 40 IN$=INPUT$(14,#2)
This reads back 14 bytes of data.
>
> 50 PRINT IN$
> 60 COLSE #2
> 70 END
>
> Could you offer me some information about Line10,20 and 40?
> What's the meaning of "RS", "CS", "DS", "CD"? Especially,
> what's the meaning of Printing "D" to COM1 port? How can these be implemented
> in Labview?
>
> The other has an example code, too:
> 10 J=1
> 20 OPEN "COM1:9600,N,8,1,RS,CD,CS,DS"AS #2
> 30 A$=INPUT$(8,#2)
> 40 IN LEN(A$)=8, GOTO 50, ELSE GOTO 80
> 50 N!=VAL(LEFT$(A$,7))
> 60 PRINT J,N!
> 70 J=J=1
> 80 GOTO 30
> 90 END
>
> What's the meaning of INPUT(8,#2)? Is it going to read 8 bytes from COM1?
> Is N! a variable of Character String? What
> is the meaning of LEFT(A$,7)?
>
The LEFT command takes the leftmost 7 bytes of the A$ and makes them an Integer
(I think)
This is meant to strip the last character (probably a Carriage return).
You realize of course that you can only talk to one piece of gear on one COM
port.
There is no addressing or arbitration on a serial port. If you try to hook up
two pieces
to the same serial port you will get a lot of nonsense.
This can all be done easily in labview. Use the VISA functions.
Kevin Kent