Showing posts with label Relay. Show all posts
Showing posts with label Relay. Show all posts

Monday, November 06, 2017

Building a Seeburg Wall-O-Matic Interface (Part 5)

Designing and Building the Circuit

This is where everything from Part 3 [Decoding the Pulses] and Part 4 [Inserting Coins] finally comes together into a complete circuit board design. Most of the work here actually took place simultaneously with what I've already described in those posts, so I won't rehash their respective elements. Basically, I did the overall design, then tested and proved out the individual elements on a breadboard, then put it all together into a final schematic and printed circuit board (PCB) layout.

Completing the Schematic

Early Iterations

It all began with a piece of scrap paper and a pencil... Starting with what I had seen on another blog posts about a similar projects, and adding in some of my own ideas about coin switch triggering, a rough schematic started to take shape:
The Pencil Sketch
At this point there were a lot of uncertainties and omissions. I hadn't yet figured out how I was going to filter the signal pulses, wasn't sure which relays I was going to use to toggle the coin switches, and apparently forgot that the relays would actually need a regulated DC voltage to trigger them. Interfacing a microcontroller was also something still far off in the future.

Not long after, I whipped out KiCad and started to layout a real schematic. I selected and tested components for filtering the signal pulses and driving relays to toggle the coin switches. As I proved things out on the breadboard in my lab, I tweaked the schematic until it ended up like this:
Early KiCad Schematic
Most of the components came straight from KiCad's libraries, but a few required some level of customization. KiCad didn't have any diode-protected relay symbols, so I had to make them. KiCad did have a ton of similar-looking rectifier bridge symbols, though, but it took a while to figure out which one best matched what I was using.

Of course, because of the constant changes, the wire routing quickly became a disorganized mess. At this point I decided to pull the various sections apart, and clean up the schematic.

I was also somewhat annoyed that the component for the 74HC14 (Schmitt trigger) didn't expose the power rails in any obvious way. This posed two problems for me: First, unlike many schematics, I had multiple power rails that needed to be distinct and separate. Second, I wanted an obvious place to put a bypass capacitor. Thankfully the newer KiCad libraries (via their Git repos) had redesigned the schematic symbols for this part, and now include a separate "unit" just for connecting power. So I kludged that library into my project, and forged ahead.

The microcontroller was still a bit of an unknown on the design, but I knew I was likely to need an isolated 3.3V supply for it. After some searching, I went ahead and threw in a DC-DC converter (NCS1S2403SC). It also required a custom symbol, albeit a rather easy one to create. The part was a tad pricey, and probably overkill, but it would do the job.

Design More Complete
(At the time I captured this iteration of the schematic, I had obviously forgotten to place a rectifier or any capacitors on the input of the DC-DC converter. I did remember to add those in later.)

Selecting a Microcontroller

Up until this point, I wasn't really sure what kind of microcontroller I wanted to use for this project. Other people have used Raspberry Pi boards, but I was fairly sure I didn't want to do that if it could be avoided. I really wanted something I could more tightly integrate, and that would be more purpose-built. Having a whole Linux system, complete with OS maintenance and startup/shutdown concerns seemed like overkill.

After watching a few too many EEVblog videos about a Nixie Tube Display Project, I became aware of this wonderful little Wi-Fi enabled microcontroller module known as the ESP8266. These modules are typically packaged onto surface mount carrier modules (which package the antenna, memory, and FCC certifications, etc). In Dave's project, he used a WEMOS D1 mini carrier board. This board packaged an ESP-12S module with a few necessary support components (USB port, reset button, etc) and a place to put pin headers.

Since I was unable to directly order that specific module when I was at this stage of design, I went ahead and instead ordered an Adafruit Feather HUZZAH. Its slightly larger, and has a few more support components I didn't really need, but is essentially the same thing. My intent was to use this module as a breadboard-friendly option for development and testing of the software, which I'll go into detail on in a future blog post.

For the actual board, however, I decided to just use an ESP-12S module directly.

Finalizing Revision A

The final step in getting the design ready was to include the ESP-12S into my schematic. Thankfully I found an existing KiCad part library that included the ESP-12E, which I could trivially edit into the part I needed. For the rest of it, I just looked at a variety of "getting started with the ESP8266" blog posts and various schematics for existing carrier boards. All I really needed was a few pull-up resistors, a reset button, a jumper for putting the thing into the flash download startup mode, and a pin header for connecting to the UART.

