Pages: [1]   Go Down
Author Topic: [solved] RF12.h: Why is there not definition of 315MHz  (Read 692 times)
0 Members and 1 Guest are viewing this topic.
Germany
Offline Offline
Full Member
***
Karma: 0
Posts: 214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#define RF12_433MHZ     1
#define RF12_868MHZ     2
#define RF12_915MHZ     3

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

Thank you
« Last Edit: July 28, 2012, 05:08:38 pm by karlok » Logged

using Arduino Uno Rev 3

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 439
Posts: 23734
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Can you just add it yourself?
Code:
#define RF12_315MHZ     1
#define RF12_433MHZ     2
#define RF12_868MHZ     3
#define RF12_915MHZ     4
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Germany
Offline Offline
Full Member
***
Karma: 0
Posts: 214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

using Arduino Uno Rev 3

Germany
Offline Offline
Full Member
***
Karma: 0
Posts: 214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Problem solved.
It is
Code:
#define RF12_315MHZ     0
.
Logged

using Arduino Uno Rev 3

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 439
Posts: 23734
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Nice going.
How'd you figure that out?
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Germany
Offline Offline
Full Member
***
Karma: 0
Posts: 214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

using Arduino Uno Rev 3

Pages: [1]   Go Up
Jump to: