April 29, 2024, 03:29:54 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Manchester encoding software modem

Started by sapero, August 09, 2009, 12:46:33 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sapero

In telecommunication, Manchester code is a line code in which the encoding of each data bit has at least one transition and occupies the same time. It is, therefore, self-clocking, which means that a clock signal can be recovered from the encoded data [...]
Manchester code always has a transition at the middle of each bit period. In the normal encoding, transition direction indicates the data bit (0 or 1). In Differential encoding, A '1' bit is indicated by making the first half of the signal equal to the last half of the previous bit's signal.

I have included both methods in this small modem. The standard method uses "m_polarization" bit to automatically detect signal polarisation, and the differential method uses the same bit variable to remember the previously received bit.

You can use this modem as the last communication medium (via sound card) with external hardware - like a microcontroller. With my build-in soundcard I was able to demodulate manchester data at 3675bits/second without any errors (with 44100 sampling rate). Attached source code is configured to simultaneously transmit and receive.


Aurora version

ZeroDog

ooooh, an EBasic version of this  ;D

You can bet ill be toying with this... Thanks !

sapero

August 09, 2009, 04:35:54 PM #2 Last Edit: August 09, 2009, 04:40:16 PM by sapero
Hi ZeroDog! Nice to see that someone is interested in modem internals :)

Sure you can play with it to see how it is working. For example if you set m_polarization to TRUE before entering PlayLoop subroutine (in the standard mode, without DIFFERENTIAL_MANCHESTER $define'd) you'll see how the polarization is {not} toggling just after receiving the second byte of "header". If the polarization is inverted (by modulator, sound driver, soundcard or external amplifier), instead 11001100 you receive 00110011 - all bits inverted.
The polarization can be also changed in the modulator part - just change indexes in states[] array in CManchester::Modulate method: states[1] = m_sine
states[0] = &*m_sine[SamplesPerHalfBit]

There is not much to play with, maybe in the symetric shmitt trigger (decode2 method). Instead xor'ing all bits with m_polarization, you can xor the whole received byte with 255, but only if m_polarization is set.
If you need more details about encoding/decoding, just ask.