From Gates to FPGA’s – Part 1: Basic Logic

It’s time to do a series on logic including things such as programmable logic, state machines, and the lesser known demons such as switching hazards. It is best to start at the beginning — but even experts will enjoy this refresher and might even learn a trick or two. I’ll start with logic symbols, alternate symbols, small Boolean truth tables and some oddball things that we can do with basic logic. The narrative version is found in the video, with a full reference laid out in the rest of this post.

Invert

1The most simple piece of logic is inversion; making a high change to low or a low change to high. Shown are a couple of ways to write an inversion including the ubiquitous “bubble” that we can apply almost anywhere to imply an inversion or a “True Low”. If it was a one it is now a zero, where it was a low it is now a high, and where it was true it is now untrue.

AND

2Moving on to the AND gate we see a simple truth table, also known as a Boolean Table, where it describes the function of “A AND B”. This is also our first opportunity to see the application of an alternate symbol. In this case a “low OR a low yields a low”

NAND

3Most if not all of the standard logic blocks come in an inverted form also such as the NAND gate shown here. The ability to invert logic functions is so useful in real life that I probably used at least three times the number of NAND gates as regular AND gates when doing medium or larger system design. The useful inversion can occur as spares or in line with the logic.

Continue reading “From Gates to FPGA’s – Part 1: Basic Logic”

Encoding Data in Packet Delays

If you’ve ever been to a capture the flag hacking competition (CTF), you’ve probably seen some steganography challenges. Steganography is the art of concealing data in plain sight. Tools including secret inks that are only visible under certain light have been used for this purpose in the past. A modern steganography challenge will typically require you to find a “flag” hidden within an image or file.

[Anfractuosus] came up with a method of hiding packets within a stream of network traffic. ‘Timeshifter’ encodes data as delays between packets. Depending on the length of the delay, each packet is interpreted as a one or zero.

To do this, a C program uses libnetfilter_queue to get access to packets. The user sets up a network rule using iptables, which forwards traffic to the Timeshifter program. This is then used to send and receive data.

All the code is provided, and it makes for a good example if you’ve ever wanted to play around with low-level networking on Linux. If you’re interested in steganography, or CTFs in general, check out this great resource.

MAMEFrame – Sweet All In One Portable MAME System

Video game enthusiast [NEIN] loves MAME. The one thing he doesn’t like much about MAME is moving large heavy MAME cabinets around. So what do you do if you want to take your games on the road? [NEIN] decided to come up with a portable MAME solution that includes everything all in one box so there is virtually no set-up time to get playing. He calls it ‘The MAMEFrame‘.

It may appear that this is a standard 2-player DIY controller, however, it is anything but. The display is housed inside the encloure — a video projector that connects to the Raspberry Pi via an HDMI cable. [NEIN] opted to use a Raspberry Pi instead of a large PC to help keep things light and samll. It’s almost like the two were made for each other. The projector has a built in battery and USB port. The Raspberry Pi is powered by the 5 volts supplied from the projector’s USB port making this unit completely portable and wireless. Just plop it down on a table, point it at a wall and you’re ready to guide Pac-Man to level 256!

Did you know one of the very first Raspberry Pi hacks ever was a MAME build?

Continue reading “MAMEFrame – Sweet All In One Portable MAME System”

Hackaday Prize Entry: An Electric Vehicle From Recycled Parts

In the future, just about everyone will be driving an electric car. We’re seeing the beginnings of this, and that means electrics and hybrids are showing up in junk yards. What does that mean? Tons of big batteries and powerful motors to build an electric vehicle from recycled parts.

A few years ago, someone exceptionally smart did the math on the environmental friendliness of different makes of vehicles from cradle to grave. The most environmentally friendly car to buy wasn’t a Prius, Leaf, or Tesla, but a used car; an old Civic or Rabbit. The logic makes sense – after two or three hundred thousand miles under its timing belt, the Civic or Rabbit has already paid the cost of forging the body and refining the plastic. Obviously, then, the most environmentally friendly car would be reusing the batteries and motor out of a newer hybrid.

For his Hackaday Prize build, [mauswerkz] is taking a 2001 BMW 330ci coupe and replacing the motor and transmission with some salvaged EV equipment. In this case, it’s the transmission and inverter from a Lexus GS450h and the batteries from a Chevy Volt ‘Extended Range’. Where the magical junkyard [mauswerkz] is pulling this equipment out of is anyone’s guess, but he did it. Maybe you can too.

So far, [mauswerkz] has the charger out of the Chevy Volt hooked up to the inverter and transmission from the Lexus and is making stuff turn. It’s only running at 200V instead of the final voltage of 650, but it’s enough for a proof of concept. Now it’s just a matter of stuffing everything inside the BMW.

Of course going to a junk yard isn’t the only way to get an EV. The more enterprising builder might want to build their own EV completely from scratch, starting with a block of foam. Yes, it even looks better than the BMW.


The 2015 Hackaday Prize is sponsored by:

Mimimalist Arduino Gaming Platform

A pretty color LCD screen, an Arduino, a buzzer and a joystick is all you need for a minimalist gaming console for under $20. At least, that’s all [João Vilaça] needed to get this sweet version of Tetris up and running. (He’s working on Breakout right now.)

It’s a testament to the current state of the hardware hacking scene that [João] could put this device together in an afternoon for so cheap, presumably after waiting a while for shipments from China. The 320×240 SPI color TFT LCD screen used to cost twice as much as this whole project did. And wiring it up is a simple matter of connecting this pin to that pin. Almost child’s play.

Equally impressive is the state of open source software. A TFT library from Seeed Studios makes the screen interface a piece of cake. [João] wrote his own sound and joystick code, and of course the Tetris gameplay itself, but it’d be much more than a few weeks’ work without standing on the shoulders of giants. Check out [João]’s Github for the project code and stick with us after the break for a demo video and some of our other favorite Arduino gaming hacks.

Continue reading “Mimimalist Arduino Gaming Platform”

Tiny Robot Jazz

Microcontroller-based projects don’t have to be fancy to be fantastic. Case in point: [r0d0t]’s “Musicomatic: the random jazz machine“. Clever programming and a nice case can transform a few servos and a microcontroller into something delightful.

musicomat_schematicsHardware-wise, there’s really nothing to see here; a speaker and some servos are hooked up to an ATmega328. We think it’s cute to have the microcontroller control its own power supply through a relay, but honestly a MOSFET in place of the relay or better still using the AVR’s shutdown sleep mode would be the way to go.

Nope, where this project shines is the programming. Technically, it might make some of you cringe — full of blocking delays and other coding “taboos”. But none of that matters, because [r0d0t] put his work in where it counts: the music. You simply must hear it for yourself in the clip after the break.

The basis of making music that humans like is rhythm, so [r0d0t] doesn’t leave this entirely to chance. The array “rhythms” has seven beat patterns that get randomly selected. The other thing humans like is predictability and repetition, so choruses and “improvs” repeat as well. All of the random notes are constrained to the pentatonic scale, which keeps it from ever sounding too bad. (The secret sauce of Kenny G.)

In short, [r0d0t] packs a lot of basic music theory into a very basic device, and comes up with something transcendent. We’re a bit reminded of the Yellow Drum Machine robot, and that’s high praise. Both projects are testaments to building something simple and then investing the time and effort into the code to make the project awesome.

For another slice of [r0d0t]’s excellent minimalist pie, check out his take on the classic Snake game: Twisted Snake.

Continue reading “Tiny Robot Jazz”

Measuring The Accuracy Of A Rubidium Standard

A rubidium standard, or rubidium atomic clock, is a high accuracy frequency and time standard, usually accurate to within a few parts in 1011. This is still several orders of magnitude less than some of the more accurate standards – for example the NIST-F1 has an uncertainty of 5×10-16 (It is expected to neither gain nor lose a second in nearly 100 million years) and the more recent NIST-F2 has an uncertainty of 1×10-16 (It is expected to neither gain nor lose a second in nearly 300 million years). But the Rb standard is comparatively inexpensive, compact, and widely used in TV stations, Mobile phone base stations and GPS systems and is considered as a secondary standard.

[Max Carter] recently came into possession of just such a unit – a Lucent RFG-M-RB that was earlier in use at a mobile phone base station for many years. Obviously, he was interested in finding out if it was really as accurate as it was supposed to be, and built a broadcast-frequency based precision frequency comparator which used a stepper motor to characterise drift.

Compare with WWVB Broadcast

WWVB Receiver
WWVB Receiver

The obvious way of checking would be to use another source with a higher accuracy, such as a caesium clock and do a phase comparison. Since that was not possible, he decided to use NIST’s time/frequency service, broadcasting on 60 kHz – WWVB. He did this because almost 30 years ago, he had built a receiver for WWVB which had since been running continuously in a corner of his shop, with only a minor adjustment since it was built.

comparator1
Comparator Circuit Installed in a Case

His idea was to count and accumulate the phase ‘slips’ generated by comparing the output of the WWVB receiver with the output of the Rb standard using a digital phase comparator. The accuracy of the standard would be calculated as the derivative of N (number of slips) over time. The circuit is a quadrature mixer: it subtracts the frequency of one input from the other and outputs the difference frequency. The phase information is conveyed in the duty cycle of the pulses coming from the two phase comparators. The pulses are integrated and converted to digital logic level by low-pass filter/Schmitt trigger circuits. The quadrature-phased outputs are connected to the stepper motor driver which converts logic level inputs to bi-directional currents in the motor windings. The logic circuit is bread-boarded and along with the motor driver, housed in a computer hard drive enclosure which already had the power supply available.

Continue reading “Measuring The Accuracy Of A Rubidium Standard”