Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Communication using Serial port using the write and read buffer simultaneously?

Hi:
 
I am using RS232 Serial cable to communicate through LabVIEW 7.1 with a controller. In my application, I have read and write operations occuring simultaneously. Can I use a single COM port to read and write information simultaneously or do I need two COM ports. I tried using single port, it seems to work but I am not getting it to work as required. Please advice,
 
Thanks,
0 Kudos
Message 1 of 15
(5,513 Views)
Dsurana,

your Q is not completely clear.
Finally, a single µC as well as a single CPU, can do basically just a single operation at any given time. (Well, as huge ICs may have several cores and/or modules, they may perform several basic instructions in parallel. But this is usually not availabel to end users like us.)
So, frankly spoken, you cannot perform read and write operations _simultaneously_.  BUT, you can -of course- use a single port to send a command to a device and afterwards read its response. Seen from the LabVIEW point of view, this might be operated simultaneously, but the CPU performs either the write _or_ the read operation at any given time.

Your problem may arise from the inherent multithreading capabilities of LabVIEW. In order to enforce a dedicated sequence, you need to use a sequence structure and/or data dependency. The latter can be done by connecting the VISA references and/or the error clusters between all the nodes in the order they have to be executed.
A typical communication task is done this way:
Open the port, configure it
While not finished do
  Send a commnad to the device/controller
  Wait some ms to let the device perform the action and respond.
  Read the response, process it
While end
close the port.

Search the examples for serial communications.

You may want to post a more detailled Q or your code here in order to get more detailled answers.


HTH   and
Greetings from Germany!<br>-- <br>Uwe
0 Kudos
Message 2 of 15
(5,501 Views)
i have the same problem.
i'm trying to comunicate between serial and my siemens m35 telephone.
when i send an at command i recive in the read buffer the same command i sent and no an answer as i should.
do you have any advice?
 
thanks.
0 Kudos
Message 3 of 15
(5,480 Views)
Moreet,

I suspect you use the wrong cable. There are so-called Nullmodem cable, which are meant to connect two serial ports of PCs. Those cross the Rxd and Txd (receive and transmit) signals. This might cause the misbehaviour as you describe it.
You may try Hyperterminal and test, if it can connect with your device and can exchange commands and responses.  But you may as well try exchanging the serial cable with a staight (not-crossed) one.

Greetings from Germany!<br>-- <br>Uwe
0 Kudos
Message 4 of 15
(5,476 Views)

it is not a problem of cable becouse with Hyperterminal it works.

if i send the command AT+CGMM  with Hyperterminal the answer is correctly "M35i", with labview

is the same string i sent.
thanks again.
p.s. how can i discharge the read buffer?
0 Kudos
Message 5 of 15
(5,462 Views)
Just read all characters that are availabel at the moment!
0 Kudos
Message 6 of 15
(5,457 Views)
Are you sending a termination character at the end of your write string? Hyperterminal does this for you. When you write a LabVIEW program, you have to add this if required by the instrument.
0 Kudos
Message 7 of 15
(5,454 Views)
for dennis: yes, i use the /n line terminal
0 Kudos
Message 8 of 15
(5,438 Views)
this is the code.
thanks so much to everybody.
 
m.
0 Kudos
Message 9 of 15
(5,436 Views)
I solve the problem.
in the "visa configure serial port" i trusted in the default termination char A (hex).
i substitute it with a 0 and it works.
now the problem is how can i determine how many bytes i have to read.
i mean some times i ask to the telephone just the state of charge of battery (10 bytes are enought), but others i could ask the entire address book.
 
thanks.
 
m.
 
0 Kudos
Message 10 of 15
(5,430 Views)