Pin Filtering or Noise Filtering?

vk6bgn

New Member
Hello All,

What can anyone tell me about filtering as describe below. Or is this not filtering?

Here is the scenario. I have a receiving radio and a transmitting radio. When the receiving radio receives a strong enough signal, the squelch “opens” and someone’s voice comes out of the speaker. At this same instant, there is a point inside the receiving radio that goes from 0VDC to 5 VDC. This is what I am using on an input pin to tell my PICAXE project that it is time to go and key up the transmitting radio and also patch the audio from the receiving radio, into the transmitting radios microphone input. All at the same instant. Yes, the receiver and transmitter are on different frequencies. They must be! ;)

This works fine 95 percent of the time unless there is some sort of interference. (like today!)

I experienced some sort of electrical interference via the antenna system, not the power supply, that was opening the receiving radios squelch and makeing the radios, key up, un key, key up, un key, key up un key etc. etc. All because of some sort of interference that would only last milliseconds at a time, but enough to be detected by the receiving radio and the appropriate PICAXE pin. Hence the reason for trying to filter out the noise in the code rather then just increasing the threshold of the Squelch control to almost maximum on the receiving radio. (which does fix things but tends to make the receiving radio a bit deaf)

So what I would like to do is add some sort of filtering in my code. What I have now is a line that basically says:

Do
If pin #N is high Goto KeyUpTxRadio (no filtering???)
Loop

What about checking the pin status multiple times over a short period of time with short pauses in between checks? What is this? Filtering in its simplest form?


Do
If pin #N is high Goto Filter
Loop

Filter:

Check Pin #N
Pause N (maybe Pause 5 )
Check Pin #N
Pause N
Check Pin #N
Pause N
Check Pin #N
Pause N
Check Pin #n

(hope you all get my drift)

If any on these checks of the pin fail, then bail out anywhere in the “filter” and return to the loop and don’t go and key up the transmitter. Is this filtering? What is the best way to go about this? Will it introduce any other problems? I can tolerate up to 255 milliseconds of total Pause’s.

What is the best way? Possibly to use For Next? I’m a bit lost at which direction to attack this. Oh, this is not for profit and it’s not my high school homework project.

Comments on a good direction to take would be most appreciative. (I only have 200 bytes left in my 18X)

“Hammy"
 

RexLan

Senior Member
I "think" the best way is to get rid of the Picaxe for this function. Use a small FET like a VN10KM to pull the PTT in the transmitter low when COS goes high. The FET turns on with Vdc, not current.

You can add a small RC network in the gate line (or Picaxe input) that will need to charge before the FET (or Picaxe) will turn on. Place a diode across the network and the gate will turn on instantly. Reverse the diode for the opposite effect .. turn on slow and off fast or turn on fast and off slow ... aim the diode accordingly. You will need to calculate the delay you want for component selection.

You would be better off providing the transmitter with discriminator audio (~1v PP) from the receiver and getting rid of the microphone bit too. Not speaker hi ..

The better way to control false triggers of course is with the use of DCS or CTCSS tones.
 

boriz

Senior Member
This will make TXpin high immediately when RXpin goes high, but TXpin will remain high for 200mS after RXpin goes low, allowing RXpin to switch states many times before stabilising. Will that work?

Code:
do
	if RXpin=1 then
		high TXpin
		b0=200
	else
		if b0>0 then
			dec b0
		else
			low TXpin
		endif
	endif
	pause 1
loop
 

212

Senior Member
Hammy, I'm almost too embarrassed to reply after RexLan's answer, I don't even know what an RC network is... I used what you have there for my video recording code. I used a 2.4ghz radio, and my microwave was upsetting things. I added a "make sure" sub and it works great now.

main:

if pin3 = 0 then make_sure 'if input 3 is low, check again
if pin3 = 1 then goto main

make_sure::
high 0 'turn on yellow LED
pause 300 'pause 3/10 second
low 0 'turn off yellow LED
if pin3 = 0 then record 'if pin 3 is still then record video
if pin3 = 1 then goto main 'if it was a false, then return
 
Last edited:

Andrew Cowan

Senior Member
To eliminate interfrence, I use what 212 recommended:

if pin1=1 then check

check:
if pin1=0 then main
pause 5
if pin1=0 then main
pause 5
if pin1=0 then main
continue with program
 

hippy

Technical Support
Staff member
With the PICAXE in place it makes sense to stick with a code-only solution which will in effect be emulating the hardware RC solution.

Should be easy enough to implement and within the 200 bytes available. It's just a matter of setting how long the 'receiver active' signal must be high before saying "that's legit, I'll un-squelch things" and rejecting activations which are too short - you can even use a pot to adjust what that period is if you have a spare analogue input.

@ 212 : An RC is a resistor-capacitor circuit, the cap charges up when the input to the R is high and discharges when the input is low, short highs ( noise ) will only push the charge up a short way, longer highs will push the charge up higher to some threshold one decides is not noise but a valid signal. That threshold can be adjusted by measuring the charge (voltage) on C with an analogue input or by adjusting the R ( bigger means the C charges slower ). That varying R is handy because it means the C can go into a digital input where the threshold is fixed by its hardware.

Code:
             __      __   __          ________
Input   ____|  |____|  |_|  |________|

                                          _---
                           _       - - -_- - - Threshold
Charge       _-_     _-_ _- -_        _-
        ____-   -___-   -     -______-
 
Last edited:

BeanieBots

Moderator
HamRadioAddict, what you describe is indeed filtering. It even follows all the rules and maths of any other type of filtering.
Anyway, I have had similar issues to solve where I've needed an input to be a particular value for a specified amount of time before certain is action is taken. This very special type of filtering is called hysteresis. Hysteresis can be applied to an input level or it can also be in time.
To cut a long story short, the simplest (non hardware) method I have found is to continually test the input with a known delay between tests. If "good", then increment a counter. If "bad", then set the counter to zero. If the counter reaches a certain value, then do whatever you need to do.
 

RexLan

Senior Member
I agree with everyone else also. Nice explanation Hippy ... I assumed that Hammy would know.

My real point was that for 50 cents a very good solution was available rather than the cost of the processor for this single task. The SW digital filter certainly works and it works well. Adding the diode in the RC builds the hysteresis in one direction by providing a short as BeanieBots point out. This is pretty common usage in PTT circuits for radio and repeaters.
 

212

Senior Member
Hey thanks guys, I learned something today :)

So like most things, there is more than one way to skin this cat. Maybe because I'm still a new...student?...I have already used a Picaxe where I know good and well it can be done easier and cheaper with something else.
 

vk6bgn

New Member
Thanks for all the help everyone. I definitely learned something today too.

RexLan, no way I can give up my PICAXE for this project. That's why I'm here! ;) Also, the PIC holds the Timeout timer, ID Timer, Morse code routine, tone pitch, rogerbeep. etc. etc. .......all the usual controller settings for a simple controller.

Hippy, always love that ASCII art mate! You have too much patients! :)


Cheers
HamRadioAddict
 
Top