Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Courtesy Tone #5

Open
kc9pos opened this issue Dec 12, 2023 · 7 comments
Open

Adding Courtesy Tone #5

kc9pos opened this issue Dec 12, 2023 · 7 comments

Comments

@kc9pos
Copy link

kc9pos commented Dec 12, 2023

Hello I am looking for ways to easily add a curtesy tone after a transmission. I was thinking of adding a function similar to this to detect when a CTCSS was detected and play the .wave file however so you have any alternative methods of adding this little feature. Thank You

` while True:

        # Check repeater in use
        count = 0
        print("[Info] :: Checking if repeater is free to ID ...")
        print("[Time] ::", end = " ")
        tim = machine.Timer(period=const.SAMPLING_PERIOD_MS * 4, callback=timer_callback)

        while True:
            count = count + 1

            # If there is some activity, start recount
            # Can be improved to be more smart then
            # a simple unique detection.
            # First approach, increase detection time
            if dr1x.ctcss_detected() == True:
                count = 0
                #print ("[Warn] :: CTCSS detected => Reset counter ...")

            utime.sleep_ms(const.SAMPLING_PERIOD_MS)

            if count % (const.SAMPLING_FREQ) == 0 and count != 0:
                print ("%d" % (int) (count / const.SAMPLING_FREQ), end=" ")
                #print ("[Time] :: Elapsed %d/%d sec." % ((int) (count / const.SAMPLING_FREQ), const.USAGE_CHECK_DURATION), end = " ")
            if count >= (const.USAGE_CHECK_DURATION * const.SAMPLING_FREQ):
                print ("")
                print ("[Info] :: Will ID Repeater ...")
                tim.deinit()
                break
                    
        # Start Tx
        dr1x.tx_start()
        utime.sleep(0.75)

        play_id()
        check_temperature_and_inform_if_above(const.TEMPERATURE_THRESHOLD)
        count_ann = check_if_its_time_to_announce(6, count_ann)

        #stop TX
        utime.sleep(0.75)
        dr1x.tx_stop()` 
@phastmike
Copy link
Owner

phastmike commented Dec 13, 2023

Hi @kc9pos, greetings from ct1enq.

Unfortunately, this ain't easy to do with the Yaesu DR1X/DR2X. These repeaters have a built-in controller and this project tries to use a feature that disables the controller. When we toggle the control pin the repeater ceases control. The project just monitors the input to be sure that no one is using the repeater. Only then, the circuit toggles the pin and starts playing the audio. Then it releases control back to the repeater. To add a courtesy tone, it would have a strange behavior. When a user stops transmission, the repeater tail ends and then we can send a sound which takes time. This will add an additional time to the "tail" and on a fast passed QSO it could render some misbehavior from the repeater.

At the moment I don't have any hardware to test. I would recommend that you fork, create a local branch, to test a few things. First of all, we would need some form of measuring the ID time asynchronously, using the pico's second core could be an option. Then you can monitor the CTCSS pin and when cease, simply put the repeater on air and play a short sound.

On the code, to test the behavior, forget the ID and focus on a loop that just monitors the CTCSS pin, when it goes high then low, play a sound. Then you can test how it behaves and if it feels right.

The code you presented it's just a "sampler" that counts for an given amount of time (5,6, 8 seconds). The counter resets if any CTCSS detection is done. If the counter can reach the given amount without any activity then we are sure that no one is using the repeater. This happens only when the repeater reaches the time to ID itself (10 minutes). On reaching it but if the repeater is still in use, the repeater won't ID until we can pass those seconds without activity. If the users take long to answer the repeater may enter ID state and ignore the user message.

Not sure if I've explained it correctly.

@phastmike
Copy link
Owner

If someday I get the repeater back or if somehow we try to change something, I may try to test something

@phastmike
Copy link
Owner

phastmike commented Dec 13, 2023

Do you have a repeater and the hardware to try this? If you have, I can draft a quick test for you to try.

@kc9pos
Copy link
Author

kc9pos commented Dec 13, 2023 via email

@phastmike
Copy link
Owner

Hi Timothy, just checked ur page. Congratulations!

Well, I need some time. I need to take a pico from the stock and prepare micropython for it. That is quick but need to refresh all of that :) Just to get started and validate the code. Then I need to read the code to contextualize. The idea is to test the courtesy tone, so probably, I'll create a branch, courtesy, to test some code runs. Can't promise nothing as I retain that it's not the intended use for Remote Mode. A possibility is to delegate the controller to the external world and let the pico do the job. In our case, the goal was solely to "replace" the builtin ID features of the repeater because it does not follow national mandatory guidelines. We also don't like the repeaters to ID while a QSO is ongoing, that's why we have been implementing this "dynamic" ID inhibition. Making a full controller with the pico is something that I've been thinking. If time allows. I had something similar, implemented on a AVR (ATMEGA328p) in bare metal C. The disadvantage is the need for a ISD audio board to record and play the audio message. The pico can overcome this and go even deeper. Only time will tell :/.

I'll get back to you when I have something, only lacking time atm but will try to do something.

73 de ct1enq

@phastmike
Copy link
Owner

Hi @kc9pos,

Check courtesy branch at:

https://github.com/phastmike/IDx/tree/courtesy

It's a small draft just to test if this behavior is even valid.

ID is disabled. On a CTCSS detection as posterior end, a courtesy tone should be played. It's the file courtesy_tone1.wav inside audio folder. Don't forget to add it too.

Should work but didn't fully tested on a DR-1X, just toggled the pin and checked for console prints.

If you dare to test it ;)

Greetings

@phastmike
Copy link
Owner

Btw, the main code is in main.py:

        while True:
            if dr1x.ctcss_detected() == True:
                print("[IDx ] :: CTCSS detected ...")
                while dr1x.ctcss_detected() == True:
                    x = 0
                try:
                    # Here we should put the repeater tail duration
                    # and a little more just to be sure the repeater stopped
                    # transmition

                    utime.sleep(0.7)
                    print("[IDx ] :: CTCSS End * Courtesy tone ...")

                    dr1x.tx_start()
                    utime.sleep(0.1)
                    player.play(courtesy_tone)
                    utime.sleep(0.1)
                    dr1x.tx_stop()
                except:
                    print("[Errr] :: exception in courtesy tone file %s ..." % courtesy_tone)

@phastmike phastmike changed the title Adding Curtesy Tone Adding Courtesy Tone Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants