Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
tpk711
PostPosted: Apr 13, 2012 - 07:14 PM
Newbie


Joined: Apr 13, 2012
Posts: 4


please help me.
Reader Promag GP8.
Data(reader)-->RX(atmega32)-->decode-->LCD
please help me
I speak english very bad.
everyone can write code for me
 
 View user's profile Send private message  
Reply with quote Back to top
JohanEkdahl
PostPosted: Apr 13, 2012 - 07:28 PM
10k+ Postman


Joined: Mar 27, 2002
Posts: 18524
Location: Lund, Sweden

Quote:

everyone can write code for me

But no-one will. You start and we will help.

I would recommend you do this development in small pieces. Start with the LCD - many people here know how to do that, so you will probably get help. While doing that you will learn a lot, so you will be able to do the other parts more and more on your own.

Start by searching the net (Google) and this site for things like "AVR LCD" and similar.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
theusch
PostPosted: Apr 13, 2012 - 07:40 PM
10k+ Postman


Joined: Feb 19, 2001
Posts: 25881
Location: Wisconsin USA

http://www.aceprox.de/pdf/gp8.pdf

The RS232 packet structure looks much like that of the ID-12/ID-20 modules sold by Sparkfun:
http://www.sparkfun.com/products/8419
http://www.sparkfun.com/datasheets/Sens ... asheet.pdf

>>except<< that the ID-12 has a two-byte checksum in the packet.

I posted my "driver" here:
http://www.avrfreaks.net/index.php?name ... 808#704808
 
 View user's profile Send private message  
Reply with quote Back to top
tpk711
PostPosted: Apr 14, 2012 - 11:35 AM
Newbie


Joined: Apr 13, 2012
Posts: 4


thanks JohanEkdahl and Superfreak. I will start
 
 View user's profile Send private message  
Reply with quote Back to top
tpk711
PostPosted: Apr 14, 2012 - 06:44 PM
Newbie


Joined: Apr 13, 2012
Posts: 4


Code:
#include <avr/io.h>
#include <avr/interrupt.h>
#include <inttypes.h>
#include <util/delay.h>
#include "myLCD.h"
// Defines
#define   BaudRate 9600
//#define UbrrValue ((F_CPU / (16ul * BaudRate)) -1)
#define UbrrValue 51

void loop();
int i = 0;
char ID;
char val = 0;
char code[6];
char checksum = 0;
char bytesread = 0;
char tempbyte = 0;
char USARTReadChar()
{
   // Wait until a data is available
   while(!(UCSRA & (1<<RXC)))
   {
      // Do nothing
   }

   // Now USART has got data
   return UDR;
}

void USARTWriteChar(char data)
{
   // Wait until transmitter is ready
   while(!(UCSRA & (1<<UDRE)))
   {
      // Do Nothing
   }

   UDR=data;
}

void USARTInit()
{
   // Set Baudrate
   UBRRL = UbrrValue;
   UBRRH = (UbrrValue>>8);
   
   // Set frame format
   // Asynch, 8n1

   UCSRC = (1<<URSEL) | (1<<UCSZ1) |  (1<<UCSZ0);

   // Enable TX/RD
   UCSRB = (1<<RXEN) | (1<<TXEN);
}

int main()
{
   init_LCD();
   clr_LCD();
   print_LCD("Tag ID");
   USARTInit();
   while(1){
      loop();
   }
}

void loop()
{
      val=USARTReadChar();
      if(val==2);
      bytesread=0;
      while(bytesread<12){
      val=USARTReadChar();
      if((val == 0x0D)||(val == 0x0A)||(val == 0x03)||(val == 0x02)){
      break;
      }
      if ((val >= '0') && (val <= '9')) {
         val = val - '0';
      }
      else if ((val >= 'A') && (val <= 'F')) {
         val = 10 + val - 'A';
      }

// Every two hex-digits, add byte to code:
if (bytesread & 1 == 1) {
// make some space for this hex-digit by
// shifting the previous hex-digit with 4 bits to the left:
code[bytesread >> 1] = (val | (tempbyte << 4));

if (bytesread >> 1 != 5) {                // If we’re at the checksum byte,
checksum ^= code[bytesread >> 1];       // Calculate the checksum… (XOR)
};
}
else
{
tempbyte = val;                           // Store the first hex digit first…
};

bytesread++;                                // ready to read next digit
}
if(bytesread==12){
print_LCD("5-byte code: ");
move_LCD(2,1);
for (i=0; i<5; i++) {
print_LCD(code[i]);
}
}
}


my code. LCD not showing up. Can you help me wrong place find. Thanks.
 
 View user's profile Send private message  
Reply with quote Back to top
tpk711
PostPosted: Apr 18, 2012 - 09:39 AM
Newbie


Joined: Apr 13, 2012
Posts: 4


please help me.
 
 View user's profile Send private message  
Reply with quote Back to top
mtaschl
PostPosted: Apr 18, 2012 - 10:18 AM
Resident


Joined: Aug 21, 2002
Posts: 895
Location: Austria

Beside not showing your LCD-routines:
Code:
      if(val==2);
      bytesread=0;

Are you sure with the semikolon at the end of the first line?
BTW, it is very dangerous to place semicolons after closing brakets:
Code:
if (a < b) {
  c = 1;
};
else {
  c = 2
}

is not valid and will generate an error.

_________________
/Martin.
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits