Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How do I send a frame using an RF Module?

Status
Not open for further replies.

kaitokid41

Newbie level 6
Joined
Nov 20, 2011
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,362
Hi! I'm new here and I really need your help. I need to send a frame using an RF module which will be serial transmission. I'm using PIC18F4550 and a mikroC compiler. I need to transmit the data from a device where I used the microcontroller to my computer using Visual Basic 6 or PHP (i'm planning to put a database later), vice versa. This will be the frame I need to send with at least 1 byte each:

SYNC | RECEIVER | SENDER | LENGTH | DATA | CHECKSUM

Advance thank you for the help! :)


EDIT: Typo Error. :( Sorry for that
 
Last edited:

As what I understand, you want some data(date) to send through rf module to the other device...
1.You may use any window based software(that can communicate with the serial port) and send a byte to the uC...store that byte(8 bits) in some register REG...
2.connect the 4 pins of encoder ic(in case of 4 bits transmission at once) to the some port of your controller..
3.now put the value stored in REG to the port connected to decoder ic, then swap it, again send it...hence you can send the whole byte..
4.At the recieving side, take the values through the decoder ic and put in a register and show it on lcd or whatever you want...

hope it helps..
 

hi! sorry for the typo. it's not "date" i wanted to transfer, but the "data". the frame format i posted above contains 8 bits each part. that's 48 bits in total i need to send serially. do i need to store it into an array or something? if it's okay, could you give me a sample program? it's better if it's in C. :) i'm really new at this. :)
 

anyways,, date is also a data..
you will need to store it in an array only if you need it for further use..
1.tell me which rf module you are using.??(its pic or just pinout)
2.confirm the schematic
is it like: transmitter part connected to the pc and reciever part is remote connected to some lcd or other thing..??
or something else??
 
actually, it's a transceiver so i could send either way. it's this one >>> **broken link removed** (Model 863 RF Wireless Data Transceiver)

yes, one part is connected to the PC and one part is connected to the device with the PIC. and I need to send this FRAME from the PC to the device, and vice versa:

SYNC (1byte) | RECEIVER (1byte) | SENDER (1byte) | LENGTH (1byte) | DATA (1byte) | CHECKSUM (1byte)
 

Thanks but I already had mine. I'm just having problems with sending the frame serially. :)
 

I assume that you must have atleast done the correct wiring of the transceiver with the pc(serial connections..via max232)
and with another transciever to the uC..
so make it simpler,,,break it into parts..
first do for transmitter side only..
(make cross connections, i.e. rx to tx and tx to rx for pc and transciever)
make the connections with pc, then send any character through any terminal software(putty or hyperterminal)..
you may use "putty"(bcz. it will not let you write a single character on the screen if the serial port is not good or in case of wrong connections)..
if you have done this, then you are transmitting a character..

the reciever side is powered on as it will recieve the characters automatically(prematched), make its connections with the controller's UART..
and show it on lcd or whatever you may feel like....
You may add pullups resistors to the reciever part i.e. make the UART of the controller connected through the pull ups and also to the transceiver Rx and Tx..

try it,, hope it helps..
 
Yes I already sent a character and made it work. I've done all the hardware part. But how do I send a "48-bit frame"? I mean how to code/program it in the PIC?
 

okk!! i now understand what you are saying!
you are trying to send the "48 bit in a frame" against the pre set rule of 8 bit frame??
am i getting you?
can you tell me the reason why you want to send "48 bit in a frame" instead of 8 bit one??
and do tell me the method by which you are giving the 48 bits...i mean, the 48 bits(that are to be transferred)are coming from where??
48 characters entered from the user or prestored in array or something else..?
i don't think that your device supports more than 8 bit data transfer at once..(you may consult to hardware vendor)..
but you can have ways to do it..
ex-let this be your desired 48 bit frame: 11010100 00100110 11001110 10101100 10100011 01011100
virtually divide the frame into 6 bytes then store them in registers/variables in arr[6], each byte must be representing a character(ascii value),,
send variables function
{
for(i=;i<6;i++)
{sbuf=arr
delay();
}
on the recieving side, collect all the 6 bytes, break their ascii codes and concatinate them into a char string...

it is just an idea...(i never have done anything like it before)....
 
EXACTLY!!!

it's a requirement by our project. that's the reason i'm so troubled right now because i knew i could only send an 8-bit one. i can't synchronize their clock speeds (the uC and the PC)

it's like when i press a button on my device, that 48-bit that's PRESTORED in an array transmits and is received by the receiver connected to the PC (going to use Visual Basic to interface the commport), and vice versa.
 

if this is the case then you can give a try to my abovesaid way...
when the button is pressed (interrupt is called)-->a function is called that sends the divided 6 bytes serially...(these 6 bytes are of no use as they may represent random characters..)

sending the bits in a byte by byte fashion is one task...
recieving the bits byte by byte and then take the data coming from the comport to the vb and make a new variables that stores the binary representation of the recieved ascii value(total of 6 bytes)..concatinate them in a string...
it may be done through this way...
what you think...any problem or flaws in this???
 
yeah really helped me a lot about that. i just need to find a way to catch all those bytes in order. :) thanks a lot! :)

