Wye-delta Motor Controll For Basic PRO Compiler

Summary of Wye-delta Motor Controll For Basic PRO Compiler


This article presents a C-like microcontroller program for the PIC16F877, designed to control three outputs (K1, K2, K3) based on two input triggers: start and stops. The code initializes PORTA as inputs and PORTB as outputs, configuring an 8-bit ADC. It implements a logic loop where activating the start button initiates a sequence of output states that repeat until the stop button is pressed, followed by a reset state.

Parts used in the PIC16F877 Control Project:

  • PIC16F877 Microcontroller
  • 4 MHz Oscillator
  • PORTA Input Pins (Start and Stop buttons)
  • PORTB Output Pins (K1, K2, K3 indicators or loads)
  • ADC Module configured for 8 bits
  • Delay/Pause Functionality
@ device pic16f877
define osc 4
define adc_bits 8
main:
    trisb =$00
    trisa =$ff
    adcon1 = 7
    K1         var portb.0
    K2         var portb.1
    K3         var portb.2        
    start      var porta.0
    stops      var porta.1    
    K1=0 :K2=0:k3=0

while(1)
     if(!start and stops) then 
         K1=1
         K2=1
         K3=0         
         pause 3000   
      repeat     
         K1=1
         K2=0
         K3=1 
     until(!stops)         
     endif
         K1=0
         K2=0
         K3=0                             
    pause 10   
 wend
end

Quick Solutions to Questions related to PIC16F877 Control Project:

  • What oscillator frequency is defined in the code?
    The code defines the oscillator frequency as 4 MHz using the define osc 4 command.
  • How are the input pins configured?
    PORTA is configured as input by setting trisa to $ff, while PORTB is set as output with trisb set to $00.
  • Which ports control the Start and Stop functions?
    The Start function uses porta.0 and the Stop function uses porta.1 as defined in the variable assignments.
  • What happens when the start button is pressed and stops is not active?
    K1 and K2 turn on while K3 turns off for 3000 milliseconds before entering a repeating cycle.
  • How does the system respond to the stop button during the repeat loop?
    The repeat loop continues toggling K1 and K3 until the stops signal becomes inactive, at which point the loop exits.
  • What is the initial state of K1, K2, and K3 upon startup?
    All three variables K1, K2, and K3 are initialized to 0 at the beginning of the main routine.
  • What occurs after the stop condition is met?
    All outputs K1, K2, and K3 are turned off, followed by a 10 millisecond pause before the next cycle check.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter