Originally posted by pustareka
View Post
Announcement
Collapse
No announcement yet.
RUSSIAN KVANT-SL VLF-IB-MD
Collapse
X
-
Okay!!!
I will share here the Sketch published in the Russian forum by Ken; It's the only one I found.
Also, regarding the coil, they recommend using the Garrett 6.5 ? 9 ACE PROformance Coil; I did not find any data on making a homemade coil.Attached Files
Comment
-
I made one of the first versions, I think last year, not sure.
It is interesting enough to be made and exercise with it.
Good as an "instrument" for testing and analyzing coils.
I tried to match it with several original coils that I have here.
Some of them works and some of them not.
With Garrett Ace coil i got 60% of the performances and results of what I saw that author did (there is a video somewhere on Youtube with same coil).
Long story short; I was not able to achieve any better results, nor good enough, so I abandoned it.
The PCB is still here in some box.
Must be that I miss something or done something wrong, can't tell.
Comment
-
-
16-битный I2C ADS1115 ADS1015 модуль ADC 4-канальный с усилителем усиления Pro 2,0 в до 5,5 В для Arduino RPi
https://aliexpress.ru/item/400055006...io13v250728201
ATMEGA328P Pro Mini 328 Mini ATMEGA328 5 В/16 МГц ATMEGA328 5В или 3,3 В 8 МГц для платы разработки Arduino
https://aliexpress.ru/item/32605434250.html?sku_id=10000001189597608&ysclid=l 6lxpev87g207997922
Comment
-
/ Aвтор Кен 2022
/ Сайт: https://tehnodium.ru
/ Ветка Квант: https://tehnodium.ru/thread-65.html
#include <avr/sleep.h>
#include <EEPROM.h>
#include "LiquidCrystalM.h" //#include <LiquidCrystal.h>
LiquidCrystal lcd(7,6,5,4,3,2);
#define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))// Оставляет строки в PROGMEM
#include <Wire.h>
#define ADS 0x48 // Адрес АЦП ADS1115
#define DAC 0x60 //Адрес MCP4725 0x60, 0x61, 0x62, 0x63, 0x64, 0x65.
#define F_tx(x) (F_CPU/(x*4))// Возвращяет частоту TX Hz
#define Out_Sound 11
#define LED_LCD 8
#define ALERT 12 //#define ALERT 13 старая схема
#define in_V_bat A0
#define V_bat_min 6.5 //Минимальное напряжение батареи
#define num_prof 4
struct strMem //Структура данных для EEPROM
{
int ocr1a[num_prof]; //Частота TX
int Comp_Phase[num_prof]; //Компенсация начальной фазы для канала G, ферит на -45
int Adjustment_Phase[num_prof];//Подстройка показаний фазы, ферит на -90
int amp_TX[num_prof];// Ток ТХ
int VDI_notch_L;//Обрезка нижней границы VDI
int VDI_notch_H;//Обрезка верхней границы VDI
float K_G;//Kоэффициент канал грунта G
byte Threshold; //Порог срабатывания по канлу G
char Filter; //Тип фильтра
int bat_adj;// Настройка показаний напряжения питания
byte Prof;//Текущий профиль
char Sound_schemes;//Схема звука
byte Sound_duration;// Длительность звука
byte Gain;// Усиление ADS1115
byte backlight;// Подсветка LCD
};
strMem Mem;
const PROGMEM int sound_test[] ={ 120,160,220,400,600,800,1000 };//
const byte Battery[]={B01110,B11111,B10001,B10001,B10001,B10001,B11111 ,B00000};
bool Button_FLAG=false;
bool B_hold=false;
bool Overload;
bool Menu_flag=false;
byte button_n;
bool Display_flag;
volatile bool sempl_flag=true;
int int_vdi,level;
uint16_t sempl_count;
float Xy,Yy;
float VDI=0,VDI_mem=0;
void timer_setup()
{
cli(); // отключить глобальные прерывания
TIMSK0&=~(1<<TOIE0); //Отключаем прерыване по переполнению
TCCR0A = (1 << WGM01);// режим CTC
TCCR0B =(1<<CS00)|(1<<CS02); // Тактировать с делителем 1024
OCR0A =255; //регистр совпадения
TIMSK0|=(1<<OCIE0A); // Разрешить прерывание по совпадению
DDRB |= B00000110; //устанавливает выводы 9 10 OUTPUT
PORTB &=~ B00000110;//устанавливает выводы 9 10 LOW
TCNT1=0;
ICR1=(Mem.ocr1a[Mem.Prof]*2)-1;
TCCR1A=0x50;
TCCR1B=0x19;
OCR1A= Mem.ocr1a[Mem.Prof];
OCR1B=1;
pinMode(Out_Sound, INPUT);//Звук выкл
TCCR2A = (TCCR2A & 0x3F) | 0x40; // CHANNEL_A OUTPUT ENABLE - звук, вывод 11
TCCR2A = (TCCR2A & 0xF0)|(1 << WGM21);// CTC - mode
sei(); // включить глобальные прерывания
}
ISR(TIMER0_COMPA_vect)
{
sempl_flag=false;
}
//=======================================setup()==== ================================================== ===
void setup()
{
analogReference(INTERNAL);//ИОН 1.1V
delay_M(100);
power_check();
Wire.begin();
Wire.setClock(400000);
Serial.begin(115200);
EEPROM_check();
EEPROM.get(1,Mem); // Чтение из EEPROM
pinMode(LED_LCD,OUTPUT);
digitalWrite(LED_LCD,Mem.backlight); //Подсветка LCD
pinMode(ALERT, INPUT);//ALERT ADS1115
Wire.beginTransmission(ADS);
Wire.write(B00000011);//Hi_thresh register
Wire.write(B11111111);
Wire.write(B11111111);
Wire.endTransmission();
Wire.beginTransmission(ADS);
Wire.write(B00000010);//Lo_thresh register
Wire.write(B00000000);
Wire.write(B00000000);
Wire.endTransmission();
Filter_set();
lcd.begin(16, 2);
lcd.print(F("KVANT-SL 1.5.8"));
delay_M(2000);
lcd.createChar(1,Battery);
LCD_start();
timer_setup();
for(int i=0;i<(sizeof(sound_test)/2);i++) {F_snd(pgm_read_word(&sound_test[i]));delay_M(150);}//тест звука
pinMode(11, INPUT);//Звук выкл
}
//=======================================loop======= ================================================== =
void loop()
{
static int32_t Max_G;
static byte Cut_Sempl;
static int max_level,sample_num;
while(sempl_flag);
sempl_flag=true;
buttons_scan();
processing_XY();
int32_t G = Xy+Yy*Mem.K_G;//Канал грунта
Serial_data(Xy,Yy,G);
int_vdi =VDI+Mem.Adjustment_Phase[Mem.Prof];
if(int_vdi>180)int_vdi-=360;
if(int_vdi<-180)int_vdi+=360;
if(Overload && int_vdi<=Mem.VDI_notch_H && int_vdi>=Mem.VDI_notch_L && G>(Mem.Threshold*2) )
{
if(G>=Max_G)
{
Max_G=G;
if(sample_num>0)VDI_TONE(int_vdi);
sample_num++;
level=round(log(G/6.0))-1;
if(level<1)level=1;// Ограничение G 1...7
if (level>max_level)max_level=level;
if(level>7)level=7;
VDI_mem=int_vdi;
sempl_count=0;
Display_flag=true;
}
}
else {sample_num=0; Max_G=0;}
if(Overload==false) {error_Sound();max_level=2;}
if(sempl_count>=(2+max_level*2)&&Mem.Sound_duratio n==0){pinMode(Out_Sound, INPUT); max_level=0;}
if(sempl_count>=Mem.Sound_duration&&Mem.Sound_dura tion>0){pinMode(Out_Sound, INPUT); max_level=0;}
sempl_count++;
}
//================================================== ================================================== ===
void processing_XY()
{
static float Old_Xy,Old_Yy;
const int32_t adc_max= 65500;
const int32_t adc_min=-65500;
Xy=0.0;
Yy=0.0;
ADC1115_start('X',ADS);
while(digitalReadFast(ALERT));// Ждём результата
Xy+=ADC1115_red(ADS);
ADC1115_start('Y',ADS);
while(digitalReadFast(ALERT));// Ждём результата
Yy+=ADC1115_red(ADS);
ADC1115_start('X',ADS);
while(digitalReadFast(ALERT));// Ждём результата
Xy+=ADC1115_red(ADS);
ADC1115_start('X',ADS);
while(digitalReadFast(ALERT));// Ждём результата
Xy+=ADC1115_red(ADS);
ADC1115_start('Y',ADS);
while(digitalReadFast(ALERT));// Ждём результата
Yy+=ADC1115_red(ADS);
ADC1115_start('Y',ADS);
if(Menu_flag==false)battery_volt();
while(digitalReadFast(ALERT));// Ждём результата
Yy+=ADC1115_red(ADS);
ADC1115_start('X',ADS);
if(Display_flag)
{
lcd.setCursor(3,0);
if(int_vdi>=0)lcd.print("+");
lcd.print(int_vdi);//Индикация VDI
lcd.print(" ");
lcd.setCursor(0,1);
}
while(digitalReadFast(ALERT));// Ждём результата
Xy+=ADC1115_red(ADS);
ADC1115_start('Y',ADS);
if(Display_flag)
{
for(int i=0; i<7; i++)
{
if(level>i)lcd.write(char(255));// Индикация уровня сигнала
else lcd.write('<');
}
Display_flag=false;
}
while(digitalReadFast(ALERT));// Ждём результата
Yy+=ADC1115_red(ADS);
Xy*=0.5;
Yy*=0.5;
if(Xy>=adc_max||Yy>=adc_max||Xy<=adc_min||Yy<=adc_ min)Overload = false;//Перегрузка
else Overload=true;
Xy=LPF_A(Xy);//ФНЧ
Yy=LPF_B(Yy);//ФНЧ
Xy=HPF_A(Xy);//ФВЧ
Yy=HPF_B(Yy);//ФВЧ
Xy=(Xy+Old_Xy)/2; Old_Xy=Xy; //ФНЧ
Yy=(Yy+Old_Yy)/2; Old_Yy=Yy;//ФНЧ
float Magn;
if(Xy>1000||Yy>1000)
{
int32_t Ym=abs(Yy);
int32_t Xm=abs(Xy);
Magn = max(Xm,Ym)+3*min(Xm,Ym)/8;
}
else Magn = sqrt(pow(Xy,2)+pow(Yy,2));
VDI=degrees(atan2(Yy,Xy));
VDI-=Mem.Comp_Phase[Mem.Prof];
float theta=VDI*DEG_TO_RAD;
Yy=Magn*sin(theta);
Xy=Magn*cos(theta);
}
//--------------------------------------------------ADC1115_red------------------------------------------------------------------------
void ADC1115_start(char inp, byte dev)
{
byte config_reg_X = B10000001;
byte config_reg_Y = B10110001;
config_reg_X |= (Mem.Gain<<1);
config_reg_Y |= (Mem.Gain<<1);
Wire.beginTransmission(dev);
Wire.write(B00000001);//Config register selection
if(inp=='X')Wire.write(config_reg_X);//start_conversion(1) , input_selection(000) A0-A1 , Amp gain = Mem.Gain , single_shot_mode(1).
if(inp=='Y')Wire.write(config_reg_Y);//start_conversion(1) , input_selection(011) A2-A3 , Amp gain = Mem.Gain, single_shot_mode(1).
Wire.write(B11100000);//datarate(111) 860SPS , comparator functions(00000).
Wire.endTransmission();
}
int ADC1115_red( byte dev)
{
byte buffer[2];
Wire.beginTransmission(dev);
Wire.write(B00000000);//Conversion register selection
Wire.endTransmission();
Wire.requestFrom(dev, 2);
buffer[0] = Wire.read();
buffer[1] = Wire.read();
Wire.endTransmission();
int val = buffer[0] << 8 | buffer[1];//Собираем байт
return val;
}
//-----------------------------------------Gain_ADC1115------------------------------------------------------------------
void Gain_ADC1115()
{
lcd.clear();
lcd.setCursor(5,0);lcd.print(F("GAIN:"));lcd.print (Mem.Gain);
lcd.setCursor(0,1); lcd.print(F("2"));
lcd.setCursor(3,1); lcd.print(F("3"));
lcd.setCursor(7,1); lcd.print(F("4"));
lcd.setCursor(11,1);lcd.print(F("5"));
lcd.setCursor(14,1);lcd.print(F("Ex"));
while (true)
{
Key_status();
if(Button_if(1)) {Button_enter(); Mem.Gain=2; break;}
if(Button_if(2)) {Button_enter(); Mem.Gain=3; break;}
if(Button_if(3)) {Button_enter(); Mem.Gain=4; break;}
if(Button_if(4)) {Button_enter(); Mem.Gain=5; break;}
if(Button_if(5)) {Button_enter(); break;}
}
}
//-------------------------------------------------service_data--------------------------------------------------------------
void Service_data()
{
static int Tic_ib=0;
lcd.clear();
lcd.setCursor(0,1);
lcd.print(F_tx(Mem.ocr1a[Mem.Prof]));
lcd.print(F("Hz "));
lcd.setCursor(11,1); lcd.write(1);
while (true)
{
Key_status();
Button_hold();
if(Button_if(1)) {Button_enter();V_bat_adj();}
if(Button_if(2))
{
Button_FLAG=true;
Mem.ocr1a[Mem.Prof]++;
ICR1=(Mem.ocr1a[Mem.Prof]*2)-1;
OCR1A=Mem.ocr1a[Mem.Prof];
lcd.setCursor(0,1);
lcd.print(F_tx(Mem.ocr1a[Mem.Prof]));
lcd.print(F("Hz "));
}
if(Button_if(4))
{
Button_FLAG=true;
Mem.ocr1a[Mem.Prof]--;
ICR1=(Mem.ocr1a[Mem.Prof]*2)-1;
OCR1A=Mem.ocr1a[Mem.Prof];
lcd.setCursor(0,1);
lcd.print(F_tx(Mem.ocr1a[Mem.Prof]));
lcd.print(F("Hz "));
}
if(Button_if(5)) {Button_enter();break;}//Выход
Tic_ib++;
if( Tic_ib==1)
{
lcd.setCursor(0,0);
lcd.print(F("b="));
lcd.print(i_b_coil('b'));
lcd.print(F("mv "));
}
if( Tic_ib==2)
{
lcd.setCursor(9,0);
lcd.print(F("i="));
lcd.print(i_b_coil('i'));
lcd.print(F("mA "));
Tic_ib=0;
}
battery_volt();
}
}
//----------------------------------------------i_b_coil--------------------------------------------------------------
int i_b_coil(char ib)
{
unsigned long semp1=0;
int divider;
int input;
analogPrescaler(16);//Ускоряем АЦП
if(ib=='i')
{
divider=3400;//Делительем - калибруем показания тока TX
input=A3;
}
if(ib=='b')
{
divider=2400;//Делительем - калибруем показания разбаланса RX
input=A2;
}
for(int i=0; i<8192; i++){semp1+=analogReadFast(input);}
analogPrescaler(12;//Ставим скорость АЦП по умолчанию
return semp1/divider;
}
//-------------------------------------------battery_volt-------------------------------------------------------------
void battery_volt()
{
static int V_bat=0;
static int Tic_b=0;
if(Tic_b==1
{
float V=float(V_bat)/Mem.bat_adj;
Tic_b=0;
V_bat=0;
lcd.setCursor(12,1);
lcd.print(V,1);
if(V<V_bat_min)
{
lcd.clear();
lcd.print(F("Battery Low"));
digitalWrite(LED_LCD,LOW);//Подсветка LCD выкл
sleep();
}
}
else {V_bat+=analogReadFast(in_V_bat); Tic_b++; }
if(Tic_b==1){lcd.setCursor(15,1);lcd.print('v');}
}
//------------------------
void V_bat_adj()// Калибруем показания напряжения питания
{
lcd.clear();
lcd.setCursor(4,0);
lcd.print(F("-"));
lcd.setCursor(11,0);
lcd.print(F("+"));
lcd.setCursor(0,1);
lcd.print(F("voltage set"));
while (true)
{
Key_status();
if(Button_if(2)) {Button_enter(); Mem.bat_adj+=10;}
if(Button_if(4)) {Button_enter(); Mem.bat_adj-=10;}
if(Button_if(5)) {Button_enter();break;}//Выход
battery_volt();
}
lcd.clear();
lcd.setCursor(0,1);
lcd.print(F_tx(Mem.ocr1a[Mem.Prof]));
lcd.print(F("Hz "));
lcd.setCursor(11,1); lcd.write(1);
}
//--------------------------------------------VDI_notch-----------------------------------------------------------------
void VDI_notch()
{
lcd.clear();
lcd.setCursor(0,1); lcd.print(F("- + exit - +"));
while (true)
{
lcd.setCursor(10,0); lcd.print(F("H +")); lcd.print(Mem.VDI_notch_H);
lcd.setCursor(0,0); lcd.print(F("L ")); lcd.print(Mem.VDI_notch_L);
Key_status();
Button_hold();
if(Button_if(1)) {Button_FLAG=true; Mem.VDI_notch_L--;}
if(Button_if(2)) {Button_FLAG=true; Mem.VDI_notch_L++;}
if(Button_if(3)) {Button_enter(); break;}//выход
if(Button_if(4)) {Button_FLAG=true; Mem.VDI_notch_H--;}
if(Button_if(5)) {Button_FLAG=true; Mem.VDI_notch_H++;}
if(Mem.VDI_notch_H>90)Mem.VDI_notch_H=90;
if(Mem.VDI_notch_L<-90)Mem.VDI_notch_H=-90;
delay_M(200);
}
}
//---------------------------------------------Profile_select--------------------------------------------------------------------
void Profile_select()
{
lcd.clear();
lcd.setCursor(5,0);lcd.print(F("Prof#"));lcd.print (Mem.Prof+1);
lcd.setCursor(0,1);lcd.print(F("P#1"));
lcd.setCursor(4,1);lcd.print(F("P#2"));
lcd.setCursor(9,1);lcd.print(F("P#3"));
lcd.setCursor(13,1);lcd.print(F("P#4"));
while (true)
{
Key_status();
if(Button_if(1)) {Button_enter(); Mem.Prof=0; break;}
if(Button_if(2)) {Button_enter(); Mem.Prof=1; break;}
if(Button_if(3)) {Button_enter(); break;}//выход
if(Button_if(4)) {Button_enter(); Mem.Prof=2; break;}
if(Button_if(5)) {Button_enter(); Mem.Prof=3; break;}
}
ICR1=(Mem.ocr1a[Mem.Prof]*2)-1;
OCR1A= Mem.ocr1a[Mem.Prof];
lcd.clear();
}
//-------------------------------------------LCD_start---------------------------------------------------------------------------
void LCD_start()
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(F("VDI*** Thr:"));
lcd.print(Mem.Threshold); lcd.print(F(" "));
lcd.setCursor(7,0); lcd.print(F("t"));lcd.print(Mem.Sound_duration);
lcd.setCursor(7,1);
lcd.print(Mem.Sound_schemes);
lcd.print(Mem.Filter);
lcd.setCursor(11,1); lcd.write(1);
}
//-------------------------------------------------Ferit_seting-------------------------------------------------------------------
void Ferit_seting()
{
const int Need_Ferit_phase = -50;
const int Ferit_VDI= -90;
int32_t M,max_M=0;
int count=0;
int vdi=0;
bool count_flag=false;
int Comp_Phase;
Mem.Adjustment_Phase[Mem.Prof]=Ferit_VDI - Need_Ferit_phase;
Mem.Comp_Phase[Mem.Prof]=0;
Mem.Filter='S';
Filter_set();
lcd.clear();
lcd.print(F("Wave ferrit"));
lcd.setCursor(14,1);lcd.print(F("Ex"));
while (true)
{
while(sempl_flag);
sempl_flag=true;
Key_status();
if(Button_if(5)) {Button_enter(); break;}//выход
processing_XY();
if(Overload)
{
int32_t Ym=abs(Yy);
int32_t Xm=abs(Xy);
M=max(Xm,Ym)+3*min(Xm,Ym)/8;
if(M>150&&count<30)
{
if(M>max_M){max_M=M; vdi=round(VDI);}
if(count_flag==false){F_snd(600); count_flag=true;}
}
if ( count>30)
{
max_M=0;count=0;
pinMode(Out_Sound, INPUT);
count_flag=false;
Comp_Phase=vdi - Need_Ferit_phase;
lcd.setCursor(0,0);
lcd.print(F("Real Phase:"));
if(vdi>=0)lcd.print("+");
lcd.print(vdi);
lcd.print(char(223));
lcd.print(F(" "));
int c_vdi=vdi-Comp_Phase+Mem.Adjustment_Phase[Mem.Prof];
lcd.setCursor(0,1);
lcd.print(F("VDI "));
if(c_vdi>0)lcd.print("+");
lcd.print(c_vdi);
lcd.print(char(223));
lcd.print(F(" "));
}
if (count_flag==true)count++;
}
else
{
lcd.setCursor(3,0);lcd.print("-ERROR");
F_snd(200); delay_M(500); pinMode(Out_Sound,INPUT);
}
}
Mem.Comp_Phase[Mem.Prof]=Comp_Phase;
Mem.Filter='S';
Filter_set();
}
//---------------------------------------------- Filter_select-------------------------------------------------------
void Filter_select()
{
if(B_hold){B_hold=false; return;}
Button_enter();
lcd.clear();
lcd.setCursor(0,0); lcd.print("<Filter select>");
lcd.setCursor(0,1); lcd.print("F");
lcd.setCursor(3,1); lcd.print("N");
lcd.setCursor(7,1); lcd.print("S");
lcd.setCursor(11,1);lcd.print("M");
lcd.setCursor(14,1);lcd.print("Ex");
while (true)
{
Key_status();
if( Button_if(1)) {Mem.Filter='F'; break;}
if( Button_if(2)) {Mem.Filter='N'; break;}
if( Button_if(3)) {Mem.Filter='S'; break;}
if( Button_if(4)) {Mem.Filter='M'; break;}
if( Button_if(5)) { break;}
}
Button_enter();
Filter_set();
lcd.clear();
}
//--------------------------------------------------------Phase_adjustment----------------------------------------
void Phase_adjustment()
{
lcd.clear();
int vdi;
VDI_mem-=Mem.Adjustment_Phase[Mem.Prof];
lcd.setCursor(3,1); lcd.print(F("- exit +"));
while (true)
{
vdi=VDI_mem;
vdi+=Mem.Adjustment_Phase[Mem.Prof];
lcd.setCursor(5,0);
lcd.print("VDI");
if(vdi>=0)lcd.print("+");
lcd.print(vdi);
lcd.print(" ");//Индикация VDI
Key_status();
if( Button_if(2)) {Button_enter(); Mem.Adjustment_Phase[Mem.Prof]--;}
if( Button_if(3)) {Button_enter(); break;}
if( Button_if(4)) {Button_enter(); Mem.Adjustment_Phase[Mem.Prof]++;}
}
}
//-----------------------------------------------Ground_balance-----------------------------------------------
void Ground_balance()
{
if(B_hold){B_hold=false; return;}
Button_enter();
sempl_count=0;
Menu_flag=true;
lcd.clear();
lcd.setCursor(14,1);lcd.print("Ex");
char MF=Mem.Filter;
Mem.Filter='M';
Filter_set();
char G_mode='A';
float G_set=0.1;
int G_1p = 8;
int G_1n =-8;
int G_2p = 16;
int G_2n =-16;
int G_3p = 64;
int G_3n =-64;
while (true)
{
while(sempl_flag);
sempl_flag=true;
Key_status();
if(Button_if(1)) {Button_enter(); if(G_mode=='A') G_mode='M'; else G_mode='A';}
if(Button_if(2)) {Button_enter(); Mem.K_G-=G_set;}
//if(Button_if(3)) {Button_enter(); if(G_set==0.1)G_set=1.0; else G_set=0.1;}
if(Button_if(4)) {Button_enter(); Mem.K_G+=G_set;}
if(Button_if(5)) {Button_enter(); break;}
processing_XY();
int32_t G = Xy+Yy*Mem.K_G;
int g_vdi = degrees(atan2(Yy,Xy))+Mem.Adjustment_Phase[Mem.Prof];
if( g_vdi<0 && g_vdi>-95 ) // баланс грунта
{
if(G_mode=='A')
{
if(G>G_3p)Mem.K_G+=0.1;
if(G>G_2p&&G<=G_3p)Mem.K_G+=0.01;
if(G>G_1p&&G<=G_2p)Mem.K_G+=0.001;
if(G<G_3n)Mem.K_G-=0.1;
if(G<G_2n&&G>=G_3n)Mem.K_G-=0.01;
if(G<G_1n&&G>=G_2n)Mem.K_G-=0.001;
}
if(G>(Mem.Threshold*2)){F_snd(map(g_vdi,-95,0,80,400));sempl_count=0;}
}
lcd.setCursor(0,1); lcd.print(G_mode); lcd.setCursor(6,1); lcd.print( Mem.K_G);
lcd.setCursor(0,0); lcd.print(F(" "));
int Val= G/16;
if(Val>0)
{
if(Val>Val=8;
lcd.setCursor(8,0);
for (int i=0; i<Val; i++)lcd.print(">");
}
if(Val<0)
{
if(Val<-Val=-8;
lcd.setCursor(8+Val,0);
for (int i=0; i>Val; i--)lcd.print("<");
}
if(sempl_count==6)pinMode(Out_Sound, INPUT); //Длительность звука
sempl_count++;
}
Mem.Filter=MF;
pinMode(Out_Sound, INPUT);
Menu_flag=false;
}
//-----------------------------------------------F_scan-----------------------------------------------------------
void F_scan()
{
lcd.setCursor(0,0);lcd.print(F("Start scanning ?"));
lcd.setCursor(0,1);lcd.print(F(" YES NO "));
while (true)
{
Key_status();
if(Button_if(1)) {Button_enter();break;}// Начать поиск резонанса
if(Button_if(5)) {Button_enter();return;}// Выход из функции F_scan
}
lcd.clear();
int i_max=0;
for (int i=1000; i >200; i--) // 4...20 kHz
{
ICR1=(i*2)-1;
OCR1A= i;
lcd.setCursor(15-((i-200)/50),0); lcd.print(char(255));// индикация прогресса
Key_status();
if(Button_if(5)) {Button_enter();break;}// Выход из функции F_scan
int i_TX =i_b_coil('i');
if (i_TX>(i_max+4))
{
i_max=i_TX;
Mem.ocr1a[Mem.Prof]=i;
lcd.setCursor(1,1); lcd.print(i_max); lcd.print(F("mA "));
lcd.setCursor(9,1);
lcd.print(F_tx(i));
lcd.print("Hz");
}
}
ICR1=(Mem.ocr1a[Mem.Prof]*2)-1;
OCR1A= Mem.ocr1a[Mem.Prof];
lcd.clear();
Service_data();
Ferit_seting();
}
//----------------------------------------------Sound----------------------------------------------------------
void VDI_TONE(int vdi)
{
if( Mem.Sound_schemes=='M')
{
if(vdi<0) F_snd(map(vdi,-88,-1,64,120));//Звук - Железо 64...120 Гц
if(vdi>=0) F_snd(map(vdi,0,88,180,960));//Звук - Цвет_мет 180...960 Гц
}
if( Mem.Sound_schemes=='m')
{
if(vdi>=0) F_snd(map(vdi,0,88,180,960));//Звук - Цвет_мет 180...960 Гц
}
if( Mem.Sound_schemes=='2')
{
if(vdi<0) F_snd(160);//Звук - Железо 160Гц
if(vdi>=0) F_snd(600);//Звук - Цвет_мет 600Гц
}
if( Mem.Sound_schemes=='1')
{
if(vdi>=0) F_snd(600);//Звук - Цвет_мет 600Гц
}
}
//--
void F_snd(int frequency)
{
uint8_t prescalarbits;
uint32_t ocr;
ocr = F_CPU / frequency / 2 / 64 - 1;
prescalarbits = 0b100;
if(ocr > 255)
{
ocr = F_CPU / frequency / 2 / 128 - 1;
prescalarbits = 0b101;
if(ocr > 255)
{
ocr = F_CPU / frequency / 2 / 256 - 1;
prescalarbits = 0b110;
if (ocr > 255)
{
ocr = F_CPU / frequency / 2 / 1024 - 1;
prescalarbits = 0b111;
if (ocr > 255)ocr=255;
}
}
}
OCR2A = ocr;
TCCR2B = (TCCR2B & 0b11111000) | prescalarbits;
pinMode(Out_Sound, OUTPUT); // Включить звук
}
//--
void BEEP()
{
F_snd(400);// Вкл звук 400 Гц
delay_M(100);
pinMode(Out_Sound, INPUT);//Звук выкл
}
//--
void error_Sound()
{
static bool svitch;
if (svitch) F_snd(400);
else F_snd(800);
svitch=!svitch;
if(Mem.Sound_duration>0)sempl_count=Mem.Sound_dura tion-1; // 1 семпл
else sempl_count=5;
}
//----
void Sound_schemes()
{
lcd.clear();
lcd.setCursor(0,0); lcd.print(F("<Sound schemes>"));
lcd.setCursor(0,1); lcd.print(F("M"));
lcd.setCursor(3,1); lcd.print(F("m"));
lcd.setCursor(7,1); lcd.print(F("2"));
lcd.setCursor(11,1);lcd.print(F("1"));
lcd.setCursor(14,1);lcd.print(F("Ex"));
while (true)
{
Key_status();
if( Button_if(1)) {Button_enter();Mem.Sound_schemes='M'; break;}
if( Button_if(2)) {Button_enter();Mem.Sound_schemes='m'; break;}
if( Button_if(3)) {Button_enter();Mem.Sound_schemes='2'; break;}
if( Button_if(4)) {Button_enter();Mem.Sound_schemes='1'; break;}
if( Button_if(5)) {Button_enter();break;}
}
}
//--------
void Sound_setting()
{
lcd.clear();
lcd.setCursor(0,0); lcd.print(F("t-Sound="));
lcd.setCursor(3,1); lcd.print(F("- exit +"));
lcd.setCursor(0,1); lcd.print(F("0"));
lcd.setCursor(15,1); lcd.print(F("7"));
while (true)
{
Key_status();
if( Button_if(1)) {Button_enter();Mem.Sound_duration=0; }
if( Button_if(2)) {Button_enter();Mem.Sound_duration--; }
if( Button_if(3)) {Button_enter(); break;}
if( Button_if(4)) {Button_enter();Mem.Sound_duration++; }
if( Button_if(5)) {Button_enter();Mem.Sound_duration=7;}
lcd.setCursor(8,0); lcd.print(Mem.Sound_duration);lcd.print(" ");
}
}
//-------------------------------------------------------------------------------------------------------------------------
void TX_current()
{
lcd.clear();
lcd.setCursor(3,1); lcd.print("-");
lcd.setCursor(12,1); lcd.print("+");
while (true)
{
Key_status();
if( Button_if(2)) {Button_enter(); Mem.amp_TX[Mem.Prof]-=100; if(Mem.amp_TX[Mem.Prof]<0)Mem.amp_TX[Mem.Prof]=0; set_current_TX(Mem.amp_TX[Mem.Prof]);}
if( Button_if(4)) {Button_enter(); Mem.amp_TX[Mem.Prof]+=100; if(Mem.amp_TX[Mem.Prof]>1556)Mem.amp_TX[Mem.Prof]=1556; set_current_TX(Mem.amp_TX[Mem.Prof]);}
if( Button_if(5)) {Button_enter();break; }
int curent_bar = Mem.amp_TX[Mem.Prof]/97;
lcd.setCursor(0,0);
for (int i=0; i<curent_bar; i++){lcd.print(char(255));} // Индикация уровня
for(int i=curent_bar; i<16; i++) lcd.print(' ');
lcd.setCursor(5,1);
lcd.print(i_b_coil('i'));
lcd.print(F("mA "));
}
}
void set_current_TX(uint16_t dac_output)//dac_output = 0...4095
{
Wire.beginTransmission(DAC);
Wire.write(0x60); //(0110 0000) Writes to the DAC and the EEPROM (persisting the assigned value after reset)
uint8_t firstbyte=(dac_output>>4);
dac_output = dac_output << 12;
uint8_t secndbyte=(dac_output>>;
Wire.write(firstbyte);
Wire.write(secndbyte);
Wire.endTransmission();
}
//================================================== ================================================== ====
void Serial_data(int32_t A,int32_t B,int32_t C )
{
Serial.print('A'); Serial.print(A);//Красный
Serial.print('B'); Serial.print(B);//Зелёный
Serial.print('C'); Serial.print(C);//Коричневый
Serial.print('#');//
}
//---
void sleep()
{
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_mode();
}
//---
void power_check()
{
if(analogReadFast(in_V_bat)<432)
{
lcd.clear();
lcd.print(F("Power error"));
digitalWrite(LED_LCD,LOW);//Подсветка LCD выкл
sleep();
}
}
//---
void delay_M(uint16_t delayM)// Замена функции "delay"
{
uint16_t count_M=0;
while (true)
{
if(count_M==delayM)break;
count_M++;
delayMicroseconds(1000);
}
}
//---
void EEPROM_check()
{
if (EEPROM.read(0) != 121) // если данных нет, записываем по умолчанию
{
for (int i=0;i<num_prof;i++)
{
Mem.ocr1a[i] = 572;// Частота TX 572 = 7000Гц
Mem.Comp_Phase[i]=0;
Mem.Adjustment_Phase[i]=0;
Mem.amp_TX[i]=270;
}
Mem.Prof=0;
Mem.Threshold=7;
Mem.Filter='S';
Mem.VDI_notch_H=86;
Mem.VDI_notch_L=-88;
Mem.K_G=1.0;
Mem.bat_adj=1354;
Mem.Sound_schemes='M';
Mem.Sound_duration=7;
Mem.Gain=5;
Mem.backlight=true;
EEPROM.put(1,Mem); // Запись в EEPROM
EEPROM.update(0, 121); // отметили наличие данных
set_current_TX(270);
}
}
//----
bool digitalReadFast(uint8_t pin) {
if (pin <{
return bitRead(PIND, pin);
} else if (pin < 14) {
return bitRead(PINB, pin -;
} else if (pin < 20) {
return bitRead(PINC, pin - 14); // Return pin state
}
}
//-------
uint16_t analogReadFast(uint8_t pin) {
pin = ((pin <? pin : pin - 14); // analogRead(2) = analogRead(A2)
ADMUX = (INTERNAL<< 6) | pin; // Set analog MUX & reference
bitSet(ADCSRA, ADSC); // Start
while (ADCSRA & (1 << ADSC)); // Wait
return ADC; // Return result
}
//------------
// установка делителя АЦП. Доступны 2,4,8,16,32,64,128
void analogPrescaler(uint8_t prescaler) {
switch (prescaler) {
case 2: ADCSRA = (ADCSRA & 0xF| 0x01;
break;
case 4: ADCSRA = (ADCSRA & 0xF| 0x02;
break;
case 8: ADCSRA = (ADCSRA & 0xF| 0x03;
break;
case 16: ADCSRA = (ADCSRA & 0xF| 0x04;
break;
case 32: ADCSRA = (ADCSRA & 0xF| 0x05;
break;
case 64: ADCSRA = (ADCSRA & 0xF| 0x06;
break;
case 128: ADCSRA = (ADCSRA & 0xF| 0x07;
break;
}
}
tweak
Comment
-
Квант БТ полная документация.Ссылка на яндекс диск.
https://disk.yandex.ru/d/pBtnJcDInvbI3Q
Quant BT full documentation.Link to yandex. disk.
https://disk.yandex.ru/d/pBtnJcDInvbI3Q
Вот так заливаем прошивку в Квант БТ.
That's how we fill the firmware into the BT Quant.
Заливка прошивки в блок. Для того что бы не было проблем при заливке рекомендуется сначала загрузить любой скетч в ЕСП32 через Ардуино IDE.
Win7-11
https://www.espressif.com/sites/default/files/tools/flash_download_tool_3.9.3.zip
LGT8F328P
https://github.com/dbuezas/lgt8fx
Filling the firmware into the block.In order that there would be no problems when filling, it is recommended to first upload any sketch
to ESP32 via the Arduino IDE.
Comment
-
Добавил в публичный доступ на easyeda схемы и платы в катушку для Квант БТ.Там актуальные версии.
https://easyeda.com/editor#id=|ef26d...ca1d08ebbe6d98
https://easyeda.com/editor#id=|1be7a...aebb5883721e86
Added to the public access on easyeda circuits and boards in the coil for Quant BT. There are current versions.
Comment
-
Comment
-
Квант БТ полная документация
https://disk.yandex.ru/d/pBtnJcDInvbI3Q?pane=file-info
Quant BT full documentation
Comment
Comment