I didn't bother including a USB controller directly on my board, since it wasn't something I was going to need at runtime. Instead, I opted to just buy an external CP2102 adapter that I could plug in whenever I wanted to download updated firmware.

Eventually I ended up with this schematic:
Ready For Layout

Laying out the PCB

Finding all the Footprints

The first step towards laying out a PCB is making sure you have accurate footprints assigned to all of your components. Depending on what you're building, this is often a mixture of trivial and frustrating.

For the resistors, I knew I was going to use standard-sized "jellybean" 1/4 watt parts from my collection, so I selected reasonable footprints that made sense. (Of course KiCad calls this footprint "R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal", so it did take a little bit of work to decide that was the best choice from the library.)

For the capacitors, it was a little bit more of a challenge. I had a collection of usable parts for many of them, but not necessarily of known dimensions. Just to play it safe here, I decided to source all of my capacitors from fresh Digi-Key orders using quality brands. That way I would actually know the specific dimensions of the footprints for each one.

The rectifier bridge used an unusual package type (WOG) that wasn't in the KiCad library. I managed to track down someone's library that contained the right footprint. Making sure the pins all matched the schematic symbol still took some effort, as this part doesn't actually have numbered pins.

The relays were the first fully "custom" footprint that I had to create myself. Fortunately, they were just trivial modification of a common package. I took a DIP-14, deleted the 3 middle pins on either side, and made sure the pin numbering matched up with my schematic symbol.

The DC-DC converter was also a custom footprint, and one that required a bit more work. I found an existing footprint for a similar component from the same manufacturer, and tweaked its footprint based on the datasheet for my component.

Thankfully the component library I based my ESP-12S off of also contained a footprint. I just had to make a few minor modifications to remove certain pins, and I was all set.

Getting it all routed

Now that I had all of my component footprint data sorted out, it was time to actually layout and route the printed circuit board (PCB). I soon discovered that KiCad's PCB designer is actually pretty bare in its choices for things like trace sizes, drill sizes, via sizes, design rules, and the like. Thankfully, I found a few excellent resources that helped me configure it for this project:
After spending an afternoon laying out all of my components, and routing all the traces between them, I finally had a PCB design!
PCB Layout (Revision A)

KiCad's 3D view was also pretty cool, and helped with keeping the actual look of the board in mind. I didn't bother creating or fixing any missing/incorrect 3D models, but its still worth showing off:
PCB 3D View

Fabrication Time!

Sending off to OSH Park

I had decided to use OSH Park for making my PCB, mostly because of how easy they make the whole process. I basically just had to upload my ".kicad_pcb" file on their website, and they did the rest.

OSH Park PCB Preview

Finding Design Issues

While I was waiting for the PCB to come back from OSH Park, I decided to spend some more time testing and analyzing my design. During this process, a few initial issues jumped out at me:
  • The Zener diode I was considering as a voltage clamp on the output of the signal rectifier was a bad idea. It was based on a misunderstanding of a suggestion I saw on a website, and didn't actually work for my use case. This is the one element of the schematic I did not test before doing the PCB layout, and I really should have.
  • The relays were connecting the coin switches to the Common terminal, rather than to 25VAC. This mistake can apparently be traced all the way back through every one of my schematics, even though my bench test breadboard was doing it right.
  • The ESP-12S could use another button so I'd have a way of causing my software to start in a "setup" mode. Without doing this, reflashing would be the only way to recover from a broken Wi-Fi configuration.
The first two issues thankfully could be "patched" as part of the board assembly process. The third issue was something I could live with, but would address in a future revision.

Building the Board

After an uncomfortably long (but not really that long) wait, I got the manufactured board back from OSH Park:
Actual PCB (Revision A)
While assembling the board, I took copious notes. There were many things I wanted to verify due to upfront uncertainty, and many other things I discovered during the assembly process. If I was going to do another revision, I wanted to make sure I got all the kinks out.

Fully Assembled PCB (Revision A)


