Jon Thomasson's Build Log


#72

I cleared off enough room on the workbench to do some more testing on my spartan mini fpga board with the end goal of completing this handheld NES project. Of course to be truly portable, I didn’t want to have to reprogram the NES core into the FPGA each time I wanted to play a game. It would be nice to persist the FPGA configuration off to the external SPI flash attached to the Spartan 6, and have it load in that configuration automatically when it starts up.

Here’s the pertinent part of the spartan mini schematic, showing the connections to the SPI flash:

The spartan 6 provides a way to read configuration data from an attached SPI flash. The Xilinx Impact software is used to program the SPI flash via an indirect programming method. This all seemed pretty simple and straightforward, at least on paper. But my friend Murphy likes to show up and tell me that I can mess up even the simplest of things.

After squandering what seemed like countless hours of my life, messing around with the Impact software, I was getting nowhere. I was getting the error message “spi device not found, id check failed”. That’s odd I thought, I see it right there in front of me, why can’t it find it? I ignored everything Chris had taught about whipping out the logic analyzer and checking the signals on the board. My every failed instinct seemed to take me further down the rabbit hole. I went to the schematic to see if maybe I had set the wrong mode configuration on the fpga. Then I went to check the schematic for the flash, to make sure it looked ok. I looked for clues from the manufacturer datasheet on what I was doing wrong.

Finally, when I had exhausted every last possible resource I could think of, I fished out the logic analyzer from the garage storage and clamped some probes onto the circuit :). I hooked up the probes to the chip select, data, and clock lines. To my astonishment, not a whole lot was going on. The clock was cycling a few times, but no other communication was really happening. This prompted me to start probing with the multi meter. The voice of Dave Jones echoed in my head “Thou shalt check voltages”. After confirming the voltages looked ok, I started checking for continuity between the various spi pins to the fpga. It was at this step that I found that there was no continuity between the chip select pin on the flash and the fpga. Aha! Finally I was getting somewhere. Looking at the schematic I saw that there was a 0 ohm resistor(R18) in series with the chip select pin, so I checked for continuity to it, but got nothing. Thinking it may be just a bad solder joint, I was about to grab the iron to re-flow the solder, when the multi meter probe glanced off of R20, a 10k pull-up resistor, and to my surprise I got a chirp indicating that there was continuity between that and the chip select. I pulled up the board file for these 2 resistors to see what was happening.

When I selected R18 in pcbnew, the problem became obvious. The R18 and R20 reference designators were swapped. So instead of soldering in a 0 ohm resistor on R18, I had seen the misplaced reference and placed a 10K resistor in its place. Mystery solved! After switching the resistor values, I fired Impact up, and was able to save the configuration off to the spi flash without a hitch. I guess there’s a few lessons I want to take away from this whole experience. First, make sure to pay extra attention when placing those references, that they’re next to the right component. And second, don’t wait so long to reach for the trusty logic analyzer or oscilloscope when problems arise. This may be one of the classic “trap for young players” that Dave mentions on occasion.


#73

Spent some more time soldering the final handheld NES project. Just like in routing PCB traces, the majority of the time seems to be in getting the placement of the components just right. For this particular project it wasn’t too bad. My main concern was just aligning the components so that they wouldn’t hinder the connection between the FPGA board and the proto shield. I wired in a Parallax Propeller Mini board to save on space. Here’s what the finished placement looks like:

I cut a small slot for the lcd cable to enter through the board and connect to the led driver. I ended up desoldering the screw terminals from the audio amp board in order to save room for the usb plug.

The only connections missing now are the speaker, sd card, and joypad buttons. The plan right now is to mount this to a larger board where i’ll have a bit more room to work with.


#74

I finished up the Spartan Mini NES project today. This is a project developed around my Spartan 6 FPGA development project. The end goal of this project was to learn Verilog and FPGA design, while also creating a handheld NES gamepad. I left off last time with the wiring done to the perfboard shield that connects to the FPGA board. Since there wasn’t enough room on that board to place the display and all the buttons I decided to bolt the shield to a larger perfboard that would fit all the components needed. I ran some measurements on the largest perfboard I had and mounted the shield to the board.

From there I wired up the joypad buttons, the SD card, speaker, and the Prop Plug connector for flashing the propeller board. For the speaker I bought one of these PCB mount varieties from Adafruit.

For the power supply I used 4 AA batteries wired in series and plugged directly into the barrel jack on the Spartan Mini board. I found that by placing the battery packs on the outer edge of the board, they could double as handle grips. I used velcro to hold down both the display as well as the battery holders. I did this in the hopes that it would be easier to modify or repair the board if it was needed in the future.

Here’s the finished project.

I’m going to swap out the Alkaline batteries for some NiMH 2100mAh rechargeable batteries. The total current drain of this project as measured by my power supply was around 400mA, so hopefully that should give me around 5 hours or so of operation before recharge. All in all I’m happy with how this project turned out. It was a lot of fun diving into FPGA’s and being challenged by aspects of electronics that I hadn’t encountered before.


#75

@jonthomasson,

This looks great! Nice work. Hey, I wonder if you could use 2 x 18650 batteries. They would be around 3000mah each and 3.7V nominal each. They should take up less space too.


#76

Any chance you have more of those Solder Sniffer boards left? I really need a fan for soldering, and this seems more fun than buying one…


#77

Thanks @hedrickbt! That’s a great idea with the 18650 batteries. I could stick 2 of those in parallel and get even longer run times. Maybe I’ll add those in a future revision!


#78

@jgalak, Unfortunately I’m all out of the Solder Sniffer boards. I wasn’t expecting them to be so popular. I’ll let you know if I get more of them.


#79

No worries, I can make some up easy enough.


#80

I’ve been meaning to play around with RF circuits for awhile now, but always felt a bit intimidated. However, I recently watched an amazing talk by Michael Ossmann which inspired me to give a simple RF transceiver circuit a try. My immediate goal is to see if I can build a working RF transceiver. If that goal succeeds then I’d like to see if I could take it a bit further and make a digital voice handheld transceiver or possibly something like a video transmitter for an RC plane. For those interested, here’s a link to the talk.

Mr. Ossmann gives 5 simple rules to follow for RF design. These are the rules he recommends if you want to delve into RF pcb design without having to buy expensive test gear and read mountains of books:

  1. Use 4 layers.
  2. Use integrated components.
  3. Use 50 ohms everywhere.
  4. Follow manufacturer recommendations.
  5. Route RF first.

The first rule, use 4 layers, is fairly self explanatory. By having 4 layers, it’s possible to have a stack up with a dedicated ground and power plane and a separate layer for RF signals. Here’s the recommended stack up mentioned in the video:
---------------------RF signals
---------------------GND
---------------------VCC
---------------------Signals

The second rule is to use integrated components. The idea here is to use chips that have the RF magic baked in wherever possible. For my project I opted to use a Semtech SX1238 transceiver. I discovered this chip through the digikey parametric search. Some feature’s I like about this particular transceiver is obviously it’s got an RF transmitter/receiver built in, 50 ohms output, good documentation, a built in power amplifier on the transmit(up to 27dB) as well as a low noise amplifier on the receive end. This particular transmitter has a frequency range between 868MHz and 915MHz in the ISM band.

The third rule speaks about using 50 ohms everywhere, which refers to impedance matching. So ideally you’d have 50 ohm outputs and 50 ohm transmission lines etc. In the video Mr. Ossmann uses Oshpark’s 4 layer stack up and an online pcb calculator to determine the trace width needed for 50 ohms impedance. I was planning on using Oshpark anyway, so I used the same numbers he used for his calculation. Here’s the link to Oshpark’s 4 layer board specs. By plugging in the pertinent numbers from the Oshpark website to the pcb calc we find out that in order to get a 50 ohm microstrip we need a 12 mil trace.

Rule number four states that we should follow the manufacturer recommendations. Of course, this is usually a good idea. For this rule I looked at the datasheet for the SX1238 and copied over the recommended schematic and components for the transceiver. Here’s my finished schematic:

The fifth and final rule is to route RF first. The idea is to optimize the top layer of the PCB for RF. Michael Ossmann specifies that in general for this rule, you should keep traces short and direct and keep other signals away from RF. For this rule I tried to keep the RF specific traces on the top layer and route the other traces on the bottom layer. This went pretty well, although the giant ground pad underneath the SX1238 made it difficult at times to route traces close to the component. One other problem I ran into was attaching the ground traces from the transceiver to the giant ground pad. At first I had one large pad specified in the footprint for the transceiver. But the problem with this was pcbnew wouldn’t let me route the traces out to the pad. I ended up just breaking up the pad into smaller pads and squishing them all together as can be seen below. This allowed me to route the ground traces without a hitch.

Here’s the finished routed board:

And finally, the 3d money shots. I added an optional shield over the RF components. I saw the “Designed with Kicad” graphic used by @ChrisGammell and @Steve_Mayze and really liked it, so I stuck it in a boring part of the board to give it some zest.


#81

That board (and that render!) look fantastic!

Is that a custom shield/can on top?

Also I assume from the part number you’re jumping into the LoRa world!


#82

Thanks Chris! The shield is an off the shelf variety from Wurth Electronics. It has two parts, the frame and the cover. One feature I liked about this shield is that the outer cover can be removed if necessary to gain access to the RF components underneath. It was also one of the only shields I could find with decent documentation and test results matching the frequency and power rating of my transceiver.

Although this transceiver is made by Semtech who produces the LoRa transceivers, I opted to not use a LoRa transceiver for this project. One of the main reasons for this was I wanted a transceiver with a higher data rate for possibly sending digital voice or video. If this works out though, I have a few project ideas for where I could use LoRa in the future.

If anyone is interested, here is a link to the github repo for this project.


#83

Very cool! I’ve never designed in a shield before, though i’m sure some of my designs could have benefitted from one :smiley:

It’s like making a quiet little room for your sensitive electronics!


#84

Is the 3D render from KiCad? If so, how did you model the shield?


#85

Yep, the 3D render is all done in Kicad. A lot of times the distributor will have CAD files that go along with the component. For example on Digikey they had the .step file available from the shield page where I could just click on it and download it.

You can also use the parametric search on Digikey to search for components that have CAD or EDA models. Sometimes if I have 2 components that have all the same specs/price, but one has access to the 3D model, I’ll choose the one with the model so I can use it in the PCB.
enter image description here

If the distributor doesn’t have them, a lot of times the product manufacturer will have something available on their website. Or you can also download models from online repositories like http://www.3dcontentcentral.com or https://www.snapeda.com.

Once you have the model file, you can attach it to a footprint in Kicad by opening up the Footprint Editor for the component and navigate to Edit-> Edit Properties. Then click Add 3D Shape in the 3D Settings tab to add the model you downloaded.

You may need to adjust some of the rotation/offset parameters to get the model to line up on your footprint. Then to view the model on the finished pcb, in pcbnew you would go to View->3D Viewer (or Alt+3). By default the viewer is set to render with OpenGL, but to get the really sharp, detailed renders I use Raytracing. To set Raytracing go to Preferences->Render Engine and select Raytracing.


#86

Cool, thanks! I didn’t realize that sort of model was available through digikey.


#87

Trace Parts Online also has a lot of parts. Not sure how many electrical parts they would have, but they do have a lot of connectors/plates/etc.

Digikey is certainly adding more, which is a great idea. Used them while I was doing a simple rebuild/redesign of a board for a customer and it was nice to check the connector fit to a front panel with step exports :slight_smile:


#88

I was able to make a little bit of progress on the SX1238 rf transceiver module recently. I have to admit that I was nervous just thinking about hand soldering these boards, given the close proximity of several small 0402 components and the large ground pad under the transceiver chip. For this reason I thought it would be a good time to try out a solder paste stencil. After seeing how well @Steve_Mayze’s boost regulator project turned out I decided to give oshstencils a test run.

Since I hadn’t done a stencil before, there was a bit of a learning curve. I found some resources that helped me get started. The first was this page from rheingold heavy which introduced some of the parameters needed, such as the solder paste clearance, to get the gerber files ready to send to oshstencil. The second resource was from this forum post by @ChrisGammell on the kicad.info forums. Specifically this picture helped me visualize how the pad mask parameters in Kicad worked :slight_smile: :
enter image description here

