Wireless Data Link From Beckman LS-6500 Scintillation Counter
This document describes how to set up a wireless data transfer link between a Beckman LS 6500 scintillation counter and a PC. The data from the scintillation counter are parsed into an HTML file and posted on the web page of an Apache web server running Linux. It assumes you already have a functioning wireless network configured in infrastructure mode.
Configure Serial Port and Wireless Converter
A wireless serial port device is a small box that receives data from an RS-232 port, in this case from a scintillation counter, and transmits it wirelessly to your network. When it gets to your network, the data are just ordinary IP packets. The easiest way to capture the data is to have the device send it by UDP. This allows any computer to listen on the appropriate port and collect data passively. Alternatively, sending it by TCP provides better security and data integrity. If you're using Linux, there is no need to write a network program to handle this--just use netcat.
- Connect a wireless serial device server such as a Moxa NPort W2150 to a PC using an RJ45 patch cable. Do not power up the NPort until the patch cable is connected.
- Change the IP address of your PC to 192.168.126.253 / 255.255.255.0.
- Use a browser to connect to the NPort at 192.168.126.254. There is no default password.
- Set the NPort to a static IP on your network. Note that it needs two IPs: one for the wireless link, and one for the RJ45 port that you use for the initial configuration.
- Configure the NPort serial port to 9600 8N1, no handshaking. Set the Operation Mode to Socket | UDP. In socket mode, the data are sent over the network to your server as UDP network packets. It is much easier to recover the data from these packets using netcat than to install a driver to convert the data back to RS232 format, and then trying to read the data back using a virtual serial port.
- Set the Packet length to 0.
- Enable Delimiter 1 and set it to 0D. Leave Delimiter 2 disabled. Set Delimiter process to "Do nothing". Set Force transmit to 0.
- Configure the NPort wireless settings to match your network and set it to infrastructure mode.
- Configure other settings as needed as described in the NPort manual on the CD.
Configure the Scintillation Counter
The scintillation counter does not send data out the RS232 port unless the user program specifically requests it.
- Connect the NPort to the serial port on the scintillation counter using a M-DB25---F-DE9 serial cable. Note: do not connect the NPort to the serial port of the Wyse terminal on the LS6500 by mistake. The green WLAN LED should be illuminated on the NPort.
- Use the scintillation counter menus to set the global serial port parameters to 9600 8N1, no handshaking.
- Edit your user program to activate RS232 output. This needs to be done for each user who needs remote access to their data.
Netcat copies everything that shows up on port 4001 into a file. These data are formatted in a special code devised by Beckman. The code is documented in the scintillation counter manual. We use Apache and a CGI program to parse the file and convert it into a simple HTML file.
- Install netcat (nc6), gcc, and Apache on the Linux server and configure Apache for CGI as described in linuxsetup44.html.
- Add a link on your homepage to
scintillation.htmland copy the scintillation.html file (see below) to your htdocs directory.
- Compile and install the
scinprogram (see below) in your cgi-bin directory.
- Su to the username that is running httpd, cd to your htdocs directory,
and start netcat with the following command:
nc6 -u -l -p 4001 >> stuff
Since netcat doesn't have a daemon mode, you should 'nohup' it if you plan on running it continuously.
nohup `nc6 -u -l -p 4001 >> stuff` &
- Start some samples in the scintillation counter.
The yellow serial LED should blink on the NPort.
Raw data should begin to appear in the file named
stuff. If not, check the write permissions, file ownerships, and the system logs (usually /var/log/messages). The data should look something like this:
e5D#(T 3;#*T 23-3 ;#+R 0.20;#-R -1.7;$]R 25.00;$LR 25.00;#0R 89.44VH 56D#>R 3.16;#,R 2.3700 '7D.1N%/ '8D./N%. $9Z"W $:B"@ $ S"7
- Since netcat often stops running for no apparent reason, it's recommended
to write a script using
pidofor a similar utility, and set up a cron job to check every five minutes and re-start nc6 whenever it stops running.
In order to read the data, we will use a CGI program to convert it to an HTML file. The data format from the LS6500 is different from that used in the LS3801. The biggest inconvenience in parsing the data is the fact that multiple data items can appear on a single line. Thus, data items can be separated by semicolons or by newlines.
scintillation.html should look something like this:
<html> <head> <title></title> </head> <body> <h4> Scintillation counter logs </h4> <img src="ls6500.jpg" alt="ls6500" title="ls6500" /><br /> This page displays raw output from our Beckman LS 6500 scintillation counter in room 146. <br /> The data are transmitted wirelessly to our local network using UDP. The raw data is available to anyone on port 4001. <br /> <p> Click below to refresh the printout. </p> <form method="post" action="/cgi-bin/scin"> <input type="submit" value="Refresh full version"> </form> </body> </html>
The screen will look like this:
We shortened the output to display only the basic information. The screen looks like this:
The files scin.cc and scin.h read and parse the raw data and print the formatted HTML results to stdout. When the user clicks the "Refresh" button, the data are re-analyzed and displayed on the user's browser. Now, your users no longer have to put down their bags of cheesy poofs, get up out of their chair and walk all the way over to the scintillation counter to get their data!
At least, until IT finds out that you're doing something useful with their network and blocks the port.
There are always problems. Oh, yes.
- Problem: Netcat crashes. Solution: Don't run netcat in the background.
- Problem: The scintillation counter crashes. Solution: Make sure the Operation Modes in the Moxa are set correctly. If using UDP, make sure the Local Listen Port is not the same as the Destination Port. Also, make sure you are using 0d as the delimiter. This will cause the Nport to send data every time it receives a Return character, instead of waiting until its buffer is full. Make sure the serial parameters are correct, and flow control is set to "none". Finally, do not power up or turn off the Nport while samples are running. If the scintillation counter detects characters on the serial port, it will re-initialize the counter, aborting your sample run.
- Problem: Netcat stops running for unknown reason.
Solution: create a cron job for root:
10 00 * * * /root/startnc6Create an executable script called /root/startnc6 like this:
#!/bin/bash SERVICE='nc6' if ps ax | grep -v grep | grep $SERVICE > /dev/null then echo "$SERVICE service is running, everything is just fine and dandy" else echo "$SERVICE is not running, restarting it ..." cd /usr/local/httpd/htdocs /usr/bin/nohup `/usr/bin/nc6 -u -l -p 4001 >> stuff` & fi
Wired Data Link
An alternative is to connect a computer directly to the scintillation counter and read the data from the serial port. You need a program that monitors the serial port and translates the scintillation counter output into a table. Below is a link to a program that does this for a Beckman LS 3801. Converting the parsing routine to handle the LS 6500 is left as an exercise for the reader. If your serial cable is more than a few feet long, use a diode-based surge protector such as a Tripp-Lite DRS232 to protect the scintillation counter from spikes that can fry the electronics.