After you have chosen the processor, it's time to build the rest of the system. The image above shows a typical design. I usually build on a scrap piece of 1/4" Baltic Birch plywood. In the upper right corner, you see the SparkFun ESP32 Thing Plus (WRL-15663) in the screw terminal adaptor.
The first step is to figure out the inputs and outputs to the processor. I usually start with what is usually called a graphical worksheet. Most processors have one. The most common type of input or output is digital (on or off). Most pins on a processor can be used as digital IO, sometimes referred to as GPIO. Other devices require I2C, SPI, or serial interfaces. These interfaces are usually on fixed pins of the device. Sparkfun and Adafruit have an interconnect system called Qwiic. This is really I2C but it uses a special connector to interconnect them.
Many of the digital devices require some kind of conditioning before use. Outputs will probably need a relay or MOSFET type device to drive higher voltages. Inputs may need some type of opto-coupler isolation as well. In general, I put opto-couplers on any input that has wires longer than about 1 foot, they are driven by a higher voltage or are from a system with a separate power supply. Long wires can be susceptible to static discharge and that can destroy components. I will go through these components below.
For simple, close to the processor switch inputs, you just need to connect the switch between a GPIO pin and ground. Internal pull-up resistors will make the processor read 1 when the switch is open, and 0 when it is closed.
If you don't have enough inputs or outputs for what you want to do there are IO Expanders that you can get. This is the one I usually use: SparkFun Qwiic GPIO
Power Supply
Every design is going to need a
power supply. Most of the electronics require 5 volts or 3.3 volts. The output devices (LEDs, Mag Locks, and actuators) require 12V. In order to support the various voltages, I use a 12V power supply that feeds a
5V regulator like the one shown to the right. For 3.3V, I normally use the regulator built into the processor. If I need a lot of 3.3V current, I will use a second regulator with the input connected to the 12V.
IMPORTANT NOTE: Set the regulator to the correct output voltage before connecting the output to any of the circuitry. They usually arrive with the output set to max and the 12V will destroy the other components.
Relays
The most common output is a relay.
This is the one that I usually use. The most important thing about a relay is to make sure the relay coil uses the voltage from your processor. This one is 3.3V. It can be used to drive almost any type of On/Off device.
Special note on driving mag-locks. Magnetic locks are very common in escape rooms. These are large electromagnets that hold doors shut when energized. These large inductors can be lick setting off an EMP bomb inside your puzzle when they are switched. This pulse can be several hundred volts and cause processors to reset or fail. This effect can be reduced by adding a kickback diode to the mag lock power. I use
these diodes. The band end should go to the + supply and the other side to the - side so they short out the reverse voltage spike.
MOSFETs
MOSFET is an abbreviation for Metal-Oxide-Semiconductor Field-Effect Transistor. In the configuration used, they act like a switch to turn things off and on. One advantagae is you can turn them on and off really fast using Pulse Width Modulation (PWM). This allows you to dim LEDs if needed. There are a couple of different ones that I use.
The first one is this
4-channel MOSFET version. It works great for controlling the 3 channels of RGB LEDs. The LEDs can be run off of 12V. This board is a low side switching. The MOSFET breaks the circuit on the low or negative side of the circuit. This works great for common anode type RGB LEDs. In common anode LEDs the + side (anode) of the LEDs are tied together. You then switch the - side (anode) of the LEDs. LED stripes will be marked with +12V, R, G, & B.
The other module that I like to use is
this one. It is a single channel MOSFET module. This is a high side switching module. The + side of the circuit is switched. This allows a common - connection between the input and output device.
One thing about this module is it sometimes will not switch on with a 3.3V input. If that occurs, short out the LED (D1) on the board. It is in series with the opto-coupler and will reduce the required input voltage.
One easy way to tell if a module is high side or low side switching is to measure the resistance between the input and output pins. This should be done when the module is not in a circuit. If the + input and + output are 0 ohms, It is a low side switching module. On high side switching modules, the - pins will be 0 ohms.
Optocouplers
Optocouplers are used for isolation. This isolation could be for higher voltages or simply to protect the processor from static electricity.
Optocouplers are actually an LED and phototransistor inside a chip. This is
the module I normally use. They isolate the input from the output. I use optocouplers on any wires that are longer than 1-2 feet to protect the input from static electricity. I also use them between any to boards that have separate power supplies as well as higher voltage signals. As a side note, I tend to use 12V signaling between puzzles or control panels.
Audio output
Many puzzles require audio. I use
this module for that. It has an SD card slot to hold the sounds. The built in 5W amplifier is loud enough for most puzzles and is easy to control through a serial port. With the serial port you can select the sound as well as the volume. Fo simple puzzles with one or 2 sounds, you can use the digital inputs instead.
Miscellaneous Items
As I have done this, I have come across other items that are very helpful.
Wire -- Wire is such a common thing but I have become a bit of a wire snob as I have done these puzzles. I use 22 Gauge Silicone wire for almost everything. Silicone insulation has many advantages over the standard PVC insulated wire. It is very flexible, easy to strip, and does not melt when soldering. I like the BNTECHGO wire on amazon. This is a
nice assortment to get you started. I also use some larger gauges for some higher current stuff. As far as color goes, I use red for + supplies, black for - supplys and rotate the rest of the colors for signals. You could use one color for all the signals but it is easier to trace wires if you vary the colors.
Cable clips -- I use a lot of these
little clips to keep wires organized. It is important to keep your boards organized so when you need to work on them or change them you can.
Lever Wire Connectors -- when connecting into the rest of the systems, I like these
quick connect connectors. They snap together for multiple wire assemblies and make it easy to hook things up in the room.
Comments
Post a Comment