The first step for me was to determine which pads on the PCB required a stencil. At first I was thinking about just including all the SMD components. But after giving it some more thought I opted to leave out the SMA connector and shield, since I wanted to be able to test the circuit out first before sealing it in its metal house. And the SMA connector would require some hand soldering to get a good connection.

Now that I knew which SMD pads I wanted to exclude from the stencil, I took those pads out of the stencil by unchecking the F. Paste layer (the front solder paste layer) from the Technical Layers area of the Footprint Editor. This disassociates the pad from the front solder paste layer. It looks like F. Paste is checked by default whenever you create a new SMD pad.

The next thing I learned was that there should be a little bit of clearance between the solder paste and the edge of the pad. This clearance is aptly named “Solder Paste Clearance” and is illustrated on the picture above. This property can be adjusted on a per pad level on the pad properties page, or on a global level. To set the clearance for the entire PCB you navigate to Dimensions -> Pads Mask Clearance from the Pcbnew screen.

padmaskclearance

On the Pads Mask Clearance screen, there are 2 options for adjusting the solder paste clearance. You can either choose to set the clearance a fixed amount from the edge of the pad, or you can set the clearance to be a ratio based on the size of the pad. I chose to give the clearance a ratio of -5%. After adjusting these properties, the only thing left to do was to generate the gerber files which will be sent to oshstencils. When you go to generate the gerbers, you only need to select the solder paste layer as well as the edge cuts layer, since those are the layers that oshstencils care about.

I was surprised at how quickly I received the stencil back. It seemed like it only took 2-3 days from the time of order to having the stencil in my hand! Besides the stencil, I also ordered a little jig to hold the stencil in position while applying the paste. I found out you can also just use unpopulated PCB’s to fashion your own jig. Here’s a pic of what I came up with:

Once the jig and PCB are in place, you lay the stencil over the PCB until all the pads match up and are visible through the appropriate cutouts of the stencil. Then you tape the stencil down on one side.

From here, my pictures were a little too blurry to share, but I basically followed the same procedure for applying the paste presented in this Sparkfun video. The important thing I learned from all of this was to make sure to clean up the solder paste from the stencil and anything else you want to keep right away. Otherwise it really gets tough to clean up, and it manages to get everywhere!

To reflow the solder paste after I had placed the components I simply used a hot air rework gun. I did have some solder bridges around one of the transceiver chips, but nothing a little drag soldering couldn’t fix. Here’s the finished boards (with a quarter for size reference):

Edit: I noticed that the image for this post went missing. So I uploaded it again.


#89

Just as a fun little aside, I was completely fascinated by the tiny 0402 sized inductors for the RF transceiver. If you look close enough on the board you can kinda see little windings of copper wire. So I thought it would be fun to borrow my daughters microscope and get a closer look at one.

This is blown up about 40x magnification. This one obviously isn’t connected to the board. It’s on its side in this picture. You can see the copper wire bonded to the pads on either end. And some kind of translucent blue goop covering the top. I don’t know, I just thought it was cool. :slight_smile:

Edit: I noticed that the image for this post went missing. So I uploaded it again.


#90

The RF transceiver boards passed the initial magic smoke test. I brought the boards up with a current controlled power supply and to my surprise no magic smoke escaped! After that I wired up the SPI bus to an 3.3v Arduino pro mini to see if I could communicate with the transceiver.

I wrote a simple sketch that reads/writes to various registers. The idea here is that if the SPI bus isn’t working, it’s pointless to do any further testing until that can get sorted out. The sketch simply reads the register data to a serial console so I can check it with the default parameters of the datasheet. Here’s the results from the SPI testing:

It looks like the register values match! Cool, so onto transmitter testing next…


#91

Awesome! Are you going to borrow from the Radiohead library? I’ve used that in the past for LoRa stuff. I’m a bit of two minds about it. I feel like having a feel for the registers is very important…but I’m also very lazy :smiley: