CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Remote data transfer TWS-434 and RWS-434
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

Remote data transfer TWS-434 and RWS-434
PostPosted: Mon Nov 29, 2004 8:59 am     Reply with quote

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








PostPosted: Mon Nov 29, 2004 10:39 am     Reply with quote

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
Code:




how to explain them in CCS c language?
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Mon Nov 29, 2004 11:12 am     Reply with quote

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








PostPosted: Mon Nov 29, 2004 11:32 am     Reply with quote

thank you Mark:
How about the serial in part?
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Mon Nov 29, 2004 11:41 am     Reply with quote

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








PostPosted: Mon Nov 29, 2004 11:45 am     Reply with quote

can I use puts("126Adata\r") instead of put(126); put('A'); putc(data);
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Mon Nov 29, 2004 11:48 am     Reply with quote

No
Guest








PostPosted: Mon Nov 29, 2004 11:52 am     Reply with quote

what if I want to sent some data like this"125 233 567 23"; instead of just one int data?
Guest








PostPosted: Mon Nov 29, 2004 12:26 pm     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Mon Nov 29, 2004 12:26 pm     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Mon Nov 29, 2004 12:30 pm     Reply with quote

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








PostPosted: Mon Nov 29, 2004 12:46 pm     Reply with quote

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








PostPosted: Mon Nov 29, 2004 12:50 pm     Reply with quote

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�������|Lww7���wx`w7
���� .
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Mon Nov 29, 2004 12:51 pm     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Mon Nov 29, 2004 12:56 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
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