Have a bipolar step motor rotate a certain number of steps (motor position control) and display the number of steps on an lcd

control de agulo de motor bipolar, pic16f887

Objective:

Control of the position of the motor of a bipolar motor, ie to control the number of steps of the bipolar motor

Material:

  • Motor Bipolar
  • LCD
  • pic16f887
  • l293d

Development

A bipolar stepper motor rotates certain degrees for each step (this varies by manufacturer)

To achieve this we have to introduce a variable flag that incremented in one each that is a step to take the count of the steps and in case that is reached to the step the limit to take to the motor of the sequence and to stop it.

 

Flowchart

Diagrama de proteus

 

Source Code in Proteus

 

 

// control de motor de pasos unipolar con un boton de arranque y otro de giro
#include <16F887.h>
#FUSES NOWDT                    //No Watch Dog Timer
#FUSES LP                       //Low power osc < 200 khz
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOMCLR                   //Master Clear pin used for I/O
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOCPD                    //No EE protection
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES NOFCMEN                  //Fail-safe clock monitor disabled
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOWRT                    //Program memory not write protected
#FUSES BORV40                   //Brownout reset at 4.0V
#use delay(clock=8000000)
#include "lcd.c" 

 

int8 contador=0;

int8 pasos=10;

 

void main()
{

set_tris_a(0xFF);  // configure porta como entrada
set_tris_c(0x00);  // configure portc como salida

output_c(0x00);

while(true) {

if  ((input(PIN_A0) == 1)) {

delay_ms(500);

output_c(0b00000110) ;

contador++;

   lcd_init();   
   lcd_gotoxy(1,1); 
   printf(lcd_putc,"%u",contador);
   
   if (contador==5){
   
   break;
   
   }

delay_ms(500);  // pausa de 1 seg
output_c(0b00000101) ;
contador++;
   lcd_init();   
   lcd_gotoxy(1,1); 
   printf(lcd_putc,"%u",contador);
   
   if (contador==5){
   
   break;
   
   }
delay_ms(500);
output_c(0b00001001) ;
contador++;
   lcd_init();   
   lcd_gotoxy(1,1); 
   printf(lcd_putc,"%u",contador);
   
   if (contador==5){
   
   break;
   
   }
delay_ms(500);
output_c(0b00001010) ;
contador++;
   lcd_init();   
   lcd_gotoxy(1,1); 
   printf(lcd_putc,"%u",contador);
   
   if (contador==5){
   
   break;
   
   }
delay_ms(500);

}

else {

          output_c(0x00);          
          delay_ms(1000);

}

}

          output_c(0x00);          
          delay_ms(1000);

}

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *