Total Pageviews

Tuesday, 22 August 2017

Count Down Timer using ATMega 8


Count Down Timer using ATMega 8

            A countdown timer is a down counter that counts from a specified time to 00:00. It is used in many devices such as washing machine, televisions, microwave ovens, etc. This countdown timer has three states: the running state where it counts down, the pause state where it displays the paused time and the reset state to set the countdown. The countdown is displayed on a set of four seven segment displays using the ATMega 8 microcontroller. A buzzer beeps when the countdown gets over.












   

  I/O Port Map: 






























Snippets of Code :

     1)      To enable INT0 and INT1 :
          GICR =(1<<INT1)|(1<<INT0); MCUCR =0b00001010; sei();

         2)      To perform ADC :
      ADCSRA = 0x8F|(1<<ADFR);  ADMUX = 0xC0|ADC_Channel;  sei();  ADCSRA |= 1<<ADSC;

         3)      To initialize Timer 1:
      TCCR1B |= (1 << CS12)|(1<<CS10); TCNT1 =_________;TIMSK|=(1<<TOIE1); sei();

         4)      To initialize Timer 0:
      TCCR0 = (1 << CS02)|(1 << CS00);  TCNT0 =0;     TIMSK |= (1 << TOIE0); sei();

         5)      To select the various digits in 4 -  Seven Segment Display :
          Digit 1 : PORTB = 0b00001110;   // Common Anode
          Digit 2 : PORTB = 0b00001101;
          Digit 3 : PORTB = 0b00001011;
          Digit 4 : PORTB = 0b00000111;

         6)      Interrupt Service Routine :
          INT 0    :    ISR ( INT0_vect )
          INT 1    :    ISR ( INT1_vect )
          ADC     :    ISR ( ADC_vect )
          Timer 0 :    ISR ( TIMER0_OVF_vect )
          Timer 1 :    ISR ( TIMER1_OVF_vect )


   Psuedo Code :

    main()
  {
      //  Initialize the I/O as INPUT or OUTPUT
      //   Use PULL – UP mode for Inputs
      //   Initialize ADC Channel
      while(1)
      {
          // Continuously display values on Seven Segment Display
          // If time = 00:00 , blink and beep
       }
  }

   ISR ( TIMER1_OVF_vect )
  {  //  Decrement seconds value by 1
      //   Initialize Timer 1 again 
   }

   ISR ( ADC_vect)
  {   // Store the ADC0 channel value which corresponds to Minutes
       // Store the ADC1 channel value which corresponds to Seconds
       //  Initialize ADC again
   }

  Prototype:          

  




        Video :

   

Sunday, 14 May 2017

USB to TTL Converter using MCP2221


USB 2.0 to UART/I2C Protocol Converter

            The USB to UART/ I2C converter enables USB connectivity in applications that have I2C and/or UART interfaces. It behaves like a standard serial port to the Operating System. Hence the existing Terminal softwares such as (Putty) and Terminal programs could be used. The TX and RX lines of the programmer are used for asynchronous serial communication. When the USB-TTL adapter receives a byte from the computer via USB, it will transmit that byte on the TX line and when it receives a byte on the RX input line, it will send that byte back to the computer via USB.

The bytes are sent and received eight bits at a time, with no parity and one stop bit. This coding is sometimes abbreviated 8N1. The bits must be non-inverted, meaning that a zero is sent as low voltage, and a one is sent as high voltage. All devices involved in asynchronous serial communication need to agree ahead of time on the duration of one bit (the baud rate), so all devices must be independently configured to run at the same baud rate before they will be able to communicate with each other. The USB-TTL adapter supports all integer baud rates from 110 to 115200 bits per second. 

Circuit :
         The circuit is built around MCP2221, which helps the protocol conversion. It reduces the need for external components by integrating the USB termination resistors and oscillator needed for USB operation. Hence the USB 2.0 can be used with full speed (upto 480 Mbps).


Using the Adapter :

       1)      Plug the adapter into a computer.
              




   2)    Go to Device Manager. The system doesn’t recognize the device since the drivers aren’t installed
 4)    Under the section: Documentation , download MCP2200/MCP2221 Windows Driver &        Installer and install it.
       5)    Once the drivers are installed the system should recognize the adapter  
       6)    Download MCP2221 I2C SMBUS Terminal application , install it and open it.
       7)    Under Settings , select the Device and set the Baud Rate.







 Prototype :

      

   
        
                 
      





