Control of lights of a private aerodrome by means of vhf y rele

good morning to all!

Good morning, I would like to know if anyone has experience in this matter.
vhf ptt trigger for relay control
the idea is that with a vhf band (118-136mhz) useful to receive PTT signals to the Rpi, then use Rpi to control a relay board. I have a device to control the track lights with GSM and it has been working excellent for three years, but I would like to be able to press the ptt of the radio 3 times and it closes the relay and with a contactor turns on the lights and then the relay opens turn off the lights after 30 minutes and be able to press the ptt of the radio 5 times and another relay to activate the ptt of the vhf and transmit the message atis and the relay opens or stop transmitting in 10 minutes to do so! I leave an example

Regarding the aeronautical authority, I am the head of the airport and pilot, for which I have the support and I can install it in a small private aerodrome.

PTTState

//constant value which will not change:
const int PTT = 6;
const int REL1 = 2;
const int REL2 = 3;
const int REL3 = 4;
const int REL4 = 5;

//values which will change:
int PTTState = 0;
int PTTPushCounter = 0;
int lastPTTState = 0;
unsigned long timeLastPush = 0; //Millisek. since last time PTT was pressed..
unsigned long timeOutPTT = 8000; // 2,0sek

void setup() {

pinMode(PTT,INPUT);
pinMode(REL1,OUTPUT);
pinMode(REL2,OUTPUT);
pinMode(REL3,OUTPUT);
pinMode(REL4,OUTPUT);
Serial.begin(9600);
Serial.println("PTT FUNCTION");

}

void loop() {
// read the pushbutton input pin:
PTTState = digitalRead(PTT);

// compare the PTTState to its previous state
if (PTTState != lastPTTState && lastPTTState == 0) { //If changed PTT state AND lastPTTState = 0,
if ((millis() - timeLastPush) > timeOutPTT ) { //If timeout-limit for PTT reached:
timeLastPush = millis(); //Set new timecouter start now,
PTTPushCounter = 0; //Set PTT counter to 0.
}
// if the state has changed, increment the counter
if (PTTState == HIGH) {
// if the current state is HIGH then the PTT went from off to on:
PTTPushCounter++;
Serial.println("on");
Serial.print("number of PTT pushes: ");
Serial.println(PTTPushCounter);
} else {
// if the current state is LOW then the PTT went from on to off:
Serial.println("off");
}
// Delay a little bit to avoid bouncing
delay(50);
}
// save the current state as the last state, for next time through the loop
lastPTTState = PTTState;

if (PTTPushCounter % 4 == 3) {
digitalWrite(REL1, HIGH);
}
if (PTTPushCounter % 6 == 5) {
digitalWrite(REL2,HIGH);
}
if (PTTPushCounter % 8 == 7) {
digitalWrite(REL3,HIGH);
}
if (PTTPushCounter % 10 == 9) {
digitalWrite(REL4,HIGH);
}
else if (PTTPushCounter == 10) {
digitalWrite(REL1,LOW);
digitalWrite(REL2,LOW);
digitalWrite(REL3,LOW);
digitalWrite(REL4,LOW);
}
}

Hello agus172

What is the information carrier?

Signal noise / no noise at the receiver ?

It is an Icon ic-a6 of aviation band 118-136mhz has an option squelch I intend to use it high so that it does not have interference.


I also understand that you can see interference but I guess the counter needs according to the code 3 pulses of ptt push to talk to close

Hello
As I remember the PTT is a switch.
I´m confused about your hardware interface.




recieving radio has its speaker jack connected to the arduino The circuit I have given is a peak-to-peak detector; it does not "bias to 2.5 V" but references to ground. If the audio signal is more than about 3.8 V peak to peak (2.5 V plus 1.2 V for the diode drops and a little more) it should register a HIGH on the input pin with a simple single digitalRead.

It does not include protection for the Arduino input but you would need to feed it 6.2 V or more to deliver more than 5 V to the Arduino pin. You could include a 10k resistor in series with the connection to the input pin if this was a concern.

Spk + and spk gnd

Hello agus172

Please post a timing diagram.

What I would need is to integrate the milis function so that when the relays are closed it has a timer that when it reaches a certain time it opens.

For example, when I activate 3 ptt from another radio (airplane) you listen to it, the handy goes to the arduino and the rele n 1 closes and 10 minutes pass and the same thing opens for the rele 2 Active ptt 5 times And pass 39 minutes and it opens.

Try to make a code but the My problem is now that millis function is running in background in the set interval regardless of when i toggle the relays, millis function will reset the relays in the time period which is not intentional. Just need a clever way to measure time when the relays has been turned on, check if the interval is true, if so and then turn the relays off..

//constant value which will not change:
const int PTT = 6;
const int REL1 = 2;
const int REL2 = 3;
const int REL3 = 4;
const int REL4 = 5;

unsigned long interval = 600000UL; // interval at which to turn off a relay

//values which will change:
int PTTState = 0;
int PTTPushCounter = 0;
int lastPTTState = 0;

unsigned long previousMillis = 0; // will store last time a relay was updated.
unsigned long currentMillis = 0;
unsigned long timeLastPush = 0; //Millisek. since last time PTT was pressed..
unsigned long timeOutPTT = 10000; // Timeout in milliseconds

DFRobot_LCD lcd(16,2); // Type of LCD display set 16 characters and 2 lines.

void setup() {
// initializing lcd
lcd.init();
// start serial port for LCD
Serial.begin(9600);
Serial.println("PTT READY");
lcd.setCursor(0,0);

//Pin configuration as connected by the schematic
pinMode(PTT,INPUT);
pinMode(REL1,OUTPUT);
pinMode(REL2,OUTPUT);
pinMode(REL3,OUTPUT);
pinMode(REL4,OUTPUT);
Serial.begin(9600);
Serial.println("PTT READY");

}

void loop() {
// read the PTT input pin:
PTTState = digitalRead(PTT);

// compare the PTTState to its previous state
if (PTTState != lastPTTState && lastPTTState == 0) { //If changed PTT state AND lastPTTState = 0,
if ((millis() - timeLastPush) > timeOutPTT ) { //If timeout-limit for PTT reached:
timeLastPush = millis(); //Set new timecouter start now,
PTTPushCounter = 0; //Set PTT counter to 0.
}
// if the state has changed, increment the counter
if (PTTState == HIGH) {
// if the current state is HIGH then the PTT went from off to on:
PTTPushCounter++;
Serial.println("PTT PUSHED");
Serial.print("NUMBER OF PTT PUSHES: ");
Serial.println(PTTPushCounter);
} else {
// if the current state is LOW then the PTT went from on to off:
Serial.println("off");
}
// Delay a little bit to avoid bouncing
delay(50);
}
// save the current state as the last state, for next time through the loop
lastPTTState = PTTState;

if (PTTPushCounter %4 == 3) {
lcd.clear();
lcd.setCursor(3,0);
lcd.print("RELAY 1 ON!");
digitalWrite(REL1, HIGH);
}

if (PTTPushCounter %6== 5) {
lcd.clear();
lcd.setCursor(3,0);
lcd.print("RELAY 2 ON!");
digitalWrite(REL2,HIGH);
}
if (PTTPushCounter %8== 7) {
lcd.clear();
lcd.setCursor(3,0);
lcd.print("RELAY 3 ON!");
digitalWrite(REL3,HIGH);
}
if (PTTPushCounter %10== 9) {
lcd.clear();
lcd.setCursor(3,0);
lcd.print("RELAY 4 ON!");
digitalWrite(REL4,HIGH);
}

currentMillis=millis();

if ((currentMillis - previousMillis) >= interval) {
// saves the last time we turned the relay on/off
lcd.clear();
lcd.setCursor(0,0);
lcd.print("ALL RELAYS OFF!");
digitalWrite(REL1,LOW);
digitalWrite(REL2,LOW);
digitalWrite(REL3,LOW);
digitalWrite(REL4,LOW);

previousMillis = millis();
Serial.println(previousMillis);

}
}

I really don't know how I can do it.

Hi,
Have you got the basic input working?
That is can you detect a PTT press from the Tx and coming out of the Rx speaker jack and into the Arduino.
If not, then start there, get your input working before worrying about three presses or displays.
Use the IDE serial monitor.

When you press the PTT, is it just carrier and no modulation you send?

If so consider putting a tone on it and detect the tone at the Arduino.

Thanks.. Tom... :smiley: :+1: :coffee: :australia:
PS. As you use AM modulation, all it may take is someone to start a power implement or other electrically noisy device and you may have the lights going on and off all day.

Air band radios don’t have CTCSS or any other coded squelch capabilities.

Each unknown transmitter is able to change the state of the relay.
Is that your design goal?

You hold a very simple oscillator in a hand sized box to the microphone as you press the PTT.
9V battery, LM555 and a small speaker.

Tom... :smiley: :+1: :coffee: :australia:

Good morning yes so I know the idea that when from an airplane a pilot pressed 3 ptt the arduino receives the signal and closes the rele 1 to turn on the lights or if the pilot presses 5 ptt activate rele and the ptt of the radio and transmits a message there is a worldwide established frequency 122,900. I also want when rele 1 turns on it turns off after 30 minutes.

Everyone has such a small oscillator - you just whistle three times, or 5 times.

You can register the time in ms when the relay turns ON, then compare the current ms with this initial time until the difference exceeds 30 minutes. Look at the "blink without delay" example.

I like the way you process the audio - technically that's called a charge pump rather than peak-to-peak detector. You could connect its output to an analogue input rather than digital which would allow you to set a threshold to match the audio signal. You could also consider using a tone decoder like https://www.ti.com/lit/ds/snosbq4f/snosbq4f.pdf?ts=1669109809861&ref_url=https%253A%252F%252Fwww.google.com%252F
to process the audio signal. Would need a little user training so they know what pitch of whistle is needed, if you didn't just provide a little oscillator with a speaker for them.

I know the aeronautical bands are tightly regulated (as a passenger I find it reassuring!), I assume there won't be radio reg issues with your intended application?

I don't think the aeronautical vhf is compatible with tones