![]() | |
| Home Page | Mark Forums Read | Today's Posts | My Replies | Classifieds | Reviews | Photo Gallery | Web Links | Share Files | Advertise With Us | Ad List |
| |||||||
| PIC Programing / Design Discuss programing of PIC chips here and design of electronics using PIC chips. |
![]() |
| | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
| |||
| |||
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; default utput_high(COIL1);break; } } |
|
#2
| |||
| |||
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 |
|
#3
| |||
| |||
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? |
|
#4
| |||
| |||
| 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 |
|
#5
| |||
| |||
| 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? |
| Sponsored Links |
|
#6
| |||
| |||
| 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 |
![]() |
| Tags |
| controller, firmware, pic, programming, slow |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
| |
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 |