The idea behind the OpenLog is instant data logging via high speed serial port. With some clever coding, the
OpenLog can also be used as a microSD-based disk drive.
My mission this month is to take the pain out of using the
OpenLog as an on-demand data storage device. We
already have some custom OpenLog hardware. So, let’s
get crackin’ with that code.
The Programming Model
As you can see in Schematic 1, the OpenLog circuit
consists of an Atmel ATmega328P microcontroller, a
couple of LEDs, a 16 MHz resonator, a microSD card
socket, and a minimal complement of resistors and
capacitors. The OpenLog firmware doesn’t check for the
presence of a microSD card. So, the FDN339AN MOSFET
Since all of the microSD SPI interface coding is
handled by the OpenLog firmware, our code only needs
to concentrate on the OpenLog’s serial interface.
Indication of proper data transfer on both the SPI and
serial interfaces has already been taken care of, as well.
The LED attached to the ATmega328P’s PD5 pin responds
to signals flowing on the serial port. The SPI signal
transitions can be observed by visually monitoring the LED
attached to pin PB5.
The latest version of the OpenLog firmware includes a
bootloader that allows programming of the ATmega328P
via its serial interface. I chose not to employ the services
of the bootloader and instead use a standard AVR
programmer to load the OpenLog firmware.
We will use the PIC32MX575F512H hardware I
recently introduced to you in a previous edition of
Design Cycle. The OpenLog library we are about to
create will also drive the PIC32MX795F512H board,
which was also featured in a recent Design Cycle
column. The 575F hardware is rendered in Photo 1.
The OpenLog library routines will be written
using the Microchip XC32 C compiler. The resultant
C source code can be easily ported to Arduino, CCS
C, or PICBASIC Pro.
We must have a working knowledge of how the
OpenLog firmware responds to the commands that
we will issue. Ideally, we need an OpenLog device
that is attached to a PC serial port. We would then
be able to use a terminal emulator to monitor the
OpenLog commands and responses. The good news
is that we don’t need a separate OpenLog module.
We can use our custom OpenLog
implementation and the onboard FTDI USB IC. All
THE DESIGN CYCLE
From Data Logger to On-Demand
Data Storage Device
■ BY FRED EADY
68 October 2015
Despite the “works out of the box” nature of the open source-based OpenLog data logger,
you still have to write some code to access its resources. It really doesn’t matter if you
purchase an OpenLog from SparkFun or build your own custom version. You will still need to
do some coding.
■ Photo 1. We are primarily interested in the upper lefthand
corner of the board. An added plus is the FTDI USB portal you
see in the lower righthand corner. With a bit of clever coding, the
OpenLog serial interface can be attached logically to the FTDI
FT232RL via the PIC32MX575F512H. This allows the OpenLog to
be exercised by a PC serial port.