513,019 active members
3,776 visitors online
Register for free
Login
Page 1 of 13 12311
Results 1 to 20 of 255
  1. #1
    Registered
    Join Date
    May 2006
    Posts
    190

    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
    Attached Thumbnails Attached Thumbnails IMG_20141215_013411.jpg   IMG_20141215_013429.jpg  

  2. #2
    Registered
    Join Date
    May 2006
    Posts
    190

    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.

  3. #3
    Registered
    Join Date
    May 2006
    Posts
    190

    Re: DIY AC Servo Drive - ATMega based


  4. #4
    Registered
    Join Date
    May 2006
    Posts
    190

    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...

  5. #5
    Member
    Join Date
    Jan 2005
    Posts
    10698

    Re: DIY AC Servo Drive - ATMega based

    mcm_xyz

    Well done, looks like a fun project
    Mactec54

  6. #6
    Gold Member
    Join Date
    Apr 2006
    Posts
    3487

    Re: DIY AC Servo Drive - ATMega based

    great ,,, must see more pictures and progress..
    http://free3dscans.blogspot.com/ http://my-woodcarving.blogspot.com/
    http://my-diysolarwind.blogspot.com/

  7. #7
    Registered
    Join Date
    May 2005
    Posts
    1397

    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?
    James hosts the single best wiki page about steppers for CNC hobbyists on the net:
    http://www.piclist.com/techref/io/steppers.htm Disagree? Tell him what's missing! ,o)

  8. #8
    Registered
    Join Date
    May 2006
    Posts
    190

    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.
    Attached Thumbnails Attached Thumbnails IMG_20141217_085958.jpg   IMG_20141217_090026.jpg   IMG_20141217_090224.jpg  
    Attached Files Attached Files

  9. #9
    Gold Member
    Join Date
    Dec 2004
    Posts
    1862

    Re: DIY AC Servo Drive - ATMega based

    Looks pretty good to me. Keep up the good work.

    Mike
    Warning: DIY CNC may cause extreme hair loss due to you pulling your hair out.

  10. #10
    Registered
    Join Date
    Apr 2006
    Posts
    169

    Re: DIY AC Servo Drive - ATMega based

    cd rom motor as bldc ???

    Keep up the good work

  11. #11
    Registered
    Join Date
    May 2006
    Posts
    190
    Quote Originally Posted by hesham morsy View Post
    cd rom motor as bldc ???

    Keep up the good work
    It was the only one I could find in house...
    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...

    I am about to recive a larger 'BLDC'...
    I will post progress and new schematic and firmware after...

    Mihai

  12. #12
    Registered
    Join Date
    Apr 2006
    Posts
    169

    Re: DIY AC Servo Drive - ATMega based


  13. #13
    Community Moderator Al_The_Man's Avatar
    Join Date
    Dec 2003
    Posts
    23225

    Re: DIY AC Servo Drive - ATMega based

    Quote Originally Posted by mcm_xyz View Post
    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.
    CNC, Mechatronics Integration and Custom Machine Design

    “Logic will get you from A to B. Imagination will take you everywhere.”
    Albert E.

  14. #14
    Registered
    Join Date
    May 2006
    Posts
    190

    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

  15. #15
    Registered
    Join Date
    May 2005
    Posts
    1397

    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?
    James hosts the single best wiki page about steppers for CNC hobbyists on the net:
    http://www.piclist.com/techref/io/steppers.htm Disagree? Tell him what's missing! ,o)

  16. #16
    Registered
    Join Date
    May 2006
    Posts
    190

    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

  17. #17
    Gold Member
    Join Date
    Apr 2006
    Posts
    3487

    Re: DIY AC Servo Drive - ATMega based

    great work...please keep sharing ...i want to see spinning bigger motors 100+ Nm...
    http://free3dscans.blogspot.com/ http://my-woodcarving.blogspot.com/
    http://my-diysolarwind.blogspot.com/

  18. #18
    Registered
    Join Date
    May 2006
    Posts
    190

    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
    Attached Thumbnails Attached Thumbnails IMG_20141228_114129.jpg  
    Attached Files Attached Files

  19. #19
    Registered
    Join Date
    Apr 2006
    Posts
    169

    Re: DIY AC Servo Drive - ATMega based

    :wee::wee::wee:

  20. #20
    Registered
    Join Date
    May 2006
    Posts
    190

    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

Page 1 of 13 12311

Similar Threads

  1. Servo drive with ATMEGA
    By mcm_xyz in forum Servo Motors / Drives
    Replies: 1
    Last Post: 12-15-2014, 01:12 AM
  2. Servo module for UHU based drives now available.
    By H.O in forum UHU Servo Controllers
    Replies: 0
    Last Post: 02-06-2012, 08:32 PM
  3. Suggestions on New VSD-Core Based Mains Powered Drive
    By Adamj12b in forum Granite Devices
    Replies: 4
    Last Post: 05-05-2009, 08:28 PM
  4. Pic based servo motor drive
    By ahmedrehan in forum PIC Programing / Design
    Replies: 7
    Last Post: 08-08-2007, 01:08 AM
  5. I need help on PC-based for servo control
    By NASR1 in forum Servo Motors / Drives
    Replies: 1
    Last Post: 08-14-2006, 09:43 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •