From debug messages to the fundamental ‘hello world’, serial communication does it all over three little wires. Now imagine being able to cut the cord to your next microcontroller project and use your phone as a VT100 terminal. This was the premise of [Ondřej Hruška]’s Wireless Terminal Project where he took an ESP8266 and added an in-browser terminal emulator which can be accessed over WiFi. The final hardware uses an ESP-01 module mounted atop a breadboard adapter with a 3.3V LDO, protection circuitry for the pins and under-voltage disable.
The firmware is based on [SpriteTM]’s libesphttpd code which was modified to include the VT100 escape sequence parser. The parser, in turn, was coded as a state machine and compiled using Ragel which simplifies such projects greatly. When you access the tiny web server, the loaded webpage starts to communicate over web sockets to the ESP-01. Key-presses from the terminal are sent to the buffer and onto the parser and control logic. The characters are then passed to the hardware UART lines at 115200bps and if an escape sequence is detected, the corresponding action is executed instead.
[Ondřej Hruška] shares the code as well as a user manual in PDF for anyone who would like to try it out and help improve the project. With a little inspiration on learning about state machines, you could extend the project to your own use case as well.
Thanks for the tip [Marco Saarloos]
If you have ever thought that working out a Collatz sequence by hand was alright but lacked buttons and lights, the Collatz-o-matic by [mechatronicsguy] has you covered!
The device is a type of Tag system calculator. [mechatronicsguy] explains that a Tag system is a method of computing similar to a Turing machine; it consists of a read & write FIFO array (or tape or queue) of indeterminate length, and at every step the system reads the symbol at the “head”, deletes a fixed number of symbols from the “head”, and depending on what that first symbol was, appends one or more symbols to the “tail”. Then the process repeats with whatever new symbol is at the head.
The Collatz-o-Matic uses an RGB LED string to represent the queue, and is set up in the following way:
- Delete two symbols (tags) from the front of the queue.
- If the first symbol deleted was:
- A – then write BC to the rear of the queue
- B – then write A to the rear of the queue
- C – then write AAA to the rear of the queue
Numbers are as easily represented as any other symbol, and the Collatz conjecture is that no matter what integer you start with, the system (probably) always eventually reaches state 1. There is video of the device demonstrating exactly that embedded below. Continue reading “The Collatz-O-Matic: a State Machine with Style!”
About eight years before the Xerox built the Alto at PARC and over a decade before the Apple ][ premiered, Italian business equipment manufacturer Olivetti produced a bona fide desktop personal computer. When Olivetti debuted this typewriter-sized marvel in 1965 at a business convention in New York City, people were in absolute awe that this tiny, self-contained unit could perform the same types of functions as the hulking room-sized mainframes of the time. Some were sure that it was simply a small input device for a much bigger machine hiding behind the curtain.
But the revolutionary Olivetti Programma 101 was no joke. It performed standard four-banger operations and could handle square root and absolute value calculations. The Olivetti had 16 jump instructions as well as 16 conditional jump instructions, which put it firmly in state machine territory. Programs could be printed on a roll of paper or stored long-term on long magnetic cards.
Continue reading “Retrotechtacular: A Desktop Computer from 1965”
On a desktop computer, you think of an operating system as a big piece of complex software. For small systems (like an Arduino) you might want something a lot simpler. Object Oriented State Machine Operating System (OOSMOS) is a single-file and highly portable operating system, and it recently went open source.
OOSMOS has a unique approach because it is threadless, which makes it easy to use in memory constrained systems because there is no stack required for threads that don’t exist. The unit of execution is a C++ object (although you can use C) that contains a state machine.
You can read the API documentation online. Just remember that this is not an end user OS like Windows or Linux, but an operating environment for managing multiple tasks. You can, though, use OOSMOS under Windows or Linux as well as many other host systems.
Continue reading “Object Oriented State Machine Operating System Goes Open Source”
Having seen a number of PCB business cards [Will] decided to go against the more popular choice of a micro-controller based design and show some character with a logic based finite state machine. [Will] uses a single 7-segment display to scroll through the letters of his name with a state machine that outputs the desired combination of 1’s and 0’s to the LED display each time the tactile button is pushed.
[Will] uses a 4-bit counter made up of D Flip-Flops for the clock signal as a conditional input to 6 of the 4-input AND gates. He doesn’t go into the painful details of displaying each character through the process (thankfully) but he does mention that he uses the Quine-McCluskey technique for reduction instead of Boolean algebra. Since his name is 11 characters long and the 4-bit binary counter goes from 0000 to 1111 leaving 5 more pushes of the button before rolling the count back to 0000, during which time the display is left blank. [Will] kindly includes the eagle and Gerber files for your downloading pleasure over at his blog if you’re interested in getting a little deeper into the design.
Continue reading “This PCB Business Card is Logically Different”
Raindrops on roses, and whiskers on kittens. They’re ok, but state machines are absolutely on our short list of favorite things.
There are probably as many ways to implement a state machine as there are programmers. These range from the terribly complex, one-size-fits-all frameworks down to simply writing a single
switch...case block. The frameworks end up being a little bit of a black box, especially if you’re just starting out, while the
switch...case versions are very easy to grok, but they don’t really help you write clear, structured code.
In this extra-long edition of Embed with Elliot, we’ll try to bridge the middle ground, demonstrating a couple of state machines with an emphasis on practical coding. We’ll work through a couple of examples of the different ways that they can be implemented in code. Along the way, we’ll Goldilocks solution for a particular application I had, controlling a popcorn popper that had been hacked into a coffee roaster. Hope you enjoy.
Continue reading “Embed with Elliot: Practical State Machines”