02-07-2016 02:06 AM
02-08-2016 07:13 AM
I don't know of a serial port LED.
You need a 2-5V output to turn on an LED typically. You should ensure that you protect the LED with a resistor.
Many data acquisition devices have Digital I/O. With DASYLab, simply configure your control signal (5V) to a Digital output for your device.
When I do DASYLab training, I use a Combi Trigger module for the control and output directly to a MCC USB-204 DO wired with an LED on signal and ground.
02-22-2016 03:24 AM - edited 02-22-2016 03:31 AM
You can use the Script module to open a serial port. Turn on/off the RTS/DTR pins (4 and 7, DE-9) dependent on the incoming data value. The serial library is included in DASYLab's Python.
Code fragment of a Script module with inputs only:
import serial
...
def Start (self):
self.port = None
try:
self.port = serial.Serial(port = "COM1",
baudrate = 9600,
bytesize = 8,
parity = serial.PARITY_NONE,
stopbits = serial.STOPBITS_ONE,
timeout = 0,
xonxoff = 0,
rtscts = 0)
except:
print "Unable to open COM1."
return False
#end Start
def Stop (self):
if self.port and self.port.isOpen():
self.port.close()
#end Stop
def ProcessData (self):
...
InBuff = self.GetInputBlock(0) # NULL check omitted
val = int(InBuff[0])
InBuff.Release()
if val == 0:
self.port.setDTR(False) # <-- !
self.port.setRTS(True)
else:
self.port.setDTR(True)
self.port.setRTS(False)
return True
#end ProcessData