Saturday, 21 January 2017

Student Database using LabVIEW

Student Database using LabVIEW

                                  To manage the student database , a software was developed using LabVIEW which would help the event organizers have a track of the list of events in which each student participated in that academic year . A concept of ELCOM XP was introduced wherein each student participating in an event is awarded some participation points. Winners of each event are awarded additional points. Depending upon the ELCOM XP, the levels are allocated. The participant levels up after acquiring the necessary ELCOM XP.    
Login Page :
                               The first page contains text-boxes for the user to enter the login credentials . After entering the details the user should press the next button. The software then checks the username and password and takes the user to the next tab if the details are correct. The clock designed by overlapping three gauges to indicate the hours, minutes and seconds shows the current system time.



  Database Search :  
                                     The users can search for any student details using this tab. Search can be carried out in three ways namely
       1) Search by Register Number
       2) Search by Name
       3) Search by Phone Number

           The software automatically searches for the text entered in the text box and updates the list-box with the matching records. The user can select the desired student record from the list-box. The software computes the student’s necessary details such as Campus , Department and the current Year of  Study from the students register number and displays it on the screen . The event details along with their corresponding round details are also displayed. Using an algorithm the software computes the student's XP and their current Level.  




  Add to Database :
                                                    This tab helps the organizers  enter the details of the students and their corresponding round details. To   make it convenient , the software was designed in such a way that it automatically generates the students register number depending upon their current year of study , and searches for student record with that particular register number and updates the database with their round details. The organizers should select the student’s current year and enter the Event Name and Event Number . 

  

   Leader-board :
                                    The software computes and arranges the student records depending upon the ELCOM XP and displays it . Also the details are written to a spreadsheet and a hard copy of which can be used for official records.  This lets the organizers find the active participants . Higher ELCOM XP indicates that that particular student has taken part in maximum events organized by ELCOM Dias in that academic year.
          
( Names of the students have been removed purposefully for privacy)

   Add Event Details :
                                   This tab lets the organizers enter the details of their event. A separate document is created for each event (entry ) and the document is saved with the event name. It contains a detailed description about each round of the event , the names of event organizers and the winners list.           






     View Event Details :
                   This tab lets the organizers view the details of various events. The folder containing the documents should be selected first. The list box would automatically get updated with the names of the document. The organizers can then browse through various events by selecting it from the list box. This document contains the detailed description about that particular event.





    Statistics :
                                           This tabs lets the users find the number of participants in each event and make an analysis. The software plots a graph and displays the number of participants in each event.





      

        

Sunday, 28 August 2016

USBASP Programmer for ATMEL AVR Microcontrollers

USBASP Programmer for ATMEL AVR Microcontrollers :

                   USBASP is a USB in-circuit programmer for ATMEL AVR Microcontrollers. It consists of Atmega 8 and a few passive components . The programmer uses a firmware and a USB driver . It was constructed taking  Thomas Fischl's circuit as reference

Circuit :



Features :

  i)       No special components are required
 ii)       Allows us to read or write the microcontrollers EEPROM , Firmware , fuse bits and lock bits
iii)      Programming Speed : 5 KB/sec
iv)      Works with multiple platforms such as Linux , Windows , iOS
 v)      Slow SCK option to support slow targets ( less than 1.5 MHz )
vi)      Serial Interface for target

Supported Software:

  i)         AVRDUDE supports USBASP
 ii)         eXtreme Burner - AVR
iii)         AVR Burn-o-mate

Prototype :
  
 

      Installation of WINAVR :
             1)      Install  WinAVR-20100110-install.exe
             2)      For Windows 8.1 and 10 , open the folder Winavr fix (win 8.1 and 10)     
             3)      Copy the file msys-1.0.dll to C:\WinAVR-20100110

     AVR Burn-O-Mate :
             Upon installation the following changes should be made :
            1)      Click on Settings > AVRDUDE
            2)      Change AVRDUDE location to
                 C:\WinAVR-0100110\bin\avrdude.exe
            3)      Change alternative AVRDUDE configuration File to
           C:\WinAVR-20100110\bin\avrdude.conf
            4)      Click on Apply and then Ok and close AVR Burn-O-Mate
            5)      Again Open the software and go to Settings > AVRDUDE
            6)      Under AVRDUDE options select the programmer to be usbasp
            7)      Select the port as usb
            8)      Click Apply and Ok and restart the software

      Uploading the Firmware:
              Any microcontroller can be turned into a programmer. Here I have chosen ATmega 8 .  The following steps must be followed :
            1)      Connect the self programming jumper to upload the firmware into Atmega8, for it to behave as a programmer.
            2)      Open the software AVR Burn-O-Mate and select the AVR Type as Atmega8
            3)      Click on Fuses and de-select the fuses CKSEL3 , CKSEL2,  CKSEL1, CKSEL0            

           4)      Select the destination of the Firmware

           5)      Press the write button to upload the code to the microcontroller

     Installation of Drivers:
           1)      Open Zadig and select Options>List all devices
           2)      Select the Programmer USBasp from the drop down list box
           3)      Install the driver libusb-win32 (v1.2.6.0)

    Testing the Programmer :
  1. Connect the programmer to the laptop. 
  2. Open Device Manager and check if the programmer is shown       
  
       3.  If the programmer isn't working, the system says "USB device not recognized"
     


Troubleshooting :

   1.  Connect the programmer to the system using an USB A to B cable
   2.  Ensure that the programmer receives + 5 Volts at the terminals of the USB - B Socket
   3.  Ensure that the red led bulb glows .
        

 4. While the programmer is still connected to the system , gently place the hot tip of the soldering iron on the data line . The system should soon recognize the programmer . This is because the the data line wasn't soldered properly to the USB - B socket previously .
   


    Using USBasp to program other Microcontrollers:
          
            1)      Connect the 6 pins ( GND, Vcc, Reset, SCKk, MISO, MOSI) of the programmer to the corresponding pins of the target microcontroller


             2)      Short the header pins near Vcc to use the power supply from the pc
             3)      To check whether the connections are correctly made, open Command Prompt and type
                     avrdude –c usbasp –p m8
                              here m8 stands for Atmega 8 (target)
                                      m16 – Atmega 16  (target)
                                      m32 – Atmega 32 (target)
             4)      If the connections are perfect , the following message would be displayed
       
              5)      Open AVR Burn-O-Mate and select the target microcontroller and the destination hex file .                   Click on Write to program it.

  Using Arduino IDE to program any Atmel microcontroller :


1)      Disable the internal clocks of Target microcontroller. This can be done by unchecking the fuses CKSEL3, CKSEL2, CKSEL1, CKSEL0. It is to be noted that Arduino IDE supports only external crystal.
2)      Connect the programmer to the target microcontroller
4)      Select the appropriate json file for the corresponding microcontroller. To program Atmega 8 with Arduino IDE , copy the URL https://mcudude.github.io/MiniCore/package_MCUdude_MiniCore_index.json
5)      Open Arduino IDE. 
6)      Select File > Preferences and paste the URL in Additional Boards URL
7)      Click Ok. Select
     Tools > Boards : > Boards Manager
8)      Search for MiniCore by MCUDUDE and install the board.
9)      Once the Installation is complete go to Tools > Boards and select  Atmega8
10)  Choose the programmer as USBasp and set the appropriate  external clock frequency

Now the code can be developed with Arduino IDE . It must be noted that USBasp doesn’t use COM Port for programming unlike UNO board. Hence Port section under Tools would disabled

11)   To Program the code select
Sketch > Upload using Programmer

    Limitations :

i)   This circuit can only be used for programming 5V target systems. For other systems a level converter is needed
ii)    The firmware doesn't support USB Suspend Mode. A bidirectional serial interface to slave exists in hardware but the firmware doesn't support it yet.

     Download Links :

      Firmware                                       -   http://goo.gl/3P7SLl  
      AVRDUDE                                     -   http://www.nongnu.org/avrdude/
      Zadig                                             -   http://zadig.akeo.ie/
      WINAVR                                        -   https://sourceforge.net/projects/winavr/