Embed With Elliot: Interrupts, The Bad

We love interrupts in our microcontroller projects. If you aren’t already convinced, go read the first installment in this series where we covered the best aspects of interrupts.

But everything is not sunshine and daffodils. Interrupts take place outside of the normal program flow, and indeed preempt it. The microcontroller will put down whatever code it’s running and go off to run your ISR every time the triggering event happens. That power is great when you need it, but recall with Spider-Man’s mantra: With great power comes great responsibility. It’s your responsibility to design for the implicit high priority of ISRs, and to make sure that your main code can still get its work done in between interrupt calls.

Put another way, adding interrupts in your microcontroller code introduces issues of scheduling and prioritization that you didn’t have to deal with before. Let’s have a look at that aspect now, and we’ll put off the truly gruesome side-effects of using interrupts until next time.

Continue reading “Embed With Elliot: Interrupts, The Bad”

Learn Flip Flops With (More) Simulation

In the previous installment, we talked about why flip flops are such an important part of digital design. We also looked at some latch circuits. This time, I want to look at some actual flip flops–that is circuit elements that hold their state based on some clock signal.

Just like last time, I want to look at sequential building blocks in three different ways: at the abstraction level, at the gate level, and then using Verilog and two online tools that you can also use to simulate the circuits. Remember the SR latch? It takes two inputs, one to set the Q output and the other to reset it. This unassuming building block is at the heart of many other logic circuits.

circ5A common enhancement to the SR latch is to include an enable signal. This precludes the output from changing when the enable signal is not asserted. The implementation is simple. You only need to put an additional gate on each input so that the output of the gate can’t assert unless the other input (the enable) is asserted. The schematic appears on the right.

In the case of this simulation (or the Verilog equivalent), the SR inputs become active high because of the inversion in the input NAND gates. If the enable input is low, nothing will change. If it is high, then asserted inputs on the S or R inputs will cause the latch to set or reset. Don’t set both high at the same time when the enable is high (or, go ahead–it is a simulation, so you can’t burn anything up).(Note: If you can’t see the entire circuit or you see nothing in the circuit simulator, try selecting Edit | Centre Circuit from the main menu.)

Continue reading “Learn Flip Flops With (More) Simulation”

Hackaday Dictionary: The ESP8266

In August of 2014, something new started showing up in the markets of Shenzhen, the hi-tech area of China where the majority of the world’s electronics components are made. This is the ESP8266, a WiFi SoC (System on a Chip) that can connect to 802.11b/g/n networks on the 2.4GHz band. It can be addressed with SPI or a serial connection, and has an AT command set that makes it behave rather like an old-style modem. Basically, it has everything you would need to connect a device to a WiFi network, with the ESP8266 chip itself handling the complicated business of finding, joining and transmitting/receiving over a WiFi network.

That’s nothing particularly new in itself: WiFi connection devices like the TI CC3000 have been around for longer, and do much the same thing. The difference was the price. While the TI solution costs about $10 if you buy several thousand of them, the ESP8266 costs less than $7 for an individual board that can plug straight into an Arduino or similar. Buy the chip in bulk, and you can get it for less than $2.

The ESP8266 is more than just a WiFi dongle, though: it is a fully fledged computer in itself, with a megabyte of flash memory and a 32-bit processor that uses a RISC architecture. This can run applications, turning the ESP8266 into a standalone module that can collect and send data over the Internet. And it can do this while drawing a reasonably low amount of power: while receiving data, it typically uses just 60mA, and sending data over an 802.11n connection uses just 145mA. That means you can drive it from a small battery or other small power source, and it will keep running for a long time.

It wasn’t an easy ship to write applications for in the early days, though: it was poorly documented and required a dedicated toolchain to work with. This made it more of a challenge than many hackers were comfortable with.  That changed earlier this year, though, when the Arduino IDE (Integrated Development Environment) was ported to the chip. This meant that you could use the much easier to write Arduino functions and libraries to write code for the chip, bringing it within reach of even the most casual hacker.

Continue reading “Hackaday Dictionary: The ESP8266”

Learn Flip Flops With Simulation

Digital design with combinatorial gates like AND, OR, and NOT gates is relatively straightforward. In particular, when you use these gates to form combinatorial logic, the outputs only depend on the inputs. The previous state of the outputs isn’t important in combinatorial logic. While this is simple, it also prevents you from building things like state machines, counters, and even CPUs.

Circuits that use their own outputs as inputs are known as sequential circuits. It is true that at the fundamental level, sequential circuits use conventional logic gates. However, you usually won’t deal with them as gates, but will deal with abstractions like latches, flip flops, and even higher level constructs. Learning about these higher level constructs will allow you to make more advanced digital designs that are robust. In fact, if you are using an FPGA, building blocks like flip flops are essential since a large portion of the chip will be made up of some kind of flip flop.

Continue reading “Learn Flip Flops With Simulation”

Hackaday Prize Worldwide: Zürich On Thursday

Join us for a Meetup Thursday the 24th of September in Zürich, Switzerland. We’re co-hosting a meetup with FabLab Zürich and we are excited to see you!

Doors open at 18:00 on Thursday, 24 September. We’ll have some food and drink, project show and tell, and time to hang out and get to know each other. This is a free event but please RSVP to let us know you’re coming.

Bring the project you are working on to show off, everyone loves to see projects regardless of what stage they’re in. Many times, showing your project and talking about it pushes your project forward; “oh hey, I have an extra RN42 BT module you can have” or “I already wrote a driver for that chip and it’s on github”. Showing your project to others can also inspire someone else to make their own project based on your awesome idea. I’ve been motivated many times to start a project because of what I saw someone else make.

Germany Too!

This Zurich meetup isn’t the only chance to connect with Hackaday in Europe. Next week, we’ll be in Berlin! We’re co-hosting a Berlin Meetup with Vintage Computer Festival organizers in the evening after Berlin Maker Faire and the Vintage Computing Festival. VCF have planned food and drink, a live band or two… chip tunes! It will be on October 3rd, and [Elliot], [Sophi] and [Bilke] will all be there.

Retrotechtacular: Weston Electrical Instruments

A ‘meter is one of the most important tools on any electronics bench. After you’ve exhausted your five senses trying to figure out what’s happening in a circuit, firing up the old ‘meter is usually the next step. Meters are largely digital nowadays, but their analog ancestors are still widely available. We have a chemist and inventor named [Edward Weston] to thank for the portability and ubiquity of DC measuring equipment.

After immigrating to the United States from England with the degree in medicine his parents wanted him to earn, [Edward Weston] asserted that he was more interested in chemistry. His career began in electroplating, where he soon realized that he needed a reliable, constant current source to do quality plating. This intense interest in power generation led him to develop a saturated cadmium cell, which is known as the Weston cell. Its chemistry produces a voltage stable enough to be used for meter calibration. The Weston cell is also good for making EMF determinations.

Within a few years, he co-founded the Weston Electrical Instrument Corporation. The company produced several types of meters along with transformers and transducers known for their portability and accuracy. In 1920, [Weston & Co.] created this 1920 educational film in cooperation with the United States Navy as part of a series on the principles of electricity.

The viewer is invited to consider the importance of measurement to civilization, most notably those fundamental measurements of length, mass, and time. [Weston] positions his electrical measuring instruments at this level, touting them as the international favorite. We get the full tour of a Weston meter, from the magnet treated for permanence to the specially designed pole pieces that correctly distribute lines of magnetic force. What education film about electromagnetism would be complete without an iron filings demonstration? This one definitely delivers.

Continue reading “Retrotechtacular: Weston Electrical Instruments”

Why Are You Still Making PCBs?

Few things have had the impact on electronics that printed circuit boards (PCBs) have had. Cheap consumer electronics would not be as cheap if someone still had to wire everything (although by now we’d be seeing wiring robots, I’m sure). Between removing the human from the wiring process and providing many excellent electrical properties (at least, on a well-designed board), it isn’t surprising that even the cheapest examples of electronics now use PCBs.

For many years, the hallmark of being a big-time electronic hacker was the ability to make your own PCBs. There have been many ways that people have tried to bring PCB manufacturing into the hacker’s garage: stick on decals, light-sensitive blank PCBs, and even using laser printer toner (that last one spurred me to write a book on PCB layout many years back). You also see a lot of people using 3D printers or CNC mills to create PCBs. Hardly a week goes by that someone doesn’t ask me how to make a PCB in a home or small business lab.

Continue reading “Why Are You Still Making PCBs?”