Skip to main content

It is often desirable to create reports or provide data collection for a Galil motion controller or PLC. Galil hardware provides array and variable data for local storage, but in some cases the amount of data, or length of collection time is large enough that an external storage medium, such as a hard drive, is more convenient. The following is a simple example of using Ncat to provide data archival capabilities on a network attached Windows computer. Although these examples are for Windows, Ncat is available on many other operating systems.

"Ncat is a feature-packed networking utility which reads and writes data across networks from the command line." http://nmap.org/ncat/

Download and install Ncat on your system.  The following Windows batch file will run Ncat in a loop to continuously listen for connection requests from your controller. Connections on port 1024 will be handled and the controller's output will be sent to dmclog.csv.

@echo off
:loop
REM Change the IP address to match the IP of your PC
"C:\Program Files\Nmap\ncat.exe" -l  192.168.123.100 -p 1024 >> dmclog.csv
goto loop

The following DMC code is run on the controller. It connects to Ncat, sends 5 pieces of information in comma separated value (CSV) format 100 times and then closes the connection.

IHH=192,168,123,100<1024>2
WT10;'wait for TCP handshake
i=0
#loop
'Report back some useful data
CW2;'Message data in ASCII
MG{EH}TIME,",",_TPA,",",_RPA,",",_TTA,",",_TEA
CW1;'Message data in Galil ASCII
WT10
i=i+1
JP#loop,i<100
IHH=>-2
WT10;'wait for TCP tear down
MG"Done"
EN

Once the DMC code runs, returning "Done," issue a ctrl-C to the Windows Batch file to stop the listening loop. dmclog.csv can then be opened in Open Office Calc, Microsoft Excel, or similar. The connection established to Ncat can last indefinitely, be opened and closed at will, and will save all data sent to it.