CNCzone.com-The Largest Machinist Community on the net!



Home Page Mark Forums Read Today's Posts My Replies Classifieds Reviews Photo Gallery Web Links Share Files Advertise With Us Ad List
Go Back   CNCzone.com-The Largest Machinist Community on the net! > OpenSource CNC Design Center > Open Source Controller Boards


Open Source Controller Boards Discussion for Open Source CNC type Controller Boards and other related items. (for personal use only)


This forum is sponsored by:

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 01-09-2009, 03:24 AM
 
Join Date: Feb 2005
Location: Romania
Posts: 118
dandumit is on a distinguished road
Microcontroller based bipolar stepper driver

Hi,

I would like to discuss the posibility to build a microcontroller based stepper motor driver able to drive bipolar motors in microstepping mode.

Specs of driver :
- cost effective solution composed by a microcontroller and 2 Fet based H-Bridges
- PWM driving (not current chopping)
- start point schematic is Mariss's schematic from thread New Allegro Bipolar Stepper Driver A3986


Questions :
- How to set up the fill factor of of PWM ? Would be suitable a PID function in this case ? Usually PID function thakes as input the error (defined as difference between desired value and measured value ) and sets the drive value. In this case when desired coil current it is evaluated trough a simple comparator I think that it is not applicable. Would be necessary a very fast ADC.
- It is mandatory PID on PWM ?
- What microcontroller would be suitable for this job ? (only cost effective solution that comes to my mind is at90PWM2/3 has integrated PowerStageController - pwm with programable deadtime )


Regards,
Daniel
Reply With Quote

  #2   Ban this user!
Old 01-09-2009, 06:24 AM
 
Join Date: Jul 2008
Location: UK
Age: 54
Posts: 411
irving2008 is on a distinguished road

Daniel

A lot of the top end Microchip PICs have integrated ADC and PWM hardware for this sort of job...
Reply With Quote

  #3   Ban this user!
Old 01-09-2009, 08:40 AM
 
Join Date: Feb 2005
Location: Romania
Posts: 118
dandumit is on a distinguished road

Irvin, thank you for pointing me to that direction (I don't know why I'm staked on Atmel products).
Looking trough their list of motor control dedicated products (http://www.microchip.com/ParamChartS...g=en&pageId=75) I tooked as example : dsPIC33FJ32MC202 .

From datasheet results that ADC can do :
10-bit, 1.1 Msps or 12-bit, 500 ksps conversion:
- Two and four simultaneous samples (10-bit ADC)
I wonder if 1Msps ADC on coil current would be enough to drive a stepper motor.
If 2000 steps per second would be an acceptable performance then the ADC would have 500 samples per each step + time needed for calling PID function and changing fill factor of PWM.
Reply With Quote

  #4   Ban this user!
Old 01-09-2009, 10:15 AM
 
Join Date: Aug 2006
Location: USA
Posts: 2,624
kreutz is on a distinguished road

Originally Posted by dandumit View Post
Irvin, thank you for pointing me to that direction (I don't know why I'm staked on Atmel products).
Looking trough their list of motor control dedicated products (http://www.microchip.com/ParamChartS...g=en&pageId=75) I tooked as example : dsPIC33FJ32MC202 .

From datasheet results that ADC can do :

I wonder if 1Msps ADC on coil current would be enough to drive a stepper motor.
If 2000 steps per second would be an acceptable performance then the ADC would have 500 samples per each step + time needed for calling PID function and changing fill factor of PWM.

The dsPIC33FJ32MC202 is an overkill for this task.

Mariss does not use PI or PID to control phase current, for the simple reason that there is no A/D conversion and the CPLD he uses does not have the resources to implement PID or PI control. He uses a fixed frequency chopper, although he does not want to call it a chopper, all choppers are PWM (even when some of them have variable frequency).

How are you planning to deal with current decay?, Mosfet turn on and reverse recovery switching transients affecting the results of A/d current measurements?

It would be a good learning experience.

IR2104 does not have separated high and Low side input signals, and has fixed dead-time. Using the Atmel At90PWM2/3 controller is going to be a waste of resources unless you change the Mosfet half bridge driver.

I think that controller will be very busy doing only 20Khz PI control of current, what kind of math are you planning to implement? fixed point, floating point, integer only?.

Kreutz.

Last edited by kreutz; 01-09-2009 at 10:33 AM.
Reply With Quote

  #5   Ban this user!
Old 01-09-2009, 11:46 AM
 
Join Date: Jul 2008
Location: UK
Age: 54
Posts: 411
irving2008 is on a distinguished road

I would probably use IR2110 for this as has seperate hi and lo inputs and a common shutdown gate.
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 01-09-2009, 11:50 AM
 
Join Date: Feb 2005
Location: Romania
Posts: 118
dandumit is on a distinguished road

1. Microchip says that dsPIC33FJ32MC202 is $2.59 for volume - so it's god for our purpose

2. Chopper's freq is depending also on supply voltage ... Chopper=PWM ? debatable . I think that Mariss want's to have fixed frequency on both windings and variable fill factor. Also he already explained that because of chopper's different freq in windings, motor starts to "sing".

3. BEMF ! - good quetion ! in this moment I don't know what to answer to this. Anyway if it can be found a way to analyze the BEMF we can find out some informations about the load of motor and the point where it is about to stall or to enter on resonance.

4. Procesor load : processor load it is big when the error (diference between desired and measured value) it is big. I intend to implement the following procedure : at the very first time after board power, when it is made a first complete cycle of microsteps i intend to have an array where to store values found by PID function for each coil + each microstep. At the next steps those values will be send from begining to pwm - this way the error will be smaller and load of cpu also smaller.
I would be tempted to try integer only math (thinking that we need as much speed as possible).
I still need advices if it is feasible to implement pid over adc from coil's current. 1Msps ADC would be enough ?

Beautiful part here is that if such a board would be made, would be possible to drive stepper motor or servomtor.

I think that we need Mariss advice on this ideea.

Regards,
Daniel
Reply With Quote

  #7   Ban this user!
Old 01-10-2009, 12:38 AM
 
Join Date: Feb 2005
Location: Romania
Posts: 118
dandumit is on a distinguished road

I have started to read the Application Note AN532 . Until now it confuses me : says that contol loop can go up to 2khz and the time needed for pid calculation it's 200ms. that's huge and it cannot be used to make pid pwm stepper driver
Reply With Quote

  #8   Ban this user!
Old 01-10-2009, 08:56 AM
 
Join Date: Aug 2006
Location: USA
Posts: 2,624
kreutz is on a distinguished road

Originally Posted by dandumit View Post
..................- What microcontroller would be suitable for this job ? (only cost effective solution that comes to my mind is at90PWM2/3 has integrated PowerStageController - pwm with programable deadtime )..............
Daniel;

I implemented a complete translator with multiple micro-step modes on a 2K of Flash, 128 bits of RAM, $1.00 Attiny2313-20. It is used on a 48V 5Amps bipolar Micro-stepper drive, as well as on an 80V 8Amps unipolar micro-stepper drive with ZERO Noise, both work at 100K steps/sec. Both designs are discussed on the respective threads and blogs, even provided the source code, PCB designs and schematics.

I don't intend you to follow on the same path, but maybe my implementation could give you some ideas. The PIC DSC is more than enough to do what you intend to do, a DC motor controller is something completely different from a stepper controller, so that AN will not help much.

About the chopper versus PWM debate. If you don't understand what they are and what the similitude (or difference) is, it is difficult to use any of them on your design. PWM is a pulse modulation technique, it does not have anything to do with PID, except that some PID controllers employ PWM as control output, the same way other PID controllers could give you +/-10v output.

About PID controller load, it does not depend at all on the error size. The error is only one variable on the chosen PID algorithm. It does depend on the math employed (fixed point, floating point, integer) and the number bits assigned to the variables and coefficients (precision), as well as the capabilities and speed of the processor itself. The DSPIC is fast enough for a fixed point (Q15) PI loop running at 20 Khz.

Kreutz.
Reply With Quote

  #9   Ban this user!
Old 01-10-2009, 10:32 AM
 
Join Date: Sep 2006
Location: romania
Posts: 218
eSilviu is on a distinguished road
Thumbs up

Originally Posted by dandumit View Post
From datasheet results that ADC can do :
- 10-bit, 1.1 Msps or 12-bit, 500 ksps conversion:
- Two and four simultaneous samples (10-bit ADC)
I wonder if 1Msps ADC on coil current would be enough to drive a stepper motor.
If 2000 steps per second would be an acceptable performance then the ADC would have 500 samples per each step + time needed for calling PID function and changing fill factor of PWM.
hm..
I've played with a dsPic some time ago, but I was verry dissapointed by the ADC module. Allthrough can be configured to 1Msps, I couldn't use-it for signals faster than 10kHz (ADC values were wrong...)
Fast and accurate ADC with Microchip is not for beginners. You must learn wery well how pic is working, and what can you disable while reading analog values.
But if you want to try, will give a help, if we can
Reply With Quote

  #10   Ban this user!
Old 01-10-2009, 10:34 AM
 
Join Date: Sep 2006
Location: romania
Posts: 218
eSilviu is on a distinguished road

Originally Posted by dandumit View Post
I have started to read the Application Note AN532 . Until now it confuses me : says that contol loop can go up to 2khz and the time needed for pid calculation it's 200ms. that's huge and it cannot be used to make pid pwm stepper driver
there are other law for current controlling than PID. PID is slow. A sliding mode will be much faster and intuitive
Reply With Quote

Sponsored Links
  #11   Ban this user!
Old 01-10-2009, 11:12 AM
 
Join Date: Feb 2005
Location: Romania
Posts: 118
dandumit is on a distinguished road

Kreutz, first of all thank you for giving feedback on this idea, I look on your 2313 design immediately. (comparing myself with you or Mariss I'm weak in stepper driving so, I have a lot of things to learn).

Also I have to comment a little / or better said to add some more details :
DC motor controller is something completely different from a stepper controller, so that AN will not help much
.

Very basically a stepper driver consist in 2 synchronized regulators who take care to have an amount of current trough windings.

When I say regulator I mean :
1. one device to measure the resulted output value, value which will be used as feedback
2. decision mechanism which: a) take in account desired value and measured result from point 1 ; b) decides about action that should be made and send this decision to no 3
3. Power Stage

Everywhere where is a regulator should be a PID function in no 2 - Decision Mechanism.

All designs that I have seen for driving stepper motors are based on a simple comparator. I consider this as the point where improvement has to be made.

PWM is a pulse modulation technique, it does not have anything to do with PID
Indeed PWM it's the working mode of power stage.

About PID controller load, it does not depend at all on the error size.
That's correct. What I was willing to say is :
1. in the first on pwm cycles error will be big and PID procedure will be called.
2. after few iterations will be found the correct fill factor of PWM. when all pwm values coresponding to desired winding current are known , error will be small enough to avoid calling PID function.


Daniel
Reply With Quote

  #12   Ban this user!
Old 01-10-2009, 12:36 PM
 
Join Date: Aug 2006
Location: USA
Posts: 2,624
kreutz is on a distinguished road

Originally Posted by dandumit View Post
..........All designs that I have seen for driving stepper motors are based on a simple comparator. I consider this as the point where improvement has to be made..............

Daniel
Yes, and No.

Yes, the majority of the stepper drives use "bang-bang" or chopper control, which is the term applied to a Proportional controller with infinite gain. The system works fine because of the L/R time constant of the Motor coil. The coil current could not have sudden changes due to the inductive nature of the winding.

In this way the stepper coil regulator is equivalent to a DC/DC Buck regulator, and the same general techniques are applied for current control. There are nevertheless some differences when taking into account current decay modes.

The currently employed current regulation technique does a wonderful job and is simple (and fast) enough, main factor here is: You setup a reference value for the current, it does not matter which motor or power supply dc voltage. The proportional control (chopper) will try to regulate the current and will do a great job modulating the duty cycle value in order to regulate the coil current while the drive acts as a current source (below 100% duty cycle). The problems start when the drive begins to act as a voltage source after certain speed due to the L/R time constant and BEMF (with constant DC voltage).

If you were to design a PI type of control, it will behave about the same, because you are not acting against the limiting factor, that is the L/R and the effect of the BEMF. PID is not required because the controlled variable changes relatively slow vs time (due to the inductive nature of the motor winding). Now you have a big problem: PI loop tuning for different motors and different power supply voltages, hence the competitive dis-advantage. Here goes the No, regarding to "improvements could be made".

If what you are trying to accomplish is only to eliminate the sub-harmonic instability, there are other simpler ways employed in the DC/DC controller's industry for quite some time: The use of a "Blanking time" and Slope-compensation, which by the way was not invented by Mariss or Me, it has been there for a long time, just not used on stepper drives.

A well calculated or adjustable Slope-compensation will take care of another disadvantage of the chopper technique, it will compensate against the change of average current value vs duty cycle, which is inherent to the Peak limit current regulation mechanism, so the regulator circuit becomes an effective average current regulator when properly employed (adjusted for 50% duty cycle).

If you want to go deeper into solving the problems of the L/R and BEMF effects at high speed, then there are also other techniques that have been developed, between others: Dual voltage drives and Field Oriented Control (flux vector) drives (including field weakening), that is what Mariss working on now.

Last edited by kreutz; 01-10-2009 at 12:59 PM.
Reply With Quote

Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
New Allegro Bipolar Stepper Driver A3986 BCwanderer Open Source Controller Boards 826 07-25-2011 04:32 PM
Unipolar Stepper run with Bipolar Driver bcromwell General Electronics Discussion 38 11-26-2009 04:10 AM
need help to connect microcontroller to stepper driver xinzc28 General Electronics Discussion 0 11-07-2008 02:59 AM
MicroController/DSP based Motion interface Haz General Electronics Discussion 3 03-22-2007 03:54 PM
RQ: Bipolar stepper motor driver circuit elektronchika Stepper Motors and Drives 2 12-21-2005 05:29 PM




All times are GMT -5. The time now is 12:56 AM.





Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO
Template-Modifications by TMS

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361