Wednesday, July 13, 2016

Atmel Retrokit SAM D Edition

In this post I will document an update that I designed of a classic AVR board: The Retrokit!

Atmel Retrokit SAM D Edition

Introduction


I don't have a lot of information on the original Retrokit board. Based on a post by Jo Uthus on Twitter, it was designed in 1997 by Vegard Wollan. The intent was clearly to demonstrate the speed of AVR microcontrollers compared to other 8-bit devices of the era: PIC microcontrollers, the HC08, and the 8051. The four LEDs on the board blinked at different rates, with the faster AVR completing its blinks first. Of course, the entire board was controlled by a single AVR device which simulated the comparative speeds of the other devices through the blinking LEDs.

The Original Retrokit
Source: Atmel on Twitter 

There was a 2008 re-design of the Retrokit that Jo posted about. The re-make is a really nice SMT design, and there is even a YouTube video showing it in action! It was posted by Joseph Rautenbach and he is possibly the designer. If you see this Joseph, let me know and I'll link in more information about you.

2008 Re-design of the Retrokit

YouTube video on the 2008 re-design of the Retrokit.

Updating the Retrokit to 32-Bit


A lot has changed in the past 19 years since the original Retrokit was designed. We now have a plethora of 16- and 32-bit microcontrollers available to us with speeds and feature sets that far surpass their 8-bit brethren. The devices you can purchase these days for very little cost offer amazing capabilities. Microchip Technology and Atmel, once competitors, have joined forces. The maker movement has exploded. Arduino happened... It's a great time to be a maker and embedded developer. I thought it was time to bring the Retrokit along for the ride.

I created a 2016 re-design of the Retrokit that uses the Atmel SAM D09 microcontroller. This is an excellent 32-bit device that comes in a SOIC package, making it easy to solder. I mimicked the board size and layout of the first Retrokit as closely as possible. The four LEDs are meant to show a comparison in speed between the 32-bit SAM D device, the 16-bit ATxmega, the 8-bit AVR, and the 8-bit PIC microcontroller. There are a lot of devices to select from in each of those families, and if we wanted to be really picky, I could have even chosen a PIC that blew away the little SAM D09. However, I chose representative devices in each category that also demonstrate the development of microcontroller technology over time, from the older PIC 16F series to the modern 32-bit SAM Ds.

The blink rates of the LEDs and completion times are based on MIPS/DMIPS scores for each device. Check out my code on Github linked below to learn more. Here is a video of the Retrokit SAM D Edition in action:

YouTube video showing my Retrokit SAM D Edition board in action.

The blinking LED demo takes 10 seconds to complete, after which the LEDs all stay lit for an additional 5 seconds. After that, the SAM D09 goes into deep sleep mode to save power. Current draw in deep sleep mode is around 2uA, meaning that the CR2032 battery will last a long, long time in that state. To reactive the light show, simply press the Reset button.

Shared as Open Source Hardware (OSHW)


Here is all of the information you need to order PCBs and assemble your own Retrokit SAM D Edition boards or modify the design.

Eagle Files and Firmware: Shared on Github
Atmel Retrokit SAM D Edition: Order PCBs on OSH Park!

Retrokit SAM D Edition Schematic

Parts List

Microcontroller: Atmel SAMD09C13A
Push Button: SPST Though-hole
Bussed Resistor: 470 ohm 5SIP
LEDs: 4x 3mm Red LEDs
Battery Holder: CR2032 Though-hole
R1: 10k ohm 0805 SMD
R2: 100 ohm 0805 SMD
C1: 100nF Ceramic Through-hole, 0.1" lead spacing
C2: 100nF 0805 SMD
Programming Header: 10-pin 0.050" (don't solder this, see note below)

Assembly Note: Tin the square ground pad in the middle of the battery holder footprint before soldering on the holder. The pad should have a little mound of solder on it to make good contact with the battery.

Programming Note: The 10-pin Cortex Debug port is positioned directly underneath the microcontroller so that it is not visible from the front of the board. The connector is not meant to be soldered. After assembling everything else on the board, throw in a CR2032 battery to power it and insert the male 10-pin connector into the female end of the cable from your programmer (such as an Atmel ICE). Then, wedge the connector into the port to program it. Finger pressure will keep it in place for the few seconds needed to flash the firmware, and then you should never need it again.

Conclusion


I hope you enjoy this little re-make of the classic Retrokit. If you assemble your own, please Tweet me a picture @sync_channel. Questions and comments are welcome below.

Thanks for reading!

- Dan W.

Sunday, June 26, 2016

LoRaWAN FeatherWing for Adafruit Feather

In this post I will document a new custom FeatherWing I have designed to add the MicroChip RN2483/RN2903 LoRaWAN module to Adafruit Feather.

Help your Feather fly into the IoT clouds with this awesome
LoRaWAN module from MicroChip.


Introduction


I have designed some FeatherWings in the past to add a LoRa transceiver module to Feather. I did the LoRa FeatherWing Development Breakout and the LoRa FeatherWing IOX that used the HopeRF RFM95/96(W) modules. The RFM modules are small and cheap, which is great for IoT projects. However, they have a limitation if you want to use them with LoRaWAN: the stack is not implemented in the module, leaving that burden to the microcontroller. The LoRaWAN stack takes a fair amount of code space, and it's difficult to implement in some 8-bit microcontrollers.

This new FeatherWing uses the RN2483 (868 MHz) or RN2903 (915 MHz) from MicroChip. It's an excellent module that fully implements the LoRaWAN stack itself. The microcontroller talks to it over USART with a simple command structure to configure it and send/receive messages. The module also has several GPIO pins available. This is the preferred module on The Things Network, and there are a lot of great example projects and code on the Internet to help you get started.

My FeatherWing is very simple. It connects the module serial pins and the module Reset pin to the Feather. It has an SMA connector for attaching an antenna, and a small white silk-screen box for writing in a node ID or other information. GPIO10 from the RN module is attached to an LED for status indication. Finally, I added an ICSP connector for the module that is compatible with the PicKit3. You'll probably never need this, but it can be used to update the firmware on the module if that is ever necessary.

Challenges


Despite the simplicity of the FeatherWing, there was a unique challenge along the way. The RN module is a bit wide, and in fact nearly as wide as the header spacing on the Feather boards. My first revision of this board used a very narrow footprint for the module and normal through-hole headers. It was extremely difficult to solder. Though I made two functional boards with that PCB, I didn't think it was suitable to release as a shared project.

My solution was to make the FeatherWing a bit wider (1" wide instead of the normal 0.9") and use surface mount headers on the bottom. This is the first "wide-body" FeatherWing that I have seen.

 Surface mount headers on the bottom of the LoRaWAN FeatherWing.
Notice that the board is a bit wider than normal FeatherWings.

Compatability


This board is compatible with Feather M0, Feather 32U4, and Feather WICED.

It is NOT compatible (as-is) with Feather HUZZAH (ESP8266). The single hardware USART on the HUZZAH is tied to the USB-Serial chip, and other things shouldn't be connected to those pins. If you really want to use the HUZZAH, you can:
  • Pick a software serial library for ESP8266
  • Download the Eagle design files
  • Modify the board so that the serial pins from the RN module go to the pins you want to use for software serial
  • Order your custom PCB on OSH Park or whatever service you like

Because this FeatherWing is wider than normal FeatherWings, it probably won't work on a Doubler. The board will overlap with the Feather and prevent it from being fully seated.

Shared as Open Source Hardware (OSHW)


Eagle Files: Shared on Github
Grab my Eagle parts library if you want to edit the footprints: Shared on Github

LoRaWAN FeatherWing: Order PCBs on OSH Park!

LoRaWAN FeatherWing Schematic

LoRaWAN FeatherWing Board Layout
 
Parts List:

LoRaWAN Module: MicroChip RN2483 (868 MHz) or RN2903 (915 MHz)
RF Connector: SMA or RP-SMA Edge-Launch for 1.6mm/0.062" board thickness
12-pin Header: 0.1" SMD, Female (Digikey) or make your own Male connector (see below)
16-pin Header: 0.1" SMD, Female (Digikey) or make your own Male connector (see below)
R1, R2: 680 ohm 0603 SMD (or adjust value to change brighness of LED)
PWR, G10 LEDs: 0805 SMD (color of your choice)
C1: 1uF 0603 SMD
C2: 470nF 0603 SMD

Notes: C1 and C2 are located on the bottom of the board. The ICSP header is rarely used and you don't need to solder headers to that. Be sure to pick the correct LoRaWAN module (frequency) for your country/region.

Make Your Own Male Surface Mount Headers


I typically avoid surface mount headers because they are more expensive and not something I have sitting around in the parts bin. Thankfully you can make your own surface mount male headers from right-angle breakway header strips.

Using a pair of pliers, pull every other pin on the header out of the plastic spacer, rotate it 180 degrees, then re-insert it. Next cut the pins a bit shorter so that they fit within the footprint on the PCB. Super easy and cheap. The below picture should make that more clear:

Make your own SMD male headers from right-angle breakway strips.


Software and Usage


These are the pin connections from the RN module to the Feather. On all three of these Feather variants, call "Serial1" to talk to the module instead of "Serial" in the Arduino IDE. The default baud rate is 57600. Drive Reset HIGH to enable the module.

Pin connections for Feather M0, 32U4 and WICED.

Here are some good software examples available on the Internet for using this module:
  • Great blog post on using the RN2483/2903 in Peer-to-Peer mode. This is useful for testing your boards and learning about the command interface to the modules.
  • Write-up on taking the next step into LoRaWAN and making a TTN node. The software is shared on Github.
  • This is the Command Reference for the RN modules. Definitely download a copy of this.
Finally, the status LED on the LoRaWAN FeatherWing is connected to a GPIO pin on the RN module, not the Feather. If you can make it blink with your program, that is great confirmation that the module is operational and talking to the Feather. The command is "sys set pindig GPIO10 1" to turn it on and "sys set pindig GPIO10 0" to turn it off.

Conclusion


This was a long post for a simple board! I hope you find this little FeatherWing useful. If you have any questions or feedback please post in the comments below. Finally, if you make your own LoRaWAN FeatherWing definitely tweet me a picture @sync_channel.

Thanks for reading!

- Dan W.

Tuesday, June 21, 2016

Eagle Custom Parts Library

I've created a new Eagle custom parts library for the projects I post on this blog. Though I upload the design files for individual Open-Source projects, you might like to re-use some of the parts in your own projects with a standalone, documented library. I have several parts to bring over, clean up, and comment, so it will be growing quite a bit over the next few weeks.

You can check it out on Github here:

Sync Channel Blog Design Files on Github


Ready-to-use Eagle footprints.

I will include Digikey part numbers where possible. I will only add parts to this library that I have personally tested using the OSH Park PCB service. I may also add other random things to this repo in the future. Note that I have released everything in it under the Creative Commons Zero license. Therefore, you do not have to attribute to use these in your own projects. OSHW licensing can be confusing at times, so at least you don't have to worry about this library.

Thanks for reading!

- Dan W.

Sunday, June 19, 2016

Designing a Mains Frequency Monitor, Part 2

This is the second in a series of posts about designing a mains frequency monitor using the Microchip PIC 16F1619 microcontroller. In this post we will take a look at the first revision of the board that I designed for the project and some of the features that it adds.

Be sure to read Part 1 of the project write-up if you haven't done so already.


First revision of the Mains Frequency Monitor board.


PCB Progress


I designed a PCB for this project a couple of weeks ago, and recently received the boards back from OSHPark. I think it turned out great! The board houses the microcontroller and 20MHz TCXO that we discussed in Part 1. For the power supply I opted for a Recom DC-DC converter to generate 5V from the rectified input from a 12V AC wall adapter. There is a programming port (PicKit3 compatible) for programming the microcontroller as well as a header to hook up the LCD.

I also added an opto-isolated terminal port that is compatible with common Serial-to-USB adapters such as the FTDI Friend, FTDI Basic Breakout, and all of the various clones available online. This is nice for capturing data in a log file and then analyzing it in a program such as TimeLab.

The PIC 16F1619 only has one USART, but I wanted to use the same serial LCD display I have been working with throughout the prototyping phase. I also needed the USART for the terminal interface. To get around this I added a SPDT analog switch (74LVC1G3157) to allow sharing of the USART with both ports. The serial LCD only needs the Tx line, so the Rx line from the USART connects directly to the terminal port.


 The Mains Frequency Monitor has three ports: programming, Serial LCD,
and an opto-isolated terminal port for data logging.

Here's a short video showing two of the boards in operation:


Performance


With assembled PCBs to test, I have been able to collect some data. Here is a frequency difference plot in TimeLab for a 12 hour run:

 Mains Frequency, 12 Hour Run, Frequency Difference

And here is the ADEV plot for the same run:


Mains Frequency, 12 Hour Run, ADEV

Much longer runs will be required in the future. Also, I plan to rig up a test with the board and a proper frequency counter measuring the same signal to allow for a good assessment of the board's performance. I've done some informal comparisons with a calibrated counter and I'm very confident in the accuracy of the readings from the board.

Design Files


I plan to wait until the project is finished before creating a project link on OSHPark, publishing the BOM, etc. Rev A of the board is working out well, but it might still be necessary to make some changes. Don't worry, everything will be shared and documented fully in Part 3 when we wrap up. For now, the design files are available in the GitHub repo if you would like to check them out. I have also updated the firmware version in the repo.
 
Here's the schematic of Revision A:

 Mains Frequency Monitor Revision A Schematic


Mains Frequency Monitor Revision A Layout


Measuring frequencies is fun for the whole family!


Conclusion


That's it for Part 2! I had hoped to make more progress on the firmware in this post, but the hardware took most of my time. I'm very happy with how the board turned out however. In Part 3, we will work on the code, sort out the clock functionality, and get the project finished up.

Please post any comments, suggestions, and feedback below.

Thanks for reading!

- Dan W.

Saturday, June 4, 2016

Cherry MX Keypad

In this post I will document an open-source, Arduino-compatible Cherry MX keypad that I designed using the ATmega32U4 microcontroller.

 A highly customizable Cherry MX keypad.

Introduction


You have probably heard of Cherry MX keys in relation to gaming keyboards. They are very nice keys with excellent tactile feel. They are also extremely durable and rated for 50 million keystrokes. Products that use them are often top-tier and pricey, but come with cool features like multi-colored backlighting and re-programmable keys. Many people customize their keyboards by changing the key caps to have custom labels and colors. But why stop there? Let's design our own Cherry MX keypad from scratch!

Board Overview


The board that I designed includes four Cherry MX keys. I used MX Blues, but it is also compatible with other types such as Brown and Red. It's simply a matter of soldering on the ones you want. The keys are backlit by 3mm LEDs that sit in recesses in the sides of the keys. They are controlled via PWM to allow changing the brightness. The microcontroller running the show is an Atmel ATmega32U4. This is the same microcontroller used on the Arduino Leonardo. In fact, this board looks like a Leonardo to the Arduino IDE for programming. There is an ISP port for burning the bootloader with a programmer (Atmel ICE, USBtinyISP, etc), but you only need to do that once. Afterwards simply connect the board to your computer using the Micro USB connector for programming and normal usage.

The lovely ATmega32U4. Adding USB to the project with this chip couldn't be simpler.


The left side of the board with the microcontroller is a good example of a minimal setup for the 32U4. Despite the small number of components, we still have a good 16MHz crystal, reverse polarity protection on the 5V USB line, and the necessary bypass capacitors. If you modify this board to add more keys, you can bring over most of this layout as-is.

Usage


Using this board is super easy. After flashing the Leonardo bootloader, you can upload the example program on Github over USB from the Arduino IDE. You'll see from the example sketch that the code is simple and easy to modify. After uploading a program, the board immediately re-mounts as a USB input device. Pressing the keys sends the characters you have programmed to the computer just as if it were a keyboard or mouse. You could also program in character strings and complex combinations of key presses, mouse clicks, and delays. See this reference on the Arduino page to learn about all of the keyboard and mouse commands that you can use to program your own key functions.

Check out my YouTube video on the Cherry MX keypad to see it in action:


Customization


Not only is the programming of the keypad entirely customizable, the hardware is as well. This is shared as an open-source project. You can use the Eagle files as a template to make your own numeric keypad or even a full keyboard! Adding Cherry MX keys to your project really steps it up a level, especially if you create or 3D print a nice enclosure to mount them in. Remember that these keys are not just about tactile feel. They are extremely durable, and you can purchase or make your own custom keycaps to add the finishing touches to your project's interface.

Using Cherry MX keys in this project gives us access to all of the awesome
custom keycaps available. These metal arrow keys look and feel great.


I used the internal pull-ups on the 32U4 for the key switch circuits, and debouncing is done in software. There is plenty of space around the keys on the board for adding hardware debouncing if you like.

