Tags

, , ,

 

I’m in the thick of the Contextual Electronics course.  I’m learning a a lot about designing circuits, using kicad, picking parts, and building a PCB.  The course has inspired me to make a breakout board for the RFM69 (@ 433MHz) that is controlled with an Arduino Uno instead of  a Moteino.  The RFM69HW breakout board will allow me to easily prototype the Base Station (early version discussed here) connected to one of the seemingly many Arduino Unos I have collected.   The Base Station receives sensor readings from the sensor nodes and then sends these over the Internet to my iPhone.  The breakout board will help me more easily test the capabilities of the components/parts I am thinking of using.  One of which is using the RFM69HW versus the RFM69W.  Do I need the RFM69HW or is the RFM69W good enough?  That’s just one of the questions.  

The Goals

The goal of this post is to build a schematic in kicad’s eeSchema tool that correctly identifies the circuit and components for an RFM69HW breakout board.  Future posts will discuss laying out the components on a PCB, ordering the PCB and parts, and – the YIPPEE moment (hopefully!) – soldering the parts onto the PCB and testing the breakout board.

The kicad files I created are in this github repository

Thanks to Those that Go Before

Learning electronics is an amazing community experience.  There are many very gifted people who have willingly and enthusiastically share their work. 

It is in this spirit I thank:

  • plutonomore has posted a schematic and board layout (Eagle) that is a RFM69HW shield for the Arduino.  You might want to stop reading any more of this post and build/learn from this exceptional effort (the link to plutonomore’s discussion and files).  I chose to roll my own because I want to increase my knowledge of building PCBs so that I can apply this to building PCBs for my hydroponics efforts.
  • Felix Rusu (lowerpowerlab.com)has posted the schematic and board layout (also in Eagle) for the Moteino.  This is well worth a look (the github link to the Moteino schematic and board layout).
  • Adafruit’s cc3000 breakout board and shield have helped me understand the pitfalls when 3.3V and 5V components co-exist.  I admire Adafruit.   My passion to learn about building PCBs has grown in some part to Adafruit because they take a “YES WE CAN!” approach.  They have made electronics accessible and take care not to land us in the hospital because we had an “OOPSIE” in our circuit!   They spend a significant effort on our learning and helping us learn.  I am happy to buy prototype components from them.  
‘THANK YOU!  I have gladly purchased items from both Felix and Adafruit (I am not aware of efforts from plutonomore to sell items).  They put a lot into their work.  THANK YOU!!

RFM69 Breadboard Challenges

The challenges I have run into trying to use the “off the shelf”  RFM69HW / W with the Arduino Uno on a breadboard include:

  • the pins on the RFM69 are spaced at 2mm (see p. 78 of the RFM69 data sheet) whereas a breadboard’s pin spacing is 2.54mm (0.1inch).
  • The Arduino Uno sends data over digital i/o pins using a 5V range.  Meanwhile, the RFM69′s sends 1′s and 0′s using 3.3V.  If you are new to level shifting, I thought Sparkfun’s tutorial on Logic Levels was very clear and easy to follow .  Thanks Sparkfun!
The schematic addresses these challenges.
 
Now it’s time to talk about selections for things like power source, voltage regulator, and level shifters.

Power Supply

The power source for the RFM69HW will be the Arduino.   Under 2.3.1 of the RFM69HW data sheet, transmitting data using the most powerful RF signal requires 130mA of current.  Based on Table 2 in the data sheet, the RFM69HW is at risk of being damaged if the amount of voltage supplied is greater than 3.9V.  The Arduino will need to provide at least 130mA of current and a maximum power of 3.9V.

Power can be supplied to the Arduino either through:

  • The 3.3V or 5V pins provide regulated voltage
  • Power jack (7-12V)
  • VIN – say from a wall wart (7-12V)
  • USB – 5V regulated

