Go Down

Topic: [solved] RF12.h: Why is there not definition of 315MHz (Read 1 time) previous topic - next topic

karlok

Jul 26, 2012, 03:59 pm Last Edit: Jul 29, 2012, 12:08 am by karlok Reason: 1
Hello,

in the file RF12.h (RF12 library) ,there is no definition of 315MHz , but the RFM12 module supports this frequency according to its datasheet-.

The lines around (l.28-30) are:
Code: [Select]
#define RF12_433MHZ     1
#define RF12_868MHZ     2
#define RF12_915MHZ     3


I want to initialize my module with 315MHz but HOW ?

Thank you
using Arduino Uno Rev 3

CrossRoads

Can you just add it yourself?
Code: [Select]

#define RF12_315MHZ     1
#define RF12_433MHZ     2
#define RF12_868MHZ     3
#define RF12_915MHZ     4
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

karlok

That would be useless, I think.
These definitions are used in the library to help the user. So, Ican simply write "RF12_433MHZ" instead of the "1". That is more logic for the user but the program translates it into "1" that is understood by the RFM12 module.

But I want the module to understand 315MHz!
using Arduino Uno Rev 3

karlok

Problem solved.
It is
Code: [Select]
#define RF12_315MHZ     0.
using Arduino Uno Rev 3

CrossRoads

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

karlok

Hello.

I have read the datasheet and looked into the corresponding position in the sourcecode of "RF12.cpp".
Additionally, and the really helpful source!!!, I received great help from a electronic engineer.

More detailed:
Look the definition of "uint8_t rf12_initialize (uint8_t id, uint8_t band, uint8_t g)" in RF12.cpp, this function is used to initialize teh RFM12(B) module.
Then, I want to know what paramter has to be changed, of course it was "band" (uint8_t), it was only used once in the function rf12_initialize. That means that this position is the corresponding one to be examined:
Quote
rf12_xfer(0x80C7 | (band << 4));
(RF12.cpp, l.404)
Look here:
"|" is the logical AND operator, << is a bitshift operator (shifts 4 to the left, that means a hexadecimal unit (2^4=16))
Now consider binary:
1000 0000 1100 0111
Now I need the datasheet ( hoperf : RFM12.pdf ) , see the bottom left table on page 12.
Back to the binary code:
I said << is the bitshift operator, lets apply it on the code, e.g. we use "2" as given in the definition (#define RF12_868MHZ   2) for 868MHz band. Then it is
0000 0010 << 4 ("shift" the 10 ,which is 2 in binary, 4 bits left) = 0010 0000 .
Now do the addition:
0000 0000 0010 0000   +   1000 0000 1100 0111 = 1000 0000 1110 0111
The important binary parts were highlighted.
In the datasheet's table there is written:
315MHz band: b0=0; b1=0. That means we need a zero for both b0 and b1.
That is   1000 0000 1100 0111 .

And it is a lot of fun!

Feel free to ask if there are any questions (maybe explanation was unclear because quickly written).

Regards.
using Arduino Uno Rev 3

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy