LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuous Serial signal

Hi, i would like to ask, does anyone know how to use LABVIEW to create a fix continuous string to send through the serial port using VISA? What i want is actually to send only ONE string(hopefully it maintains without stopping even for a milisecond), thus sending out a signal through PIN 3 of the serial port.
What i tried was to use a while loop to continously send the signal out, but by using this method, it will keep generating a new string afresh,thus sending pulses after checking through the oscilloscope.At every start of the while loop, there will be a short period where no signal goes through because of the relooping while loop. 
What i would like it to do is to send the signal without actually restarting the whole sending process(this is because of the while loop) thus creating only active high signals and not 0 volts.
I would really appreciate the help i can get
0 Kudos
Message 1 of 13
(4,297 Views)

Hi,

If you send something over a com port this will be with the serial protocol. It start with a startbit after that comes the data (and parity if selected) and it end with a stopbit.

The startbit is always one and the stopbit is always zero (seen at the Tx and Rx pins of a Uart)

So the TxD at a com port cannot be at one level all the time  (except when there is no data)

 

 

0 Kudos
Message 2 of 13
(4,286 Views)

Thanks for the tip. appreciate it. 🙂 Is there any other suggestion if i want to get a fix signal without going through the while loop which creates the on and off sequence over and over again? I'm using a simple program from the NI examples. The program is called "Basic serial read and write" Basically, this program requires the user to key in any string. After connecting the 2nd and 3rd pin of the serial together, the string that the user entered would be read and displayed back on the screen.

So what i did is i put a while loop over the whole program not leaving anything. This will create continuous string writting, but like i said, there will be a short delay where the signal goes down to zero and then up again through the oscilloscope. I need the signal to stay alive, that is if possible, send a string or a series of it,and thus maintaining it without looping.

Thank you

0 Kudos
Message 3 of 13
(4,273 Views)
You could use the VISA serial break command : the signal goes high for 250 ms. Repeated calls using a loop containing only the break command give a nearly continuous signal except for a 0.08 ms low signal (may vary from one PC to the other...).

Message Edité par chilly charly le 01-23-2006 05:56 AM

Chilly Charly    (aka CC)
Message 4 of 13
(4,260 Views)
Even better, the Break signal can be sent continuously using a property node found in the modem line settings.
 
Chilly Charly    (aka CC)
Download All
Message 5 of 13
(4,253 Views)
Thanks alot Chilly Charly, really opened up my view. One thing i don't quite get it. Doesn't the Break function acts to detect a break (a period where no signal goes through) ? So what does continuous break mean? I mean what does it actually do the fact that you said it will give a continuous signal? How does it function?
 
The reason why i wanted the signal to be continuous is because i need the computer to continue sending signal through the serial port (Using string characters which actually represents bit signals of 1's and 0's). I'm using the string character " < " which after you convert it to bit terms, it should give a signal of 00111100. So after sending lots of it, it gives out   001111000011110000.....  (used this signal because i can't seem to find any character which gives 11111111111.......)  The  "< " character actually gives a not too bad fluctuating signal, which shouldn't give much problem. Question: Does the Continuous Break program gives and maintains only " 1 " bit signal?Because that would actually solve the converting of string to bit problem! 
 
This is so that i get a continuous voltage flow through the serial from the computer which is around 2-3 volts to power up a 5V relay which i had connected to a PCB board.I think you should know how the relay works.So as long as i get a signal, the relay is activated thus causing the switching voltage(Which is quite a high DC voltage) of the relay to pass through it without any droppage to zero which i got in result by using the while loop.
Thanks again Chilly Charly for that .vi 🙂
0 Kudos
Message 6 of 13
(4,228 Views)
You could use one of the handshaking signals. They will stay continuously in the specified state. You can control them from a property node (I think).

Lynn
0 Kudos
Message 7 of 13
(4,222 Views)
As "Mr. Lynn" said, a handshaking signal, like DTR, is best to use for this purpose.  If you want to stick with sending characters or a break signal, you can smooth out any fluctuation by using a large capacitor on the receiving end.  A value of 250uF or above would probably work.  Put an oscope on the output to see if the DC voltage is smooth enough and adjust the capacitor value accordingly.  You may have to put a small resistor in series from the RS232 output to the capacitor to prevent a direct short when the voltage first arrives, since the capacitor will act like a short the instant the voltage is applied until it charges up.
- tbob

Inventor of the WORM Global
0 Kudos
Message 8 of 13
(4,215 Views)

Mlws

A break is a signal sent on the serial port : the line is maintained at high potential for a predetermined time. Default to 250 ms, but can be adjusted programmatically between 0 and 500 ms.

The Continuous break vi maintains the line perfectly at 1 as long as you want. I checked that with an oscilloscope. No need to send any fancy string in a loop, or to add a capacitor (tbob, that's something for you 😉 !) I suspect that only few LV users know the trick !..

However, for your application you could have used other lines. DTR is often used as a voltage source, and RTS could be used aswell. 

Clearly, a serial port can be used as an in/out port, with 3 output lines (TxD, DTR, RTS) and 4 input lines (CTS, DSR, DCD, RI).

Message Edité par chilly charly le 01-23-2006 07:50 PM

Message Edité par chilly charly le 01-23-2006 07:51 PM

Chilly Charly    (aka CC)
0 Kudos
Message 9 of 13
(4,210 Views)
The question is, does the port signal have enough voltage and current to drive the relay reliably? You may want to verify against the specs of your relay. You may be better off with an optocoupler between the serial port and the relay (for drive and isolation) or use a transitor or driver chip. If it is a coil relay, include a reversed biased diode across the coil so you don't zap the serial port with the voltage spike that results when you turn the relay off.
~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
Message 10 of 13
(4,157 Views)