May/June 2018 77
to take next and what program to run
(the PICAXE immediately starts running
the program stored in its memory). As
a result, the RaspPi takes more time to
boot up and programs aren’t started
automatically. However, there are ways
around these two issues.
New Challenges Mean New
Learning
I experienced several difficult days
going from programming a PICAXE to
programming a Pi. But hey, if the RaspPi
wasn’t challenging, then I would have
learned nothing new this last month. After
all the hair pulling and head banging, I’m
quite happy with my progress. Now, I
can’t wait to send a Pi into near space.
Step 1: Set up the Raspberry Pi
The Pi Zero comes with a single micro USB connector
for its keyboard and mouse. That required me to purchase
both a micro-to-standard USB adapter and a USB hub
before I could even connect the mouse and keyboard.
Then, there’s the single micro HDMI connector on the
Zero. So, I purchased a micro-to-standard HDMI adapter so
I could connect an inexpensive LCD monitor to the Pi.
Finally, there was a micro-USB adapter for power that
required I purchase another power adapter. After getting all
those pieces together, I was finally ready to power-up the
Pi and complete the next step.
Unlike microcontrollers, you must install an OS on
the Raspberry Pi. So, I purchased a 32 GB micro SD card
(class 10 for speed) and used the SD Card Association’s
Formatting Tool to format it. I next downloaded the latest
NOOBS (New Out of the Box Software) zipped file and
copied the extracted files onto the card. After inserting the
microSD card into the Pi, I powered it up for the first time.
Upon powering up, I was presented the OS installation
menu. I choose Raspbian (rather than Libre ELEC_RPi) and
it installed the Debian-like OS (think Linux) on the Pi. The
installation took perhaps 20 minutes to complete. Now
whenever the Pi boots, I’m given a window with options
like programming, a terminal program (for running Debian
commands), file manager, web browser, and setup menu.
Step 2: Learn How to Access Pi I/O and
Build a Printed Circuit Board
Like the PICAXE, the Pi has general-purpose input/
output (GPIO). The GPIO is accessed through a 2x20
receptacle soldered to one edge of the Pi’s printed circuit
board (PCB). Unless they’re
learning to program the
Pi using robotics, students
are probably unaware of
the GPIO. However, when
it comes to near space
exploration, the GPIO are a
critical component.
So, for readers who are curious about interfacing the
Pi to the outside world, I’ve included the pinout of the Pi
Zero. One thing readers will notice is that the configuration
of the GPIO doesn’t make it easy for sensors to access
them.
I was disappointed that the GPIO can’t directly digitize
voltages (I had grown accustomed to the PICAXE’s ability
to do this). So, using analog sensors meant connecting an
ADC (analog-to-digital converter) IC (like the MAX-186) to
the Pi and then programming it to operate the ADC.
I decided it would be easier to pass off the digitizing
work to a PICAXE, which can digitize voltages either in
eight-bit or 10-bit modes with just a tiny bit of BASIC code.
The PICAXE became an even more attractive solution
when my research indicated that some models of the
PICAXE can make their internal memory accessible over
I2C.
My plan then became to have the PICAXE collect
sensor data and store the results in its memory. The
Pi would then use I2C to copy the data out of PICAXE
memory. However, a deeper dig into the materials turned
up that only some of the older X model PICAXEs are
capable of behaving like the I2C slave I needed. Therefore,
I decided to place an I2C EEPROM between the Pi and
the PICAXE. This would enable both the Pi and PICAXE to
swap data indirectly.
Giving a PICAXE the task of digitizing sensor voltages
meant leaving some of its pins without a task since they
don’t have A-to-D capability. Therefore, I decided to
program the remaining pins to collect digital data. This
would only require a small update to the PICAXE and Pi
code to write in and read out additional data from the
EEPROM.
I was now ready to start designing the BalloonSat flight
computer PCB.
The Raspberry Pi is a 3. 3 volt
system, but it can provide five
volts to legacy electronics. Do
not, however, input five volts
to the GPIO as it can damage
the Pi. The pinout shown here
is correct for newer Raspberry
Pi computers; some older ones
have a 26-pin GPIO.
APPROACHING THE FINAL FRONTIER
Post comments on this article and find any associated files and/or downloads at
www.nutsvolts.com/magazine/issue/2018/05.