![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
blueprint
Joined: 21 Jun 2011 Posts: 12
|
Microstepping with 16F877A |
Posted: Tue Aug 09, 2011 5:59 am |
|
|
Hello Dear All,
I have a unipolar 5V stepper motor and I want to drive it with a 16f877a.
I have connected 2 pieces of tc4427 mosfet drivers and 4 pieces of IRF2807 to the pic and, as I see they are working properly.
I supply 50V to the motor and I am trying to use microstepping techniques. Because the motor is 5V, pwm output of the pic never exceeds 10%.
My schema is same with the schema in this document (http://ww1.microchip.com/downloads/en/AppNotes/00907a.pdf page 19, figure 23) (plus mosfet drivers).
My problem is that, I can only drive the motor very slowly. When I trying to increase the speed, motor is just vibrating.
Here is my some code parts:
Code: | int msTable[] = {0, 2, 4, 6, 7, 8, 9, 10, 8, 6, 4, 3, 2, 1}; //Microstepping look up table |
Code: | setup_timer_2(T2_DIV_BY_1,101,1); //49.02 khz |
Code: | void takeStep(unsigned int16 stepCount){
static int iCcp1 = 7;
static int iCcp2 = 0;
static unsigned int16 i;
static int1 swCcp1 = true;
static int1 swCcp2 = true;
for(i = 0; i < stepCount; i++){
set_pwm1_duty(msTable[iCcp1++]);
if(swCcp1) output_high(PIN_CCP1_SW); else output_low(PIN_CCP1_SW);
set_pwm2_duty(msTable[iCcp2++]);
if(swCcp2) output_high(PIN_CCP2_SW); else output_low(PIN_CCP2_SW);
if(iCcp1 > MAX_MS_TABLE_INDEX){
iCcp1 = 0;
swCcp1 = !swCcp1;
} else if(iCcp2 > MAX_MS_TABLE_INDEX){
iCcp2 = 0;
swCcp2 = !swCcp2;
}
delay_us(1000);
}
} |
I am regulating speed by changing the sleep time. Sleep time 1000 and above works fine(but very slowly). When I decrease it, motor is starting to vibrate.
Please help me :/
Last edited by blueprint on Tue Aug 09, 2011 6:56 am; edited 1 time in total |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9170 Location: Greensville,Ontario
|
|
Posted: Tue Aug 09, 2011 6:21 am |
|
|
You don't give any details about the motor(mfr/model) let alone the specs so why do you think it can run at 49KHz ?
Replace the motor with an appropriate resistor and see with a 'scope' what happens.
This test will also confirm that your driver electronics are working correctly. |
|
![](templates/subSilver/images/spacer.gif) |
blueprint
Joined: 21 Jun 2011 Posts: 12
|
|
Posted: Tue Aug 09, 2011 6:54 am |
|
|
Thank you for your answer temtronic.
Here is some details of the motor:
3A, 1,66ohm, 7.5mH, nema 24, unipolar. Unfortunately I don't have any more details.
I did some research on the internet and learnt that 20 - 50khz is good to do it. Is it wrong?
I will check the circuit with a resistor as you said and report the last situation. |
|
![](templates/subSilver/images/spacer.gif) |
blueprint
Joined: 21 Jun 2011 Posts: 12
|
|
Posted: Tue Aug 09, 2011 7:01 am |
|
|
I have just checked the circuit with a oscilloscope. It works fine at high and low speed. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19359
|
|
Posted: Tue Aug 09, 2011 7:07 am |
|
|
Probably.....
You need to distinguish the PWM frequency (used to modulate the current in the coils), from the 'step rate' (rate at which the phases of the motor are moved). 20-50KHz, is fine for the PWM frequency, but not the step rate.
Generally, unipolar motors, though the easiest to drive, also have the lowest useable step rates. Pulling the data sheet for a very similar motor, first line reads:
"This drive is only suitable for applications where low speeds and low torques are required". Then the torque curves, give 'max pull in speed' (the rate at which you can start stepping the motor), at 1000Hz - no load, and the torque versus speed curve reaches zero at just over 4Khz, with full torque only being achieved up to about 500Hz.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
blueprint
Joined: 21 Jun 2011 Posts: 12
|
|
Posted: Tue Aug 09, 2011 7:38 am |
|
|
Thank you for the answer Ttelmah.
But, this motor runs very slowly (approximately 50-60 rpm), I can not believe that this is the speed limit of a unipolar stepper motor? |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19359
|
|
Posted: Tue Aug 09, 2011 8:02 am |
|
|
How many steps/rev is the motor?.
You get types with everything from 1.8degree, to perhaps 30degrees. At 1.8 degrees/step, you have 200steps/rev. At 500Hz step rate, this gives about 150RPM. So 50-60RPM, is slow, but only a little. To get full speed, the current modulation needs to change as you move. Remember that when you start to step the motor, each phase is on for less and less time, so the actual PWM 'on' period needs to rise, or the current falls. This is what is happening with your code, and why you are well below the best speeds available.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
blueprint
Joined: 21 Jun 2011 Posts: 12
|
|
Posted: Tue Aug 09, 2011 9:40 am |
|
|
Step angle of the motor is 1.8 degree.
Dear Ttelmah, would you please clarify your last post? Do you think that, my problem is with my code? So, how can I fix the problem? |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19359
|
|
Posted: Tue Aug 09, 2011 9:57 am |
|
|
Not without getting a lot more complex, and adding a lot more hardware.
You would need to actually sense the current flowing in the motor coil, and modulate the PWM, to regulate this to the required level for your microstep. When you start moving, the current will then be on for a larger proportion of the time.
This is what microstepping control chips do, Having an internal sine table, and using this to control a comparator controlling the PWM. It is probably not 'doable' in software without a lot more speed from the chip.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
blueprint
Joined: 21 Jun 2011 Posts: 12
|
|
Posted: Tue Aug 09, 2011 10:03 am |
|
|
Thank you very much Ttelmah! |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|