|
|
View previous topic :: View next topic |
Author |
Message |
young
Joined: 24 Jun 2004 Posts: 285
|
Remote data transfer TWS-434 and RWS-434 |
Posted: Mon Nov 29, 2004 8:59 am |
|
|
I am trying to use TWS-434 & RES-434 to transfer data and receive data. My setup is like this:
Send data from PC to Transmitter TWS-434,
Setup a PIC (12f675) to receive data from RES-434
Data transferring without TWS & RES was done successfully and being check up on hyperterminal.
I directly connected PC RS232 output pin to TWS pin2 (data in pin), and signal from RES_434 pin 2 connected to MAX232 in pin, max232 out pin was connected to 12f675 data in pin.
right now, without doing anything, 12f675 is receiving garbbage data continuously?
my code is as follows:
Code: |
#if defined(__PCM__)
#include <12F675.h>
#fuses XT, BROWNOUT,NOWDT,NOPROTECT,PUT,NOMCLR
#use delay(clock =4000000)
#use rs232(baud=2400, parity=N, RCV=PIN_A3,XMIT=PIN_A2)
void main ()
{
char ch;
setup_comparator(NC_NC_NC_NC);
SETUP_ADC_PORTS(NO_ANALOGS);
while(1)
{
output_high(PIN_A0);
delay_ms(200);
output_low(PIN_A0);
delay_ms(200);
ch=getchar();
putc(ch);
if(ch=='a')
{
output_high(PIN_A1);
delay_ms(200);
output_low(PIN_A1);
delay_ms(200);
}
}
}
|
Led connected to PIN_A0 continuously blinking, (gabbarge data continuously coming in), when I click on any letter, there is no function.
related website is www.rentron.com/stamp_RF.htm
please help me out to send and receive data correctly. and why this gabbarge data comes, and how to eliminate them
thank you |
|
|
Guest
|
|
Posted: Mon Nov 29, 2004 10:39 am |
|
|
there are some code in that website in Basic:
for transmitter:
Code: |
symble dat=b2
symbol synch=b3
symbol junk=b4
synch="A"
junk=126
start:
pause 1000
for dat=1 to 255
serout 0,N2400,(junk,synch,dat)
pause 50
next
serout 0,N2400, (junk,synch,0)
goto start
|
for receiver
SYCH con "A"
BAUD CON 16780
DAT VAR byte
DIRH=%11111111
START:
SERIN 0, BAUD, [WAIT(SYNCH),DAT)
OUT=dat
GOTO start
how to explain them in CCS c language? |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Nov 29, 2004 11:12 am |
|
|
Code: |
#use rs232(baud=2400, parity=N, RCV=PIN_A3,XMIT=PIN_A2)
int dat;
char synch;
char junk;
junk = 126;
synch = 'A';
while(1)
{
delay_ms(1000);
for (dat=1; dat<=255;dat++)
{
putc(junk);
putc(synch);
putc(dat);
delay_ms(50);
}
putc(junk);
putc(synch);
putc(0);
}
|
|
|
|
Guest
|
|
Posted: Mon Nov 29, 2004 11:32 am |
|
|
thank you Mark:
How about the serial in part? |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Nov 29, 2004 11:41 am |
|
|
It would be something like
Code: |
char synch;
synch = 'A';
while (getc() != synch);
dat = getc();
|
or just
Code: |
while (getc() != 'A');
dat = getc();
|
and then they just display the data on some port |
|
|
Guest
|
|
Posted: Mon Nov 29, 2004 11:45 am |
|
|
can I use puts("126Adata\r") instead of put(126); put('A'); putc(data); |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Nov 29, 2004 11:48 am |
|
|
No |
|
|
Guest
|
|
Posted: Mon Nov 29, 2004 11:52 am |
|
|
what if I want to sent some data like this"125 233 567 23"; instead of just one int data? |
|
|
Guest
|
|
Posted: Mon Nov 29, 2004 12:26 pm |
|
|
Mark:
I test the program that you provided, I could not see any data being received, if I eliminate while (getc() != 'A'); I can see some data coming in , but the data is not right that I sent? why |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Nov 29, 2004 12:26 pm |
|
|
Code: |
putc(junk);
putc(synch);
putc(125);
putc(233);
putc(567);
putc(23);
|
Keep in mind the example they posted was a crude method for waking up the receiver and synching the data. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Nov 29, 2004 12:30 pm |
|
|
Quote: | I test the program that you provided, I could not see any data being received, |
I only translated the code for you. Post you whole program, both the receiver and transmitter code. |
|
|
Guest
|
|
Posted: Mon Nov 29, 2004 12:46 pm |
|
|
Thank you mark:
here is the code for receiver:
Code: |
#if defined(__PCM__)
#include <12F675.h>
#fuses XT, BROWNOUT,NOWDT,NOPROTECT,PUT,NOMCLR
#use delay(clock =4000000)
#use rs232(baud=9600, parity=N, RCV=PIN_A3,XMIT=PIN_A2)
void main ()
{
char ch[20];
int dat;
setup_comparator(NC_NC_NC_NC);
SETUP_ADC_PORTS(NO_ANALOGS);
while(1)
{
while (getc() != 'A');
dat = getc();
putc(dat);
}
} |
transmitter:
Code: |
#if defined(__PCM__)
#include <12F675.h>
#fuses XT, BROWNOUT,NOWDT,NOPROTECT,PUT,NOMCLR
#use delay(clock =4000000)
#use rs232(baud=9600, parity=N, RCV=PIN_A3,XMIT=PIN_A2)
void main ()
{
char ch;
int dat;
char synch;
char junk;
setup_comparator(NC_NC_NC_NC);
SETUP_ADC_PORTS(NO_ANALOGS);
junk = 126;
synch = 'A';
while(1)
{
delay_ms(1000);
for (dat=1; dat<=255;dat++)
{
putc(junk);
putc(synch);
putc(dat);
delay_ms(50);
}
putc(junk);
putc(synch);
putc(0);
}
}
|
|
|
|
Guest
|
|
Posted: Mon Nov 29, 2004 12:50 pm |
|
|
here is some data I received from RF without while (getc() != 'A');
007³³˙w³³w7³w·7³òw7³ùv3³Àw7³
w³³³÷w³À6³ w³³w·³àw·³òw7@ww·³·7³˙w·³³ŝ|Lww7wx`w7
³³ . |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Nov 29, 2004 12:51 pm |
|
|
Following their scheme it should have been:
Note that 567 requires 2 bytes
Code: |
int dat[5] = {125,233,55,2,23;
for (i=0; i<5;i++)
{
putc(junk);
putc(synch);
putc(dat[i]);
delay_ms(50);
}
|
|
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Nov 29, 2004 12:56 pm |
|
|
Quote: | #use rs232(baud=9600, parity=N, RCV=PIN_A3,XMIT=PIN_A2) |
The datasheet says the max rate is 3K BPS with the typ being 2.4K or 2400 BAUD
http://www.rentron.com/Files/rf.pdf
Also note that printing acsii 1-255 will give you some readable chars while others will do wierd things. You might want to change the range from 32 to 126. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|