PDA

View Full Version : Tws 434/ Rws 434



jmbanales21485
- 24th July 2007, 06:51
I am trying to incorporate wireless technology into my pic projects and got the TWS 434 and RWS 434 transmitter and reciever modules.

From what i understand in the datasheet and a couple of examples I found, is that you can use serial communication to communicate between these 2 modules.

my problem is that i don't get any communication. I tried my program directly from pic to pic and it works fine, the problem is when i add these 2 modules then it doesn't work. I am using the 12F683 with a 4 MHZ internal osc. here is my code and hopefully someone can shed some light on how to get these things working

===========Reciever===============
Define OSC 4 'OSC at 4 MHZ

TRISIO = %000001 'Set PORTA.0 as input rest output
ANSEL = 0 '0 analog inputs
CMCON0 = 7 'Disable analog comparator
option_reg.7 = 0 'enable pullups

LCD VAR PORTA.1 'lcd output
rx var PORTA.0 'Serial Input
baud con 396 '2400 baud

synch CON "a"
dat VAR BYTE
dummy VAR BYTE

dummy = 0
dat = 0
begin:
serin2 rx, baud, [WAIT(synch), dat] 'receive "a" then get dat
dummy = dat
pause 5:serout2 LCD, baud, ["start", 1, DEC (dummy), 0] 'send out to LCD
goto begin

'===========transmitter============
Define OSC 4 'osc at 4 MHZ

TRISIO = %000000 'all output
ANSEL = 0 '0 analog inputs
CMCON0 = 7 'comparators off
option_reg.7 = 0

tx var PORTA.0
baud con 396 '2400 baud
junk VAR BYTE
synch CON "a"
dat VAR BYTE

dat = 0
junk = "j"
loopa:
pause 1000
serout2 tx, baud, [junk, junk, junk, junk, junk, junk, junk, junk, junk, junk] 'wait to synch oscillator
for dat = 1 to 255
serout2 tx, baud, [synch, dat] 'send data
pause 500
next dat
goto loopa

Jerson
- 24th July 2007, 08:08
Try baud rate 1200 instead of 2400. Most of these modules are good at this frequency.

mackrackit
- 24th July 2007, 10:52
Two things:
First, the junk data transmitted has to be a certain type of junk. The receiver has to be put into a “middle” state in order to work. Think of a capacitor that is charged to its maximum of 25 volts. Adding a 25 volt signal to it will not have a change on its state. The same goes for one that is zero charged, 0 volts will not change its state. In order for either 0 or 25 volts to have the same effect the capacitor has to have an initial charge of 12.5 volts.

To put the receiver in a “middle” state send $55 five times. Then send the synch then your data all on one line.



'transmitted
junk = $55
synch = a
SEROUT PIN,N2400,[junk,junk,junk,junk,junk,synch, data]




'received
SERIN PIN, N2400,[“a”],data


Notice I used the SERIN/SEROUT , not SERIN2/SEROUT2.

PJALM
- 24th July 2007, 14:50
These modules require all data to be encoded using the Manchester code. Search this forum for it and you will find lots of examples.

dhouston
- 24th July 2007, 15:29
These modules require all data to be encoded using the Manchester code. Search this forum for it and you will find lots of examples.Manchester encoding is not a requirement. They are used extensively without it.

mackrackit
- 24th July 2007, 17:24
Manchester encoding is not a requirement. They are used extensively without it.
Agreed. When I was having my problems with SERIAL, tested RF by simply sending a high bit.

Kind of like Morse code. Instead of "..._ _ _..." it was "... ...":)
DOTS = HIGH

jmbanales21485
- 28th July 2007, 16:50
sorry for the late reply, i have not had time to work on this till now.


so it tried what you said and sent %10101010 to stabalize the oscillators, (put it in the neutral zone). and now i am able to get something on the other end of the pic. however i can't seem to get it continously. in my sample program i am counting numbers continously in my transmitter side and sending it to my reciever to display it. it sends numbers but it does not send it continously.

i.e i send 1,2,3,4,5,6,7,8,9,10 and will recieve 1, 4, 6,9

how do i make my program more stable.

'=====transmitter=====
junk = $55
synch = "a"
dat = 0
loopa:
pause 1000
serout tx, N2400, [junk, junk, junk, junk, junk, synch, dat]
dat = dat + 1
if dat = 255 then dat = 0
goto loopa

'=====reciever======
synch = "a"
dat = 0
begin:
serin rx, 4, [synch], dat
pause 5:serout2 LCD, baud, ["start", 1, DEC (dat), 0]
goto begin

dhouston
- 28th July 2007, 17:38
For small amounts of data I prefer using the NEC protocol which has been around since the dawn of remote control and has been widely used by manufacturers of audio/visual gear.

I posted a short example for sending/receiving in the Code Examples forum.

http://www.picbasic.co.uk/forum/showthread.php?t=6261

mackrackit
- 28th July 2007, 18:10
After re-reading this I noticed
I tried my program directly from pic to pic and it works fine, the problem is when i add these 2 modules then it doesn't work. I am using the 12F683 with a 4 MHZ internal osc.
The internal osc will sometimes work and sometimes not. To be safe use an external osc. The ones with three pins have built in caps and prove to be stable.

At some point you will need a protocol like dhouston mentioned. Here is a link that has a lot of good reading http://www.linxtechnologies.com/Support/Application-Notes/
App notes AN-00160 an AN-00232 might be of interest.

But...for sending one or two characters of data you should be "OK" if there is not out side interference. I send numbers like 11, 12, 13 or strings "HI" and so on with out using any protocol and works fine.
Try changing the osc and look at dhoustons link, good example.

jmbanales21485
- 29th July 2007, 06:17
i have 20MHz crystalz. Do i have to define 20Mhz in PBP or can i define 4Mhz.

mackrackit
- 29th July 2007, 07:04
i have 20MHz crystalz. Do i have to define 20Mhz in PBP or can i define 4Mhz.
Yes and no. I say this as some play with different speeds (over-clocking )or for some other reason. In you case

DEFINE OSC 20in PBP.

Also you will need to change you *inc file to HS_OSC. Or read this for more on the configuration methods. http://www.picbasic.co.uk/forum/showthread.php?p=6775#post6775