Loading ...
Sorry, an error occurred while loading the content.
 

Re: Wireless RF temperature transmitter and reciever

Expand Messages
  • s.holder123@btinternet.com
    Hi, A few things spring to mind 1) Your rx and tx uart seem to be at different baud rates although they have the same clock speed. 2) The variable i is defined
    Message 1 of 6 , Mar 29, 2009
      Hi,

      A few things spring to mind
      1) Your rx and tx uart seem to be at different baud rates although they have the same clock speed.

      2) The variable i is defined as an integer , but the UDR reg is a byte register, allthough the compiler may be ok with this it is better to explicitly cast it.

      3) On the receiver it would be better to use a switch statement rather than a lot of if statements, that way a default case can be put in to trap any potential errant values, this way you could deal with them.

      4) I suspect a receiver buffer overrun is occuring, try using an interrupt routine for the uart receiver and buffer the incoming data, this way you could "refuse" to receive data if the buffer is full until you had dealt with the current buffer. Also ou wouldn't have an endless loop statement like this "while ( !(UCSRA & (_BV(RXC))) );", this is also a bad odea unless you have a way of getting out of it. Also try slowing down the baud rate.

      5) The code routine has very little error trapping, try to make it so that it is very difficult for bad data to upset your routine. try including tests for a frame error, of data overun error.

      6) Perhaps you should include some sort of flow control, this will increase redundant data traffic but increases the systems vulnerabiity to crash.

      Is it only the receiver that crashes ? perhaps a watchdog may help ?

      Hope that helps

      Regards

      --- In booksbybibin@yahoogroups.com, "Ashutosh" <newtons_mind@...> wrote:
      >
      > Hello everybody I am making the mentioned project by using LM35(temperature sensor), ATmega8 (as A to D converter and UART communication), RF modules 433MHz, ATmega32 at receiver end and 4 seven segment display in which one display will indicate 'F and 'C display.
      > The problem I faced that while transmitting the data through RF the receiver shows exact temperature as on LM 35 IC for only some time and then it get hanged up until i reset the receiver's uC
      > the program for transmitter is
      >
      > #include <avr/io.h>
      >
      > #define F_CPU 1000000
      >
      >
      >
      >
      > void main()
      > {
      > DDRD=0xff;
      > unsigned int i;
      > ADMUX=0;
      > ADMUX |= _BV(REFS0)| _BV(REFS1)| _BV(ADLAR);
      > ADCSRA |= _BV(ADEN) | _BV(ADSC) | _BV(ADFR)| _BV(ADPS2)| _BV(ADPS1)| _BV(ADPS0);
      >
      >
      > UBRRH = 0x00;
      > UBRRL = 25;
      > UCSRB = (UCSRB | _BV(RXEN) | _BV(TXEN) );
      > UCSRC = (1<<URSEL)|(1<<UCSZ1)|(1<<UCSZ0); /*this wat i had added*/
      > while(1)
      > {
      > i=ADCH;
      > while ( !(UCSRA & (_BV(UDRE))) ); /* Wait for empty transmit buffer */
      > UDR =i; /* Start transmittion */
      > }
      >
      > }
      >
      >
      > the program for receiver is
      >
      > #include <avr/io.h>
      >
      > #define F_CPU 1000000
      >
      >
      >
      >
      > void main()
      > {
      > DDRA=0xff;
      > DDRC=0xff;
      > unsigned int i;
      >
      >
      >
      > UBRRH = 0x00;
      > UBRRL = 207;
      > UCSRB = (UCSRB | _BV(RXEN) | _BV(TXEN) );
      > UCSRC = (1<<URSEL)|(1<<UCSZ1)|(1<<UCSZ0); /*this wat i had added*/
      >
      >
      > while(1)
      > {
      > while ( !(UCSRA & (_BV(RXC))) );
      > i=UDR;
      >
      >
      > if(i%10==0)
      > PORTC=0x3f;
      > if(i%10==1)
      > PORTC=0x0c;
      > if(i%10==2)
      > PORTC=0x5b;
      > if(i%10==3)
      > PORTC=0x5e;
      > if(i%10==4)
      > PORTC=0x6c;
      > if(i%10==5)
      > PORTC=0x76;
      > if(i%10==6)
      > PORTC=0x77;
      > if(i%10==7)
      > PORTC=0x1c;
      > if(i%10==8)
      > PORTC=0x7f;
      > if(i%10==9)
      > PORTC=0x7e;
      >
      > if(10>i&&i>=0)
      > PORTA=0x3f;
      > if(20>i&&i>=10)
      > PORTA=0x0c;
      > if(30>i&&i>=20)
      > PORTA=0x5b;
      > if(40>i&&i>=30)
      > PORTA=0x5e;
      > if(50>i&&i>=40)
      > PORTA=0x6c;
      > if(60>i&&i>=50)
      > PORTA=0x76;
      > if(70>i&&i>=60)
      > PORTA=0x77;
      > if(80>i&&i>=70)
      > PORTA=0x1c;
      > if(90>i&&i>=80)
      > PORTA=0x7f;
      > if(100>i&&i>=90)
      > PORTA=0x7e;
      >
      >
      >
      > }
      > }
      >
    • shamsher saleem
      good job ... From: Mihai Galos Subject: [booksbybibin,www.booksbybibin.tk] Re: Wireless RF temperature transmitter and reciever To:
      Message 2 of 6 , Mar 31, 2009
        good job

        --- On Sun, 29/3/09, Mihai Galos <mihaigalos@...> wrote:

        From: Mihai Galos <mihaigalos@...>
        Subject: [booksbybibin,www.booksbybibin.tk] Re: Wireless RF temperature transmitter and reciever
        To: booksbybibin@yahoogroups.com
        Date: Sunday, 29 March, 2009, 4:47 PM

        great..

        --- In booksbybibin@ yahoogroups. com, "Ashutosh" <newtons_mind@ ...> wrote:
        >
        > Hello everybody I am making the mentioned project by using LM35(temperature sensor), ATmega8 (as A to D converter and UART communication) , RF modules 433MHz, ATmega32 at receiver end and 4 seven segment display in which one display will indicate 'F and 'C display.
        > The problem I faced that while transmitting the data through RF the receiver shows exact temperature as on LM 35 IC for only some time and then it get hanged up until i reset the receiver's uC
        > the program for transmitter is
        >
        > #include <avr/io.h>
        >
        > #define F_CPU 1000000
        >
        >
        >
        >
        > void main()
        > {
        > DDRD=0xff;
        > unsigned int i;
        > ADMUX=0;
        > ADMUX |= _BV(REFS0)| _BV(REFS1)| _BV(ADLAR);
        > ADCSRA |= _BV(ADEN) | _BV(ADSC) | _BV(ADFR)| _BV(ADPS2)| _BV(ADPS1)| _BV(ADPS0);
        >
        >
        > UBRRH = 0x00;
        > UBRRL = 25;
        > UCSRB = (UCSRB | _BV(RXEN) | _BV(TXEN) );
        > UCSRC = (1<<URSEL)|( 1<<UCSZ1) |(1<<UCSZ0) ; /*this wat i had added*/
        > while(1)
        > {
        > i=ADCH;
        > while ( !(UCSRA & (_BV(UDRE))) ); /* Wait for empty transmit buffer */
        > UDR =i; /* Start transmittion */
        > }
        >
        > }
        >
        >
        > the program for receiver is
        >
        > #include <avr/io.h>
        >
        > #define F_CPU 1000000
        >
        >
        >
        >
        > void main()
        > {
        > DDRA=0xff;
        > DDRC=0xff;
        > unsigned int i;
        >
        >
        >
        > UBRRH = 0x00;
        > UBRRL = 207;
        > UCSRB = (UCSRB | _BV(RXEN) | _BV(TXEN) );
        > UCSRC = (1<<URSEL)|( 1<<UCSZ1) |(1<<UCSZ0) ; /*this wat i had added*/
        >
        >
        > while(1)
        > {
        > while ( !(UCSRA & (_BV(RXC))) );
        > i=UDR;
        >
        >
        > if(i%10==0)
        > PORTC=0x3f;
        > if(i%10==1)
        > PORTC=0x0c;
        > if(i%10==2)
        > PORTC=0x5b;
        > if(i%10==3)
        > PORTC=0x5e;
        > if(i%10==4)
        > PORTC=0x6c;
        > if(i%10==5)
        > PORTC=0x76;
        > if(i%10==6)
        > PORTC=0x77;
        > if(i%10==7)
        > PORTC=0x1c;
        > if(i%10==8)
        > PORTC=0x7f;
        > if(i%10==9)
        > PORTC=0x7e;
        >
        > if(10>i&&i>= 0)
        > PORTA=0x3f;
        > if(20>i&&i>= 10)
        > PORTA=0x0c;
        > if(30>i&&i>= 20)
        > PORTA=0x5b;
        > if(40>i&&i>= 30)
        > PORTA=0x5e;
        > if(50>i&&i>= 40)
        > PORTA=0x6c;
        > if(60>i&&i>= 50)
        > PORTA=0x76;
        > if(70>i&&i>= 60)
        > PORTA=0x77;
        > if(80>i&&i>= 70)
        > PORTA=0x1c;
        > if(90>i&&i>= 80)
        > PORTA=0x7f;
        > if(100>i&&i> =90)
        > PORTA=0x7e;
        >
        >
        >
        > }
        > }
        >



        From Chandigarh to Chennai - find friends all over India. Click here.
      • Ashutosh
        thanks for the help your help helps me great now I working on them
        Message 3 of 6 , Apr 13, 2009
          thanks for the help your help helps me great now I working on them
        Your message has been successfully submitted and would be delivered to recipients shortly.