Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Rotery Enoder and Stepper Motor Problem

Status
Not open for further replies.
Re: Rotery Enoder and Stepper motor Problem

yes i am using discrete H-bridge sir.
 

Re: Rotery Enoder and Stepper motor Problem

I'm not sure I can help with the PWM or the delay, I suppose it is a matter of the specific driver implementation.
 

Re: Rotery Enoder and Stepper motor Problem

sorry i didn't get u which type of specific driver implementation . i have a already stepper driver .
 

Re: Rotery Enoder and Stepper motor Problem

Unfortunately you are only posting scarce code snippets, you we can't see what you are exactly doing.

Viewing these snippets, I get the impression that you are operating the stepper motor completely wrong. E.g. switching the stepper off is a no-no because it most likely causes loss of position.

I think, Alexander's game of questions and answers hasn't brought much clarity up to now. Perhaps you should start to explain the setup from the bottom.
 

Re: Rotery Enoder and Stepper motor Problem

ok FVM i post my code with my original question right
Code:
#INCLUDE<plib.h>

#define          MS_1                 BIT_1                                 //   Microstepping bit
#define          MS_2                 BIT_2

#define          stepperAquater()           (LATBSET = MS_1 , LATBCLR = MS_2 )  
#define          stepperAeighth()           (LATBSET = MS_1 , LATBSET = MS_2 )  
#define          stepperAhalf()              (LATBCLR = MS_1 , LATBSET = MS_2 )

#define mstepperAdis()  (LATECLR = BIT_4)
#define mstepperAena()  (LATESET = BIT_4)
#define mstepperArev()  (LATECLR = BIT_5)
#define mstepperAfor()  (LATESET = BIT_5)
#define mstepperAoff()  (LATECLR = BIT_6)
#define mstepperAon()   (LATESET = BIT_6)
  
int old = 0;
  
void InitializePorts(void)
{
    TRISEBits.TRISE2 = 1 ;                  // make as a input for encoder
    TRISEBits.TRISE3 = 1 ;                  // make as a input for encoder
    TRISEBits.TRISE4 = 0 ;                  // make as an output for stepper motor
    TRISEBits.TRISE5 = 0 ;                  // make as an output for stepper motor
    TRISEBits.TRISE6 = 0 ;                  // make as an output for stepper motor
    return;
}

void InitializeStepper(void)
{
    mstepperAoff();                         // stepper off
    mstepperAfor() ;                        // stepper forward
    mstepperAena() ;                        // stepper enable
    return;
}

void Encoder (void)
{
    int new = 0 ;
    int value = 0 ; 
    
    new = PORTE ;                           // read the current port status
    value = new ^ old ;                     // flag each port bit that has changed

    if(value & 0x08)                        // if bit 3 has changed since last time
    { 
        if (new & 0x08)                     // if bit 3 is set
        { 
            if (new & 0x04)                 // if bit 2 is set
            { 
                mstepperAfor() ;            // stepper forward
            } 
            else                            // else bit 3 is clear
            { 
                mstepperArev() ;            // stepper reverse
            } 
            stepperAhalf();
            mstepperAon();                  // stepper on
            Delay(20); 
            mstepperAoff();                 // stepper off
        }
    }
    old = new;                             // save current port status
    return;
}

void main(void)
{
    InitializePorts();
    InitializeStepper();
    while(1)
    {
        Encoder();
    }
}

ok this is simple code and my stepper motor rotate completely . but main issue is vibration on motor when encoder rotate low speed in half step of stepper motor driver.

any other method to operate stepper motor at the same time rotate encoder with smooth rotation. if any then please share with us.
 
Re: Rotery Enoder and Stepper motor Problem

More questions.
- What's the stepper motor driver? What's the meaning of it's signals?
- I don't fully understand what you are doing with the encoder. Do you want the stepper motor follow the encoder movement?
- The code doesn't look like a good quadrature decoder algorithm. It would be expect to process all encoder signal edges, you are only counting one out of four.
 

Re: Rotery Enoder and Stepper motor Problem

More questions.
- What's the stepper motor driver? What's the meaning of it's signals?

It's L298 and L297 based and this configuration u can easily see there is a five control pin as i described above .

- I don't fully understand what you are doing with the encoder. Do you want the stepper motor follow the encoder movement?
yes i want .


- The code doesn't look like a good quadrature decoder algorithm. It would be expect to process all encoder signal edges, you are only counting one out of four.

i don't understand with this sentence ? please tell me more detail .
 

Re: Rotery Enoder and Stepper motor Problem

yes i am using discrete H-bridge sir.

It's L298 and L297 based and this configuration u can easily see there is a five control pin as i described above

So you are using an IC driver rather than a discrete H-bridge, a schematic in the first post would have saved all the guesswork.
 

Re: Rotery Enoder and Stepper motor Problem

It's L298 and L297 based and this configuration u can easily see there is a five control pin as i described above .
Not actually clear. L297 can be switched between full and half step mode. So what's the purpose of the "quarter" and "eight" output codes, how they are connected? Also the function of mstepperAon() and mstepperAoff() isn't self explanatory. I can just guess that in constrast to their naming they are controlling the L297 clock input?

i don't understand with this sentence ? please tell me more detail
What's particularly unclear? Encoder signal edge means that one of the two quadrature encoder signals is changing state, either rising or falling. A good decoder algorithm is acting on any signal change. counting 4 steps for a full encoder period.
 

Re: Rotery Enoder and Stepper motor Problem

ok FVM now i am sorry to say about driver of L297 and L298 . but i have a another driver A3977 allegro which has a full , half , quater and eighth step so what about this.

and my decoder algorithm is change on any out of two encoder pin pulse stream on driver working perfectly . so my decoder algorithm is also working .
 

Re: Rotery Enoder and Stepper motor Problem

my decoder algorithm is change on any out of two encoder pin pulse stream on driver working perfectly .
According to your code, only rising edges of bit are counted.

but i have a another driver A3977
mstepperAon() and mstepperAoff() are controlling the STEP input?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top