2015. április 30., csütörtök

Freescale training

There was an MCU training organized by Freescale here in Budapest. This was the third one I attended in the last two years.
It looks like I was the favorite of one of the instructors (had answers to the questions raised to the audience, and had on spot questions):

2015. április 24., péntek

CNC Motor Driver 4. - MOSFET Driver revised

I was thinking, looking around a lot before I designed and built the current motor driver circuit. I wanted to use something cheep, something I can learn from.
The current one is working, but I was thinking, how can I make it a little bit faster. When I designed the current one, experimented lot on the breadboard, but not used ltspice to simulate the circuit. When it was finished, I needed to tweak it, here and there, to be able to reduce the noise for the clear measurement signal.
Now I'm trying to get faster switching, to reduce the heat generated by the MOSFET.
First of all I run a simulation of the original circuit.

The circuit:
And the result:
As you can see the the timing results:
Switch on time: ~500ns
Switch off time: ~500ns

After 2-3 weeks of continuous (in my spare time, what I not really have to much) simulation, changing components, pursuing different ideas, finally I created a little bit better one.

The circuit:




And the result:
And the timing:

Switch on time: ~30ns
Switch off time: ~100ns

Much better.
Based on the things above, I designed a little bit different circuit. The reason: I use mostly trough hole components for the home made PCB and switch to SMD when I order the final one.

The schematic
And the PCB design:
Hopefully I'll be to build it during the weekend.

2015. április 6., hétfő

CNC Motor Driver 3.

Since the last post regarding my CNC Motor Driver, in my spare time I was continuously working on the MCU board and the software for it.
Two days ago I connected the digital part to the power electronics. It started to work immediately, but unfortunately the rpm measurement was messy.
After some thinking and trying, I realized, that the source square wave has some narrow pulses around the edges, what are messing up my measurement.
The Nuvoton MCU I'm using is able to add some de-bouncing delay to the timer's capture input. Adding this feature looks like solving my problems.



Today finally I see the end of this project's. I'm trying to collect the thing still need to be finished:
  • Test and tune the PID controller
  • Try out additional filtering on the power input side
  • Try out additional filtering at the motor
  • Try out the 5th order filter I designed for the measurement
  • Test and write code for the current measurement
  • Add voltage measurement solution (circuit and code)
  • Add code for power display
  • Add code for measuring the control signal from the Linux CNC (this allows the control of the rotational speed from g-code)
  • Design a high voltage input 3.3V power supply (actually the 48V input is to much for the regular buck converter chips)
  • Design and order (hopefully) the final panel for the whole electronics
  • Correct the code for the rotary encoder (it is a little bit problematic today)
  • Clean up the code (not modularized enough, many comments missing)

2015. április 5., vasárnap

Dev Env - LightUp

The story starts almost two years ago.
As my son gets older (8 years old now), I was thinking to teach electronics, programing or both to him somehow. As I looking around just pop up something called LightUp on the Kickstarter.

http://www.lightup.io

I immediately jumped in to it, hoping that I'll get it to Christmas of 2013.
It didn't happened. After long waiting I got the kit sometime in Autumn 2014. It became a Christmas present for 2014.
My son started to play with the electronics part of the kit but not touched the MCU module included. As he reached the point making all of the tasks was included in the iOS app (what is unfortunately not too much), I tried to setup the MCU.
It was something like two month ago, and it was a major failure. I had two problem with it. The first is theoretical. I don't believe that is the best language to teach an 8 year old to program is the C++ even it is the simpler arduino's one. The second is the driver.
LightUp partnered with codebender to provide programing environment to the kit. Codebender is nothing else just an online Arduino IDE. They provide a driver pack, what is able to connect to virtually every Arduino compatible board. But the driver pack was not working with the LightUp MCU on my desk.
The story was put aside in this point.
A few days ago I seen, that my son started to play with the LightUp kit. This was a good indication to put some further work into the setup.
Went to codebender, downloaded the driver installed it, and the result was the same as two month ago:
This time I wasn't stopped here:
After installing it the result:
Success!
Finally I went to the CodeBender side to try it. When I started the IDE for the LightUp a LED blinking project was showing up:
Just downloaded it to the board, and started to work:
Conclusion:
What I see about the LightUp: This is an unfinished something. After a good start they lost their tempo. The idea to check the circuit with a camera is exciting, but they got nothing more. A large amount of example circuits and a kid friendly programing environment is missing.
In addition tons of far better kits are exists on the market (for example littlebits), what is kid friendly and gives the possibility to grow further. This one not.

2015. március 9., hétfő

CNC Motor Driver 2.

This is just an update on this project.
Some things are happened, some things are on the way, but from the overall view nothing really advanced further.
Noise:
It was a problem, and I still fill as a problem the noise generated by the switching controller. In the current version I handled this with some smaller/larger capacitors, but I think, it can be still better.
I plan to try out the following things:
1. In addition to the current input capacitor of the whole circuit I want to put an additional inductor and capacitor to form a Pi filter. I assume that the sudden changes in the input current makes the regulated power supply (currently my bench supply) a little bit unstable. Hopefully the Pi filter will eliminate most of the current spikes.
2. I plan to put this EMI filter between the switching controller and the motor:

I hope this tiny little puppy will help
3. Designed a 5th order low-pass filter to fit between the sensing diode and the opamp (I've a first order filter there today).


On the simulation:


you can see it has 110dB attenuation on 100kHz where the PWM generator runs

I hope putting this together I will not even need all of the five elements of the filter to have a good result.

Protection:
For the testing of the circuit, I left out the protection diodes not to distract the signals. As you see on the filter circuit, there is two diodes what has the role to protect the opamp acting as a comparator. In addition I'm planning to add two series diodes in parallel to the motor to protect the controller against the negative inductive spikes.

Controll:
I started to work on the MCU circuit and software. The MCU I plan to use is a Nuvoton M054LDN, if I'm able to fit into the 16K flash of it.
I almost finished the code for the LCD Display I want to use, the PWM, the rotary encoder, and the Frequency (rotational speed) measurement. I plan to polish this a bit and add the PID (or something like this) controller, and the current measurement soon. When it's done, I'll be able to try this out as a standalone thing - no function generator, no bench power supply.
The LCD is a standard Hitachi chip based one, and as such requires 5V signaling and supply.
What is cool, the Nuvoton MCU is one of the few ARM based ones, what can run from 5V.
What is even cooler that you can choose between the 3.3V and the 5V on the development board.
What is not so cool:


The selection "jumper" is a 0R 0805 resistor must be desoldered and resoldered into a different spot.


2015. február 21., szombat

CNC Motor Driver 1.

A long time ago I started to work on my CNC spindle drive. After many experiments I rendered the whole unit to useless. Today I've a dead 230W motor, a dead 600W switching power supply as a result. The box of the power supplies are taken apart. So the thing not looks great.
A few month ago I started a project to reanimate the thing.
Now I've a new power supply and a new 400W motor on hand. The only thing is missing the electronics between this two.
When I started not even considered to use the original electronics. It is a useless crap.
I have had some goals:
  1. Switching on/off from software
  2. Control the rotational speed from software (g-codes)
  3. Creating a closed loop control with measuring just the motor current and voltage. Not using optical encoder, hall sensor or any similar thing
  4. Adding some kind of digital RPM display
Unfortunately I not documented this project as deeply than I did it with the previous ones, but I write some notes about it now when I reached some of my milestones.
So:
Milestone 1 - Measure the motor rotational speed
If I put a diode in series of the motor, the diode will close briefly every time the motor brush step from one commutator segment to the next. This happening because of the sudden change in the magnetic field of the motor. When this change happens the the motor's windings are try to work against the power source, creating a negative current pulse (sorry for my phrasing, I'm not a native English speaker, and my study of physics happened long ago). This can be measured:


Ok, we can measure the frequency of the above pulse, but I thought, not to feed this signal directly into an MCU, so I did some shaping before.
First of all the signal decoupled with a 1uF capacitor, to keep just the AC part. After this I filtered out the frequencies above the the maximum I can get.
BTW what is the maximum here? The motor has 15000 rpm maximum rotational speed. This ok, but to keep some room, we can start to calculate from 30000 rpm. It should be devided by 60 to get the revolutions per second, and multiply by 12 what is the number of the segments in the commutator. This gives to us 6kHz. Everything above this can be eliminated. The filter in the current circuit has ~7.5kHz:


The filtering is needed because of the switching noise coming from the controller (In the further development this noise will be reduced as much as I can)
The filtered signal is fed into an MCP6002 opamp after transposed to the half supply voltage (2.5V in this case). The opamp is acting as a Schmitt trigger. The hysteresis is set to ~35mV. This is high enough to eliminate the remaining noise but low enough to be able to catch the signal what is around 200mV. At the output of the opamp is a stable square wave what is proportional to the rotational speed of the motor.
Milestone 2 - MOSFET driver
I needed a switching MOSFET driver for the motor. From the first look it looked simple, but finally it came out that I need DC to drive the circuit above, with the least possible amount of noise and clearly high side switching. The circuit come out is closer to a buck regulator then a simple MOSFET switch.
I chosen a P-Chanel MOSFET for switching, because the required maximum current (~8.5A) can be easily handled with a relatively low cost MOSFET and eliminate the rather tricky circuit or specialized driver IC needed for driving an N-Chanel MOSFET on the high side.
Theory of operation:
When the incoming PWM signal get high, the Q2 start to conduct and pull down the gate of the MOSFET 10V below the 48V rail (restricted by the D3 zener) and the FET start to conduct. The 50mA what can flow here is enough to fill the gate capacitor of the FET. At the same time Q1 transistor's base pulled down keeping the Q1 in nonconducting state (the D2 is used to protect Q1 base to not go bellow the BE diode rated voltage). When the PWM signal goes low, the Q2 stop conducting allowing the FET gate to go high, but because of the high gate capacitance the FET would not switch off fast enough. Here come the role of the Q2. When the Q1 stop conducting the Q2's base is pulled up to the rail through R1-D2. The Q2 start to conduct and the FET's gate capacitor gets discharged through Q2.
The high energy square wave generated by the MOSFET is fed to the L4-C8-D4 buck network creating a DC signal proportional to the PWM signal.

There is still lot of work to go, but here is the first working model:

 
 
And here is the schematic design:


2015. január 29., csütörtök

My newest "project"

My older daughter asked me to create some lighting to her into her paper lamp.
I had twenty minutes to achieve (together with the parts collection).


And yes, if you switch it on, it lights up. Purple! Awesome! :-)