Tuesday, 18 June 2013

C source code for RFID module interface MCS51

In this time we want to share with you about RFID module that very useful to RF project this day. IN our sharing, we want give you what is RFID, show you schematic diagram RFID module interface microcontroller MSC51 AT89S52, and give you download sample C source code for RFID module interface MCS51.
What is RFID?
Maybe there are many people that not know yet about RFID now. RFID stand for Radio Frequency Identification. RFID is a technology that serves to detect and identify an object through the data transmitted via radio frequency. The system requires a minimum of a tag (which serves as a transponder), a reader (who serves as interrogator), and sebuan antenna (which serves as a coupling device).

One important element in RFID is a data transfer. Data transfer occurs when there is connection between the tag and reader, known as coupling through either an antenna mounted on the tag or reader as illustrated in the following figure 1 below:

Figure 1. The relationship between the tag, reader and antenna

Schematic Diagram RFID Module Interface MCS51 AT89S52
Figure 2. RFID Mode Interface AT89S52 Schematic Diagram
Example C Source Code RFID Module Interface MCS51 AT89S52

////////////////////////////////////////////////////////////
//Test SL025x
//MCS51 source code
////////////////////////////////////////////////////////////  
#include <reg52.h>
#include <string.h>

#define  true     1
#define  false    0

#define  OSC_FREQ        22118400L
#define  TIME0_10ms      65536L - OSC_FREQ/1200L

#define  BOUND4800       256 - 24
#define  BOUND9600       256 - 12
#define  BOUND14400      256 - 8
#define  BOUND19200      256 - 6
#define  BOUND28800      256 - 4
#define  BOUND38400      256 - 3
#define  BOUND57600      256 - 2
#define  BOUND115200     256 - 1

//IO definition
sbit     CARDIN    =    P1^0;                                                    

void InitializeSystem();                                                          
void SendCom(unsigned char *g_cCommand);                                          
void StartTime(unsigned int _MS);                                                 
void StopTime();
char ReadWriteUltralight(void);
char ReadWriteMifareStd(void);

//Command List, preamble + length + command code + data frame
unsigned char code SelectCard[3] =     {0xBA,0x02,0x01 };      
unsigned char code LoginSector0[11] =  {0xBA,0x0A,0x02,0x00,0xAA,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; 
unsigned char code LoginSector1[11] =  {0xBA,0x0A,0x02,0x01,0xAA,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
unsigned char code ReadBlock1[4]   =   {0xBA,0x03,0x03,0x01};                                    
unsigned char code WriteBlock1[20] =   {0xBA,0x13,0x04,0x01,0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xAA,0xBB,0xCC,0xDD,0xEE,0xFF};                               
unsigned char code ReadValue[4]  =     {0xBA,0x03,0x05,0x05}; 
unsigned char code InitializeValue[8] ={0xBA,0x07,0x06,0x04,0x00,0x00,0x00,0x01};                               
unsigned char code IncrementValue[8] = {0xBA,0x07,0x08,0x04,0x00,0x00,0x00,0x20};                               
unsigned char code DecrementValue[8] = {0xBA,0x07,0x09,0x04,0x03,0x00,0x00,0x00};                                         
unsigned char code CopyValue[5] =      {0xBA,0x04,0x0A,0x04,0x05};
unsigned char code ReadULPage5[4] =    {0xBA,0x03,0x10,0x05};                                         
unsigned char code WriteULPage5[8] =   {0xBA,0x07,0x11,0x05,0x11,0x22,0x33,0x44};
unsigned char code TurnOnRedLed[4] =   {0xBA,0x03,0x40,0x01};    
unsigned char code TurnOffRedLed[4] =  {0xBA,0x03,0x40,0x00};            
                          
unsigned char g_ucReceBuf[21];                                     
unsigned char g_ucReceNum;                                         
unsigned char g_ucWatchTime;
unsigned char g_ucCardType;
char g_cStatus;                                      
char g_cErr;

bit   g_bReceOver;                                                
bit   g_bReceReady;
bit   g_bTimeOut;        
                                         
For more complete example C source for RFID Module Interface MCS51 AT89S52, please you take free download with click link below:

Make Programmable Line Follower Robot Based Microcontroller Atmega8535

Let we make programmable line follower robot based microcontroller Atmega8535 now. In here you will get more information how to make programmable line follower robot based microcontroller Atmega8535 likes know proximity sensor circuit diagram, microcontroller Atmega8535 circuit diagram, and also driver DC motor circuit diagram. In here we also give you source code Atmega8535 program that made from CodeVision AVR.

Part 1

In the part 1, we will show you all of schematic diagram of programmable line follower robot based microcontroller Atmega8535.
  • Proximity Sensor (Line Sensor)
Programmable line follower robot designed to follow black line on the floor, so we need sensor that can do it. In here we use proximity sensor or line sensor to do this work. Proximity sensor work to detect a black line with using LED and Photo-diodes component that will detect light or not light changing like in figure 1 below:


Figure 1. Work Principle of Proximity Sensor

We can make our self proximity sensor easily with follow proximity  sensor schematic diagram like in figure 2 below:

Figure 2. Proximity Sensor Schematic Diagram

  • Data Processing Microcontroller Atmega8535
To process data from sensor and also give command to driver DC motor circuit, we use microcontroller Atmega8535 to do this work. To know the schematic diagram of microcontroller  Atmega8535 as base in line follower robot, please see figure 3 below:


Figure 3. Data Processing Atmega8535 Schematic Diagram

  • Driver DC Motor using L298
To make line follower robot can rotate the dc motor, we need driver dc motor. In this design we use L298 as main component in driver dc motor. We not design driver motor dc using transistor component but using Integrated Circuit (IC) L298. Here is schematic diagram of driver DC motor using L298 like in figure 4 below:


Figure 4. Driver DC Motor using L298 Schematic Diagram

Part 2

In part 2, we will show you source code of programmable line follower robot based microcontroller Atmega8535. This is software part that you can make this program using CodeVision AVR software that you also can download freely from this blog. 

We must need source code program to make our line follower robot can "think" good to work follow the black line on the floor. Here is source code program for line follower robot that we are designed.

#include <mega8535.h> 
unsigned char sensor; 
void main(void) 
{ while (1) 
sensor=PINA; 
sensor&=0b00000011; 
switch(sensor) 
case 0b00000001: PORTC=0b00000001; break; // to the right
case 0b00000010: PORTC=0b00000100; break; // to the left
case 0b00000011: PORTC=0b00000101; break; // straight 
case 0b00000000: break;
 }
 }; 
}

Part 3

In part 3, we will show you mechanical design for programmable line follower robot based Atmega8535. And than we can test our line follower robot that we make. Figure 5 show mechanical design for line follower robot that we designed.

Figure 5. Mechanical Part of Line Follower Robot

After we are installing all part of line follower robot, now we can test it using a black line like in figure 6 below:

Figure 6. Line Follower Robot Track Line Test

Figure 7. Line Follower Robot Based Atmega8535

Active Antenna AA-7 HF/VHF/UHF, 3 to 3000 MHz


Construction:
The AA-7, which can be built from scratch or purchased in kit form from the supplier listed in the Parts List, was assembled on a printed circuit board, measuring 4 by 4-11/16 inches. A template for the pcb board is shown in fig. 2. You can either etch your own board from that template, or purchase the circuit board or the complete kit of parts (which includes the pcb and all parts, but not the enclosure). The kit comes with a 16-page kit instruction manual that gives step-by-step assembly instructions and contains additional information not covered in this article. Kit assembly time, working slowly and carefully, should take less than an hour. Most of the parts specidied in the Parts list are standard components and can be procured through conventional hobby electronics suppliers. However, some parts--J1, J2, S1, S2, and R5-- have particular physical mounting dimensions; the Printed Circuit Board is designed to accept these particular parts. In addition, Q1 and Q2 can be hard to find; however, it is possible to make substitutions provided that you can find a supplier. Suitable replacements for Q1 and Q2  re given in the Parts List. The telescoping whip antenna screw-mounts to the board; the screw provides contact between the printed circuit board traces and the antenna. To save time and trouble locating and ordering hard-to-find parts, a Special Parts Kit is also offered by the supplier listed in the Parts List. A parts placement (layout) diagram for the AA-7's printed circuit board is shown in figure 3. When assembling the circuit, be especially careful that transistors Q1 and Q2, and the electrolytic capacitor C4, are oriented as shown.
Although not shown in the schematic (Fig. 1) or the layout (Fig. 3) diagrams, an optional led power indicator can be added to the circuit. Adding a power indicator to the circuit allows you to tell at a glance if the circuit is on; leaving the circuit on, even though the AA-7 draws only about 0.7 mA, will eventually discharge the battery. Of coutse, adding an led will increase the current drain to by about 7 mA, but the red glow makes it obvious when the unit is on. If you decide to include the indicator in your project, power for the indicator can be easily taken from the switched 9-volt DC terminal of S2 (center terminal, right side, looking at the top of S2). Simply connect the positive voltage to the anode (longer wire) of the led and connect her cathode lead through a current limiting resistor of about 1000 ohm to a ground point on the printed circuit board, or as the author did fromt the frame of R5. Mount the led at any convenient point near the switch. Although not supplied with the kit, a custom plastic enclosure (with front and back panels) or a regular 'hobby' case of some sorts, and knobs for the switches and gain control is offered in the Parts list. The enclosure comes pre-drilled and silk-screened with the appropriate legends for all the circuit controls and connecteors, but is not equipped with holes for the whip antenna or the led (if you include


Parts List and other components:
Semiconductors:
Q1 = MFE201, SK3991, or NTE454. N-Channel, dual-gate MOSFET (see text)
Q2 = 2SC2498, 2SC2570, 2N5179, SK9139, or NTE10. NPN VHF/UHF silicon transistor (see text)
Note: If you use the NTE107 as a replacement, make sure to insert it correctly
into the pcb. The orientation is different than as shown on the parts layout
diagram. (e-c-b seen frontview for NTE107). See this Data Sheet
Resistors:
All Resistors are 5%, 1/4-watt
R1 = 1 Mega Ohm
R2 = 220K
R3,R6 = 100K
R4 = 100 ohm
R5 = 10K potentiometer, (pc mount)
Capacitors:
C1,C2,C5,C6 = 0.01μF, ceramic disc
C3 = 100pF ceramic disc
C4 = 4.7 to 10μF, 16WVDC, radial lead electrolytic

Auto-Fan, for automatic temperature control



Th1, the 50K thermistor, is a standard type. Mine was a bar or rectangular looking thingy. Available from Tandy/Radio-Shack.  Almost any type will do. I experimented with different models from 22K to 100K and all worked fine after replacing the trimmer pot. The one used in the above circuit diagram was a 50K model made by Fenwal (#197-503LAG-A01). This 50K was measured at exactly 25 °C and with 10% tolerance. The resistance increases as the surrounding temperature decreases. Tolerance for my application (cooling a large powersupply coolrib) is 10%. Another name for this thing is 'NTC'. NTC stands for "Negative
Temperature Coefficient" which means when the surrounding temperature decreases the resistance of this thermistor will increase.  I replaced my thermistor for a 60K hermetically sealed glass type since the environment for my application may contain corrosive particles which may affect performance on a future date. P1 is a regular Bourns trimmer potentiometer and adjusts a wide range of temperatures for this circuit. I used the 10-turn type for a bit finer adjustment but the regular type may work for your application.
R1 is a 'security' resistor just in case the trimmer pot P1 is adjusted all the way to '0' ohms. At which time the thermistor would get the full 12 volt and it will get so hot that it puts blisters on your fingers... :-)
R3 feeds a bit of hysteresis back into the op-amp to eliminate relay 'chatter' when the temperature of the thermistor reaches its threshold point. Depending on your application and the type you use for Q1 and Re1, start with 330K or so and adjust its value downwards until your satisfied. The value of 150K shown in the diagram worked for me. Decreasing the value of R2 means more hysteresis, just don't use more then necessary. Or temporarily use a trimmer pot and read off the value. 120K worked for me. Transistor Q1 can be a 2N2222(A), 2N3904, NTE123A, ECG123A, etc. Not critical at all. It acts only as a switch for the relay so almost any type will work, as long as it can provide the current needed to activate the relay's coil. D1, the 1N4148, acts as a spark arrestor when the contacts of the relay open and eliminates false triggering. For my application the 1N4148 was good enough since the tiny relay I used was only 1 amp. However, you can use a large variety of diodes here, my next choice would be a regular purpose 1N4001 or something and should be used if your relay type can handle more then 1 amp