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

A newbie question about Radio Communication
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
rberek



Joined: 10 Jan 2005
Posts: 207
Location: Ottawa, Canada

View user's profile Send private message

PostPosted: Tue May 29, 2007 1:29 pm     Reply with quote

Well, the wireless portion of your circuit will be the most challenging.

1) Do the obvious things first. Check all of your wiring. Also check and make sure that all filtering and bypass components are of the correct values and close to the components they are helping. As another poster pointed out, your bypass caps aren't anywhere near the ICs.

2) Where are your wireless modules and how have you connected the antenna? The antenna requires a 50 Ohm impedance matched connection. How did you connect the antenna to the transmitter? If it was through the breadboard, that won't work at all (and based on your picture, I think that might be the case, though I may be mistaken). They are very sensitive to pin loading and interference and you have to use good RF techniques to handle them. Radio modules often use their own isolated power planes to give them a clean ground and power. They certainly won't get that on a breadboard.

However, I'm no RF expert, so I might be completely wrong here. Perhaps someone with more experience in that regard could comment.

r.b.
Izzy



Joined: 27 May 2007
Posts: 106

View user's profile Send private message

PostPosted: Tue May 29, 2007 4:59 pm     Reply with quote

Your posts are priceless as always!


Anyway, I dont know how, but I was able to make it work with the help of other people. I dont know how it just worked. Shocked
Now slowly I can start writting codes, I guess.



I dont know what did you actually mean by :

Quote:
How did you connect the antenna to the transmitter? If it was through the breadboard, that won't work at all



I had soldered transmitter's antena area to a wire and then I connected that BLUE wire from the transmitter to the 50 ohms Real Antenna (Hard to see in the picture). But probably I am getting lots of noise beacause of the bread board.

Please hang around for couple of months I am going to need more help, I guess. Razz

Thanks a LOT for every bit of your help!
rberek



Joined: 10 Jan 2005
Posts: 207
Location: Ottawa, Canada

View user's profile Send private message

PostPosted: Tue May 29, 2007 8:08 pm     Reply with quote

Hi

I just wondered if you had stuck the antenna signal wire and ground shield into the breadboard itself, rather than with a proper 50 ohm connector (i.s. mini-BNC or something)

Glad to see that you have it working.

Once you get things solid, you may want to look at sending some sort of error detection/correction code along with the data to make sure that you have some extra protection against noise, etc.

r.b.
Izzy



Joined: 27 May 2007
Posts: 106

View user's profile Send private message

PostPosted: Wed May 30, 2007 4:35 am     Reply with quote

Thank your sir for your reply.

But how would I do that error correction / detection thing?

Pardon my stupidity, I am a newbie Embarassed
rberek



Joined: 10 Jan 2005
Posts: 207
Location: Ottawa, Canada

View user's profile Send private message

PostPosted: Wed May 30, 2007 6:50 am     Reply with quote

You would send another word at the end of your group of integers that was calculated using the integers themselves (i.e. a checksum, Cyclic Redundancy Check, etc). Your PIC would also calculate the checksum from the digits it received, and if the checksum matched the one transmitted, you'd know that the data that was transmitted was the same data that was received.

However, you probably want to get the rest of your system working first, as this is a secondary thing.

Your biggest issue, should you make many little robots, will be how you coordinate how they talk to the base station.

r.b.
Izzy



Joined: 27 May 2007
Posts: 106

View user's profile Send private message

PostPosted: Wed May 30, 2007 8:44 am     Reply with quote

Today I started writting codes for transmitting data from Robot to the base sation.

The way it transmits is :

For eg when base station asks for data, The robot is going to transmit:

A1360999888777666555

Where A is a command for Base station to start recording data

then the '1' means the Robot Identification no. (Means the data is from Robot no.1)

'360' means the degree valaue from the compass.

'999', '888', '777' means the values (in cm) of three ultrasonic sensors (Front , right and left)

and finally '666' and '555' means the value from 2 wheel Encoder.



So once the base station receives those data one by one, it stores those data in one long big array.

Then, that long array is converted into small no. again like
1, 360, 999 ,888 , 777..... and given to the base station program to do further calculation need to command the robot.



