Most viewed

3 Dec 2011

C PROGRAM TO CLEAR SCREEN WITH OUT USING clrscr() FUCTION


Author shahabaz:

This program is very simple and easy, you all might be thinking how could I do such thing with out using a clrscr(); function. (NOTE: Am talking for turbo c editor as well if this code does not wotrk on other edit please alter it). Lets have the code.



#include<stdio.h>
int main(){
int i,j;
   for(i=0;i<27;i++){
     printf("\n");
     for(j=0;j<80;j++)
       printf(" ");
      }
 gotoxy(1,1);
return 0;
}



Be sure with the code while editing

30 Nov 2011

AVR Programming Software


AVR BASCOM Compiler





PonyProg2000.gif

    PonyProg200 supports the following AVR Microcontrollers:
  • AT90S1200, AT90S2313, AT90S2323, AT90S2343, AT90S4414, AT90S4434, AT90S8515, AT90S8535
  • AT90S2323, AT90S2343, AT90S2333, AT90S4433, AT90S4434, AT90S8535, AT90S8534
  • ATmega103, ATmega161, ATmega163, ATmega 323, ATmega128, ATmega8, ATmega16, ATmega64, ATmega32, ATmega162, ATmega169, ATmega8515, ATmega8535
  • ATmega44, 88, 168, 164, 324, 644, 640,1280, 1281, 2560, 2561 (untested)
  • AT90can32, 64, and 128 (untested)
  • ATtiny12, ATtiny15, ATtiny26, ATtiny2313
  • ATtiny13, 25, 45, 85, 261, 461, and 861 (untested)

USB Port Programmer




Description

This is a USB in-circuit programmer for Atmel AVR controllers. It simply consists of an ATMega8 and a few passive components. The programmer uses a software USB driver, no USB controller is needed.
    Features:
  • Programs most AVR microcontrollers
  • Works under multiple platforms. Linux, Mac OS X and Windows are tested.
  • No special USB controllers or smd components are needed.
  • Programming speed is up to 5kBytes/sec.
  • Works with the programming software AVRDude
USB Port Programmer
Downloads
FileDescriptionFile size
Download this file (libusb_0.1.12.zip)libusb_0.1~.zipWindows Driver for the USB ISP Programmer69 Kb
Download this file (usbasp_atmega48_2009-02-28.hex)usbasp_atm~.hexHEX file for the ATMega4810 Kb
Download this file (usbasp_atmega8_2009-02-28.hex)usbasp_atm~.hexHEX file for the ATMega810 Kb

Parallel Port Programmers


Sample Electronics Programmer

This is the schematic for the AVR Parallel Port Programmer, also called the Sample Electronics or DT006 programmer, it can be used with the popular ISP programmers Bascom and PonyProg

IC-Prog Programmer

This is another AVR Parallel Port Programmer, also called the FunCard Programmer, it can be used with the programmer software Ic-Prog
Parallel Port Programmer Funcard

AVR Serial Port ISP Programmer




This is the schematic of a Serial Port Programmer for the popular programmer software PonyProg and avrdude.
Features:
  • Connects to PC via RS232 port (note: It will not work with USB to RS232 converters!)
  • No need for external power supply as it takes the power supply from target board.
  • It uses Atmel's 2x5 pin ICSP connector layout
  • avr serial port isp programmer sch.png

    AD Convertor


    AD Convertor

    Description

    An analog to digital converter converts a analog input voltage into a digital value. The resolution of the converter indicates the number of discrete values it can produce. It is usually expressed in bits. For example, an ADC that encodes an analog input to one of 256 discrete values has a resolution of eight bits, 28 = 256. Most ADCs are linear, which means that they are designed to produce an output value that is a linear function of, i.e. proportional to, the input. In this example the AT Mega8 is used, it has 6 AD-converters which have a resolution of 10 bits so it has 210 = 1024 discrete values. In his example a potmeter is connected to the portC.0 of the Mega8 and a LCD module of 20x4 characters is connected to portD. The LCD module displays the values that are measured on the ADC port. The values are presented on the display as discrete values (0 to 1023), the percentage (0 to 100%) of the values and in a bargraph display.
    AD Convertor

    Software

    The software of this example is written in the BASCOM AVR program language. BASCOM has build in commands for reading from an ADC port, the A/D convertor of the Mega8 has to be configured first before it can read:
      Configuration
    • ADC = single / ADC = free
    • PRESCALER - a numeric constant for the clock divider. AUTO lets the compiler generate the best value for the used crystal.
    • START ADC - puts the port in the ADC mode.
    • V = GETADC(channel) - reads the A/D value from the selected channel.
    ADC_1.jpg
    ADC_2.jpg
    Downloads
    FileDescriptionFile size
    Download this file (AD Convertor.bas)AD Convert~.basAVR BASCOM source file2 Kb
    Download this file (AD Convertor.HEX)AD Convert~.HEXhex file3 Kb

    Blink A LED


    Blink a LEDBlink a LEDblink a led

    Description

    For beginners the first thing to try on a new system or in a new programming language is to print out "hello world". The equivalent for microcontrollers and other embedded systems is to blink a LED. When even the target circuit and the programmer are freshly put together it is wise to start even lower, with a blink-a-LED program written by someone else that is known to be working.
    On this page you will find a 1 Hz blink-a-LED test programs for the Tiny12 and the AT2313 targets chips and circuits. You can build the circuits on a breadboard or use the AT2313 ISP board. The programs are made in assembler with AVR Studio 4 for the ATTiny12 and with the BASCOM complilor for the AT2313. Look on the AVR Programming Hardware pages for how to make a programming cable and on the AVR Programming Software pages for the software to get the hex file into your device.
    Because the ports of the AVR chips can draw 20mA current, only a resistor to limit the current is neccesary to connect a LED to one of the ports. In both the circuits the LED is connected to PortB.0. In the circuit for the ATTiny12 the internal 1.2 MHz oscillator is used, because of that you don't need an external oscillator, but it can be configured also for an external crystal. The ATTiny2313 can also be used with his internal oscillator.
    Downloads
    FileDescriptionFile size
    Download this file (Blink a LED Tiny12.aps)Blink a LE~.apsAVR Studio 4 project files for ATTiny122 Kb
    Download this file (Blink a LED Tiny12.HEX)Blink a LE~.HEXhex file ATTiny120 Kb
    Download this file (Blink a LED Tiny2313.bas)Blink a LE~.basAVR BASCOM source file ATTiny23130 Kb
    Download this file (Blink a LED Tiny2313.HEX)Blink a LE~.HEXhex file ATTiny23130 Kb

    IIC EEPROM Interface





    Description

    I²C is an abbreviation of Inter Integrated Circuit and is a protocol for serial communication between Integrated Circuits, it is also called Two Wire Interface (TWI). The bus is used for communication between microcontrollers and peripheral devices like memories, temperature sensors and I/O expanders. An EEPROM is a Electrically Erasable and Programmable Read Only Memory.
    The communication of the bus goes along two lines: SDA (Serial Data) and SCL (Serial Clock). Each I²C device has a unique 7-bit adress (Device Select Code). The most significant bits are fixed and assigned to Aa specific device catagory (e.g. b1010 is assigned to serial EEPROMS). The three less significant bits (A2,A1 and A0) are programmable and used to adress the device. The three bits allows eight different I2C adress combinations and therefore allowing up to eight different devices of that type to operate on the same I2C-bus. The 7-bit adressing allows up to 128 devices on the same bus. The I2C adress is send in the 1st byte, the lest significant bit of the first byte is used to indicate if the master is going to write(0) or read(1) from the slave.
    The device that sends data along the bus is calledmaster, a device that receives the data is calledslave.The master starts the transmission with a start signal and stops the transmission with a stop signal on the SDA line. During the start and stop signals the SCL line has to be high. After the master has started the data-transmission with a startsignal, the master writes a device adress byte to the slave. Each databyte has to have a length of 8 bits. The slave has to acknowledge the reception of the databyte with a acknowledge-bit (ACK).
    A write operation requires a device adress bytes, two adress bytes and the data-byte. Upon receive of the adress the EEPROM sends an ACK and then clocks in the data-byte. The EEPROM sends again an ACK and the microcontrollers sends a stop-signal to terminate the write sequence.

    Hardware

    In this example the AT24C32 EEPROM of Atmel is connected to a AT2313 microcontroller. There is also a LCD display hooked to the microcontroller to display the data. The 24C32 has 4096 bytes of memory. The SCL and SDA lines of the EEPROM are connected to PORTD.0 and PORTD.1 of the microcontroller. Below is the schematic how it is connected. Go also here to see how you can hook up a LCD module to the microcontroller.

    Software

    The BASCOM-AVR compiler is used to make a program that writes and reads one byte from the EEPROM. AVR-BASCOM has several commands embedded to control the I2C bus. Below you can see the commands:
    BASCOM I2C commands
    CommandDescription
    Config SDAConfigure the SDA line e.g. PORTB.0
    Congif SCLConfigure the SCL line e.g. PORTB.1
    I2cstartgenerates a start condition
    I2cstopgenerates a stop condition
    I2cwbytewrites a byte to the target device
    I2crbytereads a byte from the target device
    In BASCOM-AVR you first have to configure the ports you use for the SDA and SCL lines of the I2C bus. Then you send the device adress to select the EEPROM that is connected to the I2C bus. After that you send two bytes to the EEPROM to select the adress in the EEPROM to which you want to write the data. The last byte to send in a write sequence is the data byte.
    Below you see the code for the example program. The program writes a byte from variable D_wr into the EEPROM at adress 0 and then reads the byte from the EEPROM at adress 0 and puts it into the variable D_rd, which is then displayed on the LCD module.
    *****************************************************************************
    ' * Title : EEPROM 24C32.bas
    ' * Last Updated : 05.03.2006
    ' * Target device: At90s2313, 24C32
    ' * Author : www.avrprojects.net
    ' * Program code : BASCOM-AVR
    ' * Hardware req. :
    ' * Description :
    ' * This application reads and write a byte to an 24c32 EEPROM connected to an
    ' * AT2313 microcontroller.
    ' ****************************************************************************
    Dim D_w As Byte , D_r As Byte
    
    Config Lcdpin = Pin , Db4 = Portb.3 , Db5 = Portb.2 , Db6 = Portb.1 , 
    Db7 = Portb.0 , E = Portb.6 , Rs = Portb.7
    
    Config Lcd = 16 * 2
    Cls
    Cursor Off
    
    Config Scl = Portd.0 'assign the SCl line to PORTD.0
    Config Sda = Portd.1 'assign the SDA line to PORTD.1
    
    D_w = 100
    
    '********** write byte to EEPROM ***********************************************
    I2cstart 'generate start
    I2cwbyte &B1010_0000 'send device address
    I2cwbyte 0 'H adress of EEPROM
    I2cwbyte 0 'L adress of EEPROM
    I2cwbyte D_w 'data to EEPROM
    I2cstop 'stop condition
    Waitms 10
    
    '********** read byte from EEPROM **********************************************
    I2cstart 'generate start
    I2cwbyte &B1010_0000 'send device adsress
    I2cwbyte 0 'H address of EEPROM
    I2cwbyte 0 'L address of EEPROM
    I2cstart 'repeated start
    I2cwbyte &B1010_0001 'slave address (read)
    I2crbyte D_r , Nack 'read byte from EEPROM
    I2cstop 'generate stop
    
    Lcd "D_w= "
    Lcd D_w 'show byte on LCD
    Lowerline
    Lcd "D_r= "
    Lcd D_r
    End
    
    In the picture below you can see how a write sequence looks on a oscilloscope. The upper signal is the SCL line and the lower signal is the SDA line. You can easely recognise the device adress 1010 at the start of the sequence.
    Downloads
    FileDescriptionFile size
    Download this file (I2C EEPROM Interface.bas)I2C EEPROM~.basAVR BASCOM source file2 Kb
    Download this file (I2C EEPROM Interface.HEX)I2C EEPROM~.HEXhex file2 Kb

    LCD@AVR






    Description

    This page describes how to connect a Liquid Cristal Display to a AVR-microcontroller. The example is based on a LCD module with the Hitachi HD44780 LCD-controller.You can get these displays in various kinds, from 1 to 4 lines and from 8 to 40 characters per line. A display with 16 characters per line and 2 lines is used in this example. The display uses a power supply of 5V DC. Connecting of the display to the AVR-microcontroller is easy.
    The display module has 8 data lines and 3 control lines. The 8 data lines are used to send data or instructions to the module. Instructions that can be send to the display are for example clearing the display or set the cursor. The control lines are of course used to control the display.
    The 8 data lines can be used as a 4-bit bus or as a 8-bit bus. In the 4-bit bus mode the data and instructions are send by 2 groups of 4 bits after each other so the program code will be more then when the 8-bits bus is used. In this example the 4-bits bus is used, this saves 4 connections and because of that the display can be controlled by only one 8-bit port of the AVR microcontroller.
    The line Enable controls the display. If it is high the data on data bus is put in the register of the display. If the line is low all the data lines are tri-state, what means that they are not connected to the microcontroller. You can see this as a switch that is open.
    The line Read/Write enables reading from or writing to the display. If the R/W signal is low data can be written to the display, if it is high data can be read from the display. This is useful if you want to know if the module is ready to recieve new data.
    The line Register Select selects if the data send to the display are instructions for the display or characters that have to be shown on the display.
    In the table below you can see the pin assignment of the LCD module

    Hardware

    In the table below you can see how the LCD module is connected to the AVR-microcontroller.Because the display is used in the 4-bit mode, 4 lines of the data bus are not connected.The signal R/W has to be connected to GND so the display is always in the write mode. The pins 15 and 16 are used to connect the supply for the LED-backlight of the display, if it is present at the module. If you use 5V DC you need to place a resistor to limit the current. With a trimpotmeter of 10K connected at pin 3 (VO) of the display the contrast can be set.
    Below is the schematic that shows you how to connect the LCD to the AVR microcontroller via a 10 pole flatcable with a 10 pin connector. The 10 pin connector can be plugged into the 10 pin header of the STK500 Board or the ATTiny2313 ISP Board.
    The LCD module connected to the AT2313 Project Board.

    Software

    To control the display you can use BASCOM or Assembler. BASCOM has special commands for configuring and driving a LCD Display. In the table below you see the LCD commands and their functions.
    To control the LCD display you need to implement the instructions in your program code. First you have to configure the display, which type of display you use (number of lines and number of characters on a line), to which pins of the microcontroller the lines of the LCD module are connected and which mode you use, 4-bit mode or 8-bit mode (default is 4-bit mode). Below is an example program of how to write text to the LCD display.
    Downloads
    FileDescriptionFile size
    Download this file (
 <script language='JavaScript' type='text/javascript'>
 <!--
 var prefix = 'ma' + 'il' + 'to';
 var path = 'hr' + 'ef' + '=';
 var addy20159 = 'LCD' + '@';
 addy20159 = addy20159 + 'AVR' + '.' + 'bas';
 document.write( addy20159 );
 //-->\n </script> <script language='JavaScript' type='text/javascript'>
 <!--
 document.write( '<span style=\'display: none;\'>' );
 //-->
 </script>This e-mail address is being protected from spambots. You need JavaScript enabled to view it
 <script language='JavaScript' type='text/javascript'>
 <!--
 document.write( '</' );
 document.write( 'span>' );
 //-->
 </script>) LCD@AVR.basAVR BASCOM source file0 Kb

    Pulse Widfth Modulation Fading LED




    Description

    Pulse Width Modulation allows microcontrollers to dim lights, control motor speeds, fan speeds and generate analog voltages. By changing the length of the pulse, the output can be controlled. The pulse occurs at a regular frequency, the modulation frequency. The length of the pulse ratio to period time is called the duty cycle.The larger the duty cycle the higher the output is.
    swave.gif
    The AVR microcontroller can be used to generate PWM signals. The PWM signals can be generated by hardware or by software. An microcontroller like the ATTiny2313 has one hardware PWM on board of the chip. The output of the PWM signal is at the PORTB.3(OC1) pin.
    The hardware PWM can be programmed by setting the timer registers. The ATTiny2313 has three timer registers that you need to set to program the PWM:
    1. The Timer/Counter1 Control Register (TCCR1A) is to put the timer in PWM mode.
    2. The Timer/Counter1 registers (TCNT1H and TCNT1L) are used to set the modulation frequency.
    3. The Output Compare Register1 (OCR1A) is used to set the duty cycle.
    PWM with the AVR-microcontroller is a matter of comparison. If the Timer/Counter1 is running and the value of the timer is matching the value that is put in the OCR1A register, the OC1 pin changes from high to low. By changing the value of the OCR1A register the lenght of the pulse can be changed.

    Hardware

    The PWM output can be used to fade a LED in and out. On the picture you can see the LED on a bread-board connected to the ISP-board with a flat-cable.
    PWM Fading LED
    Downloads
    FileDescriptionFile size
    Download this file (PWM Fading LED.zip)PWM Fading~.zipAVR Studio 4 project files for ATTiny23134 Kb

     

    Based on your view




    You have to try this

    This is trending now #