1 Attachment(s)
Re: DIY AC Servo Drive - ATMega based
Here is the latest source code and board as promised.
Changes in software:
New parameter added:
END POSITION ERROR = when in a stable position if you move the motor shaft with external force (by hand or vibrations or stuff), it will remain unpowered until the error will be over this threshold.
Changes in hardware:
Added a capacitor to the high power line (50-100u / 50V)
Changed Step/Dir/Enable coupling resistances from 1K to 100ohm (Enable signal is still ignored by software, will be fixed in next versions)
Someone please start to build this and play with it! I need second opinions! :)
Mihai
Re: DIY AC Servo Drive - ATMega based
Quote:
Originally Posted by
mcm_xyz
Someone please start to build this and play with it! I need second opinions! :)
Mihai
First, HOW EXCELLENT! I'm very pleased to see you doing this and posting it open source.
I would be interested in making a PCB or 20 if you could post gerbers and a PDF or PNG or something of the schematic instead of the Eagle board files. I'm trying to avoid installing, but more importantly, learning Eagle.
Re: DIY AC Servo Drive - ATMega based
Part 1;
A few years ago I built a BLDC driver with an AVR. My motor had hall sensors so I used a square wave 6 position truth table to determine the commutation. I used this system as opposed to the back emf technique so I would be able to run all the way down to 0 rpm. This was for a positioning application where the motor only rotated 33 revolutions and had just a single index pulse near the center of travel. I used the hall sensors for instant resolution of the commutation at any speed, but especially at full stop.
I do not see a hall or back emf commutation solution in your code (I just quickly browsed it in notepad++) but I do see a sine-wave look-up table. Are you using the optical encoder with the look-up table? And if so do you have an index pulse or something? How do you determine position from a cold start? or if there is an error?
part 2;
I see you are using MikroPascal for AVR. I briefly looked at their offerings for AVR's several years ago, and at that time their AVR solutions seemed very buggy (while their PIC stuff was much more solid). Has this software matured since then? I seem to recall that the libraries were closed source and you were more or less locked into their hardware configurations if you used the supplied libraries. I did however like ME's IDE concept a lot. How do you like this software?
Marvin
Re: DIY AC Servo Drive - ATMega based
Quote:
Originally Posted by
punisher454
Part 1;
A few years ago I built a BLDC driver with an AVR. My motor had hall sensors so I used a square wave 6 position truth table to determine the commutation. I used this system as opposed to the back emf technique so I would be able to run all the way down to 0 rpm. This was for a positioning application where the motor only rotated 33 revolutions and had just a single index pulse near the center of travel. I used the hall sensors for instant resolution of the commutation at any speed, but especially at full stop.
I do not see a hall or back emf commutation solution in your code (I just quickly browsed it in notepad++) but I do see a sine-wave look-up table. Are you using the optical encoder with the look-up table? And if so do you have an index pulse or something? How do you determine position from a cold start? or if there is an error?
part 2;
I see you are using MikroPascal for AVR. I briefly looked at their offerings for AVR's several years ago, and at that time their AVR solutions seemed very buggy (while their PIC stuff was much more solid). Has this software matured since then? I seem to recall that the libraries were closed source and you were more or less locked into their hardware configurations if you used the supplied libraries. I did however like ME's IDE concept a lot. How do you like this software?
Marvin
Hello Marvin
Thanks for your interest! Let me clarify...
part 1;
Back EMF indeed could not be used for cold start and it's very hard to use even for low RPMs. Hall sensors are indeed a good solution but my implementation does not use them, mainly for maintaining the code and schematics simple. Cold start is done the hard way :). A short commutation sequence is applied to the motor with low speeds, then a pause is done, waiting for the motor to get stable. So, indeed a disadvantage, when starting, the motor will spin freely for a small part of a rotation. After that the commutation sequence is synced using the encoder position, a part of the algorithm maintains the correct commutation sequence (the sine wave table you saw) with the encoder position. So it's very important to know:
1. exactly how many PPR your encoder has (Parameter ENCODER PPR)
2. how many poles your motor has (Parameter MOTOR POLES). I am unsure of the terminology here... What I am expecting for you to enter here is how many times the full sine commutation table must be applied for the motor to make a whole rotation... I had motors with 4 and motors with 6. I expect there is a large variety on the market.
without setting this 2 values correctly your motor wont spin. Or if your encoder looses steps the motor will not stay in sync and will stop after a while. But what good is a positioning system that looses steps :)
part 2;
Indeed, mikroPascal might be a disadvantage, mainly because it's not free. In my opinion this compiler has reached maturity a couple of years ago, starting with the PRO versions. I developed a complex project a few years ago in mikroPascal, an ATMEGA644 webserver that had ethernet, RTC, communication with other MCU's using UART over radio modules, temperature reading with 1-wire sensors and some relays. It was a smart management thermostat with schedules and wireless sensors. the whole thing works stable for weeks without a crash.
In future I might migrate to C code in AVR Studio. I started with this because I am very familiar with it, my first development board was mikroElectronica...
Hope this helps
Mihai
2 Attachment(s)
Re: DIY AC Servo Drive - ATMega based
Quote:
Originally Posted by
James Newton
First, HOW EXCELLENT! I'm very pleased to see you doing this and posting it open source.
I would be interested in making a PCB or 20 if you could post gerbers and a PDF or PNG or something of the schematic instead of the Eagle board files. I'm trying to avoid installing, but more importantly, learning Eagle.
Sorry Gerber output form Eagle seems to be buggy. However I exported some large images of the schematic and some HPGL files. It's most probably that you could import those PLT files in your CNC Software directly and make a PCB. There are 2 files, one for milling and one for drilling.
You can see how this file looks in my CNC software.
Re: DIY AC Servo Drive - ATMega based
to: mcm_xyz
why you dont try with stm32f103,
it is cheap and have encoder interface , 72mhz, 32bit with give bester performance
Re: DIY AC Servo Drive - ATMega based
Quote:
Originally Posted by
tivoidethuong
to: mcm_xyz
why you dont try with stm32f103, you can use with mikrobasic for ARM,
it is have encoder interface , 72mhz, 32bit with give bester performance
:)
I am old school... :) I need something that I can solder myself... Just kidding...
This has started as a hobby project. If in time something faster is needed I will probably switch to a different MCU.
However the goal for now it is for this project to be fully DIY!
Mihai
Re: DIY AC Servo Drive - ATMega based
Quote:
Originally Posted by
mcm_xyz
:)
I am old school... :) I need something that I can solder myself... Just kidding...
This has started as a hobby project. If in time something faster is needed I will probably switch to a different MCU.
However the goal for now it is for this project to be fully DIY!
Mihai
thanks you, exellent diy
Re: DIY AC Servo Drive - ATMega based
Pretty good news...
I've just made a quick dirty test... I've setup the MCU tu run with internal oscillator (8Mhz)... I am still able to achieve 1500 RPM so the speed limit I have now is given only by the power source... (Still waiting for the lab source)...
So basically with 20Mhz and same encoder (400 PPR) there will be no problem to reach 3-4000 RPM. This I think it's more than enough for many uses.
I've also changed the PID code allowing the integral part to accumulate more errors (10 errors in a shift register) and the movement is now even smoother...
The only drawback I feel now is that we do not have a current sensing circuitry. Maybe someone could help me with that and give me some ideas...
I will keep you informed and up to date with source code.
Mihai
PS. I managed to reach 2000 RPM with the actual power source by decreasing PWM Frequency by 8. But I hate the high frequency noise from the coils... :)
Re: DIY AC Servo Drive - ATMega based
Current sensing, i think you can user comparator like lm393,
detec peak current and check it every procedure UpdatePID
Re: DIY AC Servo Drive - ATMega based
First tests on my new Z axis (unfinished yet)... Please do not lough about my motor coupling :)
Things seem to be good enough
https://www.youtube.com/watch?v=6lVSf3y4Phs
Mihai
Re: DIY AC Servo Drive - ATMega based
Quote:
Originally Posted by
mcm_xyz
What you need is a precision current sense amplifier. Here are a few links to get you started;
http://datasheets.maximintegrated.co...s/MAX44285.pdf
http://cds.linear.com/docs/en/datasheet/6102fe.pdf
http://www.ti.com/lit/sl/slyb165g/slyb165g.pdf
See page 13 for TI current sense amplifiers.
Hope this helps,
Iron-Man
Re: DIY AC Servo Drive - ATMega based
1 Attachment(s)
Re: DIY AC Servo Drive - ATMega based
Hello dear machinists!
I am finally satisfied! The movement is now so smooth you can barely hear anything.
I am now sure we can reach 5000 RPM with 400 PPR encoder. (even if the motor says 3000RPM max )
I found a bug in mikroelectronica's UART library. Sometimes, especially after power failures, the MCU entered a state where no data could be sent to it via UART. So I wrote my own UART implementation and all works perfect now.
The sinus commutation table has been replaced by a square one and the PID process now controls PWM duty.
Besides the fact that the circuit misses a current detector all is perfect! For this time I will use it like this. I will buy a separate PSU for each controller, with a power matching the motor, limiting the current like this.
Also I received the LAB power source. The current consumption when no load is present is near 0!!!! Perfect again!
Here is the latest firmware (reaching V 1.3).
Enjoy the video!
Mihai
https://www.youtube.com/watch?v=x-4f_ng8s-Q
Re: DIY AC Servo Drive - ATMega based
Mihai, thanks for your share
Re: DIY AC Servo Drive - ATMega based
I believe you made the right call to ditch the sine table. Really just a truth table is probably the best. for whatever position the shaft currently is in you should always have the capability to apply full torque. My controller used 3 hall sensors and it was very easy to just look at the on/off status of all three input lines and pick one of six valid combinations. Very little overhead for this approach.
I cant wait to get a chance to try this out.
thanks
Marvin
Re: DIY AC Servo Drive - ATMega based
Quote:
Originally Posted by
punisher454
I believe you made the right call to ditch the sine table. Really just a truth table is probably the best. for whatever position the shaft currently is in you should always have the capability to apply full torque. My controller used 3 hall sensors and it was very easy to just look at the on/off status of all three input lines and pick one of six valid combinations. Very little overhead for this approach.
I cant wait to get a chance to try this out.
thanks
Marvin
Thanks Marvin for your suggestions. I am improving and simplifying the code more and more. It takes 15K so far, with bootloader reserved 4K. So about 11k for app. I will try to make a bootloader with firmware capabilities also so we can ditch the ISP port.
Also I am working at integrating a current sense circuitry, allowing this way for this project to compete with commercial ones.
Mihai
Re: DIY AC Servo Drive - ATMega based
Hi hi hi....
A current limiting circuit has been added... :) Only used a 0.1 ohms shunt resistance and the ADC in the ATMega ... no other circuits... :)
This give us a max limit to 50A until the ADC input clips. The 10 bit resolution of the ADC is also good enough to test low power.
We might need to protect the ADC imput of ATMega with a zenner diode... The schematic is not updated yet but soon...
Enjoy the video
Mihai
https://www.youtube.com/watch?v=71Gdv1eEARk
Re: DIY AC Servo Drive - ATMega based
Quote:
Originally Posted by
mcm_xyz
Hi hi hi....
A current limiting circuit has been added... :) Only used a 0.1 ohms shunt resistance and the ADC in the ATMega ... no other circuits... :)
This give us a max limit to 50A until the ADC input clips. The 10 bit resolution of the ADC is also good enough to test low power.
We might need to protect the ADC imput of ATMega with a zenner diode... The schematic is not updated yet but soon...
Enjoy the video
Mihai
https://www.youtube.com/watch?v=71Gdv1eEARk
really cool, waiting your new shecmatic