How to program the SN761672A

I finally managed to modify the last code you posted to make it work with this tuner and show the right frequency:

//here is the code for SN761672A TV tuner, I'm assuming you using Arduino nano board.
#include <Arduino.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#define clk 2 // rotary encoder clk pin
#define dta 3 //rotary encoder dt pin
int CurrentClock =0;
int PreviousClock =0;
uint16_t RF =2890; //initial frequency =(f+if)/(32/640)
uint8_t OSCI =1;
//uint8_t lockFlag =0;
void SNTVtuner(uint16_t RF,uint8_t OSCI)
{
uint16_t fpd =0;
Wire.beginTransmission(0x61);
switch (OSCI)
{
case 1 : //Setting for OSCIillator #1 VHF-LO
fpd = RF ;
Wire.write(fpd >> 8); //DB1
Wire.write(fpd & 0xFF ); //DB2
Wire.write(0xC8); //CB
Wire.write(0x01); //BB
break;
case 2://Setting for OSCIillator #2 VHF-HI
fpd = RF ;
Wire.write(fpd >> 8); //DB1
Wire.write(fpd & 0xFF); //DB2
Wire.write(0xC8); //CB
Wire.write(0x02); //BB
break;
case 3://Setting for OSCIillator #3 UHF
fpd = RF ;
Wire.write(fpd >> 8); //DB1
Wire.write(fpd & 0x0FF); //DB2
Wire.write(0xC8); //CB
Wire.write(0x08); //BB
break;
}
Wire.endTransmission();
delay(10);
//Wire.requestFrom(0x61,1); //in-lock flag (FL = 1 when the loop is phase-locked)
//while (Wire.available())
{
//lockFlag = Wire.read();
}
}
void setup()
{
Wire.begin();
lcd.begin(16,2);
lcd.backlight();
pinMode(clk,INPUT_PULLUP);
pinMode(dta,INPUT_PULLUP);
PreviousClock = digitalRead(clk);
SNTVtuner(RF,OSCI);
lcd.setCursor(0,0);
lcd.print("RF:");
lcd.setCursor(3,0);
lcd.print(RF*3.2/64-37); //DB1+DB2x32/640-IF
lcd.setCursor(0,1);
lcd.print("OSCI:");
lcd.setCursor(5,1);
lcd.print(OSCI);
lcd.setCursor(10,1);
//lcd.print("LF:");
//lcd.setCursor(13,1);
//lcd.print(lockFlag);
}
void loop() 
{
// put your main code here, to run repeatedly:
CurrentClock = digitalRead(clk);
if(CurrentClock != PreviousClock){
if(CurrentClock != digitalRead(dta)){
RF--;
SNTVtuner(RF,OSCI);
}
else
{
RF++;
SNTVtuner(RF,OSCI);
}
lcd.setCursor(0,0);
lcd.print("RF:");
lcd.setCursor(3,0);
lcd.print(RF*3.2/64-37);
lcd.setCursor(0,1);
lcd.print("OSCI:");
lcd.setCursor(5,1);
lcd.print(OSCI);
//lcd.setCursor(8,1);
//lcd.print("LF");
//lcd.setCursor(11,1);
//lcd.print(lockFlag);
}
PreviousClock = CurrentClock;
}

It's set for an initial frequency of 107.5Mhz. you can change that at RF =2890, according to the formula in the comment. To change the intermediate frequency is in the two lines lcd.print(RF*3.2/64-37), just replace 37 with whatever your IF is.

1 Like