2 Attachment(s)
DIY AC Servo Drive - ATMega based
Hello dear machinists!
A long time ago I tried to build my own servo drive (and I almost did), based on ELM CHAN Servo drive schematics and code.
I am now building an AC servo drive from scratch. I have my own program, and my own schematic.
After a couple of weeks of hard working, reading, soldering and programming this is what I obtained:
A cheap servo drive, based on ATMEGA644 (lower versions can also be used as compiled program hardly occupies 15% of MCU flash).
The whole boar wont cost you more than 30$!!!
The features so far:
Works with AC motors without using any Hall sensors.
Step / Dir inputs
UART connection for tuning and debuging
I can tell you that I am really happy with the performance obtained so far. My own build servo (a cdrom motor and an optic encoder from an old mouse) works really fine. I was able to obtain about 1200 RPM with this 6 poles motor and 90 PPR encoder.
Little software / hardware description.
MCU must have 6 pwm outputs and 3 external interrupts.
3 x IR2101 are used for driving the final stage mosfets.
1 x 74hc14 is used to buffer my encoder inputs.
16 Mhz clock on MCU (can be raised to 20 Mhz)
PID process for controlling movement.
I will make the schematic and source code available for anyone here. Please feel free to modify them as you need (they are not under any kind of licensing)
Here are some pictures and video of my very beta board and servo!
https://www.youtube.com/watch?v=Auw7-5yBa3o
1 Attachment(s)
Re: DIY AC Servo Drive - ATMega based
Here is the firmware and schematic as promised.
Program is compiled with Mikropascal Pro for AVR.
Schematic and board are done in Eagle 5.8.0.
I am a software engineer so please forgive my mistakes in the schematic.
I am open to any suggestion or remark!
I will come back later explaining functionality and where and how the PID process is involved.
Mihai.
Re: DIY AC Servo Drive - ATMega based
Re: DIY AC Servo Drive - ATMega based
Short description of software commands:
1. 'getconfig' - will display the config parameters stored in the EEPROM
example output:
CONFIG:
ENCODER PPR = 90
MAX PPR ERROR = 45
MOTOR POLES = 6
PID Kp = 450
PID Ki = 350
PID Kd = 100
2. 'set ppr XXXX' - will set the PPR rate of the encoder. XXXX must be unsigned int 16
3. 'set error XXXX' - will set the max allowed error. If during movement the EncoderPosition - DesiredPosition is greater than this value servo stops and error led is powered. This is used only when STEP/DIR commands are applied. XXXX must be unsigned int 16
4. 'set poles XXXX' - will set the number of poles of the motor. (I am not sure about this terminology, what I did is: for eg. 6 poles means the motor makes a full turn in 6 sine periods)
5. 'set kp XXXX' , 'set ki XXXX', 'set kd XXXX' - will set Kp, Ki and Kd constants of PID process calculation.
6. 'start', 'stop' - starts or stops the PID process. if stopped no power is applied to motor and PID calculation is stopped.
7. 'enc' - will display the encoder position register (Int 32 signed). PID must be stopped to allow this
8. 'move XXX'X - starts a free movement of XXXX steps. During this the max allowed error is set to max int 32 so no error will be raised during this kind of move.
Give it a try... :)
Re: DIY AC Servo Drive - ATMega based
mcm_xyz
Well done, looks like a fun project
Re: DIY AC Servo Drive - ATMega based
great ,,, :) must see more pictures and progress..
Re: DIY AC Servo Drive - ATMega based
Wow! That's nice!
Can it work with a larger motor? What would it take to support that? Can I help?
4 Attachment(s)
Re: DIY AC Servo Drive - ATMega based
First PCB!
It's milled and drilled on CNC. Not so good. The separation is very poor, parts are very hard to solder.
I will stick to old chemical way for the next versions and maybe drill the holes on CNC.
I am waiting for a bigger motor. The board will work with higher currents, it's just a problem of final stage Mosfets.
Here is the latest schematic and firmware also.
Re: DIY AC Servo Drive - ATMega based
Looks pretty good to me. Keep up the good work.
Mike
Re: DIY AC Servo Drive - ATMega based
cd rom motor as bldc ???
Keep up the good work
Re: DIY AC Servo Drive - ATMega based
Re: DIY AC Servo Drive - ATMega based
Quote:
Originally Posted by
mcm_xyz
Actually I do not even understand the term BLDC... There is no way that kind of motors to work with DC...
They are simply triphasic motors...
Mihai
The term BLDC or Brushless DC comes from the fact that with a BLDC motor, only two or three stator coils are energised at any given time and represents a DC motor turned inside out, as opposed to the virtually identically wound 3ph motor that energises all three windings, often in 3ph sinusoidal pattern.
Al.
5 Attachment(s)
Re: DIY AC Servo Drive - ATMega based
Final PCB... (I hope...)
Servo drive mounted on radiator. Waiting for a bigger motor.
New status and error led added.
Schematic features so far:
Error output
Step / Dir / Enable inputs - toggling enable will also clear servo error if any
RS232 TTL for setup and debugging
ICP port for firmware upgrades. (it's not time yet for flashing firmwares through RS232 as many things are in test, but if things get ok and all works well this port should be removed and firmware should be upgraded via RS232)
Pictures and documents below...
In the eagle folder you can find the HPGH files for milling and drilling the board if you wish.
Firmware still needs some fine adjustments but things are functional. The board is unlikely to change anymore.
I hope tomorrow I will receive a bigger motor. I will let you know on progress
https://www.youtube.com/watch?v=H0R8rw6JPEE
Mihai
Re: DIY AC Servo Drive - ATMega based
That is seriously cool! Can I ask what sort of motor you have on the way? E.g. what types of larger motor can this be used with?
Re: DIY AC Servo Drive - ATMega based
I am waiting for a: 57BLF02, see pdf here: http://www.ht-motor.com/en/01/57BLF.pdf. That is a NEMA 23 mount motor, ready to fit in my cnc. I still need to solve the problem of the encoder, although the mouse encoder did not failed me in anyway... :) I will use something with about 200PPR.
For bigger motors than that I am not sure. I saw on the internet that other commercial servo drives have some kind of current sensing circuit. This one does not... I am afraid something might blow without that...
But I will keep digging... I think the software is based on a simple and reliable ideea. The PID process controls in fact the phase shift required to move the motor from one position to another. If the error is big the phase shift is big forcing the motor to spin fast. if error is small the shift is small... anyway... I will keep working...
Mihai
Re: DIY AC Servo Drive - ATMega based
great work...please keep sharing ...i want to see spinning bigger motors 100+ Nm...
2 Attachment(s)
Re: DIY AC Servo Drive - ATMega based
New motor in place!
125W Nema 23 mount BLDC motor with my own milled encoder wheel (200PPR)
All seems to work just fine.
Some significant changes in the firmware since last version:
1. PWM frequency got a bigger prescaler. Seems that with high loads the final mosfet and drivers are too slow to switch.
2. A power limiter has been added as a configuration parameter. PMax = 0 .. 100 %. I only have for now a 19VDC 3A power source that enters protection mode when in full power. I managed to obtain good results at max 70% power as you can see in the movie.
3. The PID process now works on int16 instead of int32 giving this way a better performance. (Theoretically all math calculation is done twice as fast).
I will keep you informed.
Mihai
https://www.youtube.com/watch?v=wSWapA9UW-k
Re: DIY AC Servo Drive - ATMega based
Re: DIY AC Servo Drive - ATMega based
New tests with 125W motor, fitted with a 400PPR Avago encoder.
The Step/Dir signal is provided by PlanetCNC USB software and board.
You can see how servo parameters affect movement smoothness and so...
I managed to reach 1500 RPM with about 80% power (I am still waiting for a lab power source... soon to come... :) )
I think the movement got really smooth and precise. I will mount this to my new Z axis and see how it acts under some load conditions.
Enjoy the video.
https://www.youtube.com/watch?v=PPH6...AFGMm4G97dv1pw
Firmware updates very soon.
Mihai