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! > Electronics > PIC Programing / Design


PIC Programing / Design Discuss programing of PIC chips here and design of electronics using PIC chips.


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #13   Ban this user!
Old 10-22-2007, 10:07 PM
bsharp's Avatar  
Join Date: Apr 2005
Location: usa
Posts: 82
bsharp is on a distinguished road

Yea I did not like the idea of using an opamp ether . I am going to build an HBridge using high power mosfets with optodrivers for the power stage. But the source gives me something to start with anyway. Ill take a look at that variable tomorrow and see if I can figure it out .
Reply With Quote

  #14   Ban this user!
Old 10-29-2007, 07:12 AM
bsharp's Avatar  
Join Date: Apr 2005
Location: usa
Posts: 82
bsharp is on a distinguished road

Well got the dsPIC30's in.
First thing was to get them hooked up so I could Program them.
I used this Idea for a simple serial programmer.
http://www.piclist.com/techref/picli...apic/COM84.htm
It seems to work well but some times it fails to write correctly.
So I will most likely add an amp to the MCLR supply to up the volts a little.
The next thing was programmer software.
http://www.qsl.net/dl4yhf/winpicpr.html
As it will work with most dsPIC's.
I am going to start working on the encoder interface and control IO.
I will post some pics when I get a chance.
Reply With Quote

  #15   Ban this user!
Old 11-27-2007, 08:14 AM
 
Join Date: Aug 2007
Location: Canada
Posts: 15
michael_giesbre is on a distinguished road

I have some experience using the DSPIC 30F4011 for motion control (using PWM and the Quadrature Interface) so I've go that part pretty much figured out (mostly) but I'm having a little difficulty fdiguring out how to collect the step and direction signals to create the desired position. Maybe we could combine our efforts on this project? I'm using the DSPIC 30F4011, programming in basic with an in circuit programmer from Mikroe.
Reply With Quote

Sponsored Links
  #16   Ban this user!
Old 11-28-2007, 08:33 AM
 
Join Date: Aug 2007
Location: Canada
Posts: 15
michael_giesbre is on a distinguished road

Ok so I had the whole system setup last night. As a test to get the PWM and Quadrature systems working correctly I have Setup my motor/encoder combo like an RC servo (it just tries to maintain a position) When I deflect the encoder the motor turns on to correct, with the duty cycle being calculated through the PID function. The problem that I am having with it as is, is that when I deflect the encoder in one direction, the system works properly, and the speed of the motor is somewhat proportional to the error (as I increase the error the speed increases). When I deflect the encoder in the other direction, the proportionality seems to be opposite, a small defelection gets a very fast speed, and as I increase the deflection, the speed decreases.

I also had a thought about using an external interrupt to count input pulses, basically on an interupt, the controller goes into an interupt routine that checks the direction (ie high or low) and then increments or decrements a counter variable accordingly. Even at Mach's maximum frequency (45 kHz right?) this should leave lots of cycle time in between input pulses to implement the rest of the control

Any thoughts?

-Mike
Reply With Quote

  #17   Ban this user!
Old 11-29-2007, 10:11 PM
 
Join Date: Aug 2007
Location: Canada
Posts: 15
michael_giesbre is on a distinguished road

Tried out using interrupts for counting pulses, and also figured out the problem with the PWM. Now the system reacts correctly to the errors, and will move as needed to correct for each pulse that is input into the controller.

yesterday I messed up one of my Mosfets. I replaced them all today (just to make sure) and had a bit of an interesting problem with them........

When I applied +5V to one side of the bridge everything worked fine and the motor came on.


When I applied +5V to the other side of the bridge, the high side mosfet on that side of the bridge started smoking (right away) so I quickly removed the power. Then the mosfet started to smoke more. Then alot. Then the flames......

Anyway everything but the hbridge is ok, but it is toast. As is the breadboard it was on. and everything else on the breadboard.

So that is the end of experimenting with high power motor control on my desk in my room.....

Anyway once I have the code perfected I'll post it, as well as the schematics for the circuit
Reply With Quote

  #18   Ban this user!
Old 11-30-2007, 02:56 PM
 
Join Date: Dec 2005
Location: Usa
Posts: 93
Horsedorf is on a distinguished road
Buy me a Beer?

Ohhhh. OUCH.. I HATE it when that happens. Though it's not as bad as powering up with your face over the circuit board and having bits of plastic suddenly embedded in your face. Been there, done that.
Reply With Quote

  #19   Ban this user!
Old 12-02-2007, 11:21 AM
 
Join Date: Aug 2007
Location: Canada
Posts: 15
michael_giesbre is on a distinguished road

Ive done that too!!!! Im beginning to think that electronics and I don't agree....
Reply With Quote

  #20   Ban this user!
Old 12-19-2007, 01:26 AM
 
Join Date: Nov 2007
Location: Philippines
Posts: 55
rdpzycho is on a distinguished road

same here..I hate it when MOSFETs burn..

how do you upgrade the position variable? I tried this before but using Step/Dir makes the motor move unlike a servo, it overshoots and hunts..I ended up trying to make a program that reads G and M codes that could directly communicate with my drivers so it upgrades the position variable as a whole..but it seems like I ended with a bit harder project because I need to make room for kinematics/interpolation..overall, the project is postponed until I have enough time to play with it again..
Reply With Quote

Sponsored Links
  #21   Ban this user!
Old 12-20-2007, 12:09 AM
bsharp's Avatar  
Join Date: Apr 2005
Location: usa
Posts: 82
bsharp is on a distinguished road

Sorry I haven't had the time to devote to this project lately. I did get A PICKIT2 to speed up programming the chips. I currently have the DSpic, voltage reg's and encoder input optos on a perf board. All I need to do is setup a serial interface to set the PID parameters and I can start testing the output of the DSpic. I have played with the code from the dspic servo project and "think" I have it modified for step and direction inputs. I still need to design and build the output stage. Hopefully I can get some of my other projects done over the holiday and I can devote more time to this one.
Reply With Quote

  #22   Ban this user!
Old 12-21-2007, 12:56 AM
 
Join Date: Nov 2007
Location: Philippines
Posts: 55
rdpzycho is on a distinguished road

btw, on my project I used 3 MSP430's to accomplish different tasks and let them pass data through a bus. I never looked at how the data is transferred from my step/direction controller to the PID one.

I just never had a better controller at that time so I resorted to using 3 closely powered ones. (one processes quadrature signals, one for PID, one for step/direction counts; I just graduated college when I started the project and had not enough money to buy development boards for more powerful controllers).

never had time for this project for around 2 years now.
Reply With Quote

  #23   Ban this user!
Old 12-28-2007, 11:20 AM
 
Join Date: Aug 2007
Location: Canada
Posts: 15
michael_giesbre is on a distinguished road

Originally Posted by rdpzycho View Post
same here..I hate it when MOSFETs burn..

how do you upgrade the position variable? I tried this before but using Step/Dir makes the motor move unlike a servo, it overshoots and hunts..I ended up trying to make a program that reads G and M codes that could directly communicate with my drivers so it upgrades the position variable as a whole..but it seems like I ended with a bit harder project because I need to make room for kinematics/interpolation..overall, the project is postponed until I have enough time to play with it again..
Basically I setup an interupt routine that is triggered on every step pulse coming into the controller. The routine checks the state of the direction input (high/low) and increments or decrements a variable accordingly.

The quadrature counter uses the poscnt register to count encoder pulses.

They rest of the program on the chip just compares the value of the step variable and the poscnt register to determine position error, then applies the PID algorithm to correct for the error. I'm still working on getting the PID algorithm right, but using a simple Proportional control actually works pretty well as long as the gain is not to high.

The overshooting and hunting that you were seeing was probably caused by poor gain settings for your PID algorithm. If using only proportional control the controller will tend to do this unless the gain is set quite low.

The other thing that you want to do is allow a little bit of a "fudge factor" on the position error (I'm using 2048 line (8192 ppr) encoders so If allow a window around the desired position of 50-100 pulses it results in a very very tiny linear position error of the system, but makes the controller alot more stable. (Basically once the controller gets the motor to within the "fudge range - about +/-50 counts" it turns off the motor power, and (hopefully) the motor will come to a stop within the "fudge range" and so the controller will call it close enough - as long as the motor is not at very high speed this actually works quite well, and only proportioanl control is needed. (with a 2048 line encoder and a fudge range of +/-50 counts, on a 12 TPI lead results in a MAXIMUM linear error of 0.0005" (that is if the error is +/-50, but because of the slow down of the motor, this usually ends up being quite a bit closer)

It is important to note that this only works with slower motor speeds, a faster motor speed will require a much larger fudge range, and therefore will result in much lower accuracy (unless some overshoot and return is allowed)
The I & D terms of the PID will help to allow faster motor speeds with high accuracy.



Mike

Last edited by michael_giesbre; 12-28-2007 at 11:35 AM.
Reply With Quote

  #24   Ban this user!
Old 12-29-2007, 10:43 AM
 
Join Date: Nov 2007
Location: Philippines
Posts: 55
rdpzycho is on a distinguished road

thanks.

I also thought it might be the gains, but no longer played much with them. it can follow a whole distance command but cannot keep up good with stepping sequence. linear interpolation of two axis results in a wobbly line but at some point the line goes straight. I only got 500 ppr one.
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 Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with servo and servo drive littlejohn Servo Motors and Drives 0 09-14-2007 05:22 PM
Servo drive / Servo Amplifier Ken_Shea Servo Motors and Drives 9 07-10-2007 05:12 PM
pm feild servo servo eloid Servo Motors and Drives 4 03-03-2007 04:27 PM




All times are GMT -5. The time now is 03:48 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