Runway Lighting Controller - VHF Squelch Break .. #2

Thread Starter

agustinr

Joined Nov 21, 2022
14
the idea is that with a vhf band (118-136 mhz) am handy to receive PTT signals to the Rpi, then use Rpi to control a relay board which again controls some lights.
but with a low budget for Latin America regarding small aerodromes that are very important for medical flights, the idea is we need the arduino to read the ppt of the radio from a handy/plane and if you press the ptt four times from another handy vhf you close the relay for 10 minutes and be able to turn on the lights or activate the ptt of the base radio and transmit an automatic message atis.

I found this in a forum and I was able to correct the code somewhat

How could you solve the problem? I need to do something low-cost for my use of the private airfield.

Mod: Created a new thread.
Link to old:

https://forum.allaboutcircuits.com/...troller-vhf-squelch-break.168317/post-1492694

/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 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);
}

// 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);
}

timeLastPush=millis();

if ((timeLastPush - previousMillis) >= 600000UL) {
// 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);

}
}
 
Last edited by a moderator:

Thread Starter

agustinr

Joined Nov 21, 2022
14
original code



//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);
}
}
 

Ya’akov

Joined Jan 27, 2019
9,068
I guess I had a misunderstanding of what CTCSS was - I thought it was a decoder board detecting the introduced tone to prevent interference between users on the same channel. Airband VHF doesn't utilize CTCSS (That I'm aware of). Can you recommend any specific hardware?
You understood. Air band radios don’t have CTCSS or any other coded squelch capabilities.
 

Ya’akov

Joined Jan 27, 2019
9,068
I read in a reference that the typical squelch delay time is 50-150ms for the squelch to operate after a transmission ends.
So, if that generates a burst of random noise at the audio output for that length of time, then I would think you could rectify the noise to get a DC pulse, and the run that to a comparator with an adjustable trigger level to respond to the high amplitude noise, but not to lower level audio.
You could add discrimination at the comparator output (if needed ) to ignore signals longer that the longest squelch noise burst (which are likely audio).
A complication is that airband is AM not FM. The squelch tail noise is very different from normal VHF FM radios. It’s really necessary to know what the signal looks like, as you said.

If might be better to tap the signal the squelch circuit uses to mute/unmute the audio that to try to use the audio output of the radio. Alternatively, an AF oscillator might be able to inject a signal pre-muting that would be present when the squelch breaks. That way there is a definite signal to key on.
 

Thread Starter

agustinr

Joined Nov 21, 2022
14
I would like to add to that arduino code that the rele open after a certain time.

For example, press ptt 3 times and close the rele 1 but I want to set a counter or timer function so that it opens again after 10 minutes and the rele 2 to 30 minutes
 

MisterBill2

Joined Jan 23, 2018
18,167
REally, an arduino and code is not needed to implement the function of switching on the lights for a while. USE a circuit like the one in post #2 to trigger a 555 timer IC, for a few seconds, and if the signal is still present during that time then it can trigger the second timer that controls the lighting relay. BUT the caller will need to repeat the message for the short time so that there is an adequate signal to trigger the timer. That way a noise burst will not trigger the lights, but the message: "Airport please switch on the lights" would switch them on. Cheap, easy, reliable, and no programming required. Thus no needing to restart after a short power outage. And it will not require very much standby power.
 

WBahn

Joined Mar 31, 2012
29,976
Please be sure that you are in compliance with FAA/FCC requirements for pilot-controlled-lighting. For instance, are you required to comply with L-854?

There are off-the-shelf solutions available specifically for PCL at airports. Is there a reason you are not just using one of them?
 
Last edited:

Thread Starter

agustinr

Joined Nov 21, 2022
14
Unfortunately in Latin America there is no budget for small airports we are forgotten. For this reason one has to fend for himself if the aeronautical authority approves you if it is well built but only for small airfields.
 

WBahn

Joined Mar 31, 2012
29,976
REally, an arduino and code is not needed to implement the function of switching on the lights for a while. USE a circuit like the one in post #2 to trigger a 555 timer IC, for a few seconds, and if the signal is still present during that time then it can trigger the second timer that controls the lighting relay. BUT the caller will need to repeat the message for the short time so that there is an adequate signal to trigger the timer. That way a noise burst will not trigger the lights, but the message: "Airport please switch on the lights" would switch them on. Cheap, easy, reliable, and no programming required. Thus no needing to restart after a short power outage. And it will not require very much standby power.
That's not how pilot-controlled lighting works.

When approaching an airport with PCL, the pilot simply keys the microphone on the CTAF (common traffic advisory frequency) three, five, or seven times within a five second period. Doing so turns on specific lights at one of (up to) three increasing intensities. The lights turn off fifteen minutes after the last command received. The frequency used is also the same frequency that announcements are made by the pilot, so the PCL system has to be able to ignore those transmissions by only counting squelch breaks that occur within the five second window.

Note: There are some slight variations to the system described above (e.g., Type J and Type K) and some variations from country to country.
 

WBahn

Joined Mar 31, 2012
29,976
Oh. I see. You hijacked someone else's thread and a Mod has split it off for you.

I don't know how comfortable I would feel landing at an airport knowing that the pilot-controlled lighting that I am relying on for my life and those of my passengers as I cross the threshold making a crosswind landing on a moonless night is controlled by someone's homespun code in an Arduino on a homespun circuit board.

Scratch that -- I know exactly how comfortable I would be... not at all.
 
Last edited:

Thread Starter

agustinr

Joined Nov 21, 2022
14
The idea is to test it for a period of time. I already have worked with ruino a rele with a gal module I control it by sending a message 3 years ago and it's perfect. The airfield only receives flights from small aircraft the use would be the responsibility of the unfortunate crew there is no budget to acquire the approved system in addition imports are closed
 

WBahn

Joined Mar 31, 2012
29,976
The idea is to test it for a period of time. I already have worked with ruino a rele with a gal module I control it by sending a message 3 years ago and it's perfect. The airfield only receives flights from small aircraft the use would be the responsibility of the unfortunate crew there is no budget to acquire the approved system in addition imports are closed
"Unfortunate crew" indeed.

So if your system fails and results in a fatal crash, you and the airport have no liability in your country?

Good luck. I do understand the situation you are in and that you are trying to provide a service with inadequate resources. Just ask yourselves whether it is a service you should be attempting to provide given those lack of resources and that it is critical to safety of flight.
 

Thread Starter

agustinr

Joined Nov 21, 2022
14
"Unfortunate crew" indeed.

So if your system fails and results in a fatal crash, you and the airport have no liability in your country?

Good luck. I do understand the situation you are in and that you are trying to provide a service with inadequate resources. Just ask yourselves whether it is a service you should be attempting to provide given those lack of resources and that it is critical to safety of flight.
I think it's tinkering if it really works and testing it not in service and in the future being able to approve it. Unfortunately, the team in the country is worth 1500 dollars, an unattainable figure for our airfield like many others

Also, as in the first part, we don't want to turn on lights. We just want 3 ptt to send a small message of the weather conditions temperature point of Rocio and wind we only need the rele to simulate the handy button. And the message would come from the PC connected with a rperry pi with battery support.
 

MisterBill2

Joined Jan 23, 2018
18,167
Not being aware of the standard process, but only of the required results, I described the very simplest scheme that could function. Using the first timer to enable a simple counter could easily work as well.
Also, please be advised that neither the FCC nor our FAA have authority in Latin America.
 

Thread Starter

agustinr

Joined Nov 21, 2022
14
MODERATOR NOTE: Added CODE tags, please use them when posting code.

C++:
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 = 10000; // Timeout in milliseconds
void setup() {
pinMode(PTT,INPUT);
pinMode(REL1,OUTPUT);
pinMode(REL2,OUTPUT);
pinMode(REL3,OUTPUT);
pinMode(REL4,OUTPUT);
Serial.begin(115200);
Serial.println("PTT FUNCTION");
}
void loop() {
// read the pushbutton input pin:
PTTState = digitalRead(PTT);
// Serial.println(PTTState);
// 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:
Serial.print("time :");
Serial.println(millis());
Serial.println(timeLastPush);
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);
Serial.print("LastPTTState : ");
Serial.println(lastPTTState);

} 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);

}
Serial.println("Counters");
Serial.println(  PTTPushCounter % 4);
Serial.println(  PTTPushCounter % 5);
Serial.println(  PTTPushCounter % 7);
Serial.println(  PTTPushCounter % 9);
Serial.println(  PTTPushCounter % 10);

// 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);
}
}
 
Last edited by a moderator:
Top