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 Previous  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
Guest








PostPosted: Mon Nov 29, 2004 2:34 pm     Reply with quote

I changed baud rate to 2400, and for (dat=32; dat<=126;dat++)
and follwoing are the data I got from the hyperterminal:
It seems not right yet! what else might be wrong!
W*=DOXa'@d!*4ENYmrv+=>AEO�S\`jnorx{=BO�afhj'B�$%
).167>?CDGSY_it%6KQimvw,45=>FOPX`cot4BCG�]|~ bc27<W*.9BK�Qq4F�a&T\e":
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 2:41 pm     Reply with quote

Post both programs please
Guest








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

I believe with your help, I am approaching to the target nearer and nearer. thank you!
here is the code:

receiver:

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[20];
  int dat;
  setup_comparator(NC_NC_NC_NC);
  SETUP_ADC_PORTS(NO_ANALOGS);
 
  while(1)
     { 
     while (getc() != 'A');
     dat = getc();
     putc(dat);
     }
}


transmiter:

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;
  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=32; dat<=126;dat++)
  {
    putc(junk);
    putc(synch);
    putc(dat);
    delay_ms(50);
  }
  putc(junk);
  putc(synch);
  putc(0);
  }

}
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 3:05 pm     Reply with quote

Did you change Hyperterminal or whatever terminal program you are using to 2400 baud as well?
Guest








PostPosted: Mon Nov 29, 2004 3:23 pm     Reply with quote

Thank you very much mark:
I finally I figured it out. The problem with it is the delay in the transmitter side. It should delay_ms(5) instead of delay_ms(50);

I may try some other options also, like delay less time, and I will let you know the uper limite to get nice signal.

Appreciated a lot!
languer



Joined: 09 Jan 2004
Posts: 144
Location: USA

View user's profile Send private message

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

Edit:
I guess you can probably disregard this message


I've been trying to follow this thread and I lost you quite early.

You started with the following I think:
PC -> TWS -> RWS -> MAX232 -> PIC

You're echoing back to the PC like this:
PIC -> PC
or like this:
PIC -> MAX232 -> PC

Now you have some transmitter in the way, how does the new path looks?

Like this:
PIC -> TWS -> RWS -> PIC
or like this:
PIC -> TWS -> RWS -> MAX232 -> PIC

Same question applies for echoing back to PC.

Note that for proper operation with your code, you want to keep to the BOLD interfaces (where there are two choices).

In case it helps.


Last edited by languer on Mon Nov 29, 2004 5:22 pm; edited 1 time in total
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 3:36 pm     Reply with quote

He has 2 pics connected with a radio link. The receiver echos the receiver data to a PC for debugging.

Young:
Read the post
http://www.electronics-forum.info/design/Strange_RF_Problem_377554.html
Guest








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

Thank you mark:
I will check it immediately.

best wishes!
Guest








PostPosted: Mon Nov 29, 2004 3:52 pm     Reply with quote

Hi mark:
One thing I forgot is that delay_ms(5) is the only options I tried 4, 3,2,1 it wont work well.
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

PostPosted: Tue Dec 07, 2004 4:45 pm     Reply with quote

Hi mark:

I am facing aproblem with the wireless comunication right now.
The problem is

I send data from a PIC to transimitter, and use another PIC to receive data, everything works fine except when I turn off power and restart the program. when I restart the program by turn on power, the received side is not working, I have to take off the crystal and put them back a few times, and then it start to print out data to terminal, I feel very wired, could you help me with this.
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

PostPosted: Tue Dec 07, 2004 6:16 pm     Reply with quote

I think my crystal is no stable, I changed my crystal, now is working.
tr
Guest







RWS434 problem
PostPosted: Wed Jan 31, 2007 9:34 am     Reply with quote

I have a problem with rws-434. Even if there is no transmitter to send any rf data, when i connect rws-434's digital output pin(Pin2) to pc's serial por over max232 circuit, I read weird ascii chars(hyperterminal).

The max232 circuit works just fine. I'm using it to bootload my firmware into pic.

What can the problem be? Am i using the wrong output pin or what?
Should I use linear output pin(pin3)

I know this topic is obsolete, but please help..
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

PostPosted: Wed Jan 31, 2007 9:40 am     Reply with quote

What you're seeing is normal. The RF receiver's job is to demodulate signals in its frequency band. It's supposed to lock onto the strongest signal and demodulate it. In your case, the strongest signal is just noise, which explains the random junk you're receiving. Power up a transmitter, and the junk will go away.

Here's a post from the code library with some working code: http://www.ccsinfo.com/forum/viewtopic.php?t=23953 At the top of the post is a link to another forum post, read everything in that thread and what you're seeing will start to make sense.
tr
Guest







PostPosted: Wed Jan 31, 2007 9:48 am     Reply with quote

hi newguy,
thanks for your quick reply..
ze.vana



Joined: 11 Jun 2011
Posts: 15

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

TWS434 16F628
PostPosted: Thu Jul 19, 2012 5:17 am     Reply with quote

Hello people I was also looking for a code in C that could translated that such Basic Stamps.
And I also wanted to leave my contribution, maby this serves as base for others.
Then based on what was published here I created other code using PICS 2 16F628. I noticed that the largest problem in a serial communication is to synchronize the RECEIVER with the transmitter. This code uses the Interruption RDA (RS232 Interruption ) in the Receiver and a hardware Reset: a 1uF CAPACITOR connected from pin6 RB0 to pin4 MCLR and 10K resistor from MCLR to vdd (Note: soft reset "resetcpu()" does not work) . When e Transmitter or Receiver is turned off and ON, data can come aleatory; CPU restarts and get normal sequence, it takes miliseconds. I've tested this on Proteus and also by hardware, it really works!
Transmitter
Code:

////////////434trans628.c///////////////////////////
#include <16f628a.h>
#fuses INTRC_IO, NOLVP, NOWDT, PUT, BROWNOUT
#use delay (clock=4M)// No crystall is needed
#use rs232(baud=2400,XMIT=PIN_B2,RCV=PIN_B1,bits=8)
#define a2 (pin_a0)//pin 17
#define a3 (pin_a1)//pin 18
  char junk;
  char synch;
  int dat,dat2;
byte send[4];
 // int8 div;
void send_dat(void)
{
  int i;
  for (i=0; i<4; ++i)//send 4 data
  {                 //0 is the first 3 the last
  putc(send[i]);
  }
}
void main(void)
{
  set_tris_a(0x00);// All output 
  set_tris_b(0b00000010); //RB1 RB2  Rx/tx)
  junk = 126;
  synch = 'A';//decimal 65
  dat   = 50; dat2=60;
  while(true)
   {
   send[0]=junk; send[1]=synch; send[2]=dat; send[3]=dat2;
   output_toggle a2;
   send_dat();
   // delay_ms(100);//no delays
   }
  }
Receiver

//////////////434receiv628.c//////////////////////
#include <16f628a.h> //<16F876a.h>
#fuses INTRC_IO, NOLVP, NOWDT, PUT, BROWNOUT
#use delay (clock=4M)// No crystall is needed
#use rs232(baud=2400,XMIT=PIN_b2,RCV=PIN_b1,bits=8)
#define a2 (pin_a2)
#define a3 (pin_a3)
#define reset (pin_b0)
char junk;
char synch;
int dat,dat2;
byte receiv[4];
#INT_RDA // RS232 Interrpt
void rda_isr()
{
int i;
for (i=0; i<4; ++i)//receive 4 data
{ //0 is the first
receiv[i]=getc();
OUTPUT_TOGGLE A2;//knowing data are receiving
}
junk=receiv[0]; synch=receiv[1]; dat=receiv[2];dat2=receiv[3] ;
}

void main()
{
enable_interrupts(global);
enable_interrupts(INT_rda);// RS232 Interrpt
set_tris_a(0x00);// All output
set_tris_b(0b00000010);//reset (pin_b0)/ XMIT=PIN_B2,RCV=PIN_B1
output_high reset;//---__----
while (true)
{
if(synch== 'A') {//led A3 lights up when data are Ok then you don't need
//using Hyperterminal if you want.
output_high a3; printf("J:%u S1:%c D:%u D%u OK\n\r",junk,synch,dat,dat2);
}
else {
output_low a3; printf("J:%u S1:%u D:%u D%u ER\n\r",junk,synch,dat,dat2);
}//If data come aleatory
if(dat==126 || dat==65 ||dat2==126|| junk==65 ) output_low reset;//65 is the same 'A'.
//connect a 1uF capacitor between B0 and MCLR. If there are //incorrect data
}//reset CPU
}
Hyperterminal

    J:223 S1:218 D:250 D239 ER
    J:223 S1:218 D:250 D239 ER
    J:223 S1:218 D:250 D255 ER
    J:60 S1
    :65 D:50 D60 ER
    J:126 S1:A D:50 D60 OK
    J:126 S1:A D:50 D60 OK
    J:126 S1:A D:50 D60 OK
    J:126 S1:A D:50 D60 OK
    J:126 S1:A D:50 D60 OK
    J:126 S1:A D:50 D60 OK
    J:126 S1:A D:50 D60 OK
    J:126 S1:A D:50 D60 OK
    J:126 S1:A D:50 D60 OK
    J:126 S1:A D:50 D60 OK
    J:126 S1:A D:50 D60 OK
    J:126 S1:A D:50 D60 OK
    J:126 S1:A D:50 D60 OK
    J:126 S1:A D:50 D60 OK
    J:126 S1:A D:50 D60 OK
    J:126 S1:A D:50 D60 OK
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 Previous  1, 2, 3  Next
Page 2 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