Skip to content

Commit

Permalink
Doc
Browse files Browse the repository at this point in the history
  • Loading branch information
pu2clr committed Jul 17, 2024
1 parent 209ee8f commit 6d59b64
Show file tree
Hide file tree
Showing 3 changed files with 186 additions and 0 deletions.
Binary file modified .DS_Store
Binary file not shown.
96 changes: 96 additions & 0 deletions examples/01_SERIAL_MONITOR/C_RDS/C_TX.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
UNDER CONSTRUCTION...
Checking QN8066 RDS feature.
This sketch is an example of using the QN8066 Arduino library with the DIY Kit 5W-7W FM
board.
The purpose of this application is to guide developers in using the functions implemented
in this library to develop their own FM transmission station using the "KIT DIY 5W-7W FM
board based on QN8066". It is important to emphasize that users should be aware of and
comply with the applicable laws and regulations in their location when using this FM
transmitter. The following table illustrates the connections between the KIT and
the Arduino Uno, Nano, or Pro Mini boards.
| Anduino Nano or Uno pin | Kit 5W-7W FM |
| ----------------------- | ------------- |
| GND | GND |
| D9 | PWM |
| A4 | SDA |
| A5 | SCL |
Attention: Use the "Serial Monitor" function in the Arduino IDE to monitor the system
initialization process.
Author: Ricardo Lima Caratti (PU2CLR) - 2024/06/17
*/

#include <QN8066.h>

#define PWM_PIN 9 // Arduino PIN used to control the output power of the transmitter via PWM.
#define FREQUENCY 1067 // 106.7 MHz - This library does not use floating-point data.
// This approach helps to save microcontroller memory.
// Therefore, to represent a frequency in the commercial FM band,
// multiply the desired frequency by 10. In this case 106.7MHz is 1067.

QN8066 tx;

char str[80];

void setup() {


Serial.begin(9600);
while (!Serial) ;

pinMode(PWM_PIN, OUTPUT); // Sets the Arduino PIN to operate with with PWM

delay(1000); // Wait a bit while the system stabilizes.

if (tx.detectDevice()) {
Serial.println("\nDevice QN8066 detected");
} else {
Serial.println("\nDevice QN8066 not detected");
while (1);
}


tx.setup(); // Sets some internal parameters

Serial.print("\nStarting the system.");
delay(500);
tx.setTX(FREQUENCY); // Chenge the FREQUENCY constant if you want other value
// tx.setTxOffAfterOneMinuteNoAudio(false); // The trasmitter will never sleep.
tx.setPAC(56); // PA output power target is 0.91*PA_TRGT+70.2dBu. Valid values are 24-56.
tx.setToggleTxPdClear();

tx.setTxPilotGain(10);

tx.setTxStereo(true);
tx.setTxPreEmphasis(75);

tx.setTxInputImpedance(0); // 0=10; 1 = 20; 2=40 (default); 3=80. Kohms.
tx.setTxInputBufferGain(5); // With input inpedance 0 (10K), and input buffer 5, the gain shoud be 18dB
tx.setTxSoftClippingEnable(false);
tx.setTxSoftCliptTreshold(2);
tx.setAudioTxDiff(true);
tx.setTxDigitalGain(2); // TX digital gain => 2 = 2dB (default is 0 dB)

tx.setTxFrequencyDerivation(200); // Valid valued from 0 to 255

// Check - Undocumented registers in the datasheet that affect audio.
tx.setRegister(0x49, 223); // 0B11011111
tx.setRegister(0x6E, 255 ); // 0B11111111

sprintf(str, "\n\nBroadcasting with RDS...");
Serial.print(str);

analogWrite(9, 50); // It is about 1/5 of the max power. It is between 1 and 1,4 W
}

void loop() {
sprintf(str,"\nTop FSM state code: %d", tx.getStatus1().arg.FSM);
Serial.print(str);
delay(15000);
}
90 changes: 90 additions & 0 deletions examples/01_SERIAL_MONITOR/C_TX_RDS/C_TX_RDS.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
UNDER CONSTRUCTION...
Checking QN8066 RDS feature.
This sketch is an example of using the QN8066 Arduino library with the DIY Kit 5W-7W FM
board.
The purpose of this application is to guide developers in using the functions implemented
in this library to develop their own FM transmission station using the "KIT DIY 5W-7W FM
board based on QN8066". It is important to emphasize that users should be aware of and
comply with the applicable laws and regulations in their location when using this FM
transmitter. The following table illustrates the connections between the KIT and
the Arduino Uno, Nano, or Pro Mini boards.
| Anduino Nano or Uno pin | Kit 5W-7W FM |
| ----------------------- | ------------- |
| GND | GND |
| D9 | PWM |
| A4 | SDA |
| A5 | SCL |
Attention: Use the "Serial Monitor" function in the Arduino IDE to monitor the system
initialization process.
Author: Ricardo Lima Caratti (PU2CLR) - 2024/06/17
*/

#include <QN8066.h>

#define PWM_PIN 9 // Arduino PIN used to control the output power of the transmitter via PWM.
#define FREQUENCY 1067 // 106.7 MHz - This library does not use floating-point data.
// This approach helps to save microcontroller memory.
// Therefore, to represent a frequency in the commercial FM band,
// multiply the desired frequency by 10. In this case 106.7MHz is 1067.

QN8066 tx;

char str[80];
char strSDR[] = "QN8066..";

void setup() {


Serial.begin(9600);
while (!Serial) ;

pinMode(PWM_PIN, OUTPUT); // Sets the Arduino PIN to operate with with PWM

delay(1000); // Wait a bit while the system stabilizes.

if (tx.detectDevice()) {
Serial.println("\nQN8066 detected");
} else {
Serial.println("\nQN8066 not detected");
while (1);
}


tx.setup(); // Sets some internal parameters

Serial.print("\nStarting the system.");
delay(500);
tx.setTX(FREQUENCY); // Chenge the FREQUENCY constant if you want other value
tx.setTxOffAfterOneMinuteNoAudio(false); // The trasmitter will never sleep.
tx.setPAC(56); // PA output power target is 0.91*PA_TRGT+70.2dBu. Valid values are 24-56.
tx.setToggleTxPdClear();
tx.setTxPilotGain(10);
tx.setTxStereo(true);
tx.setTxPreEmphasis(50);

tx.setTxInputImpedance(1); // 0=10; 1 = 20; 2=40 (default); 3=80. Kohms.
tx.setAudioTxDiff(true);
tx.setTxFrequencyDerivation(120); // Valid valued from 0 to 255

// RDS setup
tx.setTxRDS(true);
tx.writeTxRDSBuffer(strSDR);
tx.setTxToggleRDSReady();

sprintf(str, "\n\nBroadcasting with RDS...");


analogWrite(9, 50); // It is about 1/5 of the max power. It is between 1 and 1,4 W
}

void loop() {

delay(15000);
}

0 comments on commit 6d59b64

Please sign in to comment.