With only four keys on the board, I was able to connect each one to an individual pin of the microcontroller. However, if you make a large board with several keys, this will not be possible. You will need to switch over to row-and-column scanning to be able to handle something like a full keyboard. There are also some interesting things you could do with the backlighting. You could put the LEDs on a parallel charlieplexed grid, allowing you to turn on individual ones. This would be useful for key press indication, making games like Simon Says, and adding cool lighting effects.

Shared as Open Source Hardware (OSHW)


Here's the information you need to assemble your own Cherry MX keypads using the PCB I designed or design your own.

Eagle Files and Example Program: Shared on Github
Cherry MX Keypad: Order PCBs on OSHPark!

Cherry MX Keypad Schematic

 Cherry MX Keypad Layout

Parts List:


Microcontroller: Atmel Atmega32U4 TQFP
LEDs: 4x 3mm Green (or substitute with LEDs that have the same compact dimensions)
USB Connector: FCI 10103594-0001LF
D1: BAT20J or similar schottky diode, SOD-323 package
Q1: MMBT2222A NPN transistor, SOT-23 or similar NPN with same footprint
Y1: 16MHz, 5x3.2mm 4-lead SMD crystal
Programming Header: Standard AVR ISP 2x3 0.1" header (no need to actually solder it)
C1: 4.7uF 0603 SMD
C2: 100nF 0603 SMD
C3: 1uF 0603 SMD
C4, C5: 22pF 0603 SMD (or adjust value based on crystal load capacitance)
R1: 10k 0603 SMD
R2, R3: 20 ohm or 22 ohm 0603 SMD
R4, R5, R6, R7: 330 ohm 0603

Notes: Be sure to get the "PCB Mount" version of the Cherry MX keys, such as the part numbers shown in the links above. They have the necessary "fixation pins" for stability on the board. The 3mm LED needs to have a very small rim and short height to seat fully into the side of the MX key body. Any substitute needs to have similar dimensions to the part number linked above or it may protrude above the key body and interfere with the keycap.

Soldering Note: Be sure to examine the pictures, footprints, and part dimensions to ensure you can successfully assemble this board. I did use hot air for the crystal and USB connector. They can be done with an iron, but hot air and solder paste is more reliable.

Wrap Up


I hope you find this project interesting. As I said, it is really just a template for designing your own Cherry MX keypad. You can modify it to make it easier to solder, expand the board to include many more keys, or customize it to your intended enclosure. Tweet me a picture @sync_channel if you make some of these boards or design your own custom Cherry MX keypad. I'd love to see it!

Also let me know what you thought of the YouTube video. I have wanted to add video content to my articles for some time, and this is a first attempt at it. I have nothing close to a proper setup for making videos, so I apologize for the poor quality. Perhaps in the future I will invest in some better lighting and equipment to improve my videos. This written blog will always be my primary means of sharing my projects however.

Thanks for reading!

- Dan W.

Monday, May 16, 2016

Designing a Mains Frequency Monitor, Part 1

This is the first in a series of posts about designing a mains frequency monitor using the Microchip PIC 16F1619 microcontroller. Today we will talk about the features of this device that make it a good choice for such a project. We will also start to piece together our circuit, program, and test a prototype on the breadboard.

Prototype of a mains frequency monitor using the PIC 16F1619.

Introduction


Many people assume that the mains frequency is exactly 50/60Hz, but in fact that is rarely true. Accuracy and stability of the mains frequency is an interesting topic to research. No two points on the grid will have exactly the same characteristics, so collecting data at your location can reveal some interesting findings. This is especially true if you have (or are interested in building) a mains-referenced clock. There are many industrial applications as well for such a project.

Numerous circuits and methods have been published for monitoring the mains frequency. Recently, I came across the PIC 16F1619 microcontroller and thought it would be a great device to design my own solution around. It is a very inexpensive chip that comes in a DIP package, making it breadboard-friendly for prototyping. This PIC has an interesting set of features including a Zero Crossing Detector (ZCD), a Signal Measurement Timer (SMT), and an Angular Timer. It also includes several 16-bit timers, configurable logic cells, a PID math accelerator, a hardware USART, and lots more. Check out the datasheet for this device to learn more.

Pinout of the 16F1619 in a 20-pin PDIP/SOIC/SSOP package.

Zero Crossing Detector


The first peripheral we will examine in more detail is the ZCD. It allows the detection of both the positive- and negative-going zero crossings of the input signal. Additionally, the output of the ZCD can be used as an input to another peripheral such as the SMT for gating and windowing. Externally, it requires only a single series resistor to limit the current into the module. Additional pull-up and pull-down resistors can be added to correct the offset on the comparator reference voltage or intentionally set an offset from true 0V. Check out this Technical Brief to learn more about the capabilities and setup of the module.

