Skip to main content

A Programming Mystery...

 As hams we all love the challenge of a mystery especially when a process approach can help unravel that a malicious person put a pin in your coax. That is why you aren't hearing stuff and the SWR is through the roof. That didn't happen but is an example and something that is physical in nature -- you spot the pin, pull the pin and all back to normal. 

On the other hand, where the issue is software the obvious is not easily seen or detected. The off the wall SWR and nothing being heard were huge clues in our example. Those clues are not so clear in a software problem I have with the Pi Pico.

You hit the PTT tab on the QUISK software and thanks to KK4DAS the on-board LED lights green, so you have a visual cue that the MHST is in the transmit mode. But we need one more action in the code and the very same sequence of code that lights the on-board LED must also create a HIGH signal on one of the GPIO pins to trigger the TR relay system.

This sound so much like the Blinking LED tutorials on many devices. The Mr. Miyagi LED ON LED OFF code. (Teaching Daniel san how to wax on wax off.)




The 1st issue with the Pi Pico is that there is an On-Board Green LED but it is hardwired on the Pi Pico substrate and not accessible as a Pin. A real sledgehammer approach is to have a no-touch control (proximity mode IR photoelectric sensor) read the Green LED and it triggers the TR. What a KLUDGE!

The software aficionado would write code to affect that pin going HIGH. There are 4 places where code entry would be required.

1. Designating a Name and Pin Number 

int PTT = 4; This says Pin 4 is the chosen pin.

2. In the setup()

pinMode(PTT, OUTPUT);
digitalWrite(PTT, LOW);

This tells the code that Pin 4 is an Output pin and its initial state is LOW, or no output

3 & 4. In the loop void()

if (something happens like the PTT Button pushed) then

{

digitalWrite(PTT, HIGH);

}

So long as the PTT button is engaged then the designated Pin (4) will be high, and the On-Board LED will be lit Green.

Now if we do nothing else the 1st time you hit the PTT button the designated pin will be HIGH until you power off the Pi Pico.

Following that if statement you need to state the alternative using an else statement. 

else
{ digitalWrite(PTT, LOW);

}

When the PTT button is invoked then the LED comes ON and the designated Pin goes HIGH. When the PTT button is not engaged the LED is off and the designated Pin is low.

Placing this code in the very same locations in the sketch where the On-board LED statements are placed, we should see the LED Glow and the Pin is HIGH. 

Well, it doesn't as the LED lights, but no Pin goes HIGH. The first issue I saw was the Pin designation. This was observed with the Seed, Xiao RP2040. Or the example from Arduino Nano. Pins 2 and 3 are interrupt pins frequently the connection points for an encoder. But these are Pin designations not the real pin numbers on the device and I think are the 5th and 6th pins on the actual hardware. 

My conclusion is one problem is how the Pins are named in the sketch.

An internet search on the Pi Pico revealed others were having this same issue. Spoiler, no clear answer as one solution was to use a code form specific to the Raspberry Pi and non-Arduino -- that doesn't help if you are using the Arduino IDE.

In the Seed RP2040 the pin designations used in the code are like 26u, 27u, 28u and not pin numbers like 1, 2 or 3.

So, while the sketch will compile it does not work. Actual Pin 4 is GPIO Pin 2 or GP2, use of this causes the sketch to abort. Other suggestions in the Internet search were to use D4 or p4. Those compiled but did not work!

This is just a Mr. Miyagi wax on wax off code (from the Karate Kid movie). It can't be that hard. Any suggestions? 

I have already found a company who will provide me a free sample of a no-touch control as that may be the means du jour to TR the rig.

Them that know can make it go.

On the recent SolderSmoke Podcast #258 it was clarified as to what Crank it in Robert and Crank it in Ralph actually means. I also want to thank the many podcast listeners who offered their condolences and support on the passing of my XYL.


73's
Pete N6QW


Popular posts from this blog

MHST Repair Details

MHST is Fixed and Back Working!

The Beat(ing) Goes On.

The Ship is Righted.

AI to the rescue...