Author Archives: Michelle Shorter

How to get a Bootloader on your Board

via SparkFun: Commerce Blog

Modern microcontrollers are almost always programmed over USB - we rarely deal with lower level programming - but how does that work? First, let's talk about bootloaders and what they are: a small piece of code that will check to see if there is new code coming in, and if so, place the code in a certain location. If there is no new code coming in, it just goes to that location and runs the code that's there. That's basically it! Arduino made bootloaders popular because you no longer needed special (and expensive) programmers to get your code on a board - in fact SparkFun's very first product was a development board (or programmer with I/O and more). Now you can just program it over USB.

Here at SparkFun, when we make our boards we install the bootloader for you, whether it's the Arduino Pro Mini, RedBoard Qwiic or SAMD51 Thing Plus. But how do we do it? AVR-based boards like the Arduino Uno, RedBoard and Arduino Mega used a six-pin header that breaks out the three SPI pins need for programming (MOSI, MISO, CLK), as well as Power, Ground and Reset. These pins make up the ICSP (In Circuit Serial Progammer) port, which is the 2x3-pin port you'll see on most larger size AVR boards. Some boards like the Pro Mini don't have room for the header, but all those pins are broken out for the user, so our test beds just connect to those pins directly.

Pocket AVR Programmer

Pocket AVR Programmer

PGM-09825
$16.95
47
J-Link EDU Mini Programmer

J-Link EDU Mini Programmer

PGM-15345
$18.00
J-Link BASE Compact Programmer

J-Link BASE Compact Programmer

PGM-15347
$378.00
SparkFun Pi AVR Programmer HAT

SparkFun Pi AVR Programmer HAT

DEV-14747
$21.95

ARM-based chips like the SAMD21 and SAMD51 use SWD or JTAG for programming. The typical SWD header is a 2x5-pin, half-inch header that breaks out the required SWDIO and SWCLK pins, as well as Power, Ground and Reset. Once again, many of our larger boards like the RedBoard Turbo will have this header on them, but some, like the Pro RF, don't have room and will only have test points that connect to our test beds for programming.

But what if you want to change the bootloader, or design your own board and add a bootloaders? SparkFun has a few different programmers for both AVR and ARM, as well as tutorials on programming those boards. Whether you want to add your own bootloader or just want to program your code without one, we've recently added an ARM Programming Tutorial in addition to our Arduino Bootloader Tutorial to help you get started loading whatever code you need.

New!

ARM Programming

May 23, 2019

How to program SAMD21 or SAMD51 boards (or other ARM processors).

Also, check out our older tutorials and guides for some of our programmers.

Installing an Arduino Bootloader

This tutorial will teach you what a bootloader is and why you would need to install or reinstall it. We will also go over the process of burning a bootloader by flashing a hex file to an Arduino microcontroller.

Pocket AVR Programmer Hookup Guide

Skip the bootloader and load your program directly onto an AVR with the AVR Pocket Programmer.

Installing a Bootloader on the MicroView

Fix your bootloader-less MicroView! This tutorial covers how to: disassemble the MicroView, wire it up to an assortment of programmers, program the bootloader, and test it out.

Raspberry Pi Stand-Alone Programmer

This tutorial will show you how to use a headless Raspberry Pi to flash hex files onto AVR microcontrollers as a stand-alone programmer. It also tells the story about production programming challenges, how SparkFun came to this solution, and all the lessons learned along the way.

comments | comment feed

Antenna Connectors

via SparkFun: Commerce Blog

With a plethora of GPS/GNSS products going live recently, I wanted to talk a bit about the various connectors you'll find. SMA and RP-SMA are some of the older antenna options. SMA stands for SubMiniature version A and was developed in the 1960s with a male connector having the pin, and the female connector having the socket. This means that the female connector is inserted into the male connector (I know, confusing).

Then along came RP-SMA or Reverse Polarity SMA. This connector type reversed the location of the pin and socket but didn't change the gender of the connectors. So, now the female RP-SMA has a pin and the piece is inserted into the male housing.