Issues discovered during assembly:
  • Diode bridge (WOG) footprints had holes and pads that were almost too small. (I managed to make the parts fit, but it was extremely tight.)
  • DC-DC converter's silkscreen was all wrong. (I expected this when I first figured out the footprint. Thankfully this one was just cosmetic.)
  • DC-DC converter probably should have filter capacitors on its output. (Just in case.)
  • Opto-isolator pins were a bit too wide, and took extra bending to fit. (It turned out I had ordered "DIP-4M" parts, whereas I used "DIP-4" footprints.)
  • UART pin header (J3) had the +V and Gnd silkscreen labels backwards (Big problem if I hadn't caught it, trivial to work around now that I know about it.
  • The board had tons of dead space, and was way larger than it needed to be.
After assembly, once I got the board working, I made another discovery. Apparently, my ESP-12S (ordered from Electrodragon) had only 1MB of flash. I had been led to believe that the ESP-12S comes with 4MB of flash, so this was quite annoying. Just to be safe, I decided that any future ESP-12S parts would come from another supplier that actually said 4MB on their product page (e.g. Adafruit).

Revision B

Okay, I'll admit that a second PCB revision is kinda silly for a hobby project like this. However, I was taking the design process for this project far more seriously than your average one-off hobby build. So what the heck...

Small Schematic Changes

I fed all the design changes from the previous sections back into the schematic, and arrived at a more "final" revision B:
Schematic (Revision B)

Compacting the Layout

I then spent some more time moving components around, and got the layout quite a bit more compact:
PCB Layout (Revision B)

Running the numbers, this turned out to be more than 8.5 square inches smaller than the Revision A layout!

Back to OSH Park

This time it was simply a matter of uploading and ordering. Since I has gotten the kinks out, I also felt confident enough to actually share the design:
OSH Park ~ wallbox.kicad_pcb

OSH Park PCB Preview (Revision B)

Building the Board

This time assembly was very straightforward. All the issues I had discovered in the last revision were resolved, so it was simply a matter of soldering in components.
Assembled PCB (Revision B)
Well, it was mostly simple. At least until I got to the ESP-12S module itself. This time I had the bright idea to attempt "proper" SMD soldering with solder paste. Everything seemed to go fine until I was actually ready to switch the power on... And it didn't work...

During the painful troubleshooting process, I discovered that all the pins on one side of the module were apparently shorted to ground. I tried reheating them with my soldering iron, using solder wick to clean things up, and even using a desoldering gun to suck away excess solder. Nothing seemed to fix the shorts.

I then had this crazy idea to point my ridiculously oversized hot air gun at the thing, in an attempt to reflow the solder. For a long time, nothing seemed to be happening. Then, out of nowhere, the whole ESP-12S module popped right off the PCB!

At this point I tested both the PCB and the module, and couldn't find any evidence of shorts. So I resoldered it the "old fashioned way," and it started working. Phew!

Since the ESP-12S module is not a "real" SMD part, but rather a surface-mountable carrier PCB, I suspect the PCB "sandwich" prevented the solder paste from correctly reflowing around some of the pins.

Bill-Of-Materials

One thing I made sure to do throughout this entire process, was to keep a detailed and accurate bill-of-materials (BOM) for the project. Initially I did this with a plain text file, but eventually I did the grunt work to move all the data into the KiCad schematic itself. The BOM included part descriptions, datasheet links, part numbers, and vendor information. This made it easy to use various companion tools to generate HTML or CSV versions for easy sharing and part ordering, and provided a handy reference during assembly and testing.

Bill-Of-Materials Snippet

Project Resources




Tuesday, October 31, 2017

Building a Seeburg Wall-O-Matic Interface (Part 4)

Inserting Coins

Credit Mechanism

The whole process of accepting coins into the wallbox is comprised of at least three major components:

Slug Rejector

The slug rejector is a mechanism that uses magnetic fields and mechanical components to determine whether an actual coin has been inserted, or simply a "slug" of similar dimensions. Its operation is perhaps best explained by this excerpt:

Here's what my wallbox's slug rejector actually looks like:
Wall-O-Matic 100 Slug Rejector

Coin Switch Assembly

Once a coin has successfully passed through the slug rejector, it hits one of the three coin switches within the coin switch assembly:
These switches toggle different components of the credit assembly, depending on what kind of coin was inserted.

Credit Assembly

When the coin switches are toggled, the credit assembly electromechanically counts the "credits" using gears and solenoids:
Credit Solenoid & Switch Assembly
This is one area where the model 200 is significantly more complicated, as it uses a "dual credit assembly" that is capable of assigning different credit amounts to different songs. The mechanism in the model 100 (shown above) is much simpler.

Once sufficient credit has been recorded, the program light is illuminated and the selector buttons are unlocked.

Relay Circuit

Fairly early on in this project, it was clear that I didn't actually want family and friends to have to put actual coins into the wallbox. Sure, its kinda neat to do every once in a while, but I'd rather not have keep a pile of coins nearby and constantly open it to empty the coin tray. Thankfully, simulating a coin drop is actually quite easy. All you have to do is solder some wires to the coin switch terminals, and momentarily short them as if a switch had been toggled.

Coin Switch Assembly /w Control Wires

Now the easy way to do this would simply be to install a button somewhere. But what's the fun in that? If I'm going to be connecting a microcontroller to this thing anyways, I might as well incorporate the "coin drop" into its functionality.

Circuit Design


In theory, this is actually quite easy to do. You just need to bring wires from the coin switches to outside the wallbox, and connect them to a few relays (one for each switch).

In practice, there were some additional considerations:
  • I wanted to maintain complete isolation from the microcontroller side to the wallbox side, just like I was doing for the signal pulses
  • I needed to drive the relays with something like "logic level" signals
  • Relays capable of doing the job needed at least 5VDC to function
The first thing I needed was a 5VDC power supply that could exist on the "wallbox side" of the system. So I built this fairly standard over-engineered LM7805 setup:
Relay Power Supply

The next thing I needed were three instances of this opto-isolated relay driving circuit:
Relay Circuit (x3)
Its important to note that the +5V and Ground rails from these two schematics exist entirely within the confines of the relay portions of the system. They don't connect to anything else.


While this all looks fairly straightforward, I did run into some interesting problems figuring all of this out.

Making it work


The first problem was getting the relays to actually trigger. These relays were designed with diode protection, something I'd never used before, and thus only worked if connected in a single direction. They are also reed-switch relays, and don't actually make any noise when switching. Throughout most of this process, I had a multimeter in continuity-beep mode with its probes across the relay's load pins. It was quite satisfying when I finally got it to beep.

The second, and perhaps larger problem, was actually getting the relays to trigger when running off my own driver circuit. I could get them to work off my bench power supply, but every time I used my own circuit it was a complete fail. It seemed as though I was having issues getting the 5V supply to work correctly.

During my initial frustrating attempts, I somehow managed to short something and blow up or fry a couple regulators and relays. When it still didn't work, I thought the regulator must not like the oscillations of rectified AC and needed a bigger input capacitor. So I put the biggest capacitor I could find across the inputs... A 6600uF 25V monster that was in my bin... All of a sudden, everything seemed to be working... And then it exploded...

After picking up most of the larger pieces, my breadboard looked like this:
Breadboard After Capacitor Explosion

It then occurred to me that I was probably over-driving that capacitor. The output of my diode bridge was supposed to be a rectified 25VAC wave, which should have been right on the edge. Of course AC voltage is actually measured by RMS, not peak. So doing the math, my peak was actually closer to 35V.

Of course once I measured things, it was actually even worse than that. Everything up until this point had been assuming my main transformer was getting 115VAC and outputting 25VAC. Close, but not quite:

Mains AC
Transformer Output AC
Yep, I was actually driving the capacitor (and regulator) with almost 40V peak. No wonder it went boom a little while after it charged up.

The next thing I did was try again with a capacitor rated for 50V. This time nothing blew up, thankfully. However, the relays also didn't work. I then began to notice a very odd problem. Apparently the regulator consistently produced a 5V output whenever I measured it at idle, but instantly dropped to around 1V whenever I put any load (including a simple resistor) across it.

Time to look at the datasheet:
LM7805CT Absolute Maximum Ratings
Okay, looks like I was driving this thing just a few volts past its maximum rating. Thankfully not enough to release any more magic smoke, but apparently enough to make the regulator malfunction.

Fortunately, I had one more option. Like most transformers, mine had a center tap. I didn't originally think I was going to need it, but now it seemed like a useful option. Measuring from the center tap, I had a more reasonable input voltage to work with:
Transformer Center Tap AC
Once I used this as my regulator input, everything started to work just fine.

Next Steps

Now that I have major components of the actual wallbox interface circuitry all figured out, the next step is to put them together into a complete circuit and system design. Of course that's a topic for another blog post.