Pi Zero USB

Pi Zero USB hub

I’m far from the first person to put together a Pi Zero USB hub. In fact, mine is loosely based on the open source design from @richardhawtorn, which was based on the design by @MakerBro.

The key difference is that I removed one of the USB A ports in exchange for a reduced footprint. As much as possible, I’d like my Pi Zero boards to have the same footprint. This design allows for a small USB WiFi adapter to be plugged in while remaining within the Pi Zero board outline.

Pi LiPoly charger on Pi day

Pi with Zero charger

I considerably reworked the design, and now have one of those boards built up.. I put a P channel MOSFET on the power line going into the MCP73831 LiPoly charger chip, which is the Pi 5 volt line. The power line out, has a Schottky diode, and then goes to the Pi 5 volt line. I use a comparitor across that diode to switch the input MOSFET on and off.

1-20160314_205324If I’m running from the Pi, and charging the battery, the cathode of the diode has 5 volts, while the anode has the about 4 volts coming out of the charger chip, keeping the comparitor off. When I disconnect the Pi power supply, The anode has the 4 volts from the battery, and the Pi 5 volt line has that, less the voltage drop from the diode. This sets the comparitor, which turns off the MOSFET. That way, I won’t be feeding a low voltage back into the charging chip when running from battery.

After the Schottky diode drop, I get about 3.7 volts on the Pi 5 volt line. That’s enough for the 3.3 volt LDO regulator on the Pi. Most 5 volt peripherals won’t be able to run, but the Pi and 3 volt peripherals will be fine.

 

This is a bit of a late entry on Pi day, but rounded, today is 3.14.16

Simblee Breakout Shield – Almost

Simblee breakout shield

I got the blank PC boards in for my Simblee breakout board Arduino shield. They look nice, and I started to build one up. Fortunately, I thought to only partially build it up for test purposes. Unfortunately, I didn’t do a continuity test on the board before I started. It’s got a short between +5 volts and ground.

1-20160306_140029The other blank boards are fine, but I didn’t check this one before putting parts on. I’ve only got four components that sit on +5 and ground, and I’ve removed, tested, and replaced all of them. Chances are it’s the board, but I can’t say with 100% confidence.

I would throw some parts on another board, but my small-tipped soldering iron has eroded to the point where it’s not usable on such small parts anymore. I’ve got a spare tip. I just don’t know where it is at the moment.

So, what does this board do exactly?

It takes one of the Simblee Bluetooth boards and puts 3 volt to 5 volt line level converters on each pin so it can be used on a standard Arduino.

 

Are you there Moles? It’s Edgar.

The World’s Geekiest MP3 Player

Launchpad and capacitive touch booster pack

I’m helping put together  the Wireless Mesh Networked “Hello There!” badges for the upcoming 2016 Boston ESC (Embedded Systems Conference). My biggest contribution is that I got my company, Screaming Circuits, to assemble all of the badges for free, and I got Sunstone Circuits to fab the boards for free. Beyond that, I’m just trying to customize mine, so it will be just a little different than everyone else’s. [Read more about the badge here]

David Ewing, of Synapse-Wirelsss designed it to use their SNAP wireless engine, and display things on an 8×8 LED matrix. It’s also Arduino hardware compatible, which brings me to the world’s geekiest MP3 player.

I’ve got a 7-band equalizer Arduino-shield that I designed a while back with Max, who wrote the linked article above. I’m going to put that on my badge, with a microphone and turn my badge into a 1950’s style robot voice display.

Lauch pad and equalizer shieldAs a music source, while writing the software, I pulled out a Ti MSP430 Launch Pad development board with an “Audio Capacitive Touch” booster back, as shown on the right.

I acquired the Launchpad and booster pack back in 201, when I was writing for the website Microcontroller Central. I haven’t used it since then, but after bringing it back out, I might end up inspired to build it into some new project. More on the badge later.

 

Robots good. Neurotic thermonuclear devices bad.

Pi Zero In Hand

Raspberry Pi Zero

