15 May, 2016

Motor Controller

In my first post (which has been ages ago) i showed you my styrofoam cutter which used my variac and 2 motors. Now i wanted to build a controller for the big motor for a long time. And i finally took my first steps in that project.

What we have:
Motor with tachometer at the back (a little generator putting out 8 pulses(sinewave) per revolution)

What we need:
Circuit that interprets the signal from the tachometer and calculates RPM and adjusts power to the motor depending on wanted speed.

This circuit needs several parts:
Arduino nano (or any microcontroller)
Convert sinewave of pulses into a rectanglewave (0-5V)
Power supply with zero cross detection so we can do phase control
Something to control the motor with the arduino

Lets look at the power supply first:
For our circuit we need positive and negative voltage, a stable 5V supply and a signal for zero cross detection. luckily i disassembled some old wall adapters which had transformers in them. The one i chose puts out 16V peak to peak. Now i need a circuit:

And this is it. At the top we have mains AC (which is 230V @50Hz here) which goes through a transformer and is then processed. I basically used 2 half wave rectifiers and connected them in series so i get + and - 8V. I then used the +8V and put them into a 5V regulator to get my 5V. i also directed the signal from the transformer directly into an opamp which creates a rectangle wave. This is then put through a diode, so we dont get any negative voltage to the arduino and through a voltage divider to go from the 8V down to a little under 5V, which is enough for the arduino to properly detect the signal.

Now for the tachometer part:
This is also a part where we need the + and - 8V. The tachometer is here depicted as a motor, but it puts out a signal depending on the motors RPM. now i measured the signal and it already got to almost 20V at 5000 RPM. So as the Opamp has an almost infinite gain, i decided to just put a 10 Ohm resister between the pins, so the voltage the Opamp sees is still very low and there is no risk of damaging it. Then again the output is put trough a diode and a voltage divider to get it to a 0-5V range.

Now lets get to the more difficult part:
How to control the motor? My initial plan was to use a beefy mosfet. It was rated at 15A @ 500V which should be enough for the motor. This solution would not require a zero cross detection circuit, but i would have to rectify the mains voltage (which would be 340V DC) and then use pwm to change the motors power. problem here is, that i have to connect my GND from my 5V circuit to the GND of the 340V circuit to switch the mosfet. or i would have to build an extra circuit that is isolated by an optoisolator.
I had this in my head for a long time, till i came across solid state relays. These are basically a relay, but can switch much faster, and dont degrade as there are no mechanical parts. So i want ahead and changed the circuit to what it is now. i added the zero cross detection so i can do phase control with the relay. phase control is basically PWM but with a very low period dictated by the mains frequency. You switch on the power during the sine and switch off at zero cross. The reason you do it this way is, that the Triac (the thing that is switching inside the solid state relay) can not be switched off as long as there is current flowing. With AC it always switches off at zero cross, as there cant be any current flowing, So i built the circuit around the arduino and did my first testrun:
The powersupply worked
The tachometer worked
The code on the arduino worked
... But the relay....

I tested the relay before i used it (not with the big motor). It switched on and off as expected. But there was something i was not aware of at the time. The relay that i bought (Fotek SSR-40 DA) has builtin zero cross detection. Which means it only switches on at Zero cross. The reason for this is, that you dont get any current spikes in your line and no electromagnetic fields and what not. Now this was bad. The motor has a pretty high startup torque and jumps a bit when just switched on. Also its impossible with this to make lower RPM happen without a big load. So i began searching for an alternative. There are solid state relays without zero cross detection, but they are rare and therefore more expensive (ironic as they have less parts inside). So why buy a relay, when you can build one? Such a relay is basically an optoisolator, an LED, a triac and some resistors. And we dont necessarily need the LED.

So i bought a triac and some optoisolators on ebay. The optoisolators work fine, and it doesnt hurt too much when they are a bit off spec. But the triacs.... I ordered 2 BTA41800 which are rated for 800V and 41A RMS. The spec says it should have a resistance of maximum 10 milli Ohm. I tested one of them and it has a resistance of 200 milli Ohm (or even more, im still unsure). when testing it i put around 20W through it in a short circuit. 3.20 Volts at 5.10A(cant get more out of my lab power supply). This was DC power and the BTA is rated at 41 Amps RMS, so maybe thats also another factor. Now i dont know the forward voltage of the BTA, so maybe i got skewed readings. i will try again with a resistor attached to see if it really is the BTA having such a high resistance. For those that dont know why this is bad:

The higher the resistance, the more voltage is dropped over the device when current flow through it. The resulting powerloss is the dropped voltage times the current flowing through it. So if you want to pump 40 Amps through such a small device you need a damn low resistance, or else you will just melt the component cause of the heat generated at that point.

Update on testing the triac:
I added a piece of an old heating element that i got a from a hairdryer to the circuit. with that i could pump >60W through it. 30V at ~2.3A. strangely the dropped voltage stayed(stood?) constant at 850mV. i tested with 13V at 950mA (amp values due to resistance of heating element) and got the same voltagedrop. does this mean the resistance gets lower with higher voltage? again this was done using DC voltage. Guess my knowledge just isnt enough to really understand triacs. I will just go for it and use the triac with the motor. If it blows up in my face i have to rethink again.