Recently I got an Arduino Uno clone to play around with. It turns out it can also act as an USB RS232 serial interface for devices connected to it. Since I never got an USB–serial interface before either, I thought it would be interesting to try interfacing with the NetIO GC10 counter I have. I previously used to count and log 5V Geiger pulses from it using an audio jack connection and a very simple electric circuit, but this method over time proved to be a bit overkill for my purposes, in addition to being prone to various issues.
Arduino Uno only has one built-in hardware serial port available (pins 0–1), which is shared with the USB computer connection. This means that if a serial device is connected here, it can intefere with PC communication. However, arranging a so-called soft serial connection with other pins is a possibility, although it will have lower performance than the hardware serial connection. To do this I used the altsoftserial library, which adds a serial port on pins 8–9. This is where I connect the Geiger counter.
The GC10 counter automatically sends CPM data every second. Every string is terminated with an explicit CRLF sequence, which in printf-like commands in many programming languages is represented by the escape sequence /r/n.
Below is a photo of my current arrangement. The Geiger counter is powered directly by the Arduino board through the VCC pin of the data I/O interface. The manufacturer points out that other VCC/DC inputs must not be used at the same time or the Geiger counter will be damaged.
In the above photo, black tape is covering the annoyingly bright LED and the loud buzzer (when it's enabled).
Arduino C code used:
#include <AltSoftSerial.h>
// https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html
AltSoftSerial altSerial;
void setup() {
Serial.begin(115200);
altSerial.begin(9600);
}
void loop() {
char c;
if (Serial.available()) {
c = Serial.read();
altSerial.print(c);
}
if (altSerial.available()) {
c = altSerial.read();
Serial.print(c);
}
}
Display More
Python code used to continuously log data from it through the hardware serial port:
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 29 01:17:35 2020
@author: can
"""
import datetime
import serial # https://pyserial.readthedocs.io/en/latest/index.html
# Log file onto which new CPM data will be continuously appended
gc_logfile = "d:/logs/gclog_cpm_02.txt"
# No significant delay is expected, so the timeout should be low.
# Remember that the NetIO GC sends data every second
with serial.Serial('COM4', 115200, timeout=1.5) as gc_serial:
while True:
timestamp = datetime.datetime.utcnow().isoformat()
try:
# The NetIO GC terminates every CPM string with a LFCR sequence. We
# will read new data until this sequence appears and try to convert
# it into an integer value
message = gc_serial.read_until(b"\r\n")
cpm = int(message)
except ValueError:
# Communication problems may lead to malformed messages that will
# cause value errors when trying to extract the desired value. If
# this happens, skip and try again. This entry is not logged
print(f'{timestamp:26}, CPM not found. Message: {message}')
else:
# Semi-graphical output on stdout
print(f"{timestamp:26}, {cpm:4} {'█'*int(cpm/3)}")
with open(gc_logfile, 'a') as log:
# A newline must be explicitly added in the logfile string
line = f"{timestamp}, {cpm}\n"
log.write(line)
Display More
Typical output from the above code
2020-01-29T12:02:38.193560, 86
2020-01-29T12:02:39.197706, 87
2020-01-29T12:02:40.204730, 88
2020-01-29T12:02:41.208844, 89
2020-01-29T12:02:42.212709, 90
2020-01-29T12:02:43.220673, 90
2020-01-29T12:02:44.215784, 90
2020-01-29T12:02:45.230620, 90
Other Resources
- NetIO GC10 Geiger Counter Assembled Unit (official shop page)
- Specification of GC10 Data I/O Interface (pdf)
- General Specification of GC10 (pdf)
- Suggested Arduino code for GC10 serial I/O (code)
- Arduino Mega–GC10 connection (diagram)
- Output pulse circuit (diagram)
- Geiger Counter GC10 users page (official support discussion board)
EDIT: it appears that code indentation got messed up while copy-pasting code here. This will not be an issue for the Arduino code, but it will for the Python code for logging. Until I fix this in this comment, the Python code is simple enough for most people with some experience with the language to quickly solve the issue in their favorite IDE.
EDIT2: the problem above appears to have been solved.