[time-nuts] picPET, Raspberry Pi, Logging, and a GPS module

Ben Hall kd5byb at gmail.com
Sun Aug 23 18:43:26 EDT 2015


Evening all,

Months ago, I bought several picPET's from Tom Van Baak:

<http://leapsecond.com/pic/picpet2.htm>

Plan was to set up a power line phase measurement system using my Z3801 
GPSDO as the 10 MHz input.  Life intervened...and finally got back to 
that project today.

I decided to do preliminary "playing around" to make sure I got 
everything working right before I hooked it up to the Z3801 and a 
transformer that would sample the line frequency.  Tom included a nice 
little 10 MHz oscillator unit, so I got to work using that as the 10 MHz 
reference...and searching around for something to use as an event pulse, 
I found a GPS unit that had what I suspected to be a 0.5 PPS output. 
(two birds, one stone!)

The collection device was to be a Raspberry Pi computer as they are 
simple, cheap, and in my experience, work pretty well.

First thing to do on the RPi was to disable the serial console so that I 
could use those UART pins as the serial input.  There are a number of 
automated way to do that online.

Second thing to do was to get serial into the RPi and display it.  Found 
another script to do that online.  Initially the output from the picPET 
was garbage, but thankfully I was using a pP05 and pulling pin 4 high 
made the text readable.

Third thing to do was to get some sort of serial logging program.  I 
found one called grabserial.  <http://elinux.org/Grabserial>  Grabserial 
is nice because it has a lot of options that will make it nice to use in 
an automated fashion.  IE:  I can tell it to collect for "X" seconds, 
record to a file, then terminate, plus log the system clock for giggles.

Grabserial gave me fits!  Turns out that it doesn't pass the command 
line switch for the RPi serial port somehow, but editing the source to 
reflect /dev/ttyAMA0 as the serial port made it work.  (I submitted an 
issue on github to the development team to see if I'm an idiot or if 
this is a real issue)

Fourth thing was to figure out how to name files using the time and date 
so I don't have data file collisions.  Studying the date command yielded 
an answer:

now=$(date +"%Y-%m-%d__%k-%M-%S")
python grabserial.py -e 30 -t -T -v -o log.$now.log

This names the log file "log.YEAR-MONTH-DAY__HOUR-MIN-SEC.log" which is 
mighty handy.

Next up - setting up a chron job to run the above once per day so I get 
one data file per day, keeping the file size manageable.  Also need to 
get Samba working so I can pull the data files off the RPi onto the PC 
for manipulation.  :)

thanks much and 73,
ben, kd5byb









More information about the time-nuts mailing list