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 support@ccsinfo.com

Sending and Receiving Radio Signals

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Dio
Guest







Sending and Receiving Radio Signals
PostPosted: Tue Apr 27, 2004 4:07 pm     Reply with quote

Hi all, I'm having some trouble making a remote-controlled car receive the signal from my joystick and wondered if anyone might offer some assistance?

Essentially, I've got a 2-axis joystick (two potentiometers) going in thru one PIC, performing an AtoD conversion, and outputting the results (a number representing forward, back, left or right on a number pad - 8,2,4, or 6) thru the RS232 output to a TWS-434a transmitter.

On the receiving end is a RWS-434 receiver, connected to input pin B0. Here's where it gets kind of tricky, and I'd like to know if maybe the receiver is reading the signal wrong because I'm getting one long string of zeros. My code is below:

Quote:

...(header stuff)...
#use rs232(baud=9600,parity=N,rcv=PIN_B0,INVERT,STREAM=signal)
#use rs232(baud=19200,parity=N,xmit=PIN_C6,rcv=PIN_C7,STREAM=pc)
...
...
int8 direction;

// Designate which pins are inputs and which are outputs
set_tris_c(0xc0);
set_tris_b(0x01);

while(TRUE)
{
direction = fgetc(signal);
fprintf(pc,"%d",direction);
if(direction==8) output_c(FWD);
else if(direction==2) output_c(REV);
else if(direction==4) output_c(LEFT);
else if(direction==6) output_c(RIGHT);
else output_c(OFF);
}


We're using a FPUTC() command to output from the PIC to the transmitter, and using printf statements we know it's outputting the correct number for the car to recognize directions, so we're sort of wondering where the mistake lies? Any help would be appreciated, thanks!
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Tue Apr 27, 2004 5:33 pm     Reply with quote

Are you sure you need the 'INVERT' in your #use RS232 statement? Have you tried it without 'INVERT'?
Guest








PostPosted: Tue Apr 27, 2004 5:57 pm     Reply with quote

Without INVERT active, the program collects only 3 or 4 characters and then stops for some reason. I don't see inversion being the problem though, as the output from the transmitter is also inverted in the rs232 serial output.

I guess what I'm asking is pretty much how do I take a character from the transmission PIC and interpret that into a motor control command on the receiver PIC? And how do I keep the flow of data going between the two for direction changes, constant movement, etc?

I found the TWS-RWS combo thru the "Ruf-Bot" project online, but it was written in Basic and ours is in C so there's some differences I can't quite comprehend. Our C Compiler reference book is horrible on this topic as well, and since we're only first-semester Mechatronics students we're just scratching the surface of PIC programming... figured maybe a more seasoned veteran around here could help point us in the right direction?
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Tue Apr 27, 2004 6:32 pm     Reply with quote

Anonymous wrote:
Without INVERT active, the program collects only 3 or 4 characters and then stops for some reason.


But are those 3 or 4 characters correct values? If so you have to take the INVERT out.

The fact that you are getting a long stream of zeroes indicates that the voltage levels are not being interpreted correctly. I'm not familiar with the RWS-434 chip, but it should be a TTL level RS232 signal. That means a 0v for 0 and a 5v for 1. On idle, the TX line of RWS-434 should be 1, which is 5v. Check the voltage of the TX line when it is inactive and confirm this. If it is 5v, then this is not an inverted serial port.

An inverted port uses 5v for sending 0 and 0v for sending 1. So on idle the TX line of an inverted port is 0v. It is usually used to communicate with a true RS232 device (-10v for 1 and 10v for 0) without a driver chip such as MAX232, to save cost.
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Wed Apr 28, 2004 9:07 am     Reply with quote

Hola Dio,

Quote:


#use rs232(baud=9600,parity=N,rcv=PIN_B0,INVERT,STREAM=signal)



1) Not so optimistic with this transceiver passband, try at least at 2400 baud.

Quote:


Without INVERT active, the program collects only 3 or 4 characters and then stops for some reason. I don't see inversion being the problem though, as the output from the transmitter is also inverted in the rs232 serial output.


2) Does the received characters == transmited characters?

Quote:


I guess what I'm asking is pretty much how do I take a character from the transmission PIC and interpret that into a motor control command on the receiver PIC? And how do I keep the flow of data going between the two for direction changes, constant movement, etc?



3) Does your project is running properly if you take out the RF link and wire directly Tx ->- Rx modules? As mentioned, take care of the signal polarity, be aware that the receiver PIC (Rx PIN) is expecting a going down pulse as START BIT.

After you solved steps 1 , 2 & 3, you get in the FOURTH problem:

4)Lower AM transceivers requires a balanced signal. Sending unbalanced signals as ASCII chars, the demodulator (in the received side) would get biased improperly and blocked until another string of chars of oposite polarity would recover such situation.

The "clue" is that the "weight" of the equivalent '1' and '0' of your string must be equal. Sending binary ASCII signals over the RF link obviously won´t meet this requeriment.

A) Rigth way to solve this is using Manchester encoding. Not so easy for begginers.

B) A "dirt" an easy solution -if your packet is very short- is to send each ASCII chars precedded by an "balanced" char like 'U' whose binary equivalent is 0b01010101 in this fashion :
Your packet: "G021D"
Sending: "UUGU0U2U1UD"

In the receiver side, just through away the 'U's and tell us your result.


Hope this help,

Humberto
Mark



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

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

PostPosted: Sun Apr 16, 2006 10:39 am     Reply with quote

Read this thread and any links in it
http://www.ccsinfo.com/forum/viewtopic.php?t=21127&postdays=0&postorder=asc&highlight=tws434&start=15
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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