Discussion in "Project Help" started by    spiritgate    Jan 14, 2009.
Wed Jan 14 2009, 12:15 pm
#1
Thanks guys for entering this thread, I got a problem in passing values from RFID to microcontroller. In RFID I only need to pass a single value like "1" or "2" to microcontroller. Then Microcontroller will receive the value and determine which LED to be light up.

So the problem is how to pass? If pass in serial cable, My CPU only have 1 serial port available. I heard that Register B can store things right? It is a temp location. But it still need to pass through serial cable right?

I have write down the code for this:

SCON0 = 0x50;


Think its part of the code for serial communication.

P0.4 and P0.5 is TX and RX respectively. So I have to enable them by this:

P1MDIN |= 0xFF;



But what should I assign to P0.4 and P0.5? Should I leave it blank or need to assign speical value to them?

After that, I use SBUF to send and receive things through RX and TX, like this:

"variable" = SBUF;


or store in B register like this:

B= SBUF;


Then either use B or variable to put into another local or global variable.

"local variable" = B or "variable;


Then the communication is then complete.

If you guys spot any mistakes, please tell me. I appreciate it very very much!

Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!
Wed Jan 14 2009, 03:17 pm
#2
Hi Spiritgate :-)




Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!Thank You!

spiritgate




First try to understand the concept of serial UART Communication.
1. Serial initialization for C8051F350 Model

void serial_init(){
        TMOD = 0x20;   
        SCON0 = 0x50;
        TH1  = 0xFD;
        TL1  = 0xFD;
        TR1  = 1;
}


2. To Transmit & Receive the Data through SBUF0
void serial_send(unsigned char dat){
        while(!TI);
        TI = 0;
        SBUF0 = dat;
}
unsigned char serial_read(){
        while(!RI);
        RI = 0;
        return SBUF0;
} 


and on the Software side there is nothing to do it with P0.4 & P0.5 since all the data is transmitted and received from SBUF0 Register.
and on the Hardware side it has to be connected via MAX232 Chip if performing communication with PC. and let me know how you have connected the RFID with Micro-Controller.

:bye
 spiritgate like this.
Thu Jan 15 2009, 07:33 am
#3
Hi sanath thanks for teaching me about UART communication. Thanks so much!

For now I am not so sure on how to connect these 2 device, because there is only one serial port available. If I plugged in 1 of the device, there will be not enough space for another device to be plugged in.

Got any advice on this? Because my initial thinking is that, both RFID and micro controller plugged into the computer through serial port. So they can transmit bits/byte through the serial port and a program will act like a traffic control to navigate the input from RFID from example port 2 to port 1. Then the micro controller will read thorugh the bit/byte from port 1 since it is connected to port 1.

So this is my thinking, is there anything wrong?
Thu Jan 15 2009, 03:41 pm
#4
Well you can use the bit banging approach (software UART) to connect one more serial device apart from the hardware uart.

All you would need is a couple of free gpio pins and a software 'driver'.The communication speed though should be low - ~2400 or 4800 bps to minimise errors.

For more info look here : http://www.8051projects.net/serial-communication/software-uart-8051.php
Thu Jan 15 2009, 06:20 pm
#5

:-)
U can't make use of one Serial port for Connecting two devices which will make the communication fail. So the best thing as Sashijoseph told go with the Software UART Implementation by making use of your GPIO Pins.

or else make use of RFID Reader which gives the o/p in Wiegand serial protocol so that Serial port you can make use to communicate with PC.

:bye
Fri Jan 16 2009, 12:13 am
#6
you can use uart in switchable way, like reding from RFID reader as primary task, as soon as you get a valid card, switch uart from RFID to PC, send data and switch back to RFID reader.
Fri Jan 16 2009, 06:24 am
#7
Sorry I am still a bit confuse about the software UART. I think I too noob for this thing. So I briefly say in a layman term with what you guys say, see whether it is correct.

So I plugged in the serial cable of microcontroller to the 1 and only serial port on CPU. But after that I have no space to put the serial port of the RFID to the computer?

My microcontroller now is full no available space for another serial port.

So the software UART, how can it be help?

Sorry to bother you guys:-s

Thanks Alot!
Fri Jan 16 2009, 10:27 am
#8
Well :-) Check out this RS232 expander. It may help you to solve the Current problem. :-)







But the main important thing is that how u can efficiently switch b/w two tasks in your code of Reading the data from RFID and if the Tag is valid communicate with PC and again switch back to RFID for the next Tag.
and on the hardware side instead of that manual switch you can make use of some simple Relay circuit to switch b/w 2 COM Ports
:bye


[ Edited Fri Jan 16 2009, 10:31 am ]
Fri Jan 16 2009, 10:32 am
#9
Oh thank You! Does hardware shop sell these kind of extension or we need to build it ourselves? If have do they sell more than 2 serial extension port?

Last question, if I have this implemented, where do I program to determine which part of the serial port belong to microcontroller or RFId?
Fri Jan 16 2009, 10:54 am
#10
U can do it by urself. Just take one small General PCB Board and solder the Components as the connections shown in the above circuit.

if I have this implemented, where do I program to determine which part of the serial port belong to microcontroller or RFId?



Ya right question :-)

The flow of Code is same to read the data from RFID and Communicate with PC. But you need to switch between respective COM ports which u need to control from your Code.

If u r making use of RS232 expander for example as in the fig the COM1 port will be connected your Controller , COM 1/1 connected to RFID Reader, COM1/2 Connected to PC :-)
So suppose if you are reading the data from RFID Reader first switch the COM port to COM 1/1 using some switching mechanism using Relay and then read the data .After that to communicate to PC , switch the COM port to COM1/2 with the same switching mechanism. and trasmit the data to PC. again same procedure follows.

and check out the Male & female DB9 connectors before starting.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

carpinteyrowrl
Fri Apr 19 2024, 02:51 pm
DonaldJAX
Fri Apr 19 2024, 01:08 pm
Lewisuhakeply
Thu Apr 18 2024, 06:00 pm
Darrellciz
Thu Apr 18 2024, 11:07 am
Charlessber
Thu Apr 18 2024, 09:29 am
BartonSem
Thu Apr 18 2024, 04:56 am
DonaldKnown
Thu Apr 18 2024, 12:24 am
utaletxcyw
Wed Apr 17 2024, 10:21 am