You'll still see SMA on quite a few boards and antenna, and with their 500+ mating cycles they are fairly popular for instances where you need to change your antenna. One thing to be careful of: I've seen manufactures list boards as SMA while the actual connector is RP-SMA. While technically RP-SMA can be considered a type of SMA, it is worth noting that you should be careful when buying an antenna.

SMA Male SMA Female RP-SMA male RP-SMA Female
SMA Male
Center Pin, Inner Threads
SMA Female
Center Hole, Outer Threads
RP-SMA Male
Center Hole, “Male” Inner Threads
RP-SMA Female
Center Pin, “Female” Outer Threads

The newer u.FL was created by Hirose, but because of its small and fragile size is only rated for about 30 mating cycles. While this is good for permanent connections that really only need to be changed for replacement of faulty parts, it is not so good for constantly swapping out antennas. This is one reason you will see u.FL to SMA adapters. Check out our RF Connector Buying Guide for more information on RF Connectors.

Interface Cable SMA to U.FL

Interface Cable SMA to U.FL

WRL-09145
$4.95
3
Interface Cable - SMA Female to SMA Male (25cm)

Interface Cable - SMA Female to SMA Male (25cm)

WRL-12861
$4.95
1
Interface Cable RP-SMA to U.FL

Interface Cable RP-SMA to U.FL

WRL-00662
$4.95
1
U.FL to U.FL Mini Coax Cable - 200mm

U.FL to U.FL Mini Coax Cable - 200mm

WRL-15114
$1.95

Because of the u.FL's small size and fragile connectors, we've put together some helpful tips on using u.FL to prolong the life of your board, your cables, and your antennas.

Three Quick Tips About Using U.FL

December 28, 2018

Quick tips regarding how to connect, protect, and disconnect U.FL connectors.

comments | comment feed

DIY Edge-Lit Acrylic Display

via SparkFun: Commerce Blog

I've seen some pretty nifty edge-lit DIY projects. From the Death Star, to the USS Enterprise, to fun sayings or name tags, there are lots of examples.

A few months ago I got the idea to make some for some friends. Laser cutting various pieces of acrylic would be the easy part. The hard part was a base that non-techies could use and control with ease. I wanted several features, but didn't want to have to solder together five different boards for each one, so I ended up designing my own board, doing the assembly, 3D-printing enclosures and more.

Edge lighting is a fairly basic idea. When you shine an LED through a clear substance like a piece of glass or acrylic, it just goes straight through, but if you give it something to reflect off, such as a rough surface, it will refract the light, making that area visible. When you intentionally rough up or engrave a specific pattern it will light up, making a nice sign.

Quiz time: what is the most common edge-lit display you see on a daily basis? I haven't checked any official sources for this, but seeing as this is something I see daily and you probably do too, this is the answer I'm looking for. Winner gets to have a smug look all day for correctly answering a random online question.

Working display with the SparkFun logo

A few of the features I wanted were:

  • Powered over USB - I could have gotten a different power supply, but USB is so universal and cheap now that I wouldn't have to worry about spending more money on power supplies they would lose or have to remember which to use. Because the enclosure would be decent sized, I chose a full-size USB B port for its durability as a power jack (I did end up putting two footprints there if I change my mind).
  • Capable of being programmed over USB - While I don't expect friends or family to program them, if I make a new piece of acrylic that I want a new fancy light display for, I want to just have them bring the device, plug in a USB cable, hit upload and be done.
  • Be capable of running FastLED - This library does all the work for lots of different LED strips. I could use whatever strip I had lying around, just change one or two lines in the code and be done. The code actually has lines for the most popular options that are commented out. All I have to do is make sure the right one is uncommented and hit upload.
  • Have a power button and a mode button - This allows them to change modes, which will most likely just be different colors and possibly a pattern such as rainbow or Cylon.
  • Entirely enclosed - Some people (like engineers) like to see their electronics; most don't.
  • Battery powered - I wanted the option to add a battery to this. That would allow the user to show off their new toy for a while before plugging it back in.

I chose the SamD21 chip as a nice powerhouse that can be programmed over USB and can handle the FastLED library. While it has more pins than I needed, I chose to break out a bunch of them anyway.

The board has two ports on the end that can take screw terminals (or just solder wires in). One port has power, ground and an I/O pin; the other port has power, ground and two I/O pins. This allows me to use one for WS2812s or other LED strips that only have one data line, and the other for APA102s or other LED strips that have a data line and a clock line.

I also broke out a couple of other ports with different I/O pins just in case, as well as a place for three different buttons. I spent some time digging into the graphical datasheet to determine which pins to use. There are a combination of SPI/I2C/digital and analog pins broken out. I also added a voltage regulator and battery charger with a JST connector.

Image of Board Layout

Then I had to figure out power. Most LEDs are rated for 5V power (and data), but the SamD21 runs at 3.3V. After asking around, it sounds like while out of spec the APA102s will communicate fine at 3.3V, but they need closer to 5V to power them. I ended up running Vin to my ports, which is either directly from the battery or the USB port. Vin also goes to the voltage regulator to give the SamD21 3.3V, which it will use to talk to the APA102s (or WS2812).

Then there were the non-electronics parts. I dug around in a bin of buttons and switches, found some that would work and set about designing an enclosure.

The current one fits the board snugly. Almost too snugly. If I had to redo the whole design I'd make the board as narrow as possible. One-and-a-half inches doesn't sound like much, but once you add a quarter-inch on each side and add some height, the enclosure size is pretty decent. That's OK, it still has to hold up the acrylic, and hold a power switch, USB jack and button for the mode.

The next step is 3D-printing some enclosures, and laser printing some test acrylic. After some testing, I decided to add a small slot to the lid to slide the LED strip in (Scotch tape works very poorly to hold the LED strip to the lid). I ended up printing a separate piece and using 'ABS glue' (acetone and ABS) to connect it to the lid. While it is a bit hard to explain, you can see the small trough in the image below; it gets attached to the bottom of the lid, allowing the LED strip to slide in between it and the lid.

3D printed parts and acrylic

The next step was ordering parts. I got some PCBs on one of our QC test panels, since they had some extra room, and ordered a stencil. Time to build these up. As someone who never worked in PCB assembly I was a bit nervous, but things worked out pretty well (keep in mind trying to find 0402 components can be tricky). I got a couple of boards stenciled, hand-populated and reflowed with a hot air rework station (I was afraid of all my components blowing off if I walked them downstairs to the oven). After a quick test it was go time.

populated boards

Once it was time to program I realized that my SamD21 wasn't getting any power. I had designed the board to connect Vin to either the battery or the USB port, but without a switch, it wasn't connected to either. This meant I had to add in my panel mount On/Off/On power switch to program the board. Once that was done I grabbed an Atmel ICE and got the bootloader up and running and was able to test my code. The code is fairly basic - a button connected to an interrupt changes the mode. The code runs through a switch statement and does something different for each mode.

inside of unit, showing the board, battery, and wires

After some troubleshooting and learning new skills I had a working project. I can cut new pieces of acrylic and just drop them in, and I can build more using the same board and same basic code using whatever LED strips I can find. I can switch between quite a few modes with the push of a button, and it doesn't look to the user like a bunch of wires and PCBs. I might choose to update the board and code to use Circuit Python and make it even more user friendly (might be nice for a master brightness control) now that we have that functionality on our SamD21 boards. Let me know what you think.

Gif of rainbow cylon effect

comments | comment feed

Adding Serial Ports to your SAMD21 Board

via SparkFun: Commerce Blog

Have you ever needed an extra UART, or an extra SPI line? What about that sensor that only has one address, but you need two of them? The SAMD21 boards use what is called Sercoms (Serial Communication). The board definitions in the Arduino IDE will usually define a UART, SPI and I2C port for you, but with six Sercoms, that leaves a few extra for you to play with. Check out our new tutorial on setting up new Serial ports. We use the new Redboard Turbo to control our Serial LCD screens over custom UART, SPI and I2C buses.

Redboard Turbo with serial ports outlined

Adding More SERCOM Ports for SAMD Boards

comments | comment feed

All About Ham Radio

via SparkFun: Commerce Blog

Everyone has heard of ham radio, but do you actually know what it is? Recently, the idea of amateur radio caught my attention, and I decided to look into it a bit and see what it’s all about. The short answer is that from the creation of the first radio wave, people have been playing with and modifying radio waves to send information. Whether it’s an FM music station, AM talk radio, police and fire radios or your WiFi connection, radio waves are all around you.

Old Fashioned radio

Q: What is the purpose of amateur radio?

A: Other than talking to and meeting new people and learning new technologies? While I rarely do this I’m going to quote federal regulations. FCC Part 97 is the federal regulation that defines amateur radio. Basically, it includes making friends around the world, learning, and helping others.

a) Recognition and enhancement of the value of the amateur service to the public as a voluntary noncommercial communication service, particularly with respect to providing emergency communications.
b) Continuation and extension of the amateur's proven ability to contribute to the advancement of the radio art.
c) Encouragement and improvement of the amateur service through rules which provide for advancing skills in both the communication and technical phases of the art.
d) Expansion of the existing reservoir within the amateur radio service of trained operators, technicians, and electronics experts.
e) Continuation and extension of the amateur's unique ability to enhance international goodwill.

Q: How does amateur radio help others?

A: Whenever disasters hit, communication becomes a big issue. With power down and cell towers not working (or overwhelmed), amateur radio operators will step in to help coordinate disaster relief. Ares and RACES are two organizations that work together to provide vital communication during these times. If you are looking for a way to help during disasters (think hurricanes, not zombies), consider getting your license and working with one or both of these organizations.

Q: What does the FCC do?

A: If everyone was allowed to transmit on any frequency they wanted at any time and at any power, we would quickly run into problems. The FCC has broken the radio spectrum into bands and allocated different frequency bands for different usages. While the FCC determines what frequencies can be used for what purpose, the amateur radio community, for the most part, self polices protocol and etiquette within those bands. Here is a quick visual summary of the different bands and which licenses are required to use each band.

PNG of Radio Bands

Amateur Radio Bands

Q: Why do I need to get licensed, and what is the process?

A: The license procedure is fairly straight forward, and mostly makes sure you know what you are doing before you are allowed to transmit on the air (you do not need a license to listen). Your license is also what gives you your call sign so you can identify yourself over the air.

There are currently three different licenses available. The Technician license is the most basic license and also the most popular. This gets you on the air on some of the most popular frequencies, mostly in the UHF and VHF range. The General license allows you access to most of the HF frequencies as well, and the Amateur Extra license allows you to transmit on any amateur frequency. Each license requires you to pass a test (as well as having passed all the previous tests). The entire pool of test questions is publicly available, so there shouldn’t be any surprises when taking your test. Various organizations administer the test on a regular basis all over the country. You usually have a $10-$15 fee for the test (you can take all three levels at once for that price). They then submit your results to the FCC, and you get your license in a couple of weeks.

Q: What about Morse Code? I really don’t want to learn Morse Code.

A: Morse Code is no longer required for any of the licenses, so you are in luck. Many radio operators still enjoy using Morse, so you may still come across it, but it is not necessary. While I don’t know Morse Code (yet) I am working to hide it in random places, like blog posts.

Straight Key for Morse Code

Q: What does SparkFun do with amateur radio?

A: We actually have quite a few hams around here. There are about 800,000 amateur radio operators in the U.S. (about 0.2 percent of the population), but here at SparkFun we have at least eight hams, with another few who are looking to get licensed. We also carry a few different ham radio products, such as the Hack RF, the bladeRF x40 and the HX1 APRS Transmitter, and many of our other RF products operate in amateur frequencies (not to mention that amateur radio has always been about tinkering and building things – something we are pretty good at).

HackRF One

WRL-13001
$299.95
35

What other radio stuff would you like to see? Tell us in the comment section… (.._. .)

comments | comment feed