I’m currently using an NS73M controlled by an Arduino Duemilanove. I have a very similar setup to Mike Yancey’s as seen here:
The main difference is I’m using the 3.3V pin on the Arduino instead of a seperate voltage regulator.
The NS73M is acting very strange. Some of the time it will setup just fine and start broadcasting on the frequency I tell it to. Other times it doesn’t broadcast anything. The strangest issue is after it successfully begins broadcasting, out of nowhere (and I do mean nowhere… nothing moves, no one breathes, literally nothing observable changes) the NS73M will cease broadcasting. The only usual way I can rectify the issue at this point is to power down the whole thing and wait about 30 seconds and plug it back in. Every once in a while a reset will do it but I’d say 9/10 times it will do nothing. A quick power off/on also usually does nothing.
Here is the code I am using (credit for this goes to Mike Yancey as well but in order to save scrolling space I removed the pieces that I commented out that I’m not using while trouble shooting):
#include <Wire.h>
#include <EEPROM.h>
#include <LiquidCrystal.h>
#define topFM 107900000 // Top of the FM Dial Range in USA
#define botFM 87500000 // Bottom of the FM Dial Range in USA
#define incrFM 200000 // FM Channel Increment in USA
// define incrFM 100000 // FM Channel Increment - certain countries.
// define incrFM 50000 // FM Channel Increment - certain countries...
long frequency = 97300000; // the default initial frequency in Hz
long newFrequency = 0;
boolean gOnAir = false; // Initially, NOT On The Air...
// Define the LCD
#define rs 12
#define rw 11 // Indicate RW tied to 0.0 volts / WRITE ONLY
#define enable 10
#define d0 4
#define d1 5
#define d2 6
#define d3 7
LiquidCrystal lcd( rs, rw, enable, d0, d1, d2, d3 );
void setup() {
//Serial.begin(9600); //for debugging
// Attempt to read the last saved frequency from EEPROM
newFrequency = loadFrequency();
// Test if outside our FM Range...
if ( newFrequency < botFM || newFrequency > topFM ) {
// Sorry - haven't saved before - use the default.
frequency = 97300000;
}
else {
// We have a valid frequency!
frequency = newFrequency;
}
// Startup the LCD...
lcd.begin( 16, 2 );
lcd.clear();
lcd.setCursor( 0, 0 );
lcd.print( "FM Stereo");
delay(1000);
lcd.setCursor(0, 0);
lcd.print( "Broadcas");
lcd.print( "ter...");
delay(1000);
frequency = 95100000;
displayFrequency( frequency);
Wire.begin(); // join i2c bus as master
transmitter_setup( frequency );
transmitter_standby( frequency );
delay(2000);
set_freq( frequency );
saveFrequency( frequency );
}
void loop() {
}
void transmitter_setup( long initFrequency )
{
i2c_send(0x0E, B00000101); //Software reset
i2c_send(0x01, B10110100); //Register 1: forced subcarrier, pilot tone on
i2c_send(0x02, B00000011); //Register 2: Unlock detect off, 2mW Tx Power
set_freq( initFrequency);
i2c_send(0x00, B10100001); //Register 0: 200mV audio input, 75us pre-emphasis on, crystal off, power on
//i2c_send(0x00, B00100001); //Register 0: 100mV audio input, 75us pre-emphasis on, crystal off, power on
i2c_send(0x0E, B00000101); //Software reset
i2c_send(0x06, B00011110); //Register 6: charge pumps at 320uA and 80 uA
}
void transmitter_standby( long aFrequency )
{
i2c_send(0x00, B10100000); //Register 0: 200mV audio input, 75us pre-emphasis on, crystal off, power OFF
//i2c_send(0x00, B00100000); //Register 0: 100mV audio input, 75us pre-emphasis on, crystal off, power OFF
displayFrequency( aFrequency );
delay(100);
gOnAir = false;
}
void set_freq( long aFrequency )
{
int new_frequency;
// New Range Checking... Implement the (experimentally determined) VFO bands:
if (aFrequency < 88500000) { // Band 3
i2c_send(0x08, B00011011);
//Serial.println("Band 3");
}
else if (aFrequency < 97900000) { // Band 2
i2c_send(0x08, B00011010);
//Serial.println("Band 2");
}
else if (aFrequency < 103000000) { // Band 1
i2c_send(0x08, B00011001);
//Serial.println("Band 1");
}
else {
// Must be OVER 103.000.000, // Band 0
i2c_send(0x08, B00011000);
//Serial.println("Band 0");
}
new_frequency = (aFrequency + 304000) / 8192;
byte reg3 = new_frequency & 255; //extract low byte of frequency register
byte reg4 = new_frequency >> 8; //extract high byte of frequency register
i2c_send(0x03, reg3); //send low byte
i2c_send(0x04, reg4); //send high byte
// Retain old 'band set' code for reference....
// if (new_frequency <= 93100000) { i2c_send(0x08, B00011011); }
// if (new_frequency <= 96900000) { i2c_send(0x08, ); }
// if (new_frequency <= 99100000) { i2c_send(0x08, B00011001); }
// if (new_frequency > 99100000) { i2c_send(0x08, B00011000); }
i2c_send(0x0E, B00000101); //software reset
//Serial.print("Frequency changed to ");
//Serial.println(aFrequency, DEC);
i2c_send(0x00, B10100001); //Register 0: 200mV audio input, 75us pre-emphasis on, crystal off, power ON
//i2c_send(0x00, B00100001); //Register 0: 100mV audio input, 75us pre-emphasis on, crystal off, power ON
lcd.setCursor(0, 1);
lcd.print( " On Air ");
gOnAir = true;
}
void i2c_send(byte reg, byte data)
{
Wire.beginTransmission(B1100111); // transmit to device 1100111
Wire.send(reg); // sends register address
Wire.send(data); // sends register data
Wire.endTransmission(); // stop transmitting
delay(5); // allow register to set
}
void saveFrequency ( long aFrequency )
{
long memFrequency = 0; // For use in Read / Write to EEProm
//Serial.print( "Saving: " );
//Serial.println(aFrequency, DEC);
memFrequency = aFrequency / 10000;
EEPROM.write( 0, memFrequency / 256); // right-most byte
EEPROM.write( 1, memFrequency - (memFrequency / 256) * 256 ); // next to right-most byte
}
long loadFrequency ()
{
long memFrequency = 0; // For use in Read / Write to EEProm
memFrequency = EEPROM.read(0) * 256 + EEPROM.read(1);
memFrequency *= 10000;
//Serial.print("Retrieving: " );
//Serial.println(memFrequency, DEC);
return memFrequency;
}
void displayFrequency( long aFrequency)
{
long memFrequency = 0;
int aDigit = 0;
// LCD Display template: "108.1Mhz" --> 8 characters
memFrequency = aFrequency / 100000; // Gets us down to 9999 digits (where 1011 ---> 101.1
// Write to the LCD
lcd.clear();
if (memFrequency < 1000) {
lcd.write( ' ' ); // pad left for 99.9
}
lcd.print( memFrequency / 10 );
lcd.write( '.' );
lcd.print( memFrequency % 10 );
lcd.print( "Mhz" );
lcd.setCursor(0, 1);
lcd.print( " Standby");
}
As you can see I’ve hard coded it to transmit on 95.1 (a void frequency where I live). I don’t understand what could be causing it to suddenly act the way it is. Any ideas?](Imgur: The magic of the Internet)