¿ªÔÆÌåÓý

Re: PTT Sense Issues


 

Or even better:

//configure the PTT SENSE to use the internal pull-up
pinMode(PTT_SENSE, INPUT_PULLUP);
// check if PTT sense line is installed
PTTsense_installed = !digitalRead(PTT_SENSE);
pinMode(PTT_SENSE, INPUT); //disable the internal pull-up

saves 6 bytes.

73 Allard PE1NWL

On Mon, October 2, 2017 01:06, Allard PE1NWL wrote:
Jerry,
now I think of it- I have a much better idea:

at startup, initially enable the pullup at A0 and check if the PTTsense is
installed.
Then disable the pullup, like so:

//configure the PTT SENSE to use the internal pull-up
pinMode(PTT_SENSE, INPUT_PULLUP);
// check if PTT sense line is installed
if (!digitalRead(PTT_SENSE))
PTTsense_installed = true; //yes it's installed
else
PTTsense_installed = false; //no it's not installed
pinMode(PTT_SENSE, INPUT); //disable the internal pull-up

This way we get a nice zero volts on A0 during RX.

73 Allard PE1NWL

On Sun, October 1, 2017 23:46, Allard PE1NWL wrote:
Jerry,

Correct, we need the pullup on A0 for reasons of backward compatibility.
At startup the firmware detects whether or not the PTTsense line is
installed. When the PTTsense is NOT installed, input A0 will be open.
Without a pullup the digital level will be undefined so we won't be able
to reliably detect this condition.

With the pullup resistor enabled, and a 10K resistor in the PTTsense
line,
we typically get 1.25V on A0 during RX, which is well below the
threshold.
You could use a smaller resistor value but it shouldn't be necessary.

BTW, the 1.25V suggests that the internal pullup resistors are about
30K,
which is smaller than I expected (I've always thought they were at least
50K).

73 Allard PE1NWL

On Sun, October 1, 2017 20:01, Jerry Gaffke via Groups.Io wrote:
Allard,

You are writing your firmware in such a way that users need not apply
all
mods.
That might require a pullup or pulldown on A0, in which case it's best
to
ignore my previous post.
If thresholds at A0 become an issue, perhaps the recommended resistor
at
A0 could be reduced from 10k,
Perhaps as low as 1k?

Measurements are probably the best source of information here.
However, from the datasheet:

Figures 33.25 and 33.26 on pages 391 and 392 of ??
??
(

)
show the input threshold with Vcc at 5v to be somewhere between 2.1 and
2.7 volts for a digital input on the ATmega328p

Figure 33.17 on page 387 shows pullup current from a pin at 1.3v to be
around 100uA, so (5-1.3)/0.1mA = 37k
for the typical effective pullup resistance for an ATmega328p digital
input with Vcc at 5v.

Jerry

On Sun, Oct 1, 2017 at 10:39 am, Jerry Gaffke wrote:


Allard,

What you have works well enough.
But on the next rev of firmware, you might remove the pullup from A0.
(As you are likely already planning to do.)




Join [email protected] to automatically receive all group messages.