Anyway, I looked at the manual and this compiler doesnot have any CHECKSUM functin to check for error. But let me spent some more time and see if there any other thing like checksum.


Or you could advise me. Wink
rberek



Joined: 10 Jan 2005
Posts: 207
Location: Ottawa, Canada

View user's profile Send private message

PostPosted: Wed May 30, 2007 9:32 am     Reply with quote

What happens when you have two robots? Or do you need to demonstrate two robots at the same time? I'm assuming this is a homework project.

The checksum or CRC is something you'll have to write yourself. The compiler has no function for it.

r.b.
Izzy



Joined: 27 May 2007
Posts: 106

View user's profile Send private message

PostPosted: Wed May 30, 2007 10:47 am     Reply with quote

Oh I have to write my own checksum? Embarassed

Oh well, I will have to spend some more time with programming I guess.
Actually, I am not a programmer, I a sophmore student majoring in Electrical Engineering. So my programming knowledge is not really that good.

Oh and this is a paid summer research project. Smile
Izzy



Joined: 27 May 2007
Posts: 106

View user's profile Send private message

PostPosted: Wed May 30, 2007 6:07 pm     Reply with quote

I have one problem now.

I spent almost the whole day trying to send some data through the transmitter(Robot) and receive them on the receiver(Base station).
But I was not able to do it. What I did was, I programmed the Transmitting chip to keep on sending 01234567891233456789...

But when I receive it on the base station (Which is programmed to continiously receive the data) it received some thing like:

11111155580000011111333333337777 (I made those data print on screen using debugger)

I think there is a problem with clock or some thing that I am not really familiar with.

One of the graduate student told me probably I will have to match the Baud rate of the PIC and the USB port to which the debugger is connected.

In debugger it shows USB-ICD ' baudrate 25000 (or 250000, I forgot), so that guy told em to change the PIC's baudrate to the same as USB. BUt I dont know any assembly code to change the baudrate of the PIC. Is that the problem here?

Or am I missing something?


And by the way that Transmitter TXM-433-lr and receiver RXM-433-lr didnt gave much range. In the data sheet it says upto 3000ft. But when we tried they only gave around 50 ft, that too by changing the position from time to time.

Please help me here.
rberek



Joined: 10 Jan 2005
Posts: 207
Location: Ottawa, Canada

View user's profile Send private message

PostPosted: Thu May 31, 2007 7:06 am     Reply with quote

I assume you're using the receiver code you posted earlier in this thread.

The code you posted will miss lots of data. You have a 1 second delay in the loop to blink an LED. Even if you remove that, you transmit three characters, via the printf statement, for every character you receive. Depending on the data rate of the port you're sending those printf characters to, you will miss several incoming characters.

As I mentioned on one of my earlier ports, you're going to need to use a timer interrupt to get and store characters. Trying to time your sampling by adding delays in a loop almost guarantees that things will go out of sync. Also note that 1.7ms is only an approximate delay time. It is actually 1.6666667 ms. You will get more precise time intervals using the timer interrupt.

As for radio range, you mentioned that you just soldered antenna wire onto the module. This is not a 50 Ohm termination. Thus some large measure of your transmit power is being lost with an impedance mismatch, and is being distorted as well. Check out the radio module datasheets for some tips on using them. First thing I would suggest is get rid of that breadboard as far as the radio modules go.

r.b.
Izzy



Joined: 27 May 2007
Posts: 106

View user's profile Send private message

PostPosted: Thu May 31, 2007 9:15 am     Reply with quote

This was the code I used yesterday:

Receiver:
Quote:
#include <protoalone.h>
#include <stdlib.h>

//void Radio_receive(Long Comp_1,long Ults_1,long Encd_1);

void main()
{
int i;
long input[19]; // = {1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,0};
int Robot_ID;
long Compass=0, Ults_f=0, Ults_r=0, Ults_l=0, Encd_r=0, Encd_l=0;

While(TRUE)

{

for(i=0;i<19;i++)
{
input[i] = input_c();
delay_us(1666);
}


Robot_ID = input[0];
Compass = (input[1]*100) + (input[2]*10) + (input[3]);
Ults_f = (input[4]*100) + (input[5]*10) + (input[6]);
Ults_r = (input[7]*100) + (input[8]*10) + (input[9]);
Ults_l = (input[10]*100) + (input[11]*10) + (input[12]);
Encd_r = (input[13]*100) + (input[14]*10) + (input[15]);
Encd_l = (input[16]*100) + (input[17]*10) + (input[18]);



printf("%d\n %lu\n %lu\n %lu\n %lu\n %lu\n %lu\n",Robot_ID, Compass, Ults_f, Ults_r, Ults_l, Encd_r, Encd_l);

}

}






