![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| Hi, I have a problem with serial communication. I want to send a byte to the reciver by Rf transmitter and reciever.I read the sensor data and pic16F873A send it to RF transmitter and then RF reciever take it to the pic16F873A in reciever circuit. maby you said the reoson is the errors would be occurs in RF transportation. but i coonect two micro by a wire and also i have aproblem. and in the reciever lcd don't show any number or a wrong number. wire that i use is short. what is the problem? is it in my software? i write it in pic basic. i write my program for transmitter and reciever. could you help me with this? tarnsmitter: define OSC 4 include"modedefs.bas" trisb= %00000000 x var byte y var byte i var byte pause 2000 x=23 y=2 for i=1 to 10 serout PORTB.7,N1200,[y] serout PORTB.7,N1200,[x] next i end reciever: define OSC 4 include"modedefs.bas" ' Set LCD Data port DEFINE LCD_DREG PORTC ' Set starting Data bit (0 or 4) if 4-bit bus DEFINE LCD_DBIT 4 ' Set LCD Register Select port DEFINE LCD_RSREG PORTC ' Set LCD Register Select bit DEFINE LCD_RSBIT 1 ' Set LCD Enable port DEFINE LCD_EREG PORTC ' Set LCD Enable bit DEFINE LCD_EBIT 0 ' Set LCD bus size (4 or 8 bits) DEFINE LCD_BITS 4 ' Set number of lines on LCD DEFINE LCD_LINES 2 pause 100 lcdout $fe,1 trisb= %11111111 x var byte y var byte z var byte start: lcdout $fe,1 serin PORTB.5,N1200,[2],x serin PORTB.5,N1200,[2],y serin PORTB.5,N1200,[2],z if (y=z) then lcdout $fe,1,#y endif pause 5000 goto start end Amin Derazgisoo | |
| |
| | (permalink) |
| You can't just send standard RS232 over an RF link, because it's AC coupled! - this is why coding systems are used, check my PIC RF tutorial. | |
| |
| | (permalink) |
| i just read the data of the sensor and get it to pic and then micro take it to RF transmitter and in the reciever circuit,RF reciever get the serial date and give it to micro. but i have aproblem. i also have a oproblem by connecting two micro by wire. and there are alot of errors. | |
| |
| | (permalink) |
| Begin with a simple wire solution and try to understand what you do first. Sure your program don't work. try the following Code: ' Transmitter
' ===========
define OSC 4
include "modedefs.bas"
TRISB = 0
y var byte
z var byte
i var byte
y=20
z=200
LOW PORTB.7 ' set serial output to normal state
Pause 2000 ' settle delay
Start:
for i=1 to 10
serout PORTB.7,N1200,[2,y,z]
next i
goto Start
end Code: ' Receiver
' ========
define OSC 4
include "modedefs.bas"
trisb= %11111111
DEFINE LCD_DREG PORTC
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTC
DEFINE LCD_RSBIT 1
DEFINE LCD_EREG PORTC
DEFINE LCD_EBIT 0
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
pause 100
lcdout $fe,1
y var byte
z var byte
start:
SERIN2 PORTB.5,N1200,[Wait(2),y,z]
lcdout $fe,1,DEC y, DEC z
goto start
end Last edited by mister_e; 30th July 2006 at 06:07 PM. | |
| |
| | (permalink) |
| Hi, i wrote your program but it didn't work. | |
| |
| | (permalink) |
| assuming your errors are due to serial I/O on your direct connected pics, a couple of possibilities: - running both with internal osc could result in too much baudrate error (you could be seeing up to double the spec'd error rate) - what kind of wire are you using between them - twisted or parallel? running over other signal sources? route the wires away from signal sources. - bypassed your power on both PICs? lots of people do use straight async on RF TX/RX but there are issues. it can be made to work but you are better off using some sort of coding - manchester, for example. | |
| |
| | (permalink) |
| I used 20M crystal for my work but it didn't work.when i used 4M crystal it works but it has errors.i want to use haming code . i want to send about 10 bytes.i want to know that i should send each byte for example 10 times or i send all of them 10 times? i think my program is wrong.could you help me with this? Last edited by amindzo; 31st July 2006 at 05:31 AM. | |
| |
| | (permalink) |
| can't you put the data in a latch and then extract it with the second µC | |
| |
| | (permalink) |
| i just read the data of the sensor and get it to pic and then micro take it to RF transmitter and in the reciever circuit,RF reciever get the serial date and give it to micro. but i have aproblem. i also have a oproblem by connecting two micro by wire. and there are alot of errors. what do you mean? what should i do? | |
| |
| | (permalink) |
| You should be able to use async to communicate between 2 pics. especially at 1200 baud. something else is not right here. I would chase this one down. you have connected the grounds of the 2 circuits, right? why don't you post a schematic? | |
| |
| | (permalink) |
| I am not familier with pic basic, can you connect the output of your TX chip to the PC? and use something like Hyperterminal to read the bytes coming from the TX chip, if this works ok then it's the RX that is at fault. I am also wondering if the RX chip is expecting the data to be "flipped/inverted" such as would happen with an rs232 translation chip like the MAX232, if so then you will not have any joy until you flip/invert this data You can write some simple RS232 routines in assembler (AKA bit-banging) that will let you communicate with a PC directly (only a 10K resistor needed), if you want an example of this then let me know. Is it possible to incorperate asm into pic Basic?? Basically I am trying to say, break down your problem into smaller chunks to try and find were the problem is........ As nigel has said, this won't help with radio, but you will learn along the way Hope this helps
__________________ Regards MATT! | |
| |
| | (permalink) |
| i have coonectedn the grounds of 2 circuit but in real they should be far as each other about 10 meter so i can't connect the grounds of two circuits. | |
| |
| | (permalink) |
| So are you saying that close together, with the ground connected, they work?
__________________ Regards MATT! | |
| |
| | (permalink) |
| in both situation they work with errors. | |
| |
| | (permalink) |
| i thin i have problem with program.could you help me with this in picbasic? | |
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |