dimanche 31 janvier 2016

PWM Mode Using PIC16F877A microcontroller


 


OBJECTIVE:


  • speed variation
  • Digital display of Potentiometre 
  • LCD display(duty cycle %)
  • How to work with function

COMPONENTS:

  • Potentiometre 
  • 2 CAp (22pic)
  • 1 quartz (4MHZ)
  • pic 16F877A
  • Motor
  • L293D
  • LCD 16*2
Definition :

PWM (Pulse Width Modulation) is a method of generating signal shown above.
In short, PWM allows easy control the amount of power provided to external device e.g. motor or LED. When frequency of the signal is changed in time it can be used to generate sound.



motor animated

Led  animated


Discription:

PWM Mode (PWM) In Pulse Width Modulation mode, the CCPx pin produces up to a 10-bit resolution PWM output. Since the CCP1 pin is multiplexed with the PORTC data latch, the TRISC<2> bit must be cleared to make the CCP1 pin an output

A PWM output  has a time base (period) and a time that the output stays high (duty cycle). The frequency of the PWM is the inverse of the period (1/period).






The PWM period is specified by writing to the PR2 register. The PWM period can be calculated using the following formula: 


  Period = [(PR2) + 1] • 4 • TOSC • (TMR2 Prescale Value)

 PWM frequency is defined as 1/[ period]

PWM DUTY CYCLE:


 Duty Cycle =(CCPR1L:CCP1CON<5:4>) • TOSC • (TMR2 Prescale Value)


CIRCUIT DIAGRAM:






Video:



















Continue Reading...

vendredi 29 janvier 2016

Temperature sensor using PIC16F877A microcontroller




Temperature sensor using PIC16F877A microcontroller




OBJECTIVE:

  • Temperature measurement
  • Digital display of temperature
  • used of microcontroller to measure temperature
  • used of microcontroller to Display temperature value on LCD

COMPONENTS:


  • pic 16f877
  • lm35
  • 2 cap (22p)
  • quartz (4 mhz)
  • LCD 16*2

Only 5 volt power supply is required for LM35 and there is no need of extra circuitry to operate it. PIC16F877A micrcontroller is used to read temperature value. 16X2 LCD is used to display temperature value on LCD. Code of this project written in Pic C Compiler .

IMPLEMENTATION:



LM35 temperature sensor converts temperature into its proportional analog voltage value. LM35 is three terminal device.Pin number one and three are for 5 volt voltage supply. Pin two is analog voltage output with respect to temperature value.Relation between measured temperature and analog output voltage is:
                                                              1°C = 10m volt
Hence for every 1 degree increase in temperature there will be a increment of 10m volt in output voltage of LM35 sensor. PIC16F877A microcontroller is used to measure analog voltage value.  PIC16F877A  microcontroller built in ADC (analog to digital converter) is used to measure analog voltage.  PIC16F877A PORTA have seven built in ADC channels. So one can inerface upto seven sensors with this microcontroller very easily.I will post a project on green house system.In green house system project I have used four ADC channels to measure temperature , light, humidity and moisture. Coming back to our digital thermometer, ADC has been used to read analog voltage. After reading ADC value, using voltage and temperature relationship voltage is converted back into temperature. A conversion factor is used to convert voltage back into temperature. All these conversion has been done through programming. LCD is connected to PORTB of  PIC16F877A microcontroller. I will disucss it in programming part. LCD is used to display temperature value.

CIRCUIT DIAGRAM:




NOTE: BEFORE MAKING THIS PROJECT , I RECOMMEND YOU SHOULD LEARN ABOUT LCD INTERFACING WITH MICROCONTROLLER ESPECIALLY HARDWARE PART. BECAUSE I HAVE SEEN MANY STUDENTS STRUGGLING WITH LCD DISPLAY.



CODE:


#include <16F877.h>
#device adc=10
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)                                           
#include "LCD.c"                                                                         
//#define use_portb_lcd TRUE  
#define LCD_ENABLE_PIN  PIN_B0                                    ////
#define LCD_RS_PIN      PIN_B1                                    ////
#define LCD_RW_PIN      PIN_B2                                    ////
#define LCD_DATA4       PIN_B4                                    ////
#define LCD_DATA5       PIN_B5                                    ////
#define LCD_DATA6       PIN_B6                                    ////
#define LCD_DATA7       PIN_B7   
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) 
float adc_value,temp;
void     main() {                                                                 
setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(0);delay_us(10);
lcd_init();              
while(1){
adc_value = read_adc();            // convert to volts avec précision 0.001V
temp=(float)((adc_value * 5)/1023.0)*100; // calculer 
lcd_gotoxy(1,1); 
printf(lcd_putc,"  Temperature ");   //lcd 
lcd_gotoxy(1,2); 
printf(lcd_putc,"     %2.1f%cC",temp,223);
printf("%2f\n\r",temp ); 
printf("\nsmart tech\n\r" );
}                       
}

Video:
























Continue Reading...

dimanche 24 janvier 2016

Digital Voltmeter Using PIC Microcontroller 16F877A and





Digital Voltmeter Using PIC Microcontroller                             16F877A and


Here I’m explaining the constructional details of digital panel voltmeter using PIC16F877Amicrocontroller. It can measure voltage between 0V to 30V DC.
The program for digital voltmeter using pic microcontrolle is compiled using CCS.



Circuit Schematics of Digital Voltmeter Using PIC Microcontroller


The following figure shows digital voltmeter panel circuit diagram with microchip PIC.


Components Required for Digital Voltmeter Using PIC Microcontroller


  1. PIC16F877A Microcontroller
  2. LCD 16*2
  3. Resistor ( 1KΩ; 9KΩ)
  4. Crystal (20MHz)
  5. Capacitor ( 22PF x2)

Working of Digital Voltmeter Using PIC Microcontroller


  • PIC programming is quite easy if you have a perfect C compiler like Mikro C proMPLAB Hi-tech C etc.
  • PIC16F877A has inbuilt ADC (Analog to Digital Converter) Module, I used ADC to read input voltage value.

Measuring Voltage and Design of Voltage Divider Circuit

  • First of all let I discuss how do we measure voltage? Actually PIC’s ADC can measure 0V to +5V, but here our voltage range is 0V to +100V.
  • Hence we can’t feed the input voltage directly to the controller’s ADC pins. Instead of feeding directly, input voltage is reduced by a combination of voltage divider resistors.
Maximum allowed drop will be 5V.

diviseur de tension


V out = (R1/R1+R2 )  V in 
AN. 

Vout = (1/1+9 ) 12 = 0.12 

Mapping ADC Values to Input Voltage 

  • PIC microcontroller ADC is a 10 bit ADC, that means the output of ADC can be vary from0 to 1023 maximum while input varies from 0 to 5V.
  • That is when the input voltage is +5V then ADC value is 1023, when input voltage is 0V ADC value will be 0.
  • We have to map 0 → 1023 to 0 → 5; it can be done by multiplying ADC value with a 
5-------------->1023
?---------------> ADC val 


voltge = (5* adc val /1023)

I multiply by 10 to display the exact value Battery 

TBAT=voltge *10


program 


#include <16F877A.h>
#device ADC=10
#FUSES HS
#FUSES NOWDT                    //No Watch Dog Timer
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#use delay (clock=4000000)

#define LCD_DATA_PORT getenv("SFR:PORTD")
#include <lcd.c>
int16 tbat;
float test;

 void batrie()
 { 
   set_adc_channel( 1);
   delay_us(20);
   tbat = read_adc();
   test=tbat;
   test=test*0.04887585532746823069403714565;

   lcd_gotoxy(1,1);
   printf(LCD_PUTC, "Tb=%2.1f V",test);
 }
void main()
{  setup_adc_ports( ALL_ANALOG );
   setup_adc(ADC_CLOCK_INTERNAL );
   lcd_init();
   lcd_gotoxy(1,2);
   printf(LCD_PUTC, "Smart_tech naim ");   
 while(true)
    {
      batrie();
  }
}

video  













Continue Reading...

vendredi 22 janvier 2016

Remote Communication With Bluetooth Module





Remote Communication With Bluetooth Module



Practical part :


·       Connect your Bluetooth Module
·       Connect your 12v power supply and 5V DC
·        Control  manualy  your relay 1 and relay 2 by the buttons
 s1 and s2




FIRST, select your type of Bluetooth hc-005 and press [connect] to use The application correctly .then press bouttons (ON / OFF) to enable or disable the relays that you have chosen
Grapique programm with APP INV :


Simulation ISIS :



video :














Continue Reading...

How to controle LCD widh Pic 16f877





How to controle LCD widh Pic 16f877




Introduction


The most commonly used Character based LCDs are based on Hitachi's HD44780 controller or other which are compatible with HD44580. In this tutorial, we will discuss about character based LCDs, their interfacing with various microcontrollers, various interfaces (8-bit/4-bit), programming, special stuff and tricks you can do with these simple looking LCDs which can give a new look to your application.

For Specs and technical information HD44780 controlle



Pin Description

The most commonly used LCDs found in the market today are 1 Line, 2 Line or 4 Line LCDs which have only 1 controller and support at most of 80 charachers, whereas LCDs supporting more than 80 characters make use of 2 HD44780 controllers.

Most LCDs with 1 controller has 14 Pins and LCDs with 2 controller has 16 Pins (two pins are extra in both for back-light LED connections). Pin description is shown in the table below
Pin No.NameDescription
1D7Data bus line 7 (MSB)
2D6Data bus line 6
3D5Data bus line 5
4D4Data bus line 4
5D3Data bus line 3
6D2Data bus line 2
7D1Data bus line 1
8D0Data bus line 0 (LSB)
9EN1Enable signal for row 0 and 1 (1stcontroller)
10R/W0 = Write to LCD module
1 = Read from LCD module
11RS0 = Instruction input
1 = Data input
12VEEContrast adjust
13VSSPower supply (GND)
14VCCPower supply (+5V)
15EN2Enable signal for row 2 and 3 (2ndcontroller)
16NCNot Connected
Table 2: Character LCD pins with 2 Controller



simulation :






programmation :

#include <16F877.h>
#device adc=10
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)                                           
#include "LCD.c"                                                                         

#define LCD_ENABLE_PIN  PIN_B0                                    ////
#define LCD_RS_PIN      PIN_B1                                    ////
#define LCD_RW_PIN      PIN_B2                                    ////
#define LCD_DATA4       PIN_B4                                    ////
#define LCD_DATA5       PIN_B5                                    ////
#define LCD_DATA6       PIN_B6                                    ////
#define LCD_DATA7       PIN_B7                                       

void main() {                                                                 

lcd_init(); 

while(1){                          // boucle infinie
lcd_gotoxy(1,1);
printf(lcd_putc,"Smart_Tech Naim");   //Ecrire sur l'ecran lcd 
  lcd_gotoxy(1,2);
printf(lcd_putc,"smart-tech-med-naim");
  
}                       
}

Continue Reading...

jeudi 21 janvier 2016

commande D'un Motors DC 12v avec 3 façons CCS

 

commande D'un Motors DC 12v avec  3 façons  CCS 



Principe de fonctionnement :

 je vous démontre utilisation des registre E/S de pic  16f628 on  utilise 3 motors et 3 button poussoire
une action sur le boutton B1 provoque la demarreg de  3 motor simultannement
et B0 perment la declenchement d chaque moteur a un durre bien determine
B3 pour l'arret .

Besoin malterie:

- pic 16f628
- 2 cap 22p quartz 4mhz(ossilateur )
-4 bouttons poussoire
-3 motor DC 12V

idée sur le fonctionnement d'un moteur:

Le moteur à courant continu se compose :
  • de l'inducteur ou du stator,
  • de l'induit ou du rotor,
  • du collecteur et des balais.



Type de moteur à courant continu

Des moteurs à excitation indépendante.



Des moteurs à excitation parallèle.



Des moteurs à excitation série.




Des moteurs à excitation composée.




La plupart des machines d'ascenseur sont configurées en excitation parallèle ou indépendante. L'inversion du sens de rotation du moteur s'obtient en inversant soit les connections de l'inducteur soit de l'induit.


 simulation 



programmation :
































Continue Reading...