Transmitter:
Quote:
#include <protoalone.h>
#include <stdlib.h>

int calc(long value);
void Radio(long Compass,long Ults_f, long Ults_r, long Ults_l, long Encd_r, long Encd_l);
int Data[3];


void main()
{
Long Compass = 123;
Long Ults_f = 456;
Long Ults_r = 789;
Long Ults_l = 123;
Long Encd_r = 456;
Long Encd_l = 789;
Radio(Compass,Ults_f,Ults_r,Ults_l,Encd_r,Encd_l);
}


void Radio(long Compass,long Ults_f, long Ults_r, long Ults_l, long Encd_r, long Encd_l)
{
Long Value;
// Char A;
int Send_data[19];


While(TRUE)
{
Int c,i,j=1,k=4,l=7,m=10,n=13,o=16,p=0 ;
Send_data[0]=1; // Robot Identification Number
Value=Compass;
for(c=0; c<3; c++)
{
switch(c)
{

/********************* For Compass *********************************/
case 0 :
Calc(Value);
for( i=0; i<3; i++)
{
Send_data[j] = Data[i] ;
j++;
}
Value = Ults_f;
break;




/********************* For Front Ultrasonic Sensors **********************/
case 1 :
Calc(Value);
for( i=0; i<3; i++) //Front Ultrasonic sencor
{
Send_data[k] = Data[i] ;
k++;
}
Value = Ults_r;
delay_ms(2);



/********************* For Right Ultrasonic Sensors **********************/
Calc(Value);
for( i=0; i<3; i++) //Right Ultrasonic sencor
{
Send_data[l] = Data[i] ;
l++;
}
Value = Ults_l;


/********************* For Left Ultrasonic Sensors **********************/
Calc(Value);
for( i=0; i<3; i++) //Left Ultrasonic sencor
{
Send_data[m] = Data[i] ;
m++;
}
Value = Encd_r;
break;


/********************* For Right Encoders *****************************/
case 2 :
Calc(Value);
for( i=0; i<3; i++) //Right Encoder
{
Send_data[n] = Data[i] ;
n++;
}
Value = Encd_l;


/********************* For Left Encoders *****************************/
Calc(Value);
for( i=0; i<3; i++) //Left Encoder
{
Send_data[o] = Data[i] ;
o++;
}

break;
}
}



for( p=0; p<19; p++)
{
output_d(Send_data[p]);
delay_us(1666);
output_d(0x00);

}

}
}

Int calc(long value)
{
Data[0] = (Value/100);
Data[1] = (Value/10)-(10*Data[0]);
Data[2] = Value-((100*Data[0])+ (10*Data[1]));
return 0;
}
Izzy



Joined: 27 May 2007
Posts: 106

View user's profile Send private message

PostPosted: Thu May 31, 2007 9:24 am     Reply with quote

rberek wrote:
I assume you're using the receiver code you posted earlier in this thread.


As for radio range, you mentioned that you just soldered antenna wire onto the module.
r.b.



Sorry, I mean I soldered the antenna wire to the 50 ohm Radio Antenna.
rberek



Joined: 10 Jan 2005
Posts: 207
Location: Ottawa, Canada

View user's profile Send private message

PostPosted: Thu May 31, 2007 10:18 am     Reply with quote

You've got several big problems.

First, the antenna. I'm led to believe you do not have a proper 50 Ohm termination. Not good. Also, using the breadboard is also bad. This quote is directly from the datasheet for your transmitter:

Quote:
During prototyping, the module should be soldered to a properly laid-out circuit board. The use of prototyping, or "perf" boards will give horrible performance and is strongly discouraged.


Now I can't tell exactly how you installed these modules, but I think you should read the datasheet carefully and follow their construction and implementation recommendations. Get the RF modules off your breadboard if they are there.


Second, you are not transmitting a constant stream of data. Your code loops and uses a case statement to select the next integers to send. I also see a delay off 2ms inserted. Thus it seems to me that you are sending your integers in little groups, rather than the pack of 19 you think you are sending.

Third, you have HUGE delays in your receive loop. You read the bus 19 times with the approximately correct sampling interval. Then you do several divisions and multiplications, each of which will use dozens of instruction cycles. Then you print them out, which will take lots and lots of character periods. During this time, you are missing dozens of characters in the input. Once you go back to sample 19 more characters, who knows what you'll get.

You need to go back and get set up for success.

1) read the documentation provided with your components and follow and implementation instructions they have.

2) Send data into your transmitter at 4800 baud, don't just pummel data into it. It will lose much of it. Read the datasheet. It says it sends two 8-bit words, then waits 10ms. This implies to me that it will not do sustained 4800 baud transfers. It takes 16 bits, sends them out serially at 4800 baud, waits 10ms, then sends more. At least I think so. The documentation is a little thin.


3) Your receive code must collect all the data in an array first, then you can take some time to process and display it, until the next burst of data comes along. Use a timer interrupt and try to sync up with a START word, otherwise it will just take the first X characters of the decoder bus.

I hope this helps.

r.b.
Izzy



Joined: 27 May 2007
Posts: 106

View user's profile Send private message

PostPosted: Thu May 31, 2007 4:59 pm     Reply with quote

Thank you sir for your reply.

As you said I will read the data sheet again tonight, to make sure everything is right.


Quote:
Second, you are not transmitting a constant stream of data. Your code loops and uses a case statement to select the next integers to send. I also see a delay off 2ms inserted. Thus it seems to me that you are sending your integers in little groups, rather than the pack of 19 you think you are sending.


I know the code is lil confusing. But if you look carefully, The switch case is just used to put all the data in an array in an order. Then once the array is complete. It starts sending data as a pack of 19, but one at a time.

Also please ignore While loop and printf, its there just for testing purpose.



Quote:
Third, you have HUGE delays in your receive loop. You read the bus 19 times with the approximately correct sampling interval. Then you do several divisions and multiplications, each of which will use dozens of instruction cycles. Then you print them out, which will take lots and lots of character periods. During this time, you are missing dozens of characters in the input. Once you go back to sample 19 more characters, who knows what you'll get.


Once again, here the data is FIRST stored into an array then once all the data is received the further calculation and printings are done.

Please let me know if I am wrong.



Anyway my main issue right now is The communication range. I have to improve it any how. This is the antenna I am using right now.
http://www.antennafactor.com/documents/ANT-433-PW-QW_Data_Sheet.pdf

Beside that my professor wanted me to do the communication ina notehr way.

He doesnot want me to send one decimal no. at a time.
He wants me to send the value of compass, ultarsonic sensor and encoders one at a time. So if I have 245 degree for compass he wante me to send it 245 at once.

But if its more than 255 then he wants me to send 8 bit twice.

So if I have to send 360 degree. Then I will be sending 255 in first 8 bit and 105 (360-255=105) in second 8 bit. The further addition is done by base station. I guess, this will make the commincation faster I guess.


And for each value sent he wants me to use interupt. So I will probably have to chaneg the whole code.

Once again, I as you said I will look up the data sheet again today.
rberek



Joined: 10 Jan 2005
Posts: 207
Location: Ottawa, Canada

View user's profile Send private message

PostPosted: Thu May 31, 2007 5:45 pm     Reply with quote

Hi

OK, I didn't look at your code close enough. The transmitter code does indeed send 19 integers to the encoder. But does the encoder want to see it this way? The datasheet makes reference to a 10ms break it takes in sending data, as it creates a 7 byte packet to send 2 bytes of data. You'll need to investigate this.

As far as the receive code goes, it does put the receive data in an array, but then spends 100's of instruction cycles doing something else before it goes back to get another 19 samples. There is no synchronization between the transmit data and the Rx data, so you have no idea which data you've got.

At any rate, your professor seems to have some ideas of how he wants this done, and he wants you to change the code, so you should follow his direction.

All the best

r.b.
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