No matter your project or field of endeavor, simulation is a useful tool for finding out what you don’t know. In many cases, problems or issues aren’t obvious until you try and do something. Where doing that thing is expensive or difficult, a simulation can be a low-stakes way to find out some problems without huge costs or undue risks.
Going to Mars is about as difficult and expensive as it gets. Thus, it’s unsurprising that NASA relies on simulations in planning its missions to the Red Planet. Now, the space agency is working to create a Mars sim in VR for training and assessment purposes. The best part is that you can help!
There are a few clever things here. First, different colors represent different parts. There are three different colors of wire, output and input wires, XOR gates, and AND gates. OR gates are just output wires, which or all the input wires together. By implementing these gates, Reso is, by definition, Turing complete. Since it’s just a PNG, it is trivial to open it up in GIMP and copy and paste one bit of the circuit multiple times. The different color wires are mainly to help route in a 2d plane, as you don’t have vias. Currently, the image compiles into a graph that is executed. [Lynn] chose code readability and ease of prototyping over premature optimization, so the code isn’t particularly fast. But it is pretty fun, squinting at the pixels that make up the adders and clocks he has on his blog. After giving Reso your image, it outputs a series of images that enumerate the state for several states.
Where this project shows off is the testing. It has unit tests, simulated integration tests, and simulated property tests. Since all the code is in C++, unit testing is relatively straightforward. The integration and property tests are via a simulator. Rather than recompiling the code with some new flags, he uses the simavr AVR simulator, which means it simulates the same binary file that gets flashed onto the microcontroller. This approach means the design is tested and debugged via GDB. It’s an incredible technique we’d love to see more of in hobby projects. Marketing speak might call this a “digital twin” but the idea is that you have a virtual version that’s easier to work on and has a tighter iteration loop while being as close as possible to the physical version.
[TaylorConor’s] goal was to create a from-scratch microcontroller project with easy-to-read code, fantastic documentation, and best practices. We think he nailed it. So feel free to run the simulator or jump right into building one for yourself. All the hardware is under a CERN-OHL-P license, and the firmware is under GPLv3.
In the world of the cockpit simulator hobby, no detail is too small to obsess over. Getting the look and feel of each and every cockpit control just right is important, and often means shelling out for cockpit-accurate parts. But not always, as these DIY magnetically captured toggle switches show.
Chances are good you’ve seen [The Warthog Project]’s fantastically detailed A-10 Thunderbolt II cockpit simulator before; we’ve featured it recently, and videos from the ongoing build pop up regularly in our feeds. The sim addresses the tiniest of details, including the use of special toggle switches that lock into place automatically using electromagnets. They’re commercially available, but only for those with very deep pockets — depending on the supplier, up to several thousand dollars per unit!
The homebrew substitute is mercifully cheap and easy to build, though — a momentary DPST toggle switch is partially gutted, with a length of nail substituted for one of its poles. The nail sticks out of the back of the switch, where a bracket holds a small electromagnet. When energized, the electromagnet holds the nail firmly when the switch is toggled on; the simulated pilot can still manually toggle the switch off, or it can be released automatically by de-energizing the coil. Each switch cost less than $20 to make, including the MOSFETs needed to drive the coils and the Arduino to provide the logic. The panels they adorn look fantastic, and the switches add a level of functional detail that’s just right for the whole build.
When [Michael Gardi] finished his scaled down DEC VT100 replica a few months ago, he made it very clear that the project was only meant to look like a vintage terminal on the outside. A peek into the case revealed nothing more exotic than a Raspberry Pi running its default operating system, making the terminal just as well suited to emulating classic games as it was dialing into a remote system. But as any hacker knows, some projects end up developing a life of their own.
It started simply enough. The addition of an RS-232 Serial HAT to the Raspberry Pi meant that the 3D printed VT100 could actually operate as a serial terminal using software such as minicom. Then [Lars Brinkhoff] got involved. He loved the look of the printed VT100, and thought it deserved better than a generic terminal emulator. So he went ahead and started developing a custom terminal simulator for it to run.
The idea here is that an an 8080 emulator actually runs an original VT100 firmware ROM, warts and all. It makes all the beeps and chirps you’d expect from the real hardware, and there’s even some OpenGL trickery used to mimic an old CRT display, complete with scan lines and a soft glow around characters.
Naturally the visual effects consume a fair amount of processing power, so [Lars] cautions that anything lower than the Pi 4 will likely experience slowdowns. Of course, nothing is stopping you from running the simulator on your desktop machine if you’re looking for that classic terminal experience.
Did this gorgeous recreation of the VT100 need to have a true serial interface or a simulator that recreates the unique menu system of the original? Not at all. Even without those additions, it blew us away when [Michael] first sent it in. But are we happy that these guys have put in the time to perfect this already stellar project? We think you already know the answer.
We have to admit that in the hardware hacking universe, there aren’t generally too many chances to hack elevators. Well, at least not opportunities that don’t also include the risk of incarceration. But fortune favors the bold, and when he found the remains of an elevator control panel in an abandoned Croatian resort hotel, [Davor Cihlar] undertook an extensive and instructive reverse-engineering of the panel.
The video below highlights his efforts, which were considerable given the age and state of the panel. This is a relay-only control panel, after all, with most of the relays missing and a rat’s nest of wires connecting the sockets. So [Davor] put his “RevIng” concept to work. This uses a custom PCB with a microcontroller on-board that plugs into each relay socket and probes the connections between it and every other socket. Very clever stuff, and it presented him with the data needed to develop a ladder-logic diagram of the board, with the help of some custom software.
With the original logic in hand, [Davor] set about building a simulator for the panel. It’s a lovely piece of work, with buttons and lights to mimic the control panel inside the elevator car, as well as the call stations that would have graced each lobby of the hotel. Interestingly, he found logic that prevented the elevator from being called to some floors from anywhere but inside the car. The reason remains a mystery, but we suppose that a hotel built by Penthouse publisher [Bob Guccione] would have plenty of secrets.
We love the supremely satisfying clickiness of this build, and the reverse engineering prowess on display, but we can’t find much practical use for something like this. Then again, DIY elevators are a thing.
Circuit simulations are great because you can experiment with circuits and make changes with almost no effort. In Circuit VR, we look at circuits using a simulator to do experiments without having to heat up a soldering iron or turn on a bench supply. This time, we are going to take a bite of a big topic: op amps.
The op amp — short for operational amplifier — is a packaged differential amplifier. The ideal op amp — which we can’t get — has infinite gain and infinite input impedance. While we can’t get that in real life, modern devices are good enough that we can pretend like it is true most of the time.
If you open this circuit in the Falstad simulator, you’ll see two sliders to the right where you can tweak the input voltage. If you make the voltages the same, the output will be zero volts. You might think that a difference amplifier would take inputs of 1.6V and 2.4V and either produce 0.8V or -0.8V, but that’s not true. Try it. Depending on which input you set to 2.4V, you’ll get either 15V or -15V on the output. That’s the infinite gain. Any positive or negative output voltage will quickly “hit the rail” or the supply voltage which, in this case, is +/-15V.
The biggest omitted detail in the schematic symbol above is that there’s no power supply here, but you can guess that it is +/- 15V. Op amps usually have two supplies, a positive and a negative and while they don’t have to be the same magnitude, they often are. Some op amps are specifically made to work with a single-ended supply so their negative supply can connect to ground. Of course, that presupposes that you don’t need a negative voltage output.
The amount of time it takes the output to switch is the slew rate and you’ll usually find this number on the device datasheet. Obviously, for high-speed applications, a fast slew rate is important, particularly if you want to use the circuit as a comparator as we are here.
Other practical problems arise because the op amp isn’t really perfect. A real op amp would not hit the 15V rail exactly. It will get close depending on how much current you draw from the output. The higher the current, the further away from the rails you get. Op amps will also have some offset that will prevent it from hitting zero when the inputs are equal, although on modern devices that can be very low. Some older devices or those used in high-precision designs will have a terminal to allow you to trim the zero point exactly using an external resistor.
Op Amps Can Provide Steady Voltage Under Variable Load
Rather than dig through a lot of math, you can deal with nearly all op amp circuits if you remember two simple rules:
The inputs of the op amp don’t connect to anything internally.
The output mysteriously will do what it can to make the inputs equal, as far as it is physically possible.
That second rule will make more sense in a minute, but we already see it in action. Set the simulator so the – input (the inverting input) is at 0V and the noninverting input (+) is at 4V. The output should be 15V. The output is trying to make the inverting input match the noninverting one, but it can’t because there is no connection. The output would like to provide an infinite amount of voltage, but it can only go up to the rail which is 15V.
We can exploit this to make a pretty good x1 amplifier by simply shorting the output to the – terminal. Remember, our rules say the input terminals appear to not connect to anything, so it can’t hurt. Now the amplifier will output whatever voltage we put into it:
You might wonder why this would be interesting. Well, we will learn how to increase the gain, but you actually see this circuit often enough because the input impedance is very high (infinite in theory, but not practice). And the output impedance is very low which means you can draw more current without disturbing the output voltage much.
This circuit demonstrates the power of a 1x amplifier. Both voltage dividers produce 2.5V with no load. However, with a 100 ohm load at the output, the voltage divider can only provide around 400mV. You’d have to account for the loading in the voltage divider design and if the load was variable, it wouldn’t be possible to pick a single resistor that worked in all cases. However, the top divider feeds the high impedance input of the op amp which then provides a “stiff” 2.5V to whatever load you provide. As an example, try changing the load resistors from 100 ohms to different values. The bottom load voltage will swing wildly, but the top one will stay at 2.5V.
Don’t forget there are practical limits that won’t hold up in real life. For example, you could set the load resistance to 0.1 ohms. The simulator will dutifully show the op amp sourcing 25A of current through the load. Your garden-variety op amp won’t be able to do that, nor are you likely to have the power supply to support it if it did.
What’s Being Amplified?
This is an amplifier even though the voltage stayed the same. You are amplifying current and, thus, power. Disconnect the bottom voltage divider (just delete the long wire) and you’ll see that the 5V supply is providing 12.5 mW of power. The output power is 62.5 mW and, of course, varies with the load resistor.
Notice how this circuit fits the second rule, though. When the input changes, the op amp makes its output equal because that’s what makes the + and – terminals stay at the same voltage.
Of course, we usually want a higher voltage when we amplify. We can do that by building a voltage divider in the feedback loop. If we put a 1:2 voltage divider in the loop, the output will have to double to match the input and, as long as that’s physically possible, that’s what it will do. Obviously, if you put in 12V it won’t be able to produce 24V on a 15V supply, so be reasonable.
This type of configuration is called a non-inverting amplifier because, unlike an inverting amplifier, an increase in the input voltage causes an increase in the output voltage and a decrease in input causes the output to follow.
Note that the feedback voltage divider isn’t drawn like a divider, but that’s just moving symbols on paper. It is still a voltage divider just like in the earlier example. Can you figure the voltage gain of the stage? The voltage divider ratio is 1:3 and, sure enough, a 5V peak on input turns into a 15V peak on the output, so the gain is 3. Try changing the divider to different ratios.
While it isn’t mathematically rigorous, thinking of the op amp as a machine that makes its inputs equal is surprisingly effective. It certainly made the analysis of these simple circuits, the comparator, the buffer amplifier, and a general non-inverting amplifier simple.
There are, of course, many other types of amplifiers, as well as other reasons to use op amps such as oscillators, filters, and other even more exotic circuits. We’ll talk about some of them next time and the idea of a virtual ground, which is another helpful analysis rule of thumb.