Block diagram of the ZCD module.

Scope capture of an AC input signal (blue) and ZCD output signal (yellow).
The output is also accessible in an internal register for triggering other peripherals.

Signal Measurement Timer


The SMT is a flexible 24-bit timer with many options for clocking, windowing, and gating. Check out the Technical Brief to learn more about it. We can use it to measure the relatively long cycles of the mains signal at full system clock speed and still not overrun the timer. Combined with the ZCD it gives us a means for measuring the mains frequency to a suitable level of precision. With the core functionality needed for our project handled by integrated peripherals, we save our code space for processing the data and feeding it out to another device for monitoring and logging.

Block diagram of the SMT module.

Angular Timer


Another really cool peripheral in the 16F1619 is the Angular Timer. It locks onto the input signal and allows the instantaneous phase angle to be determined at any point during the cycle. It can also be used for missed pulse detection. This peripheral relies on several registers and configuration bits, but once set up it is easy to use. You simply read out the value of the phase clock during a cycle to calculate the angle. This peripheral has many potential uses for mains applications and motor control. Microchip has a webpage on it with more information, documentation, and a video.

Designing the Circuit and Firmware


With the above three peripherals in mind, I started working on my circuit design for the project and building a prototype on the breadboard. I added a 20MHz TCXO to generate a stable, accurate clock for the microcontroller and timers. For the mains input, I used a 12V AC wall adapter. This goes into a half-wave rectifier and then a voltage regulator to generate VDD. The mains signal to be measured is tapped off before the rectifier, bringing it into the ZCD with a common ground reference. I might explore upgrading to a center-tapped full-wave rectifier in the future.

Below is a partial schematic for the circuit thus far.

The beginnings of a mains frequency monitor circuit.

The firmware came together quickly in MPLAB X IDE. I set up the various peripherals and put the SMT into Windowed Measure mode. The window is triggered by the internal ZCD output bit. When a positive-going zero crossing is detected, the SMT beginning counting at the full 20MHz system clock speed. At the end of the cycle the count is latched into a register and then stored. Once measurements for 60 cycles are accumulated, the average frequency during the second is calculated and printed via USART to an LCD display.

I didn't actually need the Angular Timer in my project, but it's such a cool peripheral I wanted to find some way to include it. I decided to use it to verify that the negative-going zero crossing occurs at the correct phase angle. That angle is of course 180 degrees (assuming a symmetric waveform). The ZCD generates an interrupt at the zero crossing and the program checks the count in the phase timer. If the phase angle is not correct, an error flag is set. Currently I just use this to set a status LED, but there is a lot more that could be done with it. In the future I might use it to detect erroneous measurements and automatically remove them before they get ingested into my data.

This hardware and firmware setup also gives us the basis for a mains-referenced clock, where the time is incremented every 60 cycles. That doesn't actually provide very good timekeeping (over short intervals) due to the instability/innacuracy of the mains frequency. For now it's an interesting addition to the project though. We will revisit this later and implement a much better solution for our clock.

The prototype on the breadboard works well, and you can see a picture of it at the top of this article. My initial testing against proper frequency counters shows that the design so far meets my expectations.

Lots More To Do


The project is coming along well, but we have a lot more to do before it is done. In Part 2, we will finish the firmware, finalize the schematic, and design a PCB for it. We will also need to do a lot of testing to verify the performance of the counter.

I have uploaded the program in its current state to a new Github repo. Please check it out if you are interested in seeing what the code looks like. This repo will also house the PCB design files and other documentation in the future.

If you have feedback and suggestions on this project, please post them in the comments below. A post on Part 2 of the project will be coming in a couple of weeks.

Thanks for reading!

- Dan W.

Saturday, May 14, 2016

Quick PCB: TCXO Breakout

I'm back with another Quick PCB. This one is a little breadboard-compatible breakout board for inexpensive temperature-compensated crystal oscillator (TCXO) modules commonly found on eBay.

Need a TCXO frequency reference for your breadboard project?
This might be a good option for you.

Introduction


