Connect with us

Microstepping with 16F877A and CCS C

Discussion in 'Microcontrollers, Programming and IoT' started by probus, Aug 9, 2011.

Scroll to continue with content
  1. probus

    probus

    3
    0
    Aug 4, 2011
    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 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.

    Here is some details of the motor:

    3A, 1,66ohm, 7.5mH, nema 24, unipolar.

    I have just checked the circuit with a oscilloscope. It works fine at high and low speed.

    Please help me :/
     
    Last edited: Aug 9, 2011
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-