I own a decent variety of Raspberry Pi models. I’ve got an old B, a Pi 2, an A+, and my Zero came in the mail today. Unfortunately, I wasn’t able to buy the $5.00 version, but had to buy it in a combo pack from Adafruit. I got the “Budget pack, product ID 2817”, for $29.95. See: It’s literally in hand:

Pi Zero in-handDon’t get me wrong. It’s a really handy set of accessories that’s included. It’s just that, in my case, I already have most of it. If you aren’t fully accessorized, buying a combo set like that is the way to go. If I need more later, I can just buy the $5.00 version (if it’s ever in stock).

These things go quickly. When the Zero first came out, Adafruit had the combo packs in stock, but they were out in a few days. Last week, they came back in stock (still no unbundled), but are already out just a few days later.

Pi with my LiPoly boardI’ve seen a number of people lament the limited usefulness, since it’s so connection poor. If your plan is to use it as a stand alone device, they have a point. You would likely be better served with one of the other models. But, that’s not my intention. I’m designing a set of same-size boards that will be the basis of specialized systems. The LiPoly battery charger / power pack shown on the right, is my first. I’ve got an I2C I/O board almost ready for fab, and I’ll follow that up with a motor control or two.

This might be a good way to look at it: The bigger Pi boards are better suited to use in software or OS training, or as stand-alone computers. The Zero is ideal for hardware design training.

Yeah, yeah. I know. Nobody cares about the Zero anymore because the Pi 3 just came out.

 

I was ionized, but I’m better now. 

Welcome Edison

Intel Edison

As I wrote earlier, I now have an Arduino 101 to play with.  I’ve also got an Intel Edison, which can run a small Linux distribution and act as an Arduino clone. It’s a lot more serious than the Curie or pretty much any other Arduino I happen to own, with a 500 MHz, dual core Atom, sporting a Gig of program RAM and 4 GB of on board storage.

SparkFun baseboard for Intel EdisonThe Edison doesn’t have any easily accessible I/O – everything is brought out to a high density 70 pin connector. So, you can’t really use it without some sort of a base board. I got the basic USB board from SparkFun, and I plan to make a few of my own. If you don’t have access to a professional assembly house (like I do in my day job at Screaming Circuits) you should probably get one of the boards that makes the I/O accessible on a 0.1″ header strip.

I ran a program to calculate out the first 5,000 prime numbers as a very rudimentary benchmark. It took about 20 seconds on the Edison, about 50 seconds on a ChipKIT uc32 (with a Microchip PIC32), about 2:30 on the Arduino 101, with the Curie, and… my Arduino Uno is… still… working… on… it…

The Edison is more complex to set up, although getting the Arduino IDE powering it wasn’t any more difficult than the 101. Out of the box, it runs a super stripped down distribution, but you can install a more full-featured Linux if you want. It’s got built-in Bluetooth, and built-in WiFi, which is pretty handy. I changed the name of my Edison to “Tesla”, so it’ll show up as that in my router.

The Uno finished up in about 15 minutes. No surprise, but it does hint at how much more you’ll be able to wring out of some of these new “Super Arduinos.”

 

Help stamp out and eliminate redundancy, and maybe ambiguity, or maybe not

Arduino 101

Arduino 101

I just received my brand new Arduino 101 – $30.00 even, plus $4.60 shipping from SparkFun – late last week. So far I’ve only had enough time to install it, and upload “blinky.” The board manager in the more recent version of the Arduino IDE makes installation pretty easy. Much easier than it used to be. The ChipKIT Arduino requires (or required) a custom version on the IDE. They have a beta version that works with the board manager, but I haven’t gotten it to work yet.

Arduino board managerI’m interested in the 101, both as an Arduino, and as the Curie module. I don’t yet know how to run native Curie code on the 101, but I’m sure it’s not too much of a hassle.

As of this writing, the Curie isn’t available to the general public in any form that I know of other than in Arduino form. I’m hoping to eventually design the Curie into a few of my own projects, so this will be my introduction.

 

With the gravity wave detected by LIGO, “A long time ago, in a galaxy far, far away” is an accurate description, not a movie intro

FPGA Beginner’s Series, 12: Driving a 7-Segement Display

It just occurred to me that learning to program FPGAs is making me feel young again. It’s not taking years off my countenance or anything, but I’m once again working with circuits I was building in my high school
electronics class back in the age of dinosaurs and dweebs.

In this column, I’ve added a binary to seven-segment decoder to the binary counting configuration I used in my previous blog. The seven-segment display I’m using is an old FND500 that I purchased in 1980 when building my first computer — a CDP1802-based singleboard
thing. My primary objectives with this project are to build on my starting project by adding more functions and to get something running that I can use to learn about the ChipScope virtual logic analyzer (a device discussed here before).

I’ve used almost all the available I/O on my Spartan FPGA, but I was able to bring out both the binary count and the seven-segment hex count. My push-on/push-off switch starts and stops the count, while my plain momentary contact push-button switch activates the decimal point. I’ve uploaded the complete UCF and Verilog file here, so you can follow our “create project” steps from previous blogs to start with working code before heading to ChipScope. I named my project “FND500count.” You can skip the “New Source Wizard” steps and just put the Verilog file and UCF into your empty project as complete source files. Copy the two files, “7-segment count.v” and “7-segment.ucf,” into a “source” folder in your project folder.

7-segment folders

After that, you just add the Verilog file, followed by the UCF file, into the project through the “Add file” option.

7-segment add file

Since we’ll be using ChipScope once this is all done, actual hardware isn’t really necessary. However, if you want to build it up, take a look at the picture at the start of this article.

In our previous sample code, the binary counting came out on the four LEDs built into the
Spartan 6 LX9 board. I started out using that sample code (both the Verilog file and the UCF).
For this exercise, I changed the binary count to drive four external LEDs, just to make it easier
to see both the binary count and the seven-segment count.

I had to change a few things in the UCF. For example, the “LOC” chip pin values for COUNTING_LEDS have changed to represent the pins connected to the header on the PCB. (Refer to Header J5 on Sheet 5 of
the Spartan schematic.)

As illustrated in the image below, I also changed the IOSTANDARD constraint from “LVCMOS18” to “LVCMOS33.” The four on-board LEDs are connected to Bank 3 of the Spartan chip, and this bank has 1.8-volt pins (Sheet 7 of the schematic). However, the headers J5 and J4 run from pins in Bank 1, which has 3.3-volt pins, hence “LVCMOS33.” I left “DRIVE” at 8mA. With an 8mA forward current and 1.7-volt forward voltage on my LEDs, I would need a 220-ohm resister to match everything up. The Spartan 6 chip will drive currents of 2, 4, 6, 8, 12, 16, and 24 mA. My LEDs will take a maximum of 20mA, but they light reliably with quite a bit less, so 8mA is fine for my parts.

7-segment change in IOSTANDARD

I put my momentary contact switch between pins 4 and 6 (chip pin E18 and Vcc) of header J4. The push-on/push-off switch goes between pins 10 and 12 (chip pin F18 and Vcc), also on header J4.

7-segment switch locations

The real spaghetti connects to my solderless breadboard. I’m using that ancient FND500 seven-segment LED I told you about earlier. This is a common cathode LED, so you’ll want to use the same if you plug in a different device. The pin-outs for this part are shown below. Your pin-outs may differ if you have a different part.

FND500 pin outNow that you have the project created and the hardware built (or visualized in your head), you can synthesize, implement, generate, and configure as we’ve done in past blogs. The result should look something like mine, which I’ve captured in the following video:

The new construct in the Verilog file (lines 80 to 99 in my file) is the binary to seven-segment decoder. I feed it (SEG_OUT) the same four bits (led_count[28:25]) that I feed the binary leds (COUNTING_LEDS). It introduced the reserved words “assign” and “case.” It also brought in the use of the term “reg” instead of “wire” back up on line 27. I still need to do a bit more reading before I can explain how this all works, but that will come later — unless anyone wants to read up and explain it to the rest of us by posting comments to this blog.

In my next post, I’ll bring up ChipScope, and I’ll explain the reg, assign, and case keywords in more detail.

FPGA Beginner’s Series, 11: Adding in the Switches

As you may recall, we have progressed beyond the light-emitting diode (LED) flashing tutorial that was provided with the Avnet Spartan-6 LX9 MicroBoard. Now we wish to plug some external switches into our FPGA development board and then use these switches to “Start” and “Stop” the
count sequence being displayed on the LEDs.

In my previous column, we got the UCF (user constraints file) taken care of, and we also got a sneak preview of the hardware (LEDs and switches) we are going to connect to our development Programmable Planet whats next - generated V codeboard. (See: Discovering FPGAs: Playing With LEDs & Switches.)

The next step is to decide what needs to be done with the *.v (Verilog) file that was automatically generated by the system. Let’s use the ISE Design Suite to look at this generated code as illustrated here:

ISE gave us a start, but there are quite a few things missing. First, we have inputs and outputs defined, but they aren’t really connected up to anything. To do that, add the reserved word “wire” to the inputs and outputs, as shown in the following image:

Programmable Planet whats next - generated V code

Next, copy and paste all of the code from the “ledflash_ISE_ver.v” example file that we completed in an earlier column, Discovering FPGAs: Loading the .BIT File. Copy the code from line 10 through to the end of the file and paste it in starting at line 31 of the new code. If you end up with two “endmodule” statement lines, just delete one of them.

Programmable Planet whats next – copy old code

Don’t run ahead and synthesize, implement, generate, and configure yet, because you won’t get very far and you will likely be a little disappointed. Before doing that, we first have to tell the Verilog code to do something with the LEDs and switches.

For the first shot, we’re just going to connect the switches directly to the LEDs. That’s pretty easy to do in actual hardware, and it’s also reasonably easy to achieve in an FPGA. Down toward the bottom of the code, change the name “LED” on line 76 to match the “COUNTING_LEDS” that we renamed it to. Also, change the bit ranges to match the fact that we’re only counting with four LEDs again. Also, add an “assign” line for each switch/LED pair. When you are done, lines 76, 77, and 78 will read as follows

Programmable Planet whats next - assign switch inputs

You probably noticed that I inverted the setting for switch input “STOP_COUNT” with the “NOT” sign “!” (this character is commonly referred to as a “bang,” “ping,” or “shriek”). In reality, this wasn’t really necessary, but it’s there now and it may be important in later exercises.

Now we can synthesize, implement, generate, configure, and program as we did earlier in series. In summary, what we’ve done is:

  • Connect pins 4 and 10 of header block J4 to the FPGA as inputs
  • Connect pins 4 and 10 of header block J5 as outputs
  • Use the FPGA to connect the two sets so that a switch setting applied to one header pin
    routes into the FPGA and back out to a different header pin

Finally, we’ll do one more thing. Go back to the Verilog file and — at line 73 — insert the statement “if (START_COUNT)” as shown below:

Programmable Planet whats next - if statement

Try it and see if you correctly predicted the behavior.

One of the risks of having a beginner (such as myself) teaching other beginners is that there’s always the possibility that I’ll miss an important detail, make incorrect statements, or just not always understand why I’m doing something. This Website being a community effort, I encourage anyone who catches me doing any of the above to correct me and to add to what I’ve written.

Along these lines, I submit the reserved word “wire” that we added in earlier. All of the documentation I’ve read thus far hasn’t been all that clear, and the examples I’ve looked at aren’t consistent in the use of this word. My understanding is that the word “wire” is telling the system to route a wire between the physical pin, as defined in the UCF, and the symbol in the Verilog code, e.g., “USER_RESET,” “START_COUNT,” etc

 

An Easy Breadboard Arduino, Part 3

This is part three of my breadboard Arduino-compatible series.

Part 1, here, wired up the breadboard
Part 2, here, programmed in the bootloader

FTDI Friend amd cable 800Next, I use an Adafruit FTDI Friend to connect the breadboard to a PC USB port so it’s ready to upload sketches. You can also use an FTDI Friend with built-in USB cable, as in the top image.

Once this step is done, the breadboard Arduino-compatible is fully useable with the standard Arduino IDE. Simply choose the board type “Deumilanove w/ Atmega328”