There are some good, inexpensive TCXO modules on eBay that come in the slightly unusual package shown above. This breakout board allows you to mount one of the modules onto the small PCB and adapt it to standard 0.1" breadboard-compatible headers. I have also included a few optional SMD components. There are spots for a power LED, a bypass capacitor on the supply rail, and a capacitor on the control voltage input.

Some of these modules don't actually have a control voltage input on pin #1. Typically they have a small trimmer on top for adjusting the frequency, which is probably more useful for how these are commonly used. If you have access to a disciplined frequency reference such as a GPSDO, you should allow the module to warm up for 24 hours and then trim the frequency.

I have tested this board with two such TCXO modules from eBay. One is a 20MHz Raltron unit that is quite useful for microcontroller projects. You could also use a D flip-flop to divide it to 10MHz. The other is a 14.4MHz Rakon unit. Other modules in the same package will work. I honestly don't know what the package is called, so if YOU do please let me know in the comments below.

Assemble Your Own


Eagle Files: Shared on Github
TCXO Breakout Board: Order PCBs on OSHPark!

TCXO Breakout Board Schematic

TCXO Breakout Board Layout
Sharp-eyed readers will note this has been updated from the boards shown above.
The circuit is the same but the layout is much cleaner.

Parts List:


TCXO Module: Raltron RTX0230LC, Rakon VTX0525-14.4MHz, or similar
C1: 100nF 0603 SMD
C2: 10nF 0603 SMD (Only necessary if your module has VFC on pin #1)
R1: 1k 0603 SMD (or adjust value to change brightness of LED)
PWR LED: 0805 SMD (color of your choice)
Headers: Four 2x1 0.1" standard male headers (snap off from breakaway strips)

Note: The outer-most pins on each header are not connected to anything. They are just there for stability on the breadboard.

Sine to Square Wave?


Many of these modules output a relatively weak sine wave. However, you probably need a logic-level square wave for your project. You can use the circuit shown below to convert the sine wave output to a square wave. Note that you may need to adjust the resistor divider values based on the output signal of your module and the inverter you use. The peak-to-peak output from the TCXO needs to extend past the High and Low logic thresholds of the inverter to successfully trigger it. The divider also adjusts the duty cycle of the output.

Use a schmitt inverter chip with TTL-compatible inputs. I use 74LVC chips exclusively for my projects. 74ACT is another good series. If you want to be really old school, find those 74Fs in the junk box.

A typical circuit for converting a sine wave signal to a logic-level square wave. 

Wrap Up


I hope this little breakout board is useful to you! Tweet me a pic @sync_channel if you build one into a project.

Thanks for reading!

- Dan W.

Monday, May 2, 2016

Learning Embedded Electronics with the ATtiny104 XNANO

In this post I will document a small add-on board that I designed for the Atmel ATtiny104 Xplained NANO. I have also created a series of lessons that use the ATtiny104 XNANO with the add-on board to provide a basic introduction to embedded electronics and programming.

The ATTiny104 XNANO next to the small add-on board I designed to
enable a series of lessons on embedded development.


Introduction


In a previous post I examined the new ATtiny104 microcontroller from Atmel and checked out their evaluation board for it, the ATtiny104 Xplained NANO. I was very impressed by this little board. It has a programmer/debugger built in, allowing it to integrate seamlessly with Atmel Studio 7. You simply connect it to your computer with a USB cable to power the board, develop programs and connect to the USART. It is a great bargain at less than $5 USD.

It is not only suitable for evaluating the ATtiny104 but also for learning and teaching embedded electronics and programming. Certainly there are numerous Arduino and Arduino-like boards available for that task as well. This is just one more option that might be interesting if you need a very low-cost board that integrates with Atmel Studio for programming in standard C.

I designed a small add-on board for the ATtiny104 XNANO that includes a 5mm LED, a trimpot, and a photoresistor. The LED goes to one of the PWM-capable pins on the microcontroller, and the outputs of the trimpot and photoresistor circuit can be read using the ADC. These components combined with the on-board push button and LED allow for many lessons and projects to be completed. It's a very small and low-cost combo for learning or teaching embedded development.

The add-on board connected to the ATtiny104 Xplained Nano.

Lessons


To support the use of the add-on board, I have created a 28-page guide with eight lessons on basic embedded programming. The lessons walk you through using various features of the microcontroller and add-on board, including: digital inputs and outputs, the ADC, PWM output, USART, and interrupts. They are designed for someone that knows a little about electronics and programming, probably with an Arduino, and wants to get a feel for programming in Atmel Studio in standard C.

The guide to support the add-on board includes eight lessons on basic embedded development.


Add-On Board Kits


The add-on board makes for a very nice first soldering kit. The PCB is cheap ($6 USD for three copies from OSHPark) and the parts are very common, through-hole components. You probably already have all of this stuff on hand. The part outlines and resistor values are shown in the silk screen of the board so you don't even need to consult a schematic while assembling it.

ATtiny104 Xplained NANO boards can be acquired from distributors such as Digikey and Mouser. The PCBs can be ordered from OSHPark. Finally, the parts can be ordered from an online vendor such as Sparkfun

Lesson #1 in the guide is soldering together your add-on board kit!


Motivation


Let me say now that this is not a Kickstarter or anything like that. I'm not planning to sell these kits or make any money off of the guide. The add-on board is Open Source Hardware, and the guide is released under the Creative Commons Attribution-Share Alike 3.0 license. I hope that the board and guide are useful for learning a little bit about programming microcontrollers and embedded design, whether that is for an individual reading this blog or someone that might use the board for a workshop or class. Feel free to modify and redistribute the guide to suit your needs, as long as you attribute and share it back to the community under the same license. I have also shared the Eagle files for the add-on board if you'd like to customize it.

Check out the guide to learn more about the lessons and what you can do with this add-on board.


Shared as Open Source Hardware (OSHW)


ATtiny104 Xplained NANO Add-On Board: Order PCBs on OSHpark!

Eagle Files and Lesson Guide: Shared on Github

Schematic for the ATtiny104 XNANO Add-On Board

Parts list:
  • 10kΩ trimpot with knob
  • Small photoresistor (5mm width)
  • 5mm LED (color of your choice)
  • 470Ω resistor, 1/4 watt, 5%
  • 10kΩ resistor, 1/4 watt, 5%
  • (2) 12-pin 0.1” female headers (snap off from a strip of breakaway headers)
  • (2) 12-pin 0.1" male headers for the XNANO board

Note: There are no component IDs in the silkscreen, but the outlines and resistor values are shown to clearly indicate where the parts go.

Headers on XNANO: I have noticed that one of the capacitors on the ATtiny104 XNANO board is a little too close to the header pins. Male headers might not seat all the way flush against the board. Luckily there is an easy fix. Use a file to slightly round the bottom corner of the header where it hits the capacitor. Just a few swipes with the file will allow it to seat fully. Also, I used male headers on the XNANO board and female headers for the add-on board, but you can reverse that if you like.


After you finish the lessons and remove the add-on board, many additional
projects can be completed with the ATtiny104 XNANO.


Wrap Up


I hope that you find this small add-on board for the ATtiny104 XNANO and the lesson guide useful. If you assemble one and work through the lessons, or use them in a class or workshop, please let me know. Also, please post any questions and comments down below.

Thanks for reading!

- Dan W.


Saturday, April 30, 2016

10MHz OCXO Teardown (NDK ENE3311A)

Here we go with another OCXO teardown. This time we are taking apart an NDK ENE3311A 10MHz OCXO. This is a little 1" square unit with a square wave output. You can find them on eBay for about $15 USD.

I have a bunch of these on hand, so I don't mind sacrificing one
to learn more about the internal construction.

I cut around the bottom of the can with a dremel.
It eventually came off with little drama.

Not a lot going on inside this unit, eh? Just like in the CTS OCXO,
the oscillator circuit is on the top of the PCB, and the crystal is
bonded to the bottom side.

Close-up view of the top of the PCB, along with annotations of the pinout.

I cut the pins and flipped the board over. Ok! This side is much more interesting.
The little IC in the upper right is the output buffer. One of the SOT-23s on the
left is a voltage regulator. The remaining IC is probably an opamp.

There's a thermal pad and some white goop bonding the crystal to the heater elements.

I scraped away most of the thermal compound and lifted up the crystal.
We have two power devices and two resistors acting as heaters, just as expected.


That's all for this teardown! I might reverse-engineer the schematic for this one as I did with the CTS 1960017 OCXO. However, it's pretty easy to see what is going on inside this unit. Besides getting exact part values and device IDs, there is probably not a lot to be gained. What are your thoughts on the internal construction of the NDK ENE3311A OCXO?

Thanks for reading!

- Dan W.