Strange RF Problem

J

Jason

Guest
Hi,

I have circuit with a MX232 that I pass serial data from my comp. It feeds
into a 16F628 chip and then the chip feeds a LCD screen. I have it set to
2400 baud and it works great. Then what I did was I put a TWS-434 from the
MX232 and a RWS-434 into the 16F628. I am trying not to use a decoder or
encoder. I have it sending data and it seems to be working. The wierd
thing is that when I send it text the first few characters are turned in
wierd characters but after that the rest of the string is ok. It seems to
be having problems initlitzing the transmitter or reciever but once it gets
started it works.

So if I send it:

d d Hello my name is bob

I get:

#&%Hello my name is bob.

Anyone got any ideas?? I included the code for the PIC below. Thanks in
advance!!




processor PIC16F628 ;16F628
__CONFIG 0x3e62

LIST P=16F628, R=DEC ; Use the PIC16F628 and decimal system

#include "P16F628.INC" ; Include header file

CBLOCK 0x20 ; Declare variable addresses starting at
0x20
dataL
ENDC

ORG 0x000 ; Program starts at 0x000
;
; --------------------------------
; SET ANALOG/DIGITAL INPUTS PORT A
; --------------------------------
;
movlw 7
movwf CMCON ; CMCON=7 set comperators off
;
; ----------------
; INITIALIZE PORTS
; ----------------
;
movlw b'00000000' ; set up portA
movwf PORTA

movlw b'00000100' ; RB2(TX)=1 others are 0
movwf PORTB

bsf STATUS,RP0 ; RAM PAGE 1

movlw 0xFF
movwf TRISA ; portA all pins input

movlw b'11110010' ; RB7-RB4 and RB1(RX)=input, others output
movwf TRISB

; ------------------------------------
; SET BAUD RATE TO COMMUNICATE WITH PC
; ------------------------------------
; Boot Baud Rate = 9600, No Parity, 1 Stop Bit
;


bcf TXSTA, SYNC ; set asynchronous
bcf TXSTA, BRGH ; set low baud rate
movlw 0x40 ; 1200bps (51 = 0x33 @ 4MHz) 19 for 2400,
40 for 10mhz at 2400 baud
movwf SPBRG

bcf STATUS, RP0 ; select bank 0
bsf RCSTA, SPEN ; ENable Serial Port

bsf STATUS, RP0 ; select bank 1
bsf TXSTA, TXEN ; ENable TX
bsf PIE1, RCIE ; Enable RX interrupt

bcf STATUS, RP0 ; back to bank 0
bsf RCSTA, CREN ; ENable RX


;
; ------------------------------------
; PROVIDE A SETTLING TIME FOR START UP
; ------------------------------------
;
clrf dataL
settle decfsz dataL,F
goto settle

movf RCREG,W
movf RCREG,W
movf RCREG,W ; flush receive buffer


; ---------
; MAIN LOOP
; ---------
;
call message ;call message ; send "16F628 alive"
loop call receive ; wait for a char
call send ; send the char
goto loop
;
; -------------------------------------------
; RECEIVE CHARACTER FROM RS232 AND STORE IN W
; -------------------------------------------
; This routine does not return until a character is received.
;
receive btfss PIR1,RCIF ; (5) check for received data
goto receive

movf RCREG,W ; save received data in W

return




;
; -------------------------------------------------------------
; SEND CHARACTER IN W VIA RS232 AND WAIT UNTIL FINISHED SENDING
; -------------------------------------------------------------
;
send movwf TXREG ; send data in W

TransWt bsf STATUS,RP0 ; RAM PAGE 1
WtHere btfss TXSTA,TRMT ; (1) transmission is complete if hi
goto WtHere

bcf STATUS,RP0 ; RAM PAGE 0
return
;
; -------
; MESSAGE
; -------
;
message movlw '1'
call send
movlw '6'
call send
movlw 'F'
call send
movlw '6'
call send
movlw '2'
call send
movlw '8'
call send
movlw ' '
call send
movlw 'a'
call send
movlw 'l'
call send
movlw 'i'
call send
movlw 'v'
call send
movlw 'e'
call send
movlw 0x0D ; CR
call send
movlw 0x0A ; LF
call send
return


END
 
"Jason" <jason@mindspring.com> wrote in message news:<vI38c.10834$Rr5.817864@twister.southeast.rr.com>...
Hi,

I have circuit with a MX232 that I pass serial data from my comp. It feeds
into a 16F628 chip and then the chip feeds a LCD screen. I have it set to
2400 baud and it works great. Then what I did was I put a TWS-434 from the
MX232 and a RWS-434 into the 16F628. I am trying not to use a decoder or
encoder. I have it sending data and it seems to be working. The wierd
thing is that when I send it text the first few characters are turned in
wierd characters but after that the rest of the string is ok. It seems to
be having problems initlitzing the transmitter or reciever but once it gets
started it works.

So if I send it:

d d Hello my name is bob

I get:

#&%Hello my name is bob.

Anyone got any ideas?? I included the code for the PIC below. Thanks in
advance!!

[snipped code]

What makes you think it's an RF problem? It's gotta be the software
;-)

Seriously, have you looked at the signal to see if you have the Start
sequence you expect? Also check the Rx signal for noise.

Frank Raffaeli
http://www.aomwireless.com/
 
To be honest Frank,

I am not sure what the start sequence should be. When I remove the
transmitter and receiver it works fine, but then when I put the transmitter
and receiver in the middle between the MX232 and the PIC chip I get this
problem. I have learned assembly language and the ins and outs of a
PIC16F628 (including how to program them) and read a 1200 page book on
microcontrollers all in about 2 weeks. I have absorbed a lot of information
and now it looks like I am about to learn about RF transmitters. I think it
might be noise. I might have to get an encoder and decoder but I was hoping
to avoid them. I will try a few more things. One guy said something about
the transmitter going into sleep mode and that I have to set something to
make it react faster. If all else fails I will just send the 4 characters
first and disregard them and only use the message that is readable. That
might be the wrong approach but hey if it works :).



"Frank Raffaeli" <SNIPrf_man_frTHIS@yahoo.com> wrote in message
news:2c8119eb.0403232001.4666743c@posting.google.com...
"Jason" <jason@mindspring.com> wrote in message
news:<vI38c.10834$Rr5.817864@twister.southeast.rr.com>...
Hi,

I have circuit with a MX232 that I pass serial data from my comp. It
feeds
into a 16F628 chip and then the chip feeds a LCD screen. I have it set
to
2400 baud and it works great. Then what I did was I put a TWS-434 from
the
MX232 and a RWS-434 into the 16F628. I am trying not to use a decoder
or
encoder. I have it sending data and it seems to be working. The wierd
thing is that when I send it text the first few characters are turned in
wierd characters but after that the rest of the string is ok. It seems
to
be having problems initlitzing the transmitter or reciever but once it
gets
started it works.

So if I send it:

d d Hello my name is bob

I get:

#&%Hello my name is bob.

Anyone got any ideas?? I included the code for the PIC below. Thanks
in
advance!!

[snipped code]

What makes you think it's an RF problem? It's gotta be the software
;-)

Seriously, have you looked at the signal to see if you have the Start
sequence you expect? Also check the Rx signal for noise.

Frank Raffaeli
http://www.aomwireless.com/
 
Jason wrote:

Hi,

I have circuit with a MX232 that I pass serial data from my comp. It feeds
into a 16F628 chip and then the chip feeds a LCD screen. I have it set to
2400 baud and it works great. Then what I did was I put a TWS-434 from the
MX232 and a RWS-434 into the 16F628. I am trying not to use a decoder or
encoder. I have it sending data and it seems to be working. The wierd
thing is that when I send it text the first few characters are turned in
wierd characters but after that the rest of the string is ok. It seems to
be having problems initlitzing the transmitter or reciever but once it gets
started it works.

So if I send it:

d d Hello my name is bob

I get:

#&%Hello my name is bob.
I suspect that the output of your radio link takes a while to settle to
the right DC level. I don't know your units specifically, but the ones I
have used have a comparator on the ouput, whose reference is set by the
signal level. So until the first few bytes have come through, the
comparator won't be switching at the midpoint.

That's why you'll find that many radio protocols have a leader (often a
number of 0x55 bytes) which is repeated say 10 times by the transmitter,
but only needs to be seen say 5 times at the receiver. And while you'll
probably be OK with short ASCII transmissions, if you are sending binary
and there are likely to be longish sequences of 0x00 or 0xff or near
those levels, you might again get the comparator level drifting.

Straight "RS232" serial over radio works best with ASCII in short
bursts, and with a header and a checksum. Binary or anything longer, and
you want something like Manchester encoding.

Paul Burke
 
Hi!
If it is a rf problem? (I think so. Probably a dc threshold restoration
delay at the receiver) you can make a sync vector to open correct
communication. That is a relatively long special bit-sequence, nether used
in normal "transparent" communication. Send it a few times at the beginning
and watch at the receiver on it to open the bit-path to the next stage.
PS: A good sync vector is a spread-spectrum sequence. You can find more on
the Net.
If you reverse the bit-sequence at the end of the communication burst, you
have a simple end flag.

(I do not regularly monitor the NG so please send private mail if you have a
need to communicate with me)

Regards -
Henry
 
the first few characters are turned in
wierd characters but after that the rest of the string is ok. It seems to
be having problems initlitzing the transmitter or reciever but once it gets
started it works.

So if I send it:

d d Hello my name is bob

I get:

#&%Hello my name is bob.
mondo snippage:
without looking at the hardware you mentioned, heres two guesses:

Ok, two possibilities off the top of my head, 1.your receiver needs
to set a bias level by charging a capacitor to decide where to chop
the incoming signal into highs and lows. commercial gear sends a
preamble, ie a string of FFs or 10101010 then a known phrase for
syncing the microprocessor, how its done depends on the hardware in
use. try sending 10101010 then your text.
ie send// ff ff ff 10101010 10101010 S Y N C \\ each time you
transmit.
This will set up a bias and let you know where you are in the data
string. Also consider adding in error checking, send a checksum byte
at the end. (look up "checksum" on google) If you are also sending
just text, you will be able to find 27 binary words close enough to
50% duty cycle(ie looks like 10101010) and can cut down your error
rate by sending them to represent each letter and decoding back to
human readable text at the receiver. Sending too slow will also cause
this problem.

Possibility two, turn the TX line on high and wait a bit time or two
before you transmit, you may be clipping your first bit of data off,
waiting for the TX to start up,stabilize, and get on frequency,
especilly if the TX oscillator is just simply on/off keyed (ie the
transmitter maker was to cheap to add a proper modulater to the TX
board)

Search a few of the RF module vendors web sites, they usually have
tutorials on start up delays, preambles, and error rates.

Steve Roberts
 

Welcome to EDABoard.com

Sponsor

Back
Top