CID protocols are described in the standard ETSI EN 300 659 parts 1, 2 and 3. Part 1 details the presentation, data link and physical layers for on-hook data transmission. Part 3 details the used data encoding. Part 2 is for off-hook data transmission. As I have only implemented on-hook data decoding, I have not used part 2.
CID data is transmitted between the first and the second ring patterns, using a FSK modulation, so basically the system has to:
- Wait until the first RING is detected.
- Enable the FSK demodulator.
- Wait for the Channel Seizure Signal (300 bits alternating "0"s and "1"s).
- Wait for the Mark Signal (a block of 180 ± 25 mark bits, or 80 ± 25 mark bits).
- Decode the messages, and match the checksum.
The designed system has a signal conditioning stage, a hardware RING detector, a dsPIC to control everything and process the input signal, and a user interface with a 2x16 LCD, some LEDs and some pushbuttons. Also included are a relay to pick up/hang the phone, a serial port mainly for debugging purposes and a microSD card reader I have not used yet. You can find the schematics here.
The FSK encoded signal has a bitrate of 1200 bps. A typical FSK demodulator for this kind of signals has only a delay block, a multiplier (that multiplies the signal by its delayed version) and a low pass filter. Before implementing the demodulator in the dsPIC, I tested it using GNU Octave (a free software clone of Matlab). I created a FSK modulator, injected noise to the modulated signal, and implemented the demodulator. The following graph illustrates how the demodulator works with these parameters:
- Input sequence: 0 0 1 0 1 0 1 0 1 1 0 0 1 0 1 0 1 0 1 1
- Sampling rate: 7200 Hz (1200 * 6)
- F0 = 2100 Hz
- F1 = 1300 Hz
- Carrier amplitude: -40 dB
- Noise: -43 dB
The demodulator works perfect and the output sequence matches the input sequence even with high noise levels. The Octave script not only tests the demodulator, it also calculates the coefficients needed for the low pass filter, in Q0.15 format.
Once the demodulator was tested in Octave, firmware for the device was coded. The system is in Sleep mode until a RING is detected by the hardware RING detector. Then the dsPIC wakes up, and starts the ADC and demodulator stages. Once the calling number is decoded, it's displayed in the LCD. if it's a hidden number, or it's blacklisted, the relay is activated to pick up the phone, and then it is deactivated to hang the phone. The FSK demodulator has been coded in highly optimized dsPIC assembly. The remaining code has been written in plain C.
Right now, the system only picks up and hangs the phone, but I'd like to add a feature to play some audio tracks recorded in the micro SD card. Also I'd like to add logging capabilities, and a flexible configuration interface. If you want a software release, you can ask for it, but I'd like to implement these capabilities first.
Hi
ReplyDeletecan you send me the Octave script? I would like to use it for an other project to decode a Radio-Sonde.
thank you in advanced
best regards from Switzerland
Roland
I'll try digging through the sources from the project when I get home. I know nothing about Radio-Sonde, but most likely you will have to adjust at least the number of delays of the dephasor filter, and maybe also the low pass filter.
DeleteOK, I have located the files. How should I send you them? Be warned that code is commented in Spanish (sorry about that).
ReplyDeleteGood day! do you have a code for the implementation of FSK modulator and demodulator?
ReplyDelete