Tuesday, 30 October 2012

PIC C An introduction to programming the Microchip PIC in C

PIC C An introduction to programming the Microchip PIC in C



PIC C An introduction to programming the Microchip PIC in C
Author Nigel Gardner | Year 1998 | ISBN : 1899013067 | 162 pages | Pdf | 7 mb

1. C Fundamentals
2. Variables
3. Functions
4. C Operators
5. C Program Control Statements
6. Arrays and Strings
7. Pointers
8. Structures and Unions
9. PIC Specific C
http://rapidshare.com/files/333776996/PICC.pdf
Sidharthan G
electricalmiracles. 

PIC Microcontrollers - Programming in C

  • Title :PIC Microcontrollers - Programming in C
  • Author(s): Milan Verle
  • Publisher: mikroElektronika; 1st edition (2009)
  • Paperback 336 pages
  • Language: English
  • ISBN-10: N/A
  • ISBN-13: 978-8684417178
  • Share This:                    
Book Description
This book is the perfect for entry into this world for engineers who have not worked with PICs, new professionals, students, and hobbyists. As MCUs become more complex C is the most popular language due to its ability to process advanced processes and multitasking. RTOSs, that is a need to know for engineers, is also discussed as more advanced MCUs require timing and organization of programming and implementation of multitasking.
What are microcontrollers, anyway? Electronics built in one single chip capable of controlling a small submarine, a crane or an elevator… It’s up to you to decide what you want them to do and dump a program containing appropriate instructions into the chip.
PIC Microcontrollers are present in almost every new electronic application that is released from garage door openers to the iPhone. With the proliferation of this product more and more engineers and engineers-to-be (students) need to understand how to design, develop, and build with them. Martin Bates, best-selling author, has provided a step-by-step guide to programming these microcontrollers (MCUs) with the C programming language.
On the other hand, the microcontroller is designed to be all of that in one. No other specialized external components are needed for its application because all necessary circuits which otherwise belong to peripherals are already built in it. It saves time and space needed to design a device.
About the Authors
  • N/A
Reviews and Rating:
  • N/A
Related Books and Categories: Read and Download Links:

Sunday, 28 October 2012

Automatic Water Level Controller

 
Program:-
// LCD module connections

sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;

sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections

char txt1[] = "Project";
char txt2[] = "Developed By....";
char txt3[] = "Ashno and Akhil";
char txt4[] = "---------------";

char mtr1[] = "Motor ";
char mtr2[] = "OFF";
char mtr3[] = "ON";

char wtr1[] = "Level: ";
char wtr2[] = "Very Low";
char wtr3[] = "Low";
char wtr4[] = "Medium";
char wtr5[] = "High";
char wtr6[] = "Full";



void main()
{

  int i = 0;
  int c = 16;
  int b = 0;
  CMCON = 0x07;
  ADCON1 = 0x06;
  TRISA = 0x0F;          // set direction to be input
  PORTA = 0x00;
  PORTD = 0x00;
  PORTC = 0x00;
  TRISB = 0x00;          //  set direction to be output
  TRISC = 0x00;          // set direction to be output
  TRISD = 0x80;          // set direction to be output

  PORTD.F2 = 1;
  PORTD.F7 = 1;

  Lcd_Init();                        // Initialize LCD
  Lcd_Cmd(_LCD_CLEAR);               // Clear display
  Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off
  Lcd_Out(1,1,txt1);                 // Write text in first row
  Lcd_Out(2,1,txt2);                 // Write text in second row
  Delay_ms(500);
  Lcd_Cmd(_LCD_CLEAR);               // Clear display
  Lcd_Out(1,1,txt3);                 // Write text in first row
  Lcd_Out(2,1,txt4);                 // Write text in second row
  Delay_ms(500);

// Moving text
for(i=0; i<15; i++)
{ // Move text to the right 16 times
  Lcd_Cmd(_LCD_SHIFT_RIGHT);
  Delay_ms(125);
}
i=0;

do
{
   Lcd_Cmd(_LCD_CLEAR);
   Lcd_Out(1,1,wtr1);
   Lcd_Out(2,1,mtr1);
   if(c>0)
   {
      PORTD.F2 = 1;
      c--;
   }
   else
      PORTD.F2 = 0;
    
   if(b>0)
   {
       PORTD.F0 = 1;
       Delay_ms(125);
       PORTD.F0 = 0;
       b--;
   }
 

    
   if(PORTD.F7 == 0)
     c = 16;
   
   if(PORTA == 0x0F)
   {
       PORTD.F1 = 1;
       Lcd_Out(1,8,wtr2);
       Lcd_Out(2,7,mtr3);
       PORTC = 1;
       if(i == 0)
       {
          c = 16;
          b=3;
       }
       i=1;
   }
   else if(PORTA == 0x0E)
   {
       Lcd_Out(1,8,wtr3);
       if(i == 1)
          Lcd_Out(2,7,mtr3);
       else
          Lcd_Out(2,7,mtr2);
       PORTC = 3;
   }
   else if(PORTA == 0x0C)
   {
       Lcd_Out(1,8,wtr4);
       if(i == 1)
          Lcd_Out(2,7,mtr3);
       else
          Lcd_Out(2,7,mtr2);
       PORTC = 7;
   }
   else if(PORTA == 0x08)
   {
       Lcd_Out(1,8,wtr5);
       if(i == 1)
          Lcd_Out(2,7,mtr3);
       else
          Lcd_Out(2,7,mtr2);
          PORTC = 15;
   }

   else if(PORTA == 0x00)
   {
       Lcd_Out(1,8,wtr6);
       Lcd_Out(2,7,mtr2);
       PORTD.F1 = 0;
       if(i == 1)
       {
         c = 16;
         b = 3;
       }
       i=0;
       PORTC = 31;
   }
   else
       PORTA = 0x0F;
   Delay_ms(125);


}while(1);            // Endless loop
}