Hello Guest it is August 03, 2021, 10:58:23 AM

Author Topic: mach 3 and the serial port  (Read 8152 times)

0 Members and 1 Guest are viewing this topic.

mach 3 and the serial port
« on: July 23, 2009, 11:37:02 AM »
Is there any way to write a script to send and receive to the serial port?

Offline Hood

  •  25,838 25,838
  • Carnoustie, Scotland
    • View Profile
Re: mach 3 and the serial port
« Reply #1 on: July 23, 2009, 03:04:51 PM »
Serial ModBUS is supported, otherwise I think you will need to write a plugin to handle it, think you can send at the moment without but not sure.
Re: mach 3 and the serial port
« Reply #2 on: July 29, 2009, 11:29:34 AM »
Step 1: Find the file mscomm32.ocx and put it in your windows\system32 directory
Step 2: Register it with the operating system using "regsvr32.exe mscomm32.ocx" at the command line
Step 3: Use the following code to open COM1 and send a 'b' character to the port

  Set MSComm1 = CreateObject("MSCOMMLib.MSComm")
  MSComm1.commport = 1
  MSComm1.settings = "57600,N,8,1"
  MSComm1.InputLen = 1024
  MSComm1.RThreshold = 0

  MSComm1.PortOpen = True
  MSComm1.Output = "b"

Unfortunately, if this code is run via a button, the port opens and automatic garbage collection appears to close the port after the script is complete.  This requires repetitive opening of the port, which can upset devices which watch control codes on the line. I'm currently looking for a workaround for this problem.