• 1

    ..

  • 2

    ...

  • 3

    ...

Saturday 26 April 2014

FREQUENCY MEASUREMENT USING AVR ATMEGA8

     Often frequency measurement is needed, but one cannot afford a DSO or an appropriate meter for that. So we have designed it in AVR microcontroller which is easily available and much easier to program.

    This frequency measurement uses Input Capture module in Timer1 via ICP pin PB0. For ease of programming, we have designed a low frequency measurement for frequencies lesser than 1KHz, but can be increased upto several 100KHz, through prescalar.

       The circuit diagram is

LCD 4 BIT INTERFACING WITH AVR MICROCONTROLLERS ATMEGA8,16,32,64

LCD 4 BIT INTERFACING WITH AVR MICROCONTROLLERS ATMEGA8,16,32,64

   This is the header file for LCD 4-bit mode interfacing with AVR Microcontroller series such as Atmega 16, 32, 64, 8, etc. It is coded in GCC & supports all AVR GCC compliers.

   This is designed for 16×2 LCD, but can be exteneded upto 20×4 LCD.
   Contains all functions with different cursor styles, string display from ram & flash rom, bcd, signed & unsigned  integer 8-bit and 16-bit numbers, shift left, shift right, etc.

Wednesday 23 April 2014

FREE ELECTRONIC ANDROID APPS



          Electronics has much more complex calculations than basic maths. More tools are available for these electronics calculation but they are mostly windows or linux based application.



          Android, an opensource smartphone OS, enables anyone to design an app for it. So it is easy for any common person who knows the electronics & basic programming can build an app.

          Lets see the commonly available free Android apps for Electronic designs, such as ohm’s law, KCL, KVL, resistor colour code calculations, series-parallel calculations, etc,etc,etc,,,,

·         Ohm's Law
Ohm's law calculator and the Watt's Law calculator.

·         Electronics Toolkit
Electronic tool kit calculates unknown quantities in the field of electrical and electronics engineering. It provides a resistor color code, power calculator, and Ohm’s Law, Series, Parallel, and Series/Parallel combination of inductors, capacitor and resistors, resistivity, Power factor triangle, i.e. active, reactive and apparent, magnetic fields, reactances and much more.

·         Every Circuit
    This is another recommended android Smartphones app for electrical and especially for electronics engineers and students. EveryCircuit app lets you understand that how do design different important electronic circuits and how they work.
     This app is handy in circuit like Logic gate, LED flashing
circuits, Resistive, inductive, capacitive, operational amplifier and other electrical & electronics circuits and can view dynamic charge, current and voltage colorful animations with waveforms.

·         DroidTesla
DroidTesla is a simple SPICE tool. Its permit you to solve, simulate and analyze different electrical and electronic circuits by using KCL and KVL. It has the ability to solve both linear and nonlinear circuits like resistive, capacitive, inductive and BJT, Transistor, Diode, AC/DC Voltage and Current sources, 555, MOSFETS, Logic gate and lots more…

·         ElectroDroid
ElectroDroid is a simple and powerful collection of electronics tools and references. It has a variety of tools & calculators, pin description, SMD details, etc,etc. This app is also available in pro version which can be bought from the Play store. Pro version supports the developer, unlocks more features and contains no ads.


·         Electrical calculations
It has the ability to identify the unknown values of different quantities of electrical and electronics circuits. There are lots of electrical calculators available in this app at once.


·         Electrical LV Calculator
It allows to design electrical system which reduces the reactive power, that is it improve power factor, the maximum allowable power installation, calculates current in a short circuit, Voltage drop, the automatic switch current in A, calculate the minimum and maximum cable and wire size, calculate the number of earth electrodes and earth resistance etc

·         Electrical Engineering
This app contains 3 of the most useful Electronic tools, the electrical calculator, the Electrical circuit calculator and the Electrical formulas. It also provides you a list of few electronics resources and ebooks that can be bought through the app.





Friday 11 April 2014

12V BATTERY HEALTH INDICATOR

This circuit is simple and easy to build & has only a few discrete components.
This indicates the 12V battery safe operating voltage.




Diode D1 protects the circuit when the battery polarity is reversed.
The LED glows with full brightness when the battery voltage is above the set threshold.

The threshold is set with the zener diode D2. for this circuit the threshold will
 Vds+VBEq1 ~= 11.5V

When the Battery voltage is above 10.8V the LED glows with very little brightness & increases with increase in battery voltage.
When it is above 11.5V the LED glows with full brightness.

The resistance R1 limts the current flow through the LED, R2 limits base current.
The current consumption is very less. Approx 10mA for battery voltage above 13V & very lesser current consumption (in few uA) when battery voltage drops below 10.5V.







Wednesday 9 April 2014

Rectangular Wave - PWM Waveform - Generation using 555

This simple circuit that produces a rectangular waveform using the most commonly available analog timer IC 555.

The on time and off time are controlled by the resistances Ra & Rb, which are variable to get the required value.

The formula for the time calculations are
The Circuit diagram is


The rectangular/pwm output is at pin 3 of the IC.
Resistance R1,R2 protects the device from shorting the terminals to VCC and ensure a minimum resistance available between the terminals.

The time delay depends on C2, RV1 & RV2. Change the values for desired output.

To get a square wave output, the condition is Ra=Rb. To get this, set the both pots to extreme left of right.



Monday 7 April 2014

SY-HS 220 Humidity Sensor Interfacing with AVR Atmega (8/16/32)

SY HS220 is the Relative Humidity Sensor with near linear output reference to relative humidity.
Its opereating RH percentage is 30-90% with Output Voltage range 990-2970mV.

Here we've interfaced SY HS220 with AVR ATMEGA8 microcontroller and display %RH in LCD.

Circuit Diagram:

undefined
ElecDude: HS220 AVR Circuit
Code:
/* ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
Author: ElecDude
         admin@elecdude.com      

Copyright - 2014 - ElecDude

DISCLAIMER:

 THIS SOURCE FILE MAY BE USED AND DISTRIBUTED WITHOUT      
 RESTRICTION PROVIDED THAT THIS COPYRIGHT STATEMENT IS NOT 
 REMOVED FROM THE FILE AND THAT ANY DERIVATIVE WORK CONTAINS
 THE ORIGINAL COPYRIGHT NOTICE AND THE ASSOCIATED DISCLAIMER.

 This is provided without any  express or implied warranties,
 including, but not limited  to, the implied warranties of merchantability
 and fitnessfor a particular purpose. FOR EDUCATIONAL PURPOSE ONLY.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
                          SY-HS 220 Humidity Sensor
     Input voltage = 5.0V                    Operating Temperature = 0-60'C
    Operating Humidity = 30-90% RH        Output Voltage = 990-2970mV
    Std.output = 1.98V   at 25`C 60%RH    Accuracy = +/-5%RH  at 25'C & 60%RH

Normal Values
%RH   mV
 30      990
 40     1300
 50     1650
 60     1980
 70     2310
 80     2640
 90     2970

    V-RH RATIO = 0.30301    by linear slope
    %RH = RATIO * Vout

ADC    Vadc = Vref * adcval/1024

If Vref= Vcc= 4.96, then
    %RH= Vout * 0.30301
       = Vref * adcval/1024 * 0.30301
    %RH= 0.0001467 * adcval
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~*/


#define F_CPU 1000000UL
/*****************MACRO's DEFINITION*********************************/
#ifndef BIT
#define BIT(x)    _BV(x)
#endif
#ifndef SETBIT
#define SETBIT(x,b)     x|=_BV(b);
#endif
#ifndef CLEARBIT
#define CLEARBIT(x,b)     x&=~_BV(b);
#endif
#ifndef TOGGLEBIT
#define TOGGLEBIT(x,b)     x^=_BV(b);
#endif
#ifndef CHECKBIT
#define CHECKBIT(x,b)     (x & _BV(b))
#endif

#include <avr/io.h>
#include <util/delay.h>
void WaitMs(unsigned int ms) // waits (pauses) for ms milliseconds
{
    unsigned int m;
    for(m=0;m<=ms/10;m++)
    {
        _delay_ms(10);
    }
}

#include "ADCHEAD.H"
#include "lcd.c"

#define PRT PIND
#define sw1 0
#define sw2 1
#define sw3 2
#define TIME 100
register unsigned char i asm("r17");

#define R 0.148
unsigned char count=0x00,chng=1;
unsigned int val,th;
char d2[]="00.0%";
void UpdateVal()
{
    float rh;
    uint16_t x;
    rh=R*val; //xx.y
    x=rh*10; //xxy
    d2[3]= (x%10) | 0x30;//ones
    x/=10;
    d2[1]= (x%10) | 0x30;//tens
    x/=10;
    d2[0]= (x%10) | 0x30;//hund
}

int main()
{
      CLEARBIT(DDRC,4)//set as i/p for adc
    CLEARBIT(DDRC,5)
    DDRD=0xF8;//enable PD as i/p & en pull ups
    PORTD=0x07;
    SETBIT(DDRB,7)
    SETBIT(PORTB,7)
   
    _delay_ms(10);
    LCD_init(COFF);
    _delay_ms(100);
    LCD_putsPXY(3,0,"Welcome to");
    LCD_putsPXY(4,1,"ElecDude");
    ADC_init();
   
    WaitMs(800);//wait for some time to initialise
    LCD_clear();
    SetCH(0x05); //PC5=HS220's Vout
    val=0;i=0;
    LCD_putsPXY(0,0,"Relativ Humidity");
    while(1)
        {
            TOGGLEBIT(PORTB,7)
            val+=ADC_readcurch();
            i++;       
            if(i==4)
             {
                val=val/4;
                UpdateVal();
                LCD_putsXY(5,1,d2);
                i=0; val=0; //clear after update
             }// endof if(i==4)
         WaitMs(200);
        }//end of while
return 0;
}

ADCHEAD.H

#define ADC_ENABLE()         SETBIT(ADCSRA,ADEN)        //Macro to enable ADC Module.
#define ADC_DISABLE()         ADCSRA &= 0x7F            //Macro to disable ADC MOdule.
#define ADC_START_CONV()     SETBIT(ADCSRA,ADSC)        //Macro to start ADC conversion.
//#define ADC_STOP_CONV()        CLEARBIT(ADCSRA,ADSC)    //Macro to stop ADC conversion.
#define ADC_CLEAR_ADIF()     CLEARBIT(ADCSRA,ADIF)        //Macro to clear ADC Interrupt flag.

#define VREF 4.96        //Defines the VREF used.
/*            Value in Volts = ADC Value * (VREF/1024)
            ADC resolution = 4.96/1024 = 4.84mV            */
/*************************************************************************************
                    ACD initialization routine
*/

void ADC_init(void)    //Function used to initialise the ADC Module.
{
    ADMUX = 0x45;         //Select the channel ADC5, AVcc, ADC right adjust, chn=0-5
    ADCSRA = 0x83;     // 

    _delay_ms(150);     //Provide adequate delay to initialise the analog circuitry.

}


#define ADC_read() ADC
/* To read & return adc value from a channel (chn=> 0 to 5)    */
#define SetCH(chn) ADMUX=(ADMUX & 0xF0) | (chn & 0x07)
                                        // 07- because Max 5 channels for ATM8
int ADC_readch(unsigned char chn)       
{
    ADMUX= (ADMUX & 0xF0) | (chn & 0x0F);
    ADC_CLEAR_ADIF(); //Clear ADC Interrupt Flag
    ADC_START_CONV(); //Start ADC Conversion.
    while(!(CHECKBIT(ADCSRA,ADIF)));//wait for conversion complete
    return(ADC_read());//----read values & return
}

/* TO READ FROM CURRENTLY SET CHANNEL IN ADCMUX.
    Note: This function doesn't change the ADC channel & uses the value set in ADCMUX
          So set the required channel before calling this function   */

int ADC_readcurch()       
{
    ADC_CLEAR_ADIF(); //Clear ADC Interrupt Flag
    ADC_START_CONV(); //Start ADC Conversion.
    while(!(CHECKBIT(ADCSRA,ADIF)));//wait for conversion complete
    return(ADC_read());//----read values & return
}

/***/


Output:

Search Here...