MDC1200 source code

The General forum is where users can discuss any topic regarding Motorola communications equipment - hardware, software, etc. There are also several focused forums on this board, so please take the time to ensure that your questions doesn't fall into one of those categories before posting here!

Moderator: Queue Moderator

Post Reply
ka6sqg
Posts: 31
Joined: Thu Aug 12, 2004 11:08 pm

MDC1200 source code

Post by ka6sqg »

For source code that implements encoding and decoding of 1200 BPS MSK data bursts that happen to be compatible (in my monitoring experience) with MDC1200:

http://www.matthew.at/mdc

The software is covered by the GPL, so may be used in any code that is also redistributed in source form under the same terms. If you want to use it in software that is closed-source, contact me for alternative license terms.

It, along with my two-tone sequential paging decoder library, is used at my http://www.firescan.net/ website, specifically:
http://www.firescan.net/cgi-bin/chindex ... =page&ch=5
if you want to see an example of the decoding that the library is capable of.
batman21
Posts: 50
Joined: Fri May 30, 2003 7:46 pm

Post by batman21 »

So how do you use this? Is is something that works with the soundcard or you have to provide it demodulated data? If so, where is the data input? a little howto would go a long way

Thanks!
ka6sqg
Posts: 31
Joined: Thu Aug 12, 2004 11:08 pm

Post by ka6sqg »

The documentation is in the header files. The decoder takes 8-bit unsigned audio samples in buffers of any reasonable length, and the encoder generates 8-bit unsigned audio samples in buffers of any reasonable length. The sample rate can be chosen at initialization time... for decoding, I tested at 8 kHz and 22.050 kHz, the latter being a bit better in most cases.

The audio to/from 1200 bps MSK modulation is implemented in this software, so no need to implement a hardware MSK modem solution. To run under Windows or Linux, for instance, you'll need to provide your own code to initialize the sound card and read samples in or write samples out as necessary. This is operating-system and in some cases hardware specific, so not part of this library.

The decoder can also be driven with a capacitively-coupled single-bit zero-crossing input with a trivial modification to the code, and that has been tested on a PIC microcontroller as well.

For most applications, you'll also want to translate to/from MDC1200 named opcodes instead of the raw opcode and argument bytes. That work isn't done in the code I posted for several reasons, but is also trivial to add.
batman21
Posts: 50
Joined: Fri May 30, 2003 7:46 pm

Post by batman21 »

The work that you have done is much appreciated! The documentation in the header file is quite sketchy however, and i'm still not clear how to implement this. I am NOT a novice at this either, i've been programming for 20 years. Again, please dont take this as a complaint - some more detail would be greatly appreciated!

Maybe a windows or linux program that is functional and shows how to get the data from a sound card, and get it into the program, etc.
ka6sqg
Posts: 31
Joined: Thu Aug 12, 2004 11:08 pm

Post by ka6sqg »

For decoding on a system like solaris or linux where you can just loop to read the input samples (as opposed to windows, where you'd need to initialize directsound, set up trigger events, and set up an event handler that could deal with the samples in a separate thread as the notifications arrived and then pass the results back to the main thread for display) the process is basically this:

#include "mdc_decode.h" /* and link with mdc_decode.c */

main()
{
mdc_decoder_t *decoder;
unsigned char op, arg, extra0, extra1, extra2, extra3;
unsigned short unitID;
unsigned char buffer[1024];
int result;

decoder = mdc_decoder_new(22050);

<<initialize sound input device for 22050 kHz, mono, 8 bit unsigned>>

while(1)
{
<<read 1024 bytes from sound card to buffer>>

result = mdc_decoder_process_samples(decoder, buffer, sizeof(buffer));

switch(result)
{
case 0: break;
case -1: exit();
case 1:
mdc_decoder_get_packet(decoder, &op, &arg, &unitID);
printf("%02x %02x %04x\n", op, arg, unitID);
<<or could translate the opcode and argument and format for better display>>
break;
case 2:
mdc_decoder_get_double_packet(decoder, &op, &arg, &unitID, &extra0, &extra1, &extra2, &extra3);
printf("%02x %02x %04x %02x %02x %02x %02x\n", op, arg, unidID, extra0, extra1, extra2, extra3);
<<or could translate the opcode and argument and format for better display>>
break;
}
}
}
batman21
Posts: 50
Joined: Fri May 30, 2003 7:46 pm

Post by batman21 »

Yes, that's quite helpful.... thanks!
syslinux
Posts: 3
Joined: Mon Feb 28, 2005 12:43 am

MDC Encoding

Post by syslinux »

Hi There
Can you post a code snippit for using your library to encode MDC

Thanks
ka6sqg
Posts: 31
Joined: Thu Aug 12, 2004 11:08 pm

Re: MDC1200 source code

Post by ka6sqg »

IMPORTANT NOTE FOR USERS: On 4 October 2010 I found and fixed several bugs which prevented mdc_decode from running properly on 64-bit architectures.
Post Reply

Return to “General Motorola Solutions & Legacy Radio Discussion”