Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Problem with atmega16

Status
Not open for further replies.

sriblue7

Member level 1
Member level 1
Joined
May 6, 2011
Messages
41
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Chennai
Activity points
1,614
Hi! i am using an atmega16L microcontroller for processing the input from ht-12D and based on this input appropriate pins of microcontroller are made high.I have used port B as input and ports A and C for output.I have set the fuse bits as lfuse=0xFF and hfuse=0xC9 for using an external 8Mhz crystal and to use port C as i/o pins.I use parallel port programmer(dapa).I use this setup for making the receiver part of my robot.
The problem is i am getting the desired output only if i switch off and switch on my power supply(i am not getting my output immediately).What could be the problem?
 
Last edited:

Could you post or upload your code and a schematic of you interface between the ATMEGA16L and the HT-12D, so that one of us could review it?
 

I have attached the schematic with code.
 

Attachments

  • Atmega16.zip
    27.8 KB · Views: 82

The circuit looks ok..but the oscillator resistor for the HT12D should be 47K and not more than that. Just use a fixed 0.25 watt in place. Too note that the HT12E must use a 1M resistor. Cheers
 
Looking at your code:

Code:
#include<avr/io.h>

int main()
{
     unsigned char y;
     DDRB=0b00000000;
     PORTB=0b11110000;//enabling pull ups for PB7-PB3
     y=PINB;
     DDRA=0b11111111;//Port A o/p
     DDRC=0b11111111;//Port C o/p

     if(y==0b00010000)//Forward
     {
        PORTA=0b10000000;
        PORTC=0b00000000;
     }
     else if(y==0b00100000)//Backward
     {
        PORTA=0b01000000;
        PORTC=0b00000000;
     }
     else if(y==0b00110000)//Left
 .....
 .....
 .....
    else
   {
       PORTA=0b00000000;
       PORTC=0b00000000;
   }

   return 0;
}


It's a straight one shot, no loop, so if you're lucky it catches the first transmitted command and then ends. Try encapsulating the " if, else" statements in a:


Code:
while(1)
{

   Your if, else statements

}


And change the resistor values as Pranam77 suggested and you should be good to go.

Ciao
 
Like above said. You do all the setup inside the main loop too. You can put that outside the main loop, so you sort of setup your system first - and only once. This should sort the problem out or get you a lot further.
 
Thank u.I got the expected output after including the while loop.However i am getting only 1.5V(instead of 5V as expected) as HIGH at the output pins.What could be the problem?
 

However i am getting only 1.5V(instead of 5V as expected) as HIGH at the output pins.What could be the problem?

Which output pins? All of PORTA and PORTC?

How are you measuring the output voltage?

I'll take another look at the schematic.

Ciao
 

The pins from which i need HIGH voltage i am getting as 1.5V instead of 5V.I measured with respect to ground(common for both ht 12 D and microcontroller).

---------- Post added at 14:45 ---------- Previous post was at 14:00 ----------

I am getting 5V at the output for other programs like glowing or blinking LED.
 

Thank you! I found out the mistake it was with my program.Now I am getting 5V at the outputs as expected.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top