Discussion in "Project Help" started by    spiritgate    Jan 14, 2009.
Wed Jan 14 2009, 06:45 AM
#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, 09:47 AM
#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, 02:03 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, 10:11 AM
#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, 12:50 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
Thu Jan 15 2009, 06:43 PM
#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, 12:54 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, 04:57 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, 05:01 AM ]
Fri Jan 16 2009, 05:02 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, 05:24 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

Conversation

Mon Apr 12 2021, 11:54 AM
Joe N
I have recently launched my own site, and I am looking to provide value for you for free, by giving away 26 professional level blog post templates (worth $297).
Mon Apr 12 2021, 09:24 AM
Aretha
Hey, I think your site might be having browser compatibility issues. When I look at your website in Ie, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, very good blog! https://onanadiete.ru/alpha-numeric-reasoning-questions-and-answers-pdf.pdf alpha numeric reasoning questions and answers pdf alpha numeric reasoning questions and answers pdf

Downloads

Comments

Mirza123
Thu Jun 25 2020, 03:46 PM
eunicelove124
Mon Jun 22 2020, 03:03 PM
cerouno
Tue Jun 16 2020, 05:10 PM
Marce
Sat Jun 13 2020, 09:43 PM
Davidthils
Thu May 21 2020, 12:44 PM
Jakeror
Thu May 21 2020, 01:28 AM
motorCar
Wed May 20 2020, 07:05 PM
Vordrync
Wed May 20 2020, 11:52 AM

Online

Guests: 100, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38215
Newest member: Mirza123