Control Panel for Workshop

by pityukecske in Circuits > Electronics

5425 Views, 31 Favorites, 0 Comments

Control Panel for Workshop

101_0181.JPG
In this instructable I will give details about a recent development in my personal workshop. This is a wall-mounted control panel, able to control three relays, a motor control board, a display, a current measurement unit, and - in the near future - a DDS signal generator.
Before having this, I used some screw terminals to power the stuff I've been working on. That wasn't that bad, but still, I wanted something better, easier, with extra feature, current measurement.
After two weeks of debugging, soldering, and repairing, I can finally see some results: though, it isn't very precise, currents are measured, the menu system I wrote, is working good, 
I've had luck (and bad luck) with some switch mode power supplies I bought some time ago, I used those as main power supplies. However, if anyone wants to build that part too, I can suggest building a symmetrical power supply with simple LM317 and LM337 adjustable regulator stages. I made three of those a few years ago, they're really useful for op-amp circuits for example, where positive and negative rails are needed, in respect to ground.

What you're gonna need, is a lot of patience, really. If you have some experience with making PCB-s, and soldering, none of the steps should give you any headaches.
Let's see what this idea of mine is all about, and how it was built.

The Power Supplies

101_0084.JPG
101_0190.JPG
As for power supplies, as I said, you can decide to buy it, or you can build it yourself. For this project I used some switch mode power supplies I already had. Both have three outputs: +12V, +5V, -5V. They also have a potentiometer, which can adjust the 5V output voltage. Connecting these was pretty simple, everything was marked, 230V L, N, and the ground too. It is very important to connect the grounding pin too, otherwise there is a chance for you to see ghost voltages on the outputs. I've measured even -30 volts on the +5V output. Of course, once you put a load on that, it immediately disappears. I don't know whether or not these kind of ghost voltages could damage the circuit you're working on, anyway, it's better if it's not there. Grounding is important, take it seriously!

The DIY version of a power supply can be seen on the second image. These come in handy, but you have to buy a symmetrical transformer for each.

Current Measurement Unit

101_0076.JPG
101_0112.JPG
101_0113.JPG
101_0176.JPG
101_0181.JPG
101_0182.JPG
101_0183.JPG
101_0188.JPG
This is the module, that gives me feedback about the currents, that are passing through the load. The method I used to make these measurements is the easiest: adding a shunt resistor in series, and measure the voltage across it. There are plenty of circuits about current measurement on the internet, I picked this, because I thought, adding some fancy sensor would only add complexity to this project. However, now that it's ready, and I see what it measures, I got to say, I could be more satisfied with it. Changing to better components (rail to rail op-amp, for instance) would probably increase precision. I made some photos with a test measurement, the difference is pretty significant, 38 mA. 

At the heart of the measurement unit there's the LM324 quad operational amplifier. The op-amps in it (intend to) scale the voltage read on the shunt resistors to the voltage that can be read by the ADC of my processor. This means, an amplifying module needs to be added. 

First, we need to know some details about our power supply, like the maximum output current at a given output. Luckily, the PSU-s I own, had this printed on the casing: 12V @ 2.5 A, and 5V @ 15A. That settled it, the maximum currents were considered to be 2.5A, and 15A, respectively. I had some 20W, 0.1R resistors hanging around, I decided to use those.

Let's see the calculations for the 5V current sensing part:
Uout = 5V; Imax = 15A; Rs = 0.1R;

The maximum current, that could ever go through that resistor, is 2.5A. According to Ohms law, the maximum voltage on it will be 15 * 0.1 = 1.5V. Now, we need to scale that to 5V to get the best resolution, so we're going to amplify it by 5 / 1.5 = 3.33.
We look up the gain formula of the op-amp (shunt voltage is on the non-inverting input of the op-amp), which is:
Vo = Vs * ( 1 + ( Rf / Ri ) ) 

So, if we're looking for an amplify of 3.33, our feedback resistor / input resistor ratio has to be 2.33. In other words, Rf should be Ri * 2.33. I used a 22K and a 10K resistor for this job. Based on these calculations, the maximum ever measured on the ADC input will be 1.5 * 3.2 = 4.8V. So, at 4.8V on the ADC, we have 15A flowing.
Let's calculate the resolution of our ADC module:
5 / 1024 = 0.004882;
That gives us 983 steps between 0 and 4.8V. 
15A / 983 = 15.25 mA, this is the minimum current we can measure with our setup. The current measurements will be multiple of this.

Now let's do the same for the 12V output:
Uout = 12V; Imax = 2.5A; Rs = 0.1R;

The maximum current flowing through Rs is 2.5A. The maximum voltage on it will be 2.5 * 0.1 = 0.25V. If we want to scale it to 5V (processor maximum voltage), we need to amplify it by: 5 / 0.25 = 20.
Again: Vo = Vs * ( 1 + ( Rf / Ri ) ), so our feedback resistor needs to be 19 times bigger, than the input resistor. A feedback resistor of 51k and an input resistor of 2.7k give me a pretty close 18.88 gain. There is probably a better match for this, i just ran the numbers on some more common resistor values.
The ADC maximum for this output will be 18.88 * 0.25 = 4,72V. The resolution in this case will be better: 2.5A / 966 = 2.58 mA.

I didn't put measuring modules for the negative power supply rails, I simply didn't had any op-amps left. Adding those later is simple, I calculate the resistors, and take care to put the shunt voltage on the inverting input pin.
A basic schematic of how one shunt should be connected to the circuit, is shown on my drawing.

Once we have the schematics done, we have to make a PCB design. I used Altium designer, that's the one I know the best, since the schematic was pretty simple, I finished in about a half hour. The op-amp and the feedback loop resistors are surface mount devices, the screw terminals and the power resistors are through-hole. Make sure you put the op-amp on the top side, so you don't get a mirrored PCB at the end.
Altium can export to pdf format, through an "Output Job" file. I set the scaling to be 1:1, i took off the mechanical, silkscreen, and keep-out layers, and made the exportation. You need to make sure, you select the "Page setup dialog" scaling option, when you click generate.

Just a brief description about how the PCB is made:
- print the artwork on transfer foil or shiny paper ( usually I rip these out of magazines )
- clean the PCB ( and cut it, however this can be done after the etching is done )
- put the artwork over the PCB, and melt the toner over to the PCB with an iron or a laminator
- wash off the paper with warm water
- put the board in the etchant, and wait for the copper to be eaten away

Mount the components on the board, starting with the one with the lowest profile. Test the board by measuring voltage on op-amp outputs while currents are flowing through the shunt resistors.

Generator Unit

101_0072-001.JPG
101_0073-001.JPG
101_0118.JPG
101_0119.JPG
gen.GIF
I wanted a generator for a long time, and got tired of wiring LM555-s on breadboard, or to dedicate a PIC just for this, so I said: I must build one. While looking around on google for built generators, or breakout boards, I found a version that looked really nice. That design is really complex, and I didn't wanted to build that exact one, but I did pick the DDS chip it used: the AD9833.

The AD9833 generator IC is a programmable waveform generator capable of generating sine, triangular, and square wave outputs. The output frequency and phase can be adjusted through SPI. Using 50MHz oscillator (not crystal), one could get resolution of 0.1 Hertz. The AD9833 has sleep mode, this allows minimization of power consumption. The one bad thing about it is the tiny package and footprint. I was able to solder it, but it took quite a few minutes to get it straight.
The maximum VOUT is 0.65 V, that needed amplification, so I included an AD8051 rail-to-rail operational amplifier.

The design was made in Altium, the PCB was made with UV exposure method. The clearance between the groundplane and the rest of the wires is 0.3 mm.
Assembling it is pretty straightforward, as usual, start with the component with the lowest profile. I recommend you to use a lot of flux when soldering the AD9833. After that, the SO8 package of the op-amp will be piece of cake.

Building it was pretty simple, getting it started is a whole other ballpark. Since I used a bit-banged SPI protocol to talk with the DDS, I've had plenty of problems until I got that to work reliably. I didn't had luck with the SPI devices, the display IC reacts at rising edge, the DDS generator clocks in data at falling edges. I managed to get out the waveforms, but changing the frequency doesn't work as expected, even though the analyzer shows valid SPI commands. There's still a lot of work that needs to be done on this, probably a new PCB, maybe a whole redesign.

Three menu points were assigned to this module, Frequency, Phase, and Waveform.
Frequency: 1 >> 50MHz
Phase: 0 >> 360 phase shift
Waveform: off, trianglewave, squarewave, sinewave

The frequency, phase and waveform can be adjusted through the rotary encoder. There is some added control, located under the display, those can be used to increase the value by tens, hundreds and thousands.

The 8 Digit Display Unit

101_0132.JPG
101_0114.JPG
101_0115.JPG
101_0130.JPG
Sch.bmp
I built this display a few months ago, it is the main feedback device, giving information about four power supply currents, generator frequency, phase, frequency counter, PIR sensor, and others. 
At the heart of it there's an SPI display controller, the MAX7219. This is a 24 pin IC, which uses a single resistor to set the current for the digits, that is the one external component you'll need to drive displays (The 10uF capacitor is optional, if you know you have a steady 5V ). I have one more MAX7219 left, I might be building another one, to see more info about the processes that are being monitored. It's a very useful tool for debugging, too. 

Aside of some hardware problems (very thin cuts on the PCB traces), this module powered up almost the first try. I had two cuts, and a short between two traces, these were pretty easy to locate. Segment 'd' simply wouldn't light up on the first 6 digits at first start, I found a cut between the 6-th and 7-th digit with the multimeter. Once that was fixed with a little bit of solder, the problem disappeared. Again, using my multimeter, I located a short between segments 'e' and 'f', scratched it, everything went back to normal.

The user can change how many digits are displayed, the luminosity of the whole display module, and of course, the variables, that change the behavior of other modules.
For visualizing waveforms, I added another, graphical display on the front panel as well, the handler routines still need to be written for it. The GLCD also communicates through SPI, that part is already done, luckily.

Input Devices, Buttons, Switches, Encoders

101_0134.JPG
101_0133.JPG
101_0135.JPG
101_0175.JPG
101_0189.JPG
When building a tool like this bigger one, having a lot of buttons is always useful, if you're thinking about possibilities to expand it later. I put five pushbuttons to add more control to the whole thing. The pushbuttons connect to a single analog pin, to reduce pin 'cost'. I used 1206 sized resistors, I already had bought for the amp-meter module, to build up resistors of 10k, 20k, 40k, 80k and 160k. It's a good practice to choose resistor values of power of two, to distinguish the ADC readings easier. The resistors connect to the low side of a voltage divider, the voltage divider output goes to the analog pin. Once a button is pressed, the output of the divider changes, that is sensed by the PIC, and goes for processing to figure out, which button was pressed. 
I used a pocket calculator  and a spreadsheet to calculate the output voltages, and the ADC values.

The switches are only there to interrupt the circuit of the power supplies. Those don't connect directly to the PIC, so there's no feedback about their states on the display, at least not yet. A future development could be to connect these too, and make a clever algorithm to automatically pick the current measurement, if only one switch is turned on.
For now, there are only small 3 mm green LED-s, they light up, if the switch is active.

Instead of messing around with buttons only, I thought of a better way to build up a menu system. I salvaged this encoder out of a DVD player. That is the same DVD player, which has its front panel mounted on the low side of my cable cover. Connecting it is pretty simple, the A and B pins need to be pulled up to VCC, one goes to the interrupt, the other to a GPIO. The outputs are turning on and off with an offset of 90 degrees, when the shaft is turned. When an interrupt occurs, that GPIO is checked, if it's '1', the encoder turned to left, if it's '0', the encoder turned right. A variable is increased/decreased when the encoder turns in one, or the other direction. This variable helps us to find out, 'where' the encoder is.
The encoder has a button as well, that connects to another GPIO, and has a pull-up to 5 volts.
I made a drawing of the stuff I just told you. The image depicts the moment, when the encoder is turned right. If the encoder would turn left, the impulse on the INT pin would come first, surprising the GPIO in a '0' state. So, long story short, this is how you work with encoders.

The PIR sensor is powered from 12V, it has two pins, which connect/disconnect when motion is detected. I put one side to ground, and tied the other one - with a pull-up to five volts - to an input pin of the microcontroller.

Main Control Board

101_0104-003.JPG
101_0117.JPG
101_0095.JPG
101_0100.JPG
101_0116.JPG
The main control board is basically the minimum hardware for the PIC18F4550 soldered all together. An oscillator, decoupling capacitors, pin headers, and the processor itself. are the components that need to be soldered.
This unit holds the program, thus controls the display, generator, reads the buttons, encoders, sensors, and makes measurements with the ADC module. Everything that needs to be known about the PIC can be found in the datasheet, or on the Microchip forums. There are friendly and smart users on there, if you know how to ask, they are very helpful. 

Like many other boards before this, I made this one mirrored. And, of course, I only realized that when I was about to push the PIC into the socket. Don't forget to double check the PCB prints when they're ready. 

Cutting, and Drilling the Front Panels

101_0157.JPG
101_0137.JPG
101_0141-001.JPG
101_0140-001.JPG
101_0149.JPG
101_0160.JPG
101_0161.JPG
101_0163-001.JPG
101_0178.JPG
101_0179.JPG
101_0180.JPG
101_0184.JPG
Both panels were designed in Alibre design. It took a lot of time to figure out how to export the designs to G code, but I did it eventually, with a lot of help from the web. I would like to mention, that people often look for answers on text search sites, and forget to search on video sites too. Most of the times there will be someone who already had the problem you have, and there is a big chance, you'll find a walk-through for the problem. It's way easier to see what to do, than to read what to do.

The first try went good with the display panel, I thought to make the other one with the CNC mill too, to make it super-precise. Bad decision, I ran out of luck, and pressed the emergency button too late, the bit broke. At least I can show you how I made front panels, before I got the mill. I drill the holes first, then drill a contour of each rectangular shape, both actions with a 3 mm drill bit. After that I use a clipper to remove the center of the rectangles, and pile down the rest, to fit the switches. I used a switch and a caliper to test the cutouts.
Then I took a larger drill bit, and widened the holes by hand, using a mandrine.

Then, the panel was painted with black spray paint, and the switches, pots, banana plugs, and the encoder were mounted.
I have to say, I finished the second panel ( the one with the switches) faster than the mill finished the first. Since I am new at milling, I set a low feed rate, just to be sure. That slowed the whole thing down to a point where I almost fell asleep at the side of the machine, with my finger on the E-stop button. Second, I set the job to be cut from the inside, spiraling out to the edges. That took a lifetime too. Even this way, I forgot to zero the default 0.625 stock, so the holes were actually smaller with 1.3 mm, I had to pile down the rest by hand.

Final Words, Cleaning the Table

Long story short, this is the control panel I built, I am already using it to debug, or work with my newer projects. 
My next project will be posted here too, in form of an other instructable, some water pump control will be added to the actual setup, along with a servomotor controller algorithm. 
I didn't attach any sch or pcb file to this project, because I don't promote laziness. This is the reason why I didn't post the PIC18F4550 code either. However, I would be more than happy to help you out with sample code or questions, or just to share experiences.
I wish to thank you for reading through my first instructable. 

Have a nice day!