December 26, 2011

Displaying string on Dot Matrix Display(Proteus simulation)

In earlier posts we have discussed about how to display alphanumeric characters on a single block of 5x7 dot matrix display.  but now it is time to move on to display characters on a series of blocks. basic concept remains same.  Only two things are new here
  1. Buffer with tristated output (74 LS 541)
  2. De-multiplexer(74 LS 138)
Buffers here are used to isolate other blocks while accessing a single block.
Let us say we want to dispaly 'Y' on 3rd block so at that time we must not disturb other blocks so we have tristated(in rough term disconnected ) them to prevent from any changes.


De-multiplexers are used to decode address of the destination block. Assume we are having 30 blocks to display in that case we can't give separate enable pin to each Buffer that's why if we are having a 5to32 demultiplexer we can address up to 32 blocks with help of only 5 pins of microcontroller.
Here in my design i only wanted to display 5 Characters simultaneously so i used 3to8 demultiplexer(decoder).



dot matrix display proteus avr
5x7 Dot matrix display in proteus


by inserting some decoding mechanism in our program and using earlier made header file we are all set to display a message 'KEYUR' on the blocks. the program is as shown below



#include"avr/io.h"
#include"delay.h"

#include"dotmatrix.h"
void main()
{

            DDRA=0xFF;          
            DDRB=0xFF;
            DDRC=0xFF;
            while(1)
            {
            PORTB=0;    //select first block
            display('k',1);
            PORTB=1;    //select second block
            display('e',1);
            PORTB=2;    //select third block
            display('y',1);
            PORTB=3;    //select fourth block
            display('u',1);
            PORTB=4;    //select fifth block
            display('r',1);
          
            }
          
}


we can further minimize the program by making a function to display message on series of displays.

final output may look like this
string on 5x7 dot matrix display
A creative imagination you will not see this in software
here is the source code, header file, Proteus ISIS design file and .hex file for AVR Atmega 8535 Microcontroller.

      I figured it out that this source code and circuit diagram is not only for a string displaying on dot-matrix.But if you want to design NxNxN (3X3X3,8X8X8,anything ) cube of LEDs to display some fancy patterns this circuit design and coding will be like a base guide for you.

  That cube display will be more attractive than this one displayed above but i found above one more commercial to make.


1           2            3
Read more ...

Creating Characters on Dot matrix display (Proteus Simulation)

In earlier post we have seen how to make a single LED,a Row  or a Column ON. But that's not enough when we want to generate a character like 'K' on a display so what we have to do for that?


Here comes a principle from physics called "Perception of eye" I hope all have studied about that in high school so not discussing more about that in detail just keep in mind that if we constantly change our ON LED we can make an image like any character on human eye.



so

 +

 +

 +

 +


  =

alphanumeric character in dot matrix display
alphanumeric character on dot matrix


this is the magic of perception of eye principle if you will repeat above 5 images at enough faster rate you will be able to see a  'K ' character.



Doing this with microcontroller is damn easy thing.

just try following code in your AVR 8535 microcontroller to see the character being displayed.


//program to display K on dot matrix display

#include"avr/io.h"
#include "delay.h"


void main(void)
 {  
    DDRA=0xFF;            // Port A data direction declaration as out put.
    DDRC=0xFF;          
// Port C data direction declaration as out put.
    while(1)      
    {
    PORTA=0b00000001;            //column 1
    PORTC=0b10000000;          
    delayms(1);
    PORTA=0b00000010;            //column 2
    PORTC=0b11110111;
    delayms(1);
    PORTA=0b00000100;            //column 3
    PORTC=0b11101011;
    delayms(1);
    PORTA=0b00001000;            //column 4
    PORTC=0b11011101;
    delayms(1);
    PORTA=0b00010000;            //column 3
    PORTC=0b10111110;
    delayms(1);
    delayms(1000);
    }
  
}

the circuit diagram for above program is given below...


with this all you can make all your  characters and display them on dot matrix display.


Once you are through with all your characters making you can group them in a standard header file to use later.you can read my earlier post  "how to make a header file?" for the help.

this is good if you want to display something on a single block of dot matrix display but what if you want to display a message such as "KEYUR" on a series of blocks????

1    2      3
Read more ...

Dotmatrix LED(5x7)

I was always fascinated to see the large boards made of  red LEDs and i always thought that some day i will make it i hope you also have same thoughts that's why you are on this page, right?
So let us start with what is a basic dot matrix LED connection?
It is connections of LED in such a way that more LEDs can be accessed by less no. of micro controller pins.


as you can see in figure.


Internally, the LEDs are organized in a matrix. Here's a 5x7 display internal wiring (requires a minimum of 13 pins, likely to be shipped in a 14 pins package).
so you can access 35 LED with just 13 pins of microcontroller isn't it a great deal?

Now got enough information about dot matrix so let us start with how to use them?

Basically you can turn on those LEDs to which you supply proper forward biasing all the game starts from here.
see in the figure if you want to make left top corner LED(we want to turn on only one LED right now note that) you have to give a high to 1 pin and a low to A pin.
but if you observe something you will come to know that if we apply low to rest of the B to G pins whole first column  will glow up but that's not we want. so we have to give A=low and B-G=high to make a LED on.

Hey wait did you again observe something? let me tell you that if we have A=low and B-G=high that's fine but what about the pins 1-5? so if we have 1-5=high and A=low and B-G=high we will get the first row on because of the connections so now what to do ?
we can again  change our configurations to 1=high, 2-5=low, A=high, B-G=low.

huh, so is that enough to turn on single LED on your display..?

yes that's all you have to do to make different LEDs on.
Now you have the power to turn on any desired LED of 5x7 matrix.


Are you happy with this thing?
if yes then what about displaying characters on matrix.


1      2        3

Read more ...

December 25, 2011

How to learn PLC?

Hello, friends I have been so much fascinated about PLC  since I have read about it.
Here is a best book which you can use to study PLC (which I am using) this is a great book which can tech PLC from scratch. It is as easy as reading a book you can use Nationa Instruments Multisim this is the best software for simulating PLC(as far as I have found)


here are some pics. of basic PLC circuits made by me
seal in circuit






oscilations
Read more ...

October 22, 2011

DAC by PWM (Proteus Design)

As i was reading a book "Embedded systems" by Rajkamal I found some thing interesting on Page 15 that was "DAC using PWM". Then I tried to implement it on my own as it was an interesting idea to generate Analog voltage from only one pin of micro controller.


so here is another post demonstrating the magic of AVR Atmega 8535.

Normally for DAC we have to use 8-pin and it is always good to use less pins.

Here we have to use only one pin to generate PWM and then Integrate the wave to make analog output.I have used an op-amp integrator(low-pass filter) .

I have used program made by me earlier that generates PWM according to potentiometer varied.
Just adding a next stage to it i gave that pwm pulse to an Op-amp based integrator.
Here is the rar file given which contains Proteus ISIS design file and source code to generate PWM in AVR atmega 8535.

The design is made for test purpose only to check the concepts, hardware is not built and tested  so enough care must be taken before converting this design file to actual hardware.

Hope the new concept is good for implementing.

:)
Read more ...

October 21, 2011

Bidirectional Motor With 1 Pin of Microcontroller (Proteus Simulation)


How to drive a motor with a single pin of microcontroller?
A tough question but I have got the answer and the answer is “H-bridge connection”
Now you may be think that normally all the motors are driven by H-bridge connection and it would be even easier to drive them with motor driver IC so what is new here?
Here is a new configuration that can drive entire H-bridge with a single pin of micro controller, but for that you have to insert some extra hardware in that
A simple configuration is given below…
Bidirection Motor control


                    You can change the frequency of pulse to change the speed of motor and you can also vary PWM to generate asymmetric motor drive, and this entire thing at the cost of just one micro controller pin

                    we can easily stop the motor by tri-stating the microcontroller pin by just two simple lines of code that is 

   DDRB=0x00;
   PORTB=0X00;

                    But when working with Proteus you realize that some things are out of your control, i mean to say that when port pin is not connected to H-bridge it is tri stated properly but as soon as you connect it to bridge your tri-stated output is magically "converted" into ground that's why i could not include "stop motor" action in this demo.
                    Here I have just used a simple program to generate a 2 second delay and run motor in clockwise or anticlockwise.
                   The program is written for Atmega 8535(crystal frequency=16Mhz ; I am using earlier made header file)
  
#include"avr/io.h"                     
#include "delay.h"

void main(void)
 {        
            DDRB=0x08;                                   // Port B data direction declaration as output.
            PORTB=0X00;
            while(1)                               //This is for the infinity loop.
            {         
             PORTB=0X08;
             delayms(2000);                //2 second delay
             PORTB=0X00;
             delayms(2000);                //2 second delay
            }
}

You can download source code file for this project and ISIS Proteus design HERE.
Read more ...

October 20, 2011

Password protect your microcontroller

Untitled Document
Hello friends, a good idea of privileging the execution of main program of microcontroller came in my mind after watching a Si-Fi movie……and I did it………

Password protecting your microcontroller is one of the coolest things you can do with it……


I created a routine that reads 5 keystrokes and then checks weather the inserted password is right or not.
the micro controller here used is  Atmega 8535
 Not discussing much more about logic, here is the program
----------------------------------------------------------------------------------------------
void main()

{
  unsigned char a,b,c,d,e;           
  DDRA=0x00;
  PORTA=0xff;
                               //ask for password

 while(1)
 {
  lcd_init();
  lcd_string("Enter a 5 digit");
  lcd_gotoxy(1,0);
  lcd_string("Password:");
                                             //read password
  while(PINA==0xff);                    //if all keys open stay here
  a=PINA;
  delayms(200);
    lcd_gotoxy(1,0);
            lcd_string("Password:*");
            while((PINA&0xf0)!=0xf0);      //wait to release the key
 while(PINA==0xff);        
             b=PINA;
  delayms(200);
    lcd_gotoxy(1,0);
            lcd_string("Password:**");
            while((PINA&0xf0)!=0xf0);     //wait to release the key
 while(PINA==0xff);        
             c=PINA;
  delayms(200);
    lcd_gotoxy(1,0);
            lcd_string("Password:***");
             while((PINA&0xf0)!=0xf0);   //wait to release the key
 while(PINA==0xff);        
 d=PINA;
  delayms(200);
    lcd_gotoxy(1,0);
            lcd_string("Password:****");
            while((PINA&0xf0)!=0xf0);   //wait to release the key
 while(PINA==0xff);        
             e=PINA;
  delayms(200);
    lcd_gotoxy(1,0);
            lcd_string("Password:*****");   //wait to release the key
              


                                   //checking the password
  if(a==0xef)
  {
  if(b==0xdf)
            {
            if(c==0xbf)
               {if(d==0x7f)
                        {
                                    if(e==0xef)
                                    {
                                    lcd_init();
                                    lcd_string("Welcome");
                                    goto wait;
                                    }
                                    else
                                    {
                                                            lcd_init();
                                                            lcd_string("Invalid password!!");
                                                            delayms(2000);
                                    }
                        }
                        else
                        {
                                                lcd_init();
                                                lcd_string("Invalid password!!");
                                                delayms(2000);
                        }

            }
            else
            {
            lcd_init();
            lcd_string("Invalid password!!");
            delayms(2000);
            }
            }
   else
  {
  lcd_init();
  lcd_string("Invalid password!!");
  delayms(2000);
  }
  }
 else
  {
  lcd_init();
  lcd_string("Invalid password!!");

  delayms(2000);

  }
  }
  wait:while(1);                      
            }

----------------------------------------------------------------------------------------------






and no post is completed without a video,




leave a comment if you want to ask any thing related to programming.

:)
Read more ...

October 16, 2011

Fast Pwm mode of avr timers


Hello folks, I once needed to generate PWM wave  in my project related to power inverter design, I had to generate PWM waveforms according to the potentiometer varied by the user.
For that first method which I adopted was discussed earlier post but now here is another sophisticated method which I came across while studying the datasheet of mine microcontroller (mine favorite Atmega 8535).I came across the PWM modes given inbuilt in AVR series.
There are three modes of generating PWM in Atmega8535
1)Clear timer on compare(CTC) mode.

2)fast PWM mode

3)Phase correct PWM mode.


You can select any of them according to your requirement as in my requirement I had to select fast PWM mode.

Here are the steps given to configure your timer in fast PWM mode…..

Step 1) set Port in output mode
                                As the PWM generated would be given to output pin first of all that pin must be taken to output mode.the PIN where PWM is to be generated depends on the timer which you use to generate PWM. The pin OCn would be your output pin if you are using Timer-n. you can find the location of pin from datasheet.

Step 2) Set TCCRn register
                                You have to configure your timer in prescaler mode, OCn pin in inverting or non-inverting mode, selection of PWM mode etc. can be configured just within one register.
Step 3) Change the value of OCRn register in run time to generate PWM whatever you want…
Now your timer is configured to work with PWM mode
As I discussed earlier if we want to have a variable resistor  that can generate variable PWM for that we have to access ADC given in Atmega.

For adc initialization you have to do following steps
Step 1)  Initialize adc
                                You can do it by ADCSRA register you have to Enable, prescale and set interrupt .
Step 2)give ADC channel no
                                This no is given in ADMUX register.
Step 3)start conversion
                                Setting ADSC bit in ADCSRA register will do this thing.
Step 4) give it some time to convert and then read the result from ADCH and ADCL register.


Now you are done to interface your ADC with Timer

A sample code which I had used is given below.
#include<avr/io.h>
#include<delay.h>
void adc_init()
 {
ADCSRA=0X86;                              //ADC enable, ADC interrupt enable, set prescaller to 64
 }
 unsigned char getdata(unsigned char chno)        
  {
    ADMUX=0X60;                                       //right align the ADC result
    ADMUX|=chno;                                      //select the ADC channel
    ADCSRA|=0X40;                                     //start ADC convertion
    delayms(1);                                             //give some time delay to complit the ADC convertion
            return ADCH;
  }

void main()
{          unsigned char pot=0;
            adc_init();
             SREG=SREG|0x80;//global interrupt enable
             DDRB=0XFF;          //set data direction as output
TCCR0=TCCR0|0x7A;       //fast pwm,inverting mode,8 prescaler
while(1)
             {
             delayms(10);
             OCR0= getdata(0);          //read value from pot to OCR0
            }
}

Link to .zip file containing source code and Proteus ISIS design is this.
and datasheet of Atmega 8535 can be found from here.


if any question  then you can post a comment. 

Read more ...
Related Posts Plugin for WordPress, Blogger...