so is it better if i make a 6-character string and send it character by character?

---------- Post added at 02:25 ---------- Previous post was at 02:16 ----------

So now I'm trying to make a test simulation using 2 PICS cross-connecting their TX's and RX's. Here's my code, though this doesn't work for the moment. Something wrong to what I'm doing?

SENDER:
Code:
void main() {
  char *mystr;
  unsigned int i;

  TRISB  = 0xFF;
  PORTB  = 0x00;
  UART1_Init(9600); // Initialize UART module at 9600 bps
  Delay_ms(100);

     while(1){

              if(RB5_bit == 1){ //pressing a button

              mystr = "abcdef";

              for(i=0; i<6; i++){
                       UART1_Write(mystr[i]);
                       Delay_ms(500);
                       }
              }

     }

}



RECEIVER:
Code:
void main() {

 char str1[6];
 short i = 0;

  TRISD  = 0x00;
  PORTD  = 0x00;
  UART1_Init(9600); // Initialize UART module at 9600 bps
  Delay_ms(100);


   while(1){

            while (UART1_Data_Ready() == 1) {
              str1[i] = UART1_Read();
              delay_ms(300);
              i++;
              }
 
                 if (str1[0] == 'a')   //turning on a LED confirming if data is received
                 RD0_bit = 1;

                 if (str1[1] == 'b')
                 RD1_bit = 1;

                 if (str1[2] == 'c')
                 RD2_bit = 1;

                 if (str1[3] == 'd')
                 RD3_bit = 1;

                 if (str1[4] == 'e')
                 RD4_bit = 1;

                 if (str1[5] == 'f')
                 RD5_bit = 1;

            };

}
 
Last edited:

bro, you may check them individually..i.e.
first connect the controller for sending part with the pc's serial port...(check if pic is able to send characters serially)...
then connect the controller for recieving part with the pc's serial port (manually send "abcdef")..check if led's are getting on...
this will atleast confirm the code and hardware part...


and i have an idea to catch all those bytes in order...if we will make the number of bytes more than 6,,i.e. rather than distributing the 48 bit in 6 bytes, we will divide the 48 bits in 12 bytes..
in each of the byte starting four bits are for data check(a sequence of 0000,0010,0011,0100.....) and the remaining four bits are the data part...so just before concatenating the string, you may apply a check then only integrate the data part i.e. the last four bits...
 

so do you mean i need to put some kind of "numbering" so that i could arrange them after they're all been sent?

sorry, i didn't get the "rather than distributing the 48 bit in 6 bytes, we will divide the 48 bits in 12 bytes.." part. :)


...gonna try that later. i still got a class to catch. thanks! :)
 

yeah, I was trying to number them so that they are used only if they are in numbered sequence otherwise not....
but that was for the case if you can lose any of the byte or confirming the right order of the bytes recieved...
nevertheless
try out the remaining part and make it work...
 

i'm gonna try it. i'll update with yah. thanks! :)
 

Sending characters in a frame usually means the stop bit of one character is immediately followed by the start bit of the next one with no intercharacter delay. UART interfaces are prepared for this usage. I don't see a purpose of waiting "ages" like 300 ms between characters. Synchronization in UART transmission is achieved by matching the baud rates.

The basic method to send a frame is to give the character to UART, wait til it's ready and send the next. The micro-C UART functions already provide the required handling.

Intelligent RF modules like the said 863 are receiving the input data with microcontroller and retransmitting it with internal generated framing on air. They typically understand a pause in input data as a transmission trigger, so they effectively transmit a RF telegram for each character when using a 300 ms delay.
 
hi FvM! thanks for that! so should I use the UART1_Write_Text or i'll use a loop to send the array of characters using UART1_Write?
 

I'm not familiar with the Micro-C library, but I guess write text is operating with null terminated strings, so it can't be used with binary data that may contain null as a data value.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top