Need Serious Help
Wed Jan 21 2009, 07:54 am
The DB9 connector,J5,in the dev board is RS232.Do not connect the RFID to this.
Instead tap the P0.4 and P0.5 ttl Rx/Tx signals from the connector J3.
For working with the COM port using VB's MSCOMM control refer to this thread...
http://www.8051projects.net/forum-t5021-0.html#post_5060
Also make sure no other device/modem is using the com port you are trying to communicate with.
Instead tap the P0.4 and P0.5 ttl Rx/Tx signals from the connector J3.
For working with the COM port using VB's MSCOMM control refer to this thread...
http://www.8051projects.net/forum-t5021-0.html#post_5060
Also make sure no other device/modem is using the com port you are trying to communicate with.
Wed Jan 21 2009, 09:32 am
sashijoseph, why cant i connect RFID to microcontroller J5?
Hmm I want to ask about the expander, if I have an expander for serial port, like on the page 1 of this forum, if connect them at the same time with no switch, will there be any clash?
Cause I was thinking for RFID, if I link 1 of them to computer and another one to microcontroller, then the linking should be complete.
But is my theory correct?
Hmm I want to ask about the expander, if I have an expander for serial port, like on the page 1 of this forum, if connect them at the same time with no switch, will there be any clash?
Cause I was thinking for RFID, if I link 1 of them to computer and another one to microcontroller, then the linking should be complete.
But is my theory correct?
Wed Jan 21 2009, 10:04 am
according to what shashi says...
you have two serial outputs..
1. TTL (Tx-Rx pair direct from port pins)J3.
2. RS232 level Tx-rX (j5).
so if u want to connect rfid directly to the uC do as shashi says.
you have two serial outputs..
1. TTL (Tx-Rx pair direct from port pins)J3.
2. RS232 level Tx-rX (j5).
so if u want to connect rfid directly to the uC do as shashi says.
Wed Jan 21 2009, 10:36 am
o ok. thanks!
I wan to ask whether is it normal when I send this string "qweqwe" to serial port and when i read it, it return "n"
I wan to ask whether is it normal when I send this string "qweqwe" to serial port and when i read it, it return "n"
Wed Jan 21 2009, 01:48 pm
guys what if I wan to try whether if I pass in 5 volt, the microcontroller will read as "1" and when I switch off, it will pass in "0". can be it done with my development board?
Wed Jan 21 2009, 02:08 pm
hi spiritgate
if u really need help then please add details to your question..
how are u sending qweqwe (PCto uC or uC to PC and how?)
similarlyhow are u reading?
for ur second ques..
yes can be done.
make any port pin as input.
now check if that pin receives high (1)
if yes then transmit /send "1"
else "0"
o ok. thanks!
I wan to ask whether is it normal when I send this string "qweqwe" to serial port and when i read it, it return "n"
if u really need help then please add details to your question..
how are u sending qweqwe (PCto uC or uC to PC and how?)
similarlyhow are u reading?
for ur second ques..
yes can be done.
make any port pin as input.
now check if that pin receives high (1)
if yes then transmit /send "1"
else "0"
Wed Jan 21 2009, 02:16 pm
for the second question right, when i try to connect it to the LED together with a wire connecting to serial port (2) and another connecting to serial port (5). also it is connecting to the female side. Then when I put them together, it light up! is it normal?
Then I follow the code given in page 1, so if it is high, SUBF0 will be equal to "1" or 0x01?
Thanks:)
Do I need to set any timer or interrupt for the controller?because i tried it but is not working..
Then I follow the code given in page 1, so if it is high, SUBF0 will be equal to "1" or 0x01?
Thanks:)
Do I need to set any timer or interrupt for the controller?because i tried it but is not working..
[ Edited Wed Jan 21 2009, 02:58 pm ]
Wed Jan 21 2009, 02:27 pm
For the first question, I am sending it to com port 1.
This is my code:
This is my code:
Set objComport = CreateObject( "ActiveXperts.Comport" ) ' Create a new Comport instance objComport.Device = "COM1" ' Use a COM port directly (no Windows Device Driver) objComport.BaudRate = 9600 objComport.Open ' Open the port ' Wscript.Echo "Open, result: " & objComport.LastError If( objComport.LastError <> 0 ) Then output.text = "Quit" End If objComport.WriteString( "0" ) ' Write command str = objComport.ReadString 'WScript.Echo "Received: [" & str & "]" output.text = "Received: [" +str + "]" objComport.Close
Thu Jan 22 2009, 07:43 am
Anyone know is there any free virtual breadboard software? Because I want to check whether my connection is correct or not. thanks!
Thu Jan 22 2009, 07:49 am
Guys help me double check....
If I want to communicate with serial port, the things that I do are:
is it correct? like that can communicate with port 1? If this one can then my problem now is with the circuit. Because I need to pass a "1" or "0" to the serial port. And if it reads it, 1 of the LED on the development board will light up.
Thanks!
If I want to communicate with serial port, the things that I do are:
//----------------------------------------------------------------------------- // Blinky.c //----------------------------------------------------------------------------- // Copyright 2005 Silicon Laboratories, Inc. // // AUTH: BD // DATE: 06 FEB 04 // // This program flashes the green LED on the C8051F35x target board about // five times a second using the interrupt handler for Timer2. // // Target: C8051F35x // // Tool chain: KEIL Eval 'c' // //----------------------------------------------------------------------------- //How Program Works? //----------------------------------------------------------------------------- //The variable start with seat represent the priority seats in the train //the seats will given a number, //"0" means Lights off //"1" means lights on but without blinking //"2" means lights on with blinking //"3" means occupy by priority people //"4" means occupy by non-priority people //----------------------------------------------------------------------------- // Includes //----------------------------------------------------------------------------- #include <c8051f350.h> #include <stdlib.h> #include <stdio.h> //----------------------------------------------------------------------------- // 16-bit SFR Definitions for 'F35x //----------------------------------------------------------------------------- sfr16 TMR2RL = 0xca; // Timer2 reload value sfr16 TMR2 = 0xcc; // Timer2 counter //----------------------------------------------------------------------------- // Global CONSTANTS //----------------------------------------------------------------------------- #define SYSCLK 24500000 / 8 // SYSCLK frequency in Hz sbit LED1 = P0^0; sbit LED2 = P0^1; sbit LED3 = P0^2; sbit LED4 = P0^3; sbit LED7 = P0^6; sbit LED8 = P0^7; sbit LED9 = P1^0; sbit LED10 = P1^1; sbit LED11 = P1^2; sbit LED12 = P1^3; sbit LED13 = P1^4; sbit LED14 = P1^5; sbit LED15 = P1^6; sbit LED16 = P1^7; sbit nLED = P2^0; // LED='1' means ON sbit SW2 = P1^0; int i; int start; unsigned int h; unsigned int p; unsigned int j; int testing123=0; unsigned int seat[17]; unsigned int section; unsigned char serialNumber[20]; unsigned char a; unsigned int counter; unsigned int track;//collect the data that RFID has pass, also act as a stopper //----------------------------------------------------------------------------- // Function PROTOTYPES //----------------------------------------------------------------------------- void SYSCLK_Init (void); void PORT_Init (void); void Timer2_Init (int counts); void Timer2_ISR (void); void Click (void); void checkSection (void); void serial_init(); unsigned char serial_read(); void blinking (void); void variable_Init(void); void serial_send(unsigned char dat); //----------------------------------------------------------------------------- // MAIN Routine //----------------------------------------------------------------------------- void main (void) { j=0; if(testing123==0){ for(i=4; i<8;i++){ seat[i] = 0; } testing123=1; } start=1; variable_Init(); //section=2;//testing purpose // track=1;//testing purpose // disable watchdog timer PCA0MD &= ~0x40; // WDTE = 0 (clear watchdog timer SYSCLK_Init (); // Initialize system clock PORT_Init (); serial_init(); //------------------------------------------------------------------------ while (start) { PCA0MD &= ~0x40; serial_init(); a=serial_read(); if(a==0x00){ LED7 = 1; } SYSCLK_Init (); // Initialize system clock PORT_Init (); //where a cycle ends if(counter==800){ variable_Init(); counter=0; track=0; start=0; main(); testing123=10; } //delay for (i = 0; i < 10000; i++) { /* Delay for 10000 Counts */ /* call wait function */ } //------------------------------------------------ //Switch testing purpose //------------------------------------------------ while(SW2==0){ if(section==0 && track ==0){ section=2; track=1; counter=1; for (i = 0; i < 18000; i++) { /* Delay for 10000 Counts */ /* call wait function */ } }else{ if(seat[7]==3 && seat[6]==3){ seat[7]=4; seat[6]=4; seat[5]=4; seat[4]=4; }else{ if(seat[7]==3){ seat[6]=3; }else{ seat[7]=3; } } counter = 799; start=0; testing123=10; main(); } } //----------------------------------------------- if(track==2){ nLED = ~nLED; } //serial_read();//read from serial port if(track==1){ checkSection();//check priority seats blinking(); } //determine which seats to light up counter++; }//end main routine //----------------------------------------------------------------------------------- EA = 1; // enable global interrupts } //----------------------------------------------------------------------------- // SYSCLK_Init //----------------------------------------------------------------------------- // // This routine initializes the system clock to use the internal 24.5MHz / 8 // oscillator as its clock source. Also enables missing clock detector reset. // void SYSCLK_Init (void) { OSCICN = 0x80; // configure internal oscillator for // its lowest frequency RSTSRC = 0x04; // enable missing clock detector } //----------------------------------------------------------------------------- // serial_Init //----------------------------------------------------------------------------- void serial_init(){ TMOD = 0x20; SCON0 = 0x50; TH1 = 0xFD; TL1 = 0xFD; TR1 = 1; } //----------------------------------------------------------------------------- // serial_read //----------------------------------------------------------------------------- // // To read data from SBUF0 // unsigned char serial_read(){ while(!RI0); RI0 = 0; return SBUF0; } //----------------------------------------------------------------------------- // Blinking //----------------------------------------------------------------------------- // void blinking (void){ if(seat[0]==1){ LED1 = 1; } if(seat[1]==1){ LED2 = 1; } if(seat[2]==1){ LED3 = 1; } if(seat[3]==1){ LED4 = 1; } if(seat[6]==1){ LED7 = 1; } if(seat[7]==1){ LED8 = 1; } if(seat[8]==1){ LED9 = 1; } if(seat[9]==1){ LED10 = 1; } if(seat[10]==1){ LED11 = 1; } if(seat[11]==1){ LED12 = 1; } if(seat[12]==1){ LED13 = 1; } if(seat[13]==1){ LED14 = 1; } if(seat[14]==1){ LED15 = 1; } if(seat[15]==1){ LED16 = 1; } if(seat[0]==2){ LED1 = ~LED1; } if(seat[1]==2){ LED2 = ~LED2; } if(seat[2]==2){ LED3 = ~LED3; } if(seat[3]==2){ LED4 = ~LED4; } if(seat[6]==2){ LED7 = ~LED7; } if(seat[7]==2){ LED8 = ~LED8; } if(seat[8]==2){ LED9 = ~LED9; } if(seat[9]==2){ LED10 = ~LED10; } if(seat[10]==2){ LED11 = ~LED11; } if(seat[11]==2){ LED12 = ~LED12; } if(seat[12]==2){ LED13 = ~LED13; } if(seat[13]==2){ LED14 = ~LED14; } if(seat[14]==2){ LED15 = ~LED15; } if(seat[15]==2){ LED16 = ~LED16; } } void variable_Init(void){ counter=0; section=0; LED1 = 0; LED2 = 0; LED3 = 0; LED4 = 0; LED7 = 0; LED8 = 0; LED9 = 0; LED10 = 0; LED11 = 0; LED12 = 0; LED13 = 0; LED14 = 0; LED15 = 0; LED16 = 0; nLED = 0; track = 0; } //----------------------------------------------------------------------------- // PORT_Init //----------------------------------------------------------------------------- // // Configure the Crossbar and GPIO ports. // P0.7 - LED (push-pull) // void PORT_Init (void) { XBR0 = 0x00; // no digital peripherals selected XBR1 = 0x40; // Enable crossbar and weak pull-ups P0MDOUT |= 0xFF; // enable LED as a push-pull output SW2 = 1; //P1MDOUT |= 0xFF; P1MDIN |= 0xFF; } void Click (void) { /* only to delay for LED flashes */ } void checkSection (void) { //--------------------------------------------------------------------- //section 1 //--------------------------------------------------------------------- if(section==1){ if(seat[1]> 2 && seat[0]> 2 && seat[2] > 2 && seat[3]> 2){ for(i=0; i<4; i++){ if(seat[i]==4){ seat[i]=2; } } //------------------------------------------------------------ if(seat[5]==0 || seat[4]==0 || seat[7]==0 || seat[6]==0){ for(i=4; i<8; i++){ if(seat[i]==0){ seat[i]=1; } } } //------------------------------------------------------------- else if(seat[9]==0 || seat[10]==0 || seat[11]==0 || seat[8]==0){ for(i=8; i<12; i++){ if(seat[i]==0){ seat[i]=1; } } } //-------------------------------------------------------------- else if(seat[13]==0 || seat[14]==0 || seat[15]==0 || seat[12]==0){ for(i=12; i<16; i++){ if(seat[i]==0){ seat[i]=1; } } } //--------------------------------------------------------------- }else{ for(i=0; i<4; i++){ if(seat[i]==0){ seat[i]=1; } } }//end else section=0; } //--------------------------------------------------------------------- //Section 2 //--------------------------------------------------------------------- if(section==2){ if(seat[5]> 2 && seat[4]> 2 && seat[7]> 2 && seat[6]> 2){ for(i=4; i<8; i++){ if(seat[i]==4){ seat[i]=2; } } //---------------------------------------------------------- if(seat[2]==0 || seat[3]==0 || seat[9]==0 || seat[8]==0){ if(seat[3]==0){ seat[3] = 1; }if(seat[2]==0){ seat[2] = 1; }if(seat[9]==0){ seat[9] = 1; }if(seat[8]==0){ seat[8] = 1; } } //----------------------------------------------------------- else if(seat[0]==0 || seat[1]==0 || seat[11]==0 || seat[10]==0){ if(seat[0]==0){ seat[0] = 1; }if(seat[1]==0){ seat[1] = 1; }if(seat[11]==0){ seat[11] = 1; }if(seat[10]==0){ seat[10] = 1; } } //------------------------------------------------------------ else if(seat[13]==0 || seat[14]==0 || seat[15] ==0 || seat[12]==0){ for(i=12; i<16; i++){ if(seat[i]==0){ seat[i]=1; } } } //------------------------------------------------------------- }else{ for(i=4; i<8; i++){ if(seat[i]==0){ seat[i]=1; } } }//end else section=0; } //--------------------------------------------------------------------- //Section 3 //--------------------------------------------------------------------- if(section==3){ if(seat[8]> 2 && seat[9]> 2 && seat[10]> 2 && seat[11]> 2){ for(i=8; i<12; i++){ if(seat[i]==4){ seat[i]=2; } } //----------------------------------------------------------------- if(seat[6]> 0 && seat[7]> 0 && seat[13] > 0 && seat[12]> 0){ if(seat[6]==0){ seat[6] = 1; }if(seat[7]==0){ seat[7] = 1; }if(seat[13]==0){ seat[13] = 1; }if(seat[12]==0){ seat[12] = 1; } } //------------------------------------------------------------------ else if(seat[15]> 0 && seat[14]> 0 && seat[4] > 0 && seat[5]> 0){ if(seat[5]==0){ seat[5] = 1; }if(seat[15]==0){ seat[15] = 1; }if(seat[14]==0){ seat[14] = 1; }if(seat[4]==0){ seat[4] = 1; } } //------------------------------------------------------------------- else if(seat[1]> 0 && seat[2]> 0 && seat[3] > 0 && seat[0]> 0){ if(seat[1]==0){ seat[1] = 1; }if(seat[2]==0){ seat[2] = 1; }if(seat[3]==0){ seat[3] = 1; }if(seat[0]==0){ seat[0] = 1; } } //-------------------------------------------------------------------- }else{ for(i=8; i<12; i++){ if(seat[i]==0){ seat[i]=1; } } }//end else section=0; } //--------------------------------------------------------------------- //Section 4 //--------------------------------------------------------------------- if(section==4){ if(seat[13]> 2 && seat[14]> 2 && seat[15] > 2 && seat[12]> 2){ for(i=12; i<16; i++){ if(seat[i]==4){ seat[i]=2; } } if(seat[9]> 0 && seat[10]> 0 && seat[11] > 0 && seat[8]> 0){ for(i=8; i<12; i++){ if(seat[i]==0){ seat[i]=1; } } } else if(seat[4]> 0 && seat[5]> 0 && seat[6] > 0 && seat[7]> 0){ for(i=4; i<8; i++){ if(seat[i]==0){ seat[i]=1; } } } else if(seat[0]> 0 && seat[1]> 0 && seat[2] > 0 && seat[3]> 0){ for(i=0; i<4; i++){ if(seat[i]==0){ seat[i]=1; } } } }else{ for(i=12; i<16; i++){ if(seat[i]==0){ seat[i]=1; } } }//end else }//end if IF section=0; }//end void //----------------------------------------------------------------------------- // Timer2_Init //----------------------------------------------------------------------------- // // Configure Timer2 to 16-bit auto-reload and generate an interrupt at // interval specified by <counts> using SYSCLK/48 as its time base. // void Timer2_Init (int counts) { TMR2CN = 0x00; // Stop Timer2; Clear TF2; // use SYSCLK/12 as timebase CKCON &= ~0x60; // Timer2 clocked based on T2XCLK; TMR2RL = -counts; // Init reload values TMR2 = 0xffff; // set to reload immediately ET2 = 1; // enable Timer2 interrupts TR2 = 1; // start Timer2 } //----------------------------------------------------------------------------- // Interrupt Service Routines //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // Timer2_ISR //----------------------------------------------------------------------------- // This routine changes the state of the LED whenever Timer2 overflows. // void Timer2_ISR (void) interrupt 5 { TF2H = 0; // clear Timer2 interrupt flag LED1 = ~LED1; LED1 = ~LED1; // change state of LED }
is it correct? like that can communicate with port 1? If this one can then my problem now is with the circuit. Because I need to pass a "1" or "0" to the serial port. And if it reads it, 1 of the LED on the development board will light up.
Thanks!
Powered by e107 Forum System