Go Down

Topic: Working on RDA5807m radio module (Read 2101 times) previous topic - next topic

WhereIsMyMind

#include <Wire.h>

unsigned char frequencyH = 0;

unsigned char frequencyL = 0;

unsigned int frequencyB;

double frequency = 0;

void setup()

{

Wire.begin();

frequency = 96.7 ; //starting frequency

setFrequency();

Serial.begin(9600);

}

void loop()

{

if (Serial.available() > 0) {

frequency = Serial.read();

setFrequency();

}}

void setFrequency()

{

frequencyB = 4 * (frequency * 1000000 + 225000) / 32768;

frequencyH = frequencyB >> 8;

frequencyL = frequencyB & 0XFF;

delay(1000);

Wire.beginTransmission(0x60);

Wire.write(frequencyH);

Wire.write(frequencyL);

Wire.write(0xB0);

Wire.write(0x10);

Wire.write((byte)0x00);

Wire.endTransmission();

delay(1000);

}

i using this code but it is not working i wanna change frequency in serial monitor can your help me ?

PaulS

Code: [Select]
frequency = Serial.read();
You read one byte from the serial port, as the new frequency.

Quote
i wanna change frequency in serial monitor
So, the values for the frequency will be '0' to '9'. What does a frequency of '7' mean to you?
The art of getting good answers lies in asking good questions.

WhereIsMyMind

Quote
You read one byte from the serial port, as the new frequency.
1byte = 8 bit (11111111=255)

but you telling me the values can be 0-9.

i dont understand sorry :(

CrossRoads

Look at asciitable.com

'0' = 0x30 = 48 decimal
:
:
'9' = 0x39 = 57 decimal

What format are your numbers being transmitted as?
character? '0' to '9'
'raw' data? 0x30 to 0x57
something else? 0b00000000 to 0b00001001 (0 to 9)
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.

PaulS

Quote
What format are your numbers being transmitted as?
Since OP said "using the serial monitor", there is only one answer - ASCII text.
The art of getting good answers lies in asking good questions.

WhereIsMyMind

for example ;

I listening 98.0 frequency and i wanna change freq. in serial monitor but serial monitor format is ascii. So, it type is integer. My frequency variable type is double.

If i wanna change it , i am afraid i must be write new function,right ?

PaulS

Quote
If i wanna change it , i am afraid i must be write new function,right ?
No. The Serial class inherits from the Stream class, which has parseInt() and parseFloat() that let you type numbers, and converts the stream of characters to int or float.
The art of getting good answers lies in asking good questions.

WhereIsMyMind

Hi again me ,I working on RDA5807m radio module(i wanna learn i2c protocol) and i find this code but i dont know mean this code can your help me ?

Code: [Select]

#include <Wire.h>
 
 unsigned char frequencyH = 0;
 unsigned char frequencyL = 0;
 
 unsigned int frequencyB;
 double frequency = 0;
 
 void setup()
 {
   Wire.begin();
   frequency = 100.0 ; //starting frequency
   setFrequency();
 }
void loop()
{

}

void setFrequency()
 {
   frequencyB = 4 * (frequency * 1000000 + 225000) / 32768; // ??
   frequencyH = frequencyB >> 8;                   // ??
   frequencyL = frequencyB & 0XFF;                // ??
   delay(1000);
   Wire.beginTransmission(0x60); // i know this code mean
   Wire.write(frequencyH);        // what is it mean
   Wire.write(frequencyL);       // and it
   Wire.write(0xB0);              // and it
   Wire.write(0x10);              // and it
   Wire.write((byte)0x00);     //and it
   Wire.endTransmission();    // i know this code mean :D
 }

nickgammon

Please do not cross-post. This wastes time and resources as people attempt to answer your question on multiple threads.

Threads merged.

- Moderator
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

WhereIsMyMind

Please do not cross-post. This wastes time and resources as people attempt to answer your question on multiple threads.

Threads merged.

- Moderator

I am so sorry :(

WhereIsMyMind

#10
Jul 18, 2015, 11:06 pm Last Edit: Jul 18, 2015, 11:15 pm by WhereIsMyMind
Code: [Select]

#include <Wire.h>

 void setup()
 {
   Serial.begin(9600);
   Wire.begin();
   setFrequency();
 
 }
 
 void loop()
 {

 }
 
 void setFrequency()
 {
   delay(500);
   Wire.beginTransmission(0x11);
   Wire.write(0x02);
   Wire.write(0xC0); Wire.write(0x0D);   
   Wire.endTransmission();
   delay(500); 
   Wire.beginTransmission(0x11); // device address
   Wire.write(0x03); // eeaddress
   Wire.write(0x1B); // High byte
   Wire.write(0x80); // Low byte
   Wire.endTransmission();
 }


I wanna use RDA5807m mode not tea5767 some body help me ?
I writing in 0x03 but it is not same to my wrote values.İt is 4FC0 but i wrote 1B80.
ı calculated frequency ch space(kHz) X frequency([15:6]10bit) + 87000
for ex;
100 X 110 + 87000 = 98000 so 98Mhz. (110 = 0b01101110) if i wanna do ten bit (0b0001101110) and six bit 000000
=> (00011011)(10000000) first byte 0x1B second byte 0x80; then
I try write this but i hear nothing pls help mee :(

Code: [Select]
#include <Wire.h>
unsigned char x,y;
 void setup()
 {
   Serial.begin(9600);
   Wire.begin();
   setFrequency();
 
 }
 
 void loop()
 {
  Wire.beginTransmission(0x11);
  Wire.write (0x03);    // request 6 bytes from slave device #2
  Wire.endTransmission();
  Wire.beginTransmission(0x11); // base address
  Wire.requestFrom(0x11,2); // We want one byte
  x=Wire.read();
  y=Wire.read();
    Serial.println(x,HEX);    // print the character
    Serial.println(y,HEX); 
delay(1000);
 }
 
 void setFrequency()
 {
   delay(500);
   Wire.beginTransmission(0x11);
   Wire.write(0x02);
   Wire.write(0xC0); Wire.write(0x0D);    // write 0xC00D (RDS on etc.) into 0x02
   Wire.endTransmission();
   delay(500); 
   Wire.beginTransmission(0x11);
   Wire.write(0x03);
   Wire.write(0x1B);
   Wire.write(0x80);
   Wire.endTransmission();
 
 }


I using this code check for 0H03 register value.

Go Up