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
  #1   Ban this user!
Old 12-12-2009, 07:53 PM
 
Join Date: Apr 2009
Location: USA
Posts: 10
mossy173 is on a distinguished road
slow-spinning driver firmware

I have written a simple stepper controller designed for a PIC with equally simple support circuitry; just a bunch of transistor arrays IC's between the microcontroller and the steppers. It does move the motors, but there is a problem--the motors can only move very slowly, capping out at something like 5 revolutions per second. Any more and they stutter and jam. I believe it is due to the firmware, but I don't know how or why. I have tried graduating the speed, ramping up until it jams, but that still occurs at the same speed. The current stepping scheme is 2-coils energized at a time--I've tried reducing that to just one, and it still spins, but just as slowly, so that's not it either. Here's the code. Right now it doesn't respond to parallel port control, it just spins when there's power. You'll notice the code which hopefully will one day allow parallel port control. Any insight into my slow speed is appreciated!! Thanks!



#include "C:\Program Files\PICC\Projects\stepper controller.h"
#include <stdio.h>


unsigned long wait, stateNum;
unsigned long waitincrementer;
unsigned int accelRate, minWait, deltaWait;
void state(int);



void main()
{

setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_comparator(NC_NC);
setup_vref(FALSE);
// enable_interrupts(INT_RA);
// enable_interrupts(GLOBAL);



while(1){
// if (input(STEP)){
if (1){//for testing. ignore step input.
// if (input(DIR)){
if (1){//for testing. ignore dir input.
stateNum = (stateNum+1)%4; //select state
state(stateNum); //change state
}
else{//in testing, this never happens.
stateNum = (stateNum-1)%4; //same thing in other direction
state(stateNum);
}
// while(input(STEP)); //wait for the pulse to end. ignored in testing.
}

delay_us(1800);//wait until proceeding until the next step so as to avoid jamming/stuttering

}
}


void state(int state1){

switch(state1){
case 0:
OUTPUT_LOW(COIL3);
OUTPUT_LOW(COIL4);
output_high(COIL1);
output_high(COIL2);
break;

case 1:
output_low(COIL1);
OUTPUT_LOW(COIL4);
output_high(COIL2);
OUTPUT_high(COIL3);
break;


case 2:
OUTPUT_LOW(COIL1);
output_low(COIL2);
output_high(COIL3);
OUTPUT_high(COIL4);
break;

case 3:
output_low(COIL2);
OUTPUT_LOW(COIL3);
output_high(COIL4);
OUTPUT_high(COIL1);
break;

defaultutput_high(COIL1);
break;
}

}
Reply With Quote

  #2   Ban this user!
Old 12-12-2009, 10:40 PM
 
Join Date: Feb 2007
Location: canada
Posts: 619
Larken is on a distinguished road

, capping out at something like 5 revolutions per second.
If you motor runs up to 5 tps, then your code is probably ok, but it could be that you need to code it in assembler to run faster. I write most of my fast pic code in assembler, and just use the c for slower stuff.
Your use of the delay may be the problem. You should be looping while checking for the rising edge then the falling edge of the step pulse. No delay should be needed.

300 rpm is not that slow for a stepper, 600 rpm is about as fast as you should expect it to have reliable useable torque.

The supply voltage has a lot to do with speed. Increase the voltage and your motor should be able to run a lot faster. You may need resistors in series with the windings to give it a constant current source.

Also whats your motor winding inductance ? Higher current, lower inductance motors perform much better than motors with lower current higher inductance.

Larry K
__________________
Manufacturer of CNC routers and Viper Servo Drives
www.LarkenCNC.com and www.Viperservo.com
Reply With Quote

  #3   Ban this user!
Old 12-13-2009, 12:33 PM
 
Join Date: Apr 2009
Location: USA
Posts: 10
mossy173 is on a distinguished road
thanks for the reply

Just to clarify: the delay is only there for testing, and when it is hooked up to Mach3 the delay will be taken care of by the control software. My understanding is that if the hardware is seizing up, writing more efficient code won't help, as the problem is electro-mechanical limitations of the stuff outside the microcontroller. I don't know what my inductance is, but the motors are about 3.1 ohm/coil, and I'm running them at 5v. If I step that up to, say, 12v, should I add resistors to keep the coil current the same? Or should I have proportionally less current to keep the wattage the same?

Right now the motors are turning hardware store threaded rod at 22tpi, and at (an optimistic) 5revs/sec it takes 1.76 minutes for the y-stage to traverse its full travel of 2 feet. That's slow. If it turns out that these motors can't go much faster with much torque, I'm thinking of switching to belt drive. Does that make sense?
Reply With Quote

  #4   Ban this user!
Old 12-13-2009, 02:08 PM
 
Join Date: Feb 2007
Location: canada
Posts: 619
Larken is on a distinguished road

At 3.1 ohm/coil,its a low-mid performance motor. What is the current rated at, thats the important spec.

I would suggest running a 24volt powersupply minimum and using a power resistor to set the current at its rated level.

eg; if your motor is rated at 1.5 amps/winding then 24volts / 1.5amps = 16 ohms (then subtract the resistance of the coil = 13 ohms)
That resistor will need to be 19.5 watts (13 ohms x 1.5amps)

You would need 1 resistor for each winding,

PS: If its a cold winter, it will also help to heat your house.

Larry K
__________________
Manufacturer of CNC routers and Viper Servo Drives
www.LarkenCNC.com and www.Viperservo.com
Reply With Quote

  #5   Ban this user!
Old 12-13-2009, 02:32 PM
 
Join Date: Apr 2009
Location: USA
Posts: 10
mossy173 is on a distinguished road

Hmm...I only have a power source from a gutted computer to work with, which only provides 12v max (unless I connect +12 to -12 instead of ground, but then I only have 800mA to use). Would 12v give me faster rpm? What kind of gains could I expect from 12 or 24v?
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 12-13-2009, 05:20 PM
 
Join Date: Feb 2007
Location: canada
Posts: 619
Larken is on a distinguished road

12 Volt will only give a bit better speed.

As the motor runs faster, the inductance increases and you need a higher voltage to charge the windings.

Get a 18-24 volt 3 amp transformer (radioshack) rectifier and filter cap. Ditch the PC power supply.
__________________
Manufacturer of CNC routers and Viper Servo Drives
www.LarkenCNC.com and www.Viperservo.com
Reply With Quote

Reply

Tags
controller, firmware, pic, programming, slow




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
New PICStep firmware available Garfield2 PicStep Controllers 19 12-06-2010 11:07 PM
VSD-A firmware upgrade Xerxes Granite Devices 4 10-27-2008 03:18 PM
VF2 I/O chip firmware Haim H. Haas Mills 1 08-30-2007 08:33 AM
Hi Firmware V1.1 20MHz elogicca PicStep Controllers 0 10-01-2006 05:46 PM
need help fet3 driver motor is choppy and slow at low steps per inch mike10 Stepper Motors and Drives 7 01-02-2005 02:41 PM




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