OneOfEleven / uv-k5-firmware-custom

A customized version of https://github.com/DualTachyon/uv-k5-firmware
Apache License 2.0
158 stars 72 forks source link

Request: Attempt real MDC-1200 #173

Closed Mason10198 closed 10 months ago

Mason10198 commented 11 months ago

The stock QS firmware contains the wonderful "fake" MDC-1200 EOT PTT ID. It does not sound like an actual 1200/1800 MDC Unit ID, and does not contain any actual information. Examples:

https://github.com/OneOfEleven/uv-k5-firmware-custom/assets/31994327/57138379-377a-4208-9a31-2ec81ffcf8c0

https://github.com/OneOfEleven/uv-k5-firmware-custom/assets/31994327/7f4317df-2c5c-4bb7-83c0-c5b58145548b

Encoding a proper MDC-1200 Unit ID should be doable, if someone with more skills than myself were to take this on. It should also be easy to add an option for this to be at BOT (beginning of TX) instead of EOT. Here is my shotty attempt at re-writing the current function:

// Define MDC-1200 Unit ID and function bits
#define MDC1200_UNIT_ID   0x0423    // Example Unit ID
#define MDC1200_FUNCTION  0x8A      // Example function

void BK4819_PlayRogerMDC(void)
{
    unsigned int i;

    BK4819_SetAF(BK4819_AF_MUTE);

    // Setting up the modulation and other settings remains the same
    BK4819_WriteRegister(BK4819_REG_58, 0x37C3);
    BK4819_WriteRegister(BK4819_REG_72, 0x3065);
    BK4819_WriteRegister(BK4819_REG_70, 0x00E0);
    BK4819_WriteRegister(BK4819_REG_5D, 0x0D00);
    BK4819_WriteRegister(BK4819_REG_59, 0x8068);
    BK4819_WriteRegister(BK4819_REG_59, 0x0068);
    BK4819_WriteRegister(BK4819_REG_5A, 0x5555);
    BK4819_WriteRegister(BK4819_REG_5B, 0x55AA);
    BK4819_WriteRegister(BK4819_REG_5C, 0xAA30);

    // Format MDC-1200 data
    uint16_t mdcData[4];
    mdcData[0] = 0x5555;  // Preamble (assuming 0x5555 for now)
    mdcData[1] = MDC1200_UNIT_ID;  // 16-bit Unit ID
    mdcData[2] = (MDC1200_UNIT_ID >> 8) | (MDC1200_FUNCTION << 8);  // Split Unit ID and function
    mdcData[3] = MDC1200_FUNCTION;  // 8-bit function code

    // Send MDC-1200 data
    for (i = 0; i < 4; i++)
        BK4819_WriteRegister(BK4819_REG_5F, mdcData[i]);

    SYSTEM_DelayMs(20);

    // 4 sync bytes, 6 byte preamble, Enable FSK TX
    BK4819_WriteRegister(BK4819_REG_59, 0x0868);

    SYSTEM_DelayMs(180);

    // Stop FSK TX, reset Tone-2, disable FSK
    BK4819_WriteRegister(BK4819_REG_59, 0x0068);
    BK4819_WriteRegister(BK4819_REG_70, 0x0000);
    BK4819_WriteRegister(BK4819_REG_58, 0x0000);
}

With my code, it sounds ever so slightly different to the ear, but it's still not correct. The pitch is too low, so maybe I'm missing something, or that's just the limitations of the baseband chip.

I also found this reference to a true MDC function in the BK4819 baseband chip, but I could not find any more information on implementing it. The reference document is full of usage data for FSK, but the MDC documentation is lacking.

Here's as much info as I could find on the actual MDC protocol. I own several MDC capable Motorola radios, so I can help test this if someone decides to pursue it. Wikipedia: MDC-1200 BATLABS: MDC-1200 Signalling SIGID: MDC-1200 DBPedia: MDC-1200 RadioReference: MDC-1200

OneOfEleven commented 10 months ago

Once you set it once thats it, no need to change it, but I can get rid of the menu option yes and do compile option, but how will people set the ID if they don't compile etc (most don't) ?

It would mean each and every radio would need it's own custom firmware. Tell that to the factory floor manager ;)

Mason10198 commented 10 months ago

I mean, it's plenty easy enough to go into the code and swap the default ID. If you can compile, then you can do this. No reason to bother adding it to the makefile although that is easy enough as well.

Certainly keep the menu option, that will definitely be useful to change IDs on the fly.

Mason10198 commented 10 months ago

lol, I see moto aren't big on showing useful info on there screens. Least they could do is say BOT 0740 or EOT 0740 ;)

Well, they intend for you to add contacts into the radio associated with IDs, for instance "0740 = Mason10198" so then "Mason10198" would show on screen when I TX.

OneOfEleven commented 10 months ago

If someones willing they can always create a new PC config software to configure the new options from the PC.

wrcrooks commented 10 months ago

I agree that the menu option for setting ID is fantastic and very easy to use. Do you know how much space it takes up by chance? A factory floor manager wouldn't like it but I know that if there was a slimmed down version with a static ID set, I'd choose that to save the space for other features. Just one man's opinion.

SylarMa commented 10 months ago

MDC1200 can display the ID through the relay station, but where to display the received MDC1200, that is, decoding, can be displayed in the position where the DTMF ID is displayed

OneOfEleven commented 10 months ago

I'm leaving the RX part for you to do :) .. I've done the TX

SylarMa commented 10 months ago

I can provide testing, I don't know how to program.:)

SylarMa commented 10 months ago

mmexport1698244802377 This is the effect of MDC received by the moto, very good

OneOfEleven commented 10 months ago

It works then !

SylarMa commented 10 months ago

I found a problem where if the other machine is set to a CTCSS/DCS, the other machine can decode it, but the sound sounds very strange, not frog calling. If there is no CTCSS/DCS , everything is normal. Another issue is that the sensitivity of this firmware has decreased by 10db.

But the current job is already very good

OneOfEleven commented 10 months ago

10dB ?

What frequency range is that on I wonder ?

bricky is playing with the front end settings, so might be that. I've already been there myself doing the same, but I'll let them carry on for bit longer

I don't understand how setting the RX radio makes the TX radio audio distorted though, what's the waveform like ?

Mason10198 commented 10 months ago

@OneOfEleven Recompiled and seeing the menu option now. Nicely done! How does one enter the ID via keypad in the menu? Keying in "0740" results in "02E4".

Does the op arg change when selecting EOT/BOT in the menu? Looks like might be hard coded to 0x80 in functions.c

Another note - my TX bar now shows 100% mic level at all times

Mason10198 commented 10 months ago

Interesting... When using BOT for ID on the QS, the TRBO radio mutes the entire transmission, even after the ID has been RXed. It does decode it and show it on the display, though - but it is definitely not happy about something in the packet. Would a high quality sample of a BOT ID from a TRBO radio fed through your analysis program help?

OneOfEleven commented 10 months ago

It sends 01 80 for BOT and 01 00 for EOT, hopefully.

I haven't tackled dec and hex input yet, I'll have a look in the next few days. For now use the up/dn buttons to find the ID you want, slow but sure.

OneOfEleven commented 10 months ago

Sounds like you've set the TX bar to TX time left/out rather than TX audio level.

OneOfEleven commented 10 months ago

@OneOfEleven Recompiled and seeing the menu option now. Nicely done! How does one enter the ID via keypad in the menu? Keying in "0740" results in "02E4".

Enter 1856 ;) .. the decimal version of 740 hex .. for now

Mason10198 commented 10 months ago

Sounds like you've set the TX bar to TX time left/out rather than TX audio level.

Ah yes, I can't read! Disregard.

Here's a sample of the BOT from my XPR4550, if it helps. Have to convert to mp4 for Github embed, but should be able to take it back to a wav without much degradation. Can do a Drive link or something if needed.

https://github.com/OneOfEleven/uv-k5-firmware-custom/assets/31994327/d339635b-2cc0-4ad0-bc26-915b67bdd33f

Enter 1856 ;) .. the decimal version of 740 hex .. for now

Sweet! Works for me

OneOfEleven commented 10 months ago

That sample is 01 80 740, is that what it should be ?

wrcrooks commented 10 months ago

Didn't want to open an issue for this because it's extremely niche, but using MDC at: -BOT disables intro Quindar Tone -EOT disables outro Quindar Tone -BOT+EOT disables both Quindar Tones

Ideally in my opinion, the process would go: -BOT: BOT MDC, Quindar, TX Audio, Quindar -EOT: Quindar, TX Audio, Quindar, EOT MDC -BOT:EOT: BOT MDC, Quindar, TX Audio, Quindar, EOT MDC

And then I'm not even sure what to think about rogers.

wrcrooks commented 10 months ago

Enter 1856 ;) .. the decimal version of 740 hex .. for now

This! My complaint earlier about adding a Makefile parameter for the default radio ID is a non-issue with this. Can you document in the README that you can enter the decimal value in the menu to get a certain hex value? That would be very helpful for a lot of folks to know.

OneOfEleven commented 10 months ago

Well, theres only 65536 different values to enter, are you sure you want each one listed ?

OneOfEleven commented 10 months ago

Didn't want to open an issue for this because it's extremely niche, but using MDC at: -BOT disables intro Quindar Tone -EOT disables outro Quindar Tone -BOT+EOT disables both Quindar Tones

Ideally in my opinion, the process would go: -BOT: BOT MDC, Quindar, TX Audio, Quindar -EOT: Quindar, TX Audio, Quindar, EOT MDC -BOT:EOT: BOT MDC, Quindar, TX Audio, Quindar, EOT MDC

That's just insane !

Stick to just one type to use, make life easy.

wrcrooks commented 10 months ago

Haha no, definitely not. Just the statement "With regards to entering MDC ID, entering the decimal value of the desired hex ID yields the correct hex ID" Something like that, I'm not fantastic with words.

wrcrooks commented 10 months ago

Stick to just one type to use, make life easy

Yeah you're probably right :laughing:

OneOfEleven commented 10 months ago

Interesting... When using BOT for ID on the QS, the TRBO radio mutes the entire transmission, even after the ID has been RXed. It does decode it and show it on the display, though - but it is definitely not happy about something in the packet. Would a high quality sample of a BOT ID from a TRBO radio fed through your analysis program help?

Don't forget to use NARROW fm for talking to most commercial radios, TX'ing WIDE fm to a radio in NARROW mode won't work, you'll be over deviating. or set the moto to WIDE if you want to use that bandwidth.

SylarMa commented 10 months ago

10分贝 ?

我想知道这是什么频率范围?

布里基正在使用前端设置,所以可能是这样。我自己已经在那里做同样的事情,但我会让他们继续更长的时间

我不明白设置 RX 收音机如何使 TX 收音机音频失真,波形是什么样的?

Videoframe_20231026_071109_com huawei himovie

There is no problem with the Quansheng firmware, and it seems that all other firmware has problems. I don't know where the problem lies.

Mason10198 commented 10 months ago

That sample is 01 80 740, is that what it should be ?

Yes, that is correct.

Don't forget to use NARROW fm for talking to most commercial radios, TX'ing WIDE fm to a radio in NARROW mode won't work, you'll be over deviating. or set the moto to WIDE if you want to use that bandwidth.

Yes, all of my radios including the QS are wide (25khz). I don't think I've ever programmed a single narrowband memory into one of my radios. All services I use are fully wide.

SylarMa commented 10 months ago

Turning off or changing the channel MDCPTT MDC1200 MODE setting will lose and become OFF

wrcrooks commented 10 months ago

@OneOfEleven taught me this about the radio/repo, that's very likely a per-channel setting. Try saving the channel through the menu after setting MDC1200 mode.

SylarMa commented 10 months ago

教我关于无线电/存储库的知识,这很可能是每个频道的设置。设置MDC1200模式后,尝试通过菜单保存频道。

That's great You're right

OneOfEleven commented 10 months ago

Yes it's a per channel setting, so need to re-save the channel if you want to keep the setting on that channel.

If it's in frequency/VFO mode, then your setting is auto-saved, should be as you left it last time you used the radio.

SylarMa commented 10 months ago

Yes it's a per channel setting, so need to re-save the channel if you want to keep the setting on that channel.

If it's in frequency/VFO mode, then your setting is auto-saved, should be as you left it last time you used the radio.

Thank you, this operation is too convenient. It's not a problem, I just don't know how to use it.

Looking forward to RX MDC, if you can achieve it, it's great.

OneOfEleven commented 10 months ago

Here's a sample of the BOT from my XPR4550, if it helps. Have to convert to mp4 for Github embed, but should be able to take it back to a wav without much degradation. Can do a Drive link or something if needed.

Am looking into what the differences are between your sample and what the K5 TX's. The motorola's may just be fussy and want a specific filtering curve on the transmitted FS, no idea what might be up - yet.

OneOfEleven commented 10 months ago

I've reduced the TX deviation slightly, it looked a little high, but without having a moto here I can't test any changes.

I've adjusted the K5 packet format slightly to be as identical as possible to the motorola one you sent. All I can say is that motorola needs to get a better design engineer, the FSK decoder/demodulator they must be using seems way to fussy and critical.

The FSK'ing is the same, the demodulated waveform is the same. The K5 TX waveform (upper) is virtually flat (I record it in the SDR RX, no de-emphasis or any other filtering distorts it), though the motorola sample (lower waveform) you sent has had some LPF'ing applied, not sure if it's in the TX or how you receive and record it ..

Image1

Mason10198 commented 10 months ago

I have one XPR4550 inside, with filtered de-emphasized audio going into PC sound card. I have another XPR4550 outside in my truck. The sample I attached, I recorded in Audacity at 48khz and went outside and PTTd from the truck.

I also have an SDR dongle that I could record it with and get another sample, the same way you do, for consistency. I'd like to know what software/settings you are using for your recording so I can try my best to replicate it.

I can compile the latest and get you a new sample this evening :)

OneOfEleven commented 10 months ago

Do you have SDR# (SDRSHARP) installed and working at all ?

That's what I'm using (with a cheap USB dongle), I set the FM RX bandwidth to about 20kHz, look for the record option down the left list of menu items ..

Image1

If you do manage to do that, then a recording or any moto radio would be interesting to see.

Mason10198 commented 10 months ago

Perfect, I mainly use SDR#. Just wanted to make sure I replicate well. I'll get that uploaded tonight.

Mason10198 commented 10 months ago

@OneOfEleven here is your new sample recorded in SDR#. Let me know if I can do anything else to assist!

https://github.com/OneOfEleven/uv-k5-firmware-custom/assets/31994327/9b32079e-a7f5-4fc4-a5a3-21993065ed9e

OneOfEleven commented 10 months ago

Looks cleaner.

I guess the moto's still don't detect the K5 with the newest firmware ?

Mason10198 commented 10 months ago

Totally forgot to check! Yes, it is working! MDC from the QS is properly decoded AND audible on the TRBO radios as intended. You've done it!20231026_175131.jpg

OneOfEleven commented 10 months ago

That's not all I've done ;)

I'll upload it tomorrow, need to clean it up n things.

OneOfEleven commented 10 months ago

You have a little UHF antenna on the QS.

I did some tests with the QS antenna on, the aerials don't work too well at VHF, replacing them with a 1/4 wave makes a huge difference.

Mason10198 commented 10 months ago

I put those little guys on my "disposable" radios. I call them dummy load antennas, lol. They go on the radios I'm not scared to let fall off my belt loop when I'm climbing up a tower to do some antenna work. I only use them for very close quarters comms, just so I don't have to deal with an actual antenna getting in the way.

mjwgeek commented 10 months ago

Disregard, I've seen that this has already been addressed :)

I've noticed that with the latest build, if I have MDC on exit the menu and use it, it's fine, If I change channels and go back, it's now off on the channel I specifically turned it on for. Is anyone else experiencing this issue?

By the way this is very exciting stuff!

OneOfEleven commented 10 months ago

You need to re-save the channel if you change any of the channel settings (such as mdc1200).

OneOfEleven commented 10 months ago

@Mason10198, could you possibly do one more recording at all for me ?

I need one that shows all timing from carrier start to carrier end. If you open the SDR's squelch, then start recording before you press the motorolas PTT and keep recording until you release the PTT that would be wonderful. If you keep a little bit of FM white noise at the start and end then it will show everything for me.

ps, your job sounds interesting, sounds like you do RF'ey stuff :)

Mason10198 commented 10 months ago

Sure! Here ya go.

https://github.com/OneOfEleven/uv-k5-firmware-custom/assets/31994327/74e75b0c-f2cf-4940-98ee-6d53c5677b71

I actually don't do any RF'ey stuff for work at all. I'm just really into my hobbies.

OneOfEleven commented 10 months ago

ah, I thought you meant you were working on herials as a job. Hobby is better though, it's all by choice then :)

mjwgeek commented 10 months ago

You need to re-save the channel if you change any of the channel settings (such as mdc1200).

Yes I saw :)