Microcontroller programming in C langauge

Advertising area for ROBOT.LK members
Post Reply
asoka
Corporal
Corporal
Posts: 4
Joined: Sun Apr 04, 2010 8:33 pm

Microcontroller programming in C langauge

Post by asoka » Sun Apr 04, 2010 8:53 pm

Workshop on Microcontroller Programming

Duration 2 Days
Course content

01. Introducton to the Microcontroller World
02. Introducton to the Structure of Microchip Microcontroller
03. Introducton to the Pin Configurations
04. Introducton to the programing Languages(Assembly Vs C Language)
05. Interfacinng PIC MCU with Outside worlds
06. Good programming Technique
07. Register & Peripherals of the PIC Microcontroller
08. Writing to Ports
09. Delay Loops and Subroutines
10. LED Running Systems
11. Multi Design LED Drivers
12. Logical and Arithmetic Operators
13. Reading for I/O ports(Switch/Sensors)
14. Interfacing Control circuits with Microcontroller
(Self Holding/Interlock/Star Delta)
15. PIC Based Multi range Timer with dual output
16. PIC Based counter with output
17. Machine Controlling & Automation Techniques


Example Programs (1)

Code: Select all

#include<16F84A.h>                   // Pic Microcontroller Model
# fuses HS                                     //Fuses
#use delay (clock =20000000)  // Cristal Osillator Frequacy
void main()
 
{
while(true) 
                                                        //for ever loop
{
output_high(pin_b0);                  // output b0 on
delay_ms(1000);                         // 1 second delay
output_low(pin_b0);                  // led off
delay_ms(1000)                        // 1 second delay
}

Code: Select all

////////////////////////////////////////////////////////////////
////                                                                                                 ////
//// PROJECT- 3 (LED RUNNING SYSTEM - ONE WAY)                          ////
//// WORKSHOP ON PIC MICROCONTROLER                                        ////
//// WRITTEN BY :                                                                           ////
//// TARGET PROCESSOR 16F84A (20 MHAZ)                                      ////
////                                                                                                 ////
////////////////////////////////////////////////////////////////


#include <16F84A.h>               // Pic Microcontroller Model
#fuses NOWDT,HS, NOPUT, NOPROTECT // Fuses
#use delay(clock=20000000)        // Crystal Oscillator Frequency

void main()
{
   while(true)                    // Forever Loop

      {

output_B(0x01);   // led 1 on
delay_ms(500);    // delay
output_B(0x02);   // led 2 on
delay_ms(500);    // delay
output_B(0x04);   // led 3 on
delay_ms(500);    // delay
output_B(0x08);   // led 4 on
delay_ms(500);    // delay
output_B(0x10);   // led 5 on
delay_ms(500);    // delay
output_B(0x20);   // led 6 on
delay_ms(500);    // delay
output_B(0x40);   // led 7 on
delay_ms(500);    // delay
output_B(0x80);  // led 8 on
delay_ms(500);    // delay

      }
}
 
}

Code: Select all

////////////////////////////////////////////////////////////////
////                                                                                                  ////
//// PROJECT - 12 (STAR/DELTA APPLICATION)                                 ////
//// WORKSHOP ON PIC MICROCONTROLER                                        ////
//// WRITTEN BY :                                                                             ////
//// TARGET PROCESSOR 16F84A (20 MHZ)                                       / ///
////                                                                                                ////
////////////////////////////////////////////////////////////////


#include <16F84A.h>                 // Pic Microcontroller Model
#fuses NOWDT,HS, NOPUT, NOPROTECT   // Fuses
#use delay(clock=20000000)          // Crystal Oscillator Frequency

void main()
{


   SET_TRIS_A (0XFF);               // SET PORT_A ALL PINS AS INPUTS
   SET_TRIS_B (0X00);               // SET PORT_B ALL PINS AS OUTPUTS

   OUTPUT_B(0X00);                  // CLEAR PORT B OUTPUTS

   {

   INT1 START;                      // START = RA0 (PUSH BUTTON SWITCH N/O)
   INT1 STOP;                       // STOP = RA1 (PUSH BUTTON SWITCH N/O)


   while(true) {                    // Forever Loop


   // PIN IDENTIFICATIONS OF POSITIVE INPUTS

   START=(INPUT(PIN_A0)==1);        // POSITIVE INPUTS (A0 = FORWARD)
   STOP=(INPUT(PIN_A1)==1);         // POSITIVE INPUTS (A1 = REVERSE)

   IF((START) && (!STOP))           // IF PRESS START & NOT STOP
   {
   OUTPUT_B(0X05);                  // OUTPUT HIGH PIN BO & B2 (FOR STAR)
   DELAY_MS(7000);                  // 7 SECONDS DELAY (7000 MS)
   OUTPUT_B(0X03);                  // OUTPUT HIGH PIN B0 & B1 (FOR DELTA)
   }

   IF((STOP) && (!START))           // IF PRESS STOP 7 NOT START
   {
   OUTPUT_B(0X00);                  // OUTPUT LOW PIN BO & B1 (BOTH OUTPUTS)
   }

   }
 }
}
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: Microcontroller programming in C langauge

Post by Neo » Sun Apr 04, 2010 10:58 pm

Again, another interesting topic for the world of embedded 8-) . Make sure you add some essential information like venue, date & time, lecturer information (qualifications, experience in the field, etc...) so those who are interested can participate.
Post Reply

Return to “Advertising”