Sunday, March 18, 2012

Circuits: They make your abstraction barriers into their bitches

The goal: Making a DC motor controller that can reverse directions. This will be used on the grabber arm for the table mentioned in previous posts.

The initial concept: Make a DC rectifier that goes one way, turn it on when you want to go that way. Let's try it:



So let's talk through this circuit. Far on the left we see the power source, I found it in the 'SOURCE' library in Orcad PSpice. It has a 60Hz wave with 60V amplitude. I chose 60V because going higher seemed to short out the other parts in the simulation. In real life I'll buy better parts.

Below the power source is a square wave generator. I'm going to use it to turn the circuit on and off. It's set to trigger a 20V high for 0.05s and repeat that ever 0.2 seconds. When it's at 20V I expect the motor to be getting power. When it's at 0V I expect the motor to be off.

Moving to the right, we have that odd part marked 2N5444. That's a triac. It's two silicon controlled rectifiers (SCRs) hooked up together. (If you aren't familiar with what these are, go look up diodes, then look up SCRs, then look up tiacs. Don't be afraid, you're here to learn electrical engineering, and it is complex. There will be a lot to learn so start now.) This device will essentially conduct current when it gets power.

Moving farther to the right, we have a bridge rectifier. It takes an AC voltage and converts it into DC. (If you've not seen one before, take a second to think about how this works)

Finally, on the far right we have a resistor which is acting as the motor. I've put two voltage traces on it so we can see how much power it's getting.



Looking at the simulation result we can see that in fact the motor is getting DC power because the green line is always above the red line. So the polarity of the power on the motor is always the same. Sure it bounces around all over with the AC input, but we can fix that later with capacitors.



Now let's try extending the circuit. I've essentially mirrored it but this time made two changes. First I hooked up the motor backward relative to the DC power I'm applying. If this works, the motor will run backwards when this second circuit is triggered. I also set it's trigger to be different from the first one. I gave it an offset so now it should run forward for a bit, turn off for a bit, run backward for a but, turn off for a bit, and repeat.



In practice, this shit doesn't work at all. The two bridge rectifiers interfere and the voltage across the motor is always zero. It totally breaks the abstraction barrier I was trying to make.

I discovered this in the process of thinking about this circuit, but it took a lot of thinking to realize that and the computer would have told me it wouldn't work. That said, the computer wouldn't have told me why. And I did need to know why.

With circuits, this shit is going to do weird stuff all the time. In the simulation, like real life, it's not going to work as you planned. I'm a reasonably smart person and it is proven to me every day that I have no idea what I'm doing. I'm going to be you don't know what you're doing either. So let's muddle through this.

My next step: thinking up a motor controller that'll actually work. Or, fuck if it comes to that, actually looking up designs for them like I should have done already.

No comments:

Post a Comment