The Arduino has two pins that provide either 3.3V or 5V or regulated power (from the overview of the Arduino Uno).   Since the RFM69HW requires 3.3V of power, can I use the 3.3V source?  The answer turns out to be no because the maximum current draw for the 3.3V power source is 50mA. The maximum current draw for 5V depends on which power source the current is coming from (I got this info from here).  If the voltage is supplied by the USB, Arduino’s voltage regulator is not used so the circuit can draw up to 500mA.  Because the 5V (and 3.3V) power is regulated, I decided to go use the Arduino’s 5V source to power the RFM69HW.  The maximum draw current is not defined for the 5V.  I (might incorrectly) assume the maximum draw current to be similar to when using the USB for a power source – 500 mA.  Also, the components draw between 100-200mA, which should be well in the range of the 5V power source.  I couldn’t find the maximum draw current when using this power, however others have used it when requiring less than 500mA, so this should give me enough current.  

Since the VIN to the RFM69HW should not be greater than 3.9V, I’ll need to put in a voltage regulator.

Part Selection: Voltage Regulator

Since I do not the acquired knowledge to build a circuit that includes voltage regulation from scratch,, I decided to pretty much duplicate voltage regulators from other schematics.  The ones I looked at included  Adafruit’s voltage regulator from the cc3000 shield:

AdafruitVoltageRegulator

And LowPowerLab.com’s voltage regular for the Moteino R4:

MoteVoltageRegulator

I decided to use the same voltage regulator that Felix uses for the Moteino R4 – the MCP1703 (data sheet).  The data sheet specifies the MCP1703 can handle a maximum of 250mA of draw current.  While the 5V power supply can provide the circuit with 500 mA of current – which from 251mA upward would be too much for the MCP1703 to handle – 250mA is more than enough for the current draw requirements of the components.

Ferrite Bead

Besides chip selection, the most obvious difference was Adafruit included a ferrite.  I found an explanation on hackaday that adding a ferrite bead is not necessary, but further filters the signal noise.  While I realize this is “good practice”, I am not including a ferrite bead in an effort to keep the design as simple as possible.  I am assuming the decoupling capacitors will smooth out that nasty high frequency noise

Decoupling Capacitors

I did not understand the term “decoupling capacitors” before I wrote this.  Here is what I have learned.  Decoupling Capacitors:

  • filter out high frequency noise 
  • filter out low frequency noise 
  • store charge so that when the IC busts into activity, some of the current draw can come from the capacitor when the chip wants more current than the voltage supply can provide at that moment.
Decoupling works by using two capacitors in parallel on a circuit
  • one filters out high frequency noise, a 0.1uF ceramic capacitor
  • one filters out low frequency noise and provides additional charge for the IC when it bursts into action.   I will use a 10uF electrolytic capacitor.
There are decoupling capacitors on the schematic swarming close to a voltage regulator and the RFM69HW.  They are placed in parallel on the circuit.  The decoupling capacitors for the RFM69HW are placed close to the chip between the chip’s Vcc line and the circuit’s GND.  I want to get the decoupling capacitors that are there for the RFM69HW as close to the chip as possible so that noise filtering and energy can be accessed by the RFM69HW as quickly as possible.
 

How I Got to What I know

Designing the schematics highlighted specific areas of electronics where I am clueless.  i say  “specific areas” because  I have no idea what I don’t know.   One area that I clearly didn’t have a grasp on was capacitors.  Luckily, there are folks on the web who are not only smart but also capable to share what they know in a way that I can understand.  Spoiler alert – DC current can’t flow through a capacitor….

I bumbled across a quest to understand capacitors in the context of decoupling capacitors when I put two capacitors in series near the RFM69HW to act as decoupling capacitors and then asked for feedback on the schematic.  Ummm??? series? If I’m putting these in series, I don’t understand capacitors.  Why?  The answer to this Why? came from a wonderful reply I received from adafruit_support_mike on the Adafruit forum when I asked for feedback on the schematic.

adafruit_support_mike’s reply:

I see a minor problem with the way you’ve routed the decoupling capacitors for the two chips: you have them in series with the chip:

cap-series.jpg

and that won’t work. current can’t flow through a capacitor. The symbol puts a gap in the ‘wire’ as a reminder of that. Charging a capacitor is kind of like pushing one magnet with another.. voltage pushes charge carries into one plate, and the increased charge on the plate pushes carriers with the same charge out of the opposite plate:

cap-charge.jpg

The displacement makes it look like current is flowing through the capacitor for a little while, but a given voltage can only push so many carriers into one side and out the other. Once you reach that limit, the current apparently flowing through the capacitor stops. To push more charge in/out/through, you have to raise the voltage again. There’s always a practical limit to how far your input voltage can rise, so there’s always a limit to the amount of current you can send ‘through’ a capacitor. The input voltage is the only thing keeping the extra charge carriers in the capacitor’s upper plate, so if you reduce the input voltage, some of the carriers will flow back out of the upper plate. That allows carriers to flow back into the lower plate, creating the appearance of current flowing the capacitor the other way.That’s handy if you have a signal where you care about the changes (called the ‘AC component’), but not about the absolute voltage (called the ‘DC component’). It doesn’t work for powering chips though. A decoupling cap takes advantage of the in-and-back-out nature of charge on the upper plate, but to make it work you have to connect it like this:

decouplingconnecttovcc








There’s a DC path from the power supply to the chip’s VCC pin, and also to the upper plate of the capacitor. The supply voltage pushes charge carriers into the cap just like before.f the chip suddenly wants more than the DC path to the voltage supply can provide, the voltage at the chip’s VCC pin will fall. That also lowers the voltage across the cap, so some of the charge carriers stored in the cap will flow out of the upper plate. That creates additional current for the chip’s VCC pin.

adafruit_support_mike’s explanation helped me understand the role a capacitor can play when an IC needs bursts of transient energy.  For example, when the RFM69HW transmits data in “burst mode”, it draws 130mA of current.

Back to the Work of Others

There is a lot of great information on topics like decoupling capacitors on the Internet.  The challenge is finding the “right” ones to learn from.  Given all our different learning styles and the context of knowledge we are coming from, there is no “one size fits all” set of information.  The information that helped me included:

  • I assume the reason the use of the term “decoupling” has to do with filtering out the high and low frequencies.  I liked the explanation on this blog post that discusses what decoupling capacitors are all about:

When an otherwise good design works, but is erratic, unreliable or just goes crazy then nine time out of ten it is the power supply de-coupling…Things can get so bad that the noise can stop a circuit from functioning correctly. It is to get rid of this noise that we have to de-couple the power supply. “

later on in the blog post:

For effective supply de-coupling that frequency has to cover as wide a range as possible and certainly the range of noise being generated by the circuits. So this is why we often see two different values of capacitor used in parallel. One large one to filter out the low frequency variations and a small on for the high frequency noise. Typical values are 47uF and 0.1uF or 0.01uF (10nF) …

  •  The advice given in this document on Decoupling Techniques by Analog Devices helped give me more insight into the practical side of decoupling capacitors.  Figure 2 in the document contains:
    • A large electrolytic capacitor (typically 10 µF – 100 µF) no more than 2 in. away from the chip.  The purpose of this capacitor is to be a reservoir of charge to supply the instantaneous charge requirements of the circuits locally so the charge need not come through the inductance of the power trace. ‹ 
    • A smaller cap (typ. 0.01 µF – 0.1 µF) as physically close to the power pins  of the chip as is possible.  The purpose of this capacitor is to short the high frequency noise away from the chip.
    • All decoupling capacitors should connect to a large area low impedance ground plane through a via or short trace to minimize inductance.
  • plutonomore recommended this document Low Dropout Regulators—Why the Choice of Bypass Capacitor Matters.  The document provides insight into how and why the size of a capacitor matters.

SPI -Talking Between the Arduino and the RFM69HW

The Arduino Uno talks to the RFM69HW using the SPI bus.  The “traffic lanes” of SPI include CLK, MISO, MOSI, and CS.  Three of the traffic lanes – CLK, MOSI, CS – send traffic FROM the Arduino TO the RFM69HW.  MISO sends data FROM the RFM69HW TO the Arduino.  Here’s where I need to take into account the logic level differences between a 5V logic level and a 3.3V logic level that I noted earlier.

Arduino UNO Voltage Signals for HIGH/LOW SEND/RECEIVE

Sparkfun’s tutorial on sending 1′s and 0′s between 5V and 3.3V components has a nice image showing the voltages required for the Arduino to send or receive a 1 or a 0.

 

ATMega328DCCharacteristics 

Talk Direction

Logic

Voltage

Send

1

>=4.2V

Send

0

<=.9V

Receive

1

>= 3V

Receive

0

<= 1.5V

Let’s pretend the Arduino sends a 1 followed by a 0 on the MOSI traffic lane to be read by the RFM69HW.  The Arduino will send out a voltage signal that is at or above 4.2V to represent the 1, and a voltage signal at or less than .9V to represent the 0.   Here we are confronted with an “UH OH” moment.  The maximum voltage the RFM69HW can receive is 3.9V (see the RFM69HW data sheet, p. 11).  This means if the Arduino sends a voltage signal representing a 1, there is a good chance the RFM69HW will be damaged (beyond repair).  POOF – there goes that chip!  

3.3V Voltage Signals for HIGH/LOW SEND/RECEIVE


3V3DCCharacteristics

Talk Direction

Logic

Voltage

Send

1

>=2.4

Send

0

<=.5V

Receive

1

>= 2V

Receive

0

<= .8V

This time, let’s pretend the RFM69HW sends a 1 and then a 0 over the MISO traffic lane TO the Arduino.  If the RFM69HW sends a voltage signal between 2.4 and just below 3V – which as you can see in the table is an OK value for sending a 1 from a 3.3V component- the Arduino does not know how to interpret this signal since the minimum voltage for a 1 is 3V and the maximum voltage for a 0 is 1.5V.

Hmmm… our biggest challenge is sending and receiving a 1.  The Arduino Uno could SEND a 1 at a voltage that is higher than the RFM69HW is specified to accept.  On the other hand, the RFM69HW could send a 1 at a voltage the Arduino can’t figure out if it should receive a 1 or 0.

Now with that said, I run into schematics that have a 5V device – usually an Arduino – talking with a 3.3V device without “up shifting” the 3.3V’s voltage signal to be within the range.  An example of this is Adafruit’s cc3000 breakout board (here is the schematic for both Adafruit’s cc3000 shield and breakout board).  The breakout board includes the 74HC40500 high to low level shifter (data sheet) – preventing the 3.3V chip (in this case the cc3000) from receiving a voltage that will fry the chip.  However, the MISO is not level shifted.  As noted in a comment from Adafruit support:

In practice, the CC3000 has a quirk: it doesn’t release the MISO line when the CS pin is HIGH. On the CC3000 Shield, we added a buffer chip that isolates the data lines correctly. The breakout doesn’t have a buffer, but you can add one externally.

For those lucky folks who have the cc3000 shield instead of the breakout board, Adafruit included a 74AHC1G125 (data sheet).

 I ran into the problem on the MISO traffic lane that occurs without it and talked about it in this post.

74HC1G125

This way the “up shift” needed by the MISO traffic line happens.  I decided not to include the 74HAHC1G125 because I plan to use the RFM69HW in circuits that do not include the cc3000.  The schematic is simpler and the BoM is less.

Part Selection: Level Shifting for Talking on the SPI Bus

 I’m going to go with the 74LVC245 (data sheet) for handling a 1 coming from the Arduino and going to the RFM69HW.  Adafruit sells a breadboard friendly version.  Another option is to use resistors and put in voltage dividers between each 5V and 3.3V traffic lane.  I decided to use a chip instead of resistors because soldering one component seemed simpler than soldering 6 resistors.  Also, at one point I posted a 5V to 3.3V circuit using voltage dividers.  I recall getting feedback that using voltage dividing is not as robust as using a level shifter.  Although I don’t have the in-depth knowledge to do the contrast/comparison between using a level shifter and down shifting the voltage using voltage dividers.

Pull-Up Resistor

I added a 10Ω ohm pull-up resistor  (SparkFun has a great explanation of pull-up resistors) to the Arduino’s CS line.  This makes sure the conversation is over between the RFM69HW and the Arduino over SPI is “over”.  I covered basic SPI traffic in this post.

Interrupt

The RFM69HW Arduino library on GitHub uses an Interrupt Service Routine to monitor when data should be read from the MISO traffic line.  I won’t level shift the interrupt traffic land since it is not a shared line.

The Antenna

My appreciation of the antenna has grown during my exploration of in-home networking options.  After reading:

I decided to go with the antenna option that  lowpowerlab used for the Moteino.  I soldered on a copper wire that according to this online calculator should be 6.8 inches for a 1/4 Wavelength at 433MHz.  

Antenna

Copper Wire Monopole Antenna

The great part about this project is the discovery of how much I thought I knew but really did not!  One area where this is true is the role of the ANA pin on the RFM69HW.  It was one thing to stick a wire in a breakout board I purchased from Felix at lowerpowerlabs.com.  It was another to understand the implications when working through the circuit.  I only hope persistence beats density when it comes to learning electronics!

My “knock my head against the wall” misunderstanding of how the antenna works was understanding the role of the ground plane.  I realized I was getting my terms mixed up.  I kept wanting to short out the ANA pin!!!  As pointed out in this wikiepedia entry on the ground plane

In antenna theory, a ground plane is a conducting surface large in comparison to the wavelength, such as the Earth, which is connected to the transmitter’s ground wire and serves as a reflecting surface for radio waves. In printed circuit boards, a ground plane is a large area of copper foil on the board which is connected to the power supply ground terminal and serves as a return path for current from different components on the board.

Just having a ground plane on the PCB serves the purpose of “ground” for the antenna. If the ANA was connected to GND, then a return path in the circuit is created – which is not what we want since the ANA is not drawing current it is pulsing the 1′s and 0′s which the wire picks up.

A HUGE SHOUT OUT to Chip’s indefatigable willingness to evolve my understanding on the Sparkfun forum!  Since I was confused on how to apply terms, I thought it best to write down what Chip helped me understand.

TERMS

ANA – it is the pin on the RFM69HW that sends out a current to the…
Wire – a piece of copper of the appropriate length* that is soldered onto a connector that conducts the current. The wire in proximity to a ground plane forms an antenna that generates a shaped electromagnetic field (radiates) so that another RFM69HW with an antenna connected to its ANA pin can pick up the field and receive the info in the current.
The wire and ground plane together form the antenna(the job of ANA is to send out a current, the job of the antenna is to radiate the current).

Debugging

Test Points 

My first thought was to place LEDs along the SPI bus and INT traffic lanes so that I can test the traffic going between the Arduino and RFM69HW with a logic analyzer (I discussed using a logic analyzer with SPI traffic in this post).  Chris (the master mind behind Contextual Electronics) pointed out the SPI’s bus speeds would be too fast for LEDs.  He recommended test points, which I liberally included in the schematic. .

TestPoint

A Test Point

 

LED

Figuring out if the data is flying around the SPI bus is worth pulling out all stops.  So I added an LED based on what I saw in plutonomore’s schematic (the link to plutonomore’s discussion and files).   An LED is placed in the path of the CLK and CS traffic lanes.  Perhaps because electronics is new to me, I thought what plutonomore did was clever.

 As plutonomore notes:

LED2 blinks unmistakably when SCK is high and CSS is low, thus indicating that the RFM69HW wireless module is being accessed.”    You can see this in image below.

CS_on

 

CS LOW 

Since the SCK is like a heart beat, there will be times when SCK is high and CS is high.  In this case, the LED won’t light.  

CS_off

CS HIGH

The Schematic

The kicad files – as well as a pdf file for folks that do not use kicad – for the schematic is located in this github repository.  

We are using kicad in the Contextual Electronics course.  After 5 weeks of consistent use I have to say kicad is a powerful and fairly easy to use schematic-to-PCB tool.  My complaint is the Mac version is unusable.  I end up using bootcamp to boot my Mac into Windows 7 and use kicad on Windows – which works very well.  If you want to give kicad a try, install it from here and perhaps learn by creating a PCB by following the Chris’s “Getting To Blinky” series of videos.

What’s Next

My next post is about associating parts to the schematic symbols.  

Thank you for reading this post.  I hope you find many things to smile about.

 

About these ads