Wireless communication protocol using parity check and checksum [ASK modules]

    This project aims to provide a unidirectional digital communication protocol, designed for applications requiring reliability and stability in the received information. Therefore, the chosen approach involves designing a model with a high load of redundant information for error detection.

    It is worth clarifying that the project is focused on applications involving the gradual control of parameters. In addition to error detection, a user-customizable anomaly detection system is implemented in the transmitter. This mechanism ensures the coherence of values read by the analog-to-digital converter, preventing false readings caused by electronic component failures or noise.

    In this proposed system, speed is not the priority; rather, it is tailored for applications where the risk of receiving incorrect data, misinterpreted as valid, must be avoided.

Implementation

    As a test model, communication between two Arduino microcontrollers is proposed. A potentiometer is connected to the transmitter to regulate the intensity of an LED connected to the receiver.

    For establishing the link, FS1000A modules are chosen for the transmitter, and XY-MK-5V modules for the receiver. These modules receive serial data from Arduino and handle the modulation-demodulation process through ASK modulation at 433MHz.

    The Arduino's ADC, to which the potentiometer is connected, is 10 bits (0 to 1023 values). Initially, these values are analyzed by the anomaly detection code and then encoded into a systematic 4-byte code package.

    In the receiver, the sole task is to decode the information and reflect the received value in the intensity of an LED using PWM modulation.


Connection diagram


Data packet


    Systematic code block with a total size of 4 bytes, of which 10 bits are for data (ADC), and the rest are for control. It consists of start and stop bytes, the data, and, concerning error detection, the following is implemented:
  • Checksum: Sum of '1s' in the data. It can take values from 0 to 10 (decimal), hence using 4 bits. For example, if Data = 1011010101, Checksum = 0110.
  • Data Parity Bit: Even parity bit generator for the data.
  • Checksum Parity Bit: Even parity bit generator for the checksum.

Stages


    The RadioHead library is utilized for the ASK modules, greatly facilitating their integration with Arduino. This implementation can be observed in the .ino files.


    For the development of the encoder, decoder, and anomaly detection, C++11 is employed.

Encoder

    In the encoder, a checksum is generated along with even parity bits for both the data and the checksum itself. The repository attached to this report provides a detailed insight into the implementation of each process, with extensive comments.

Decoder

    The decoder is a bit more extensive as it needs to extract the received data and verify its correctness (both the checksum and parity). The repository contains information on the purpose of each process necessary for decoding.

Anomaly Detector


    This block, which can be deactivated, consists of a circular buffer where values read by the potentiometer are stored. The buffer size is user-selectable. The AnomalyDet class compares the values stored in the buffer with a threshold also chosen by the user. If any of these values surpass the threshold, the reading is considered invalid, and the message is not sent. This can prevent false potentiometer readings caused by circuit failures or interference.

    For instance, if the ADC is gradually reading ascending values {510, 513, 515, 823}, the last data point might be considered an anomaly if the threshold is properly configured. In this case, this data won't be sent to the encoding stage.

    It's important to emphasize that these threshold and buffer size values are highly specific to the application. As mentioned, the code is designed to make it easy for the user to modify them. Additionally, with these values stored, more complex logic could be implemented to decide whether a value is or isn't an anomaly.


Code

    In the repository, the code is extensively commented and segmented. (In the scheme on page 3, you can see which code file corresponds to each process.) It is recommended to start reading the code from Source/TX/TX.ino. "Bitwise operators" are extensively used both in the encoder and decoder, performing bitwise logical operations.

Considerations in the scope of the link

    The oversizing in error control can lead to a high error rate, which can be inevitably resolved by increasing power and improving hardware. Additionally, transmitting 10-bit data words is excessive in this implementation. Therefore, it is a compromise between the size of the messages sent (packet) and the range of the link.

Appendix

ASK Modulation

    Amplitude Shift Keying (ASK) modulation is a digital modulation technique in which the amplitude of the carrier wave varies according to the bit sequence of the input signal. In other words, the amplitude of the carrier wave is modulated with a digital signal.

    In general, M-ASK modulation has M different levels to represent information; in this case, modules that only use two levels were employed. This modulation is called On-Off Keying (OOK) and is based on the presence or absence of the carrier to transmit a '1' or '0'. Therefore, information is transmitted by varying the amplitude of the carrier wave between these two levels.

    This modulation tends to occupy a larger bandwidth than other techniques and is highly susceptible to noise. Therefore, encoding methods and error control are often used.


PWM Modulation

    Pulse Width Modulation (PWM) is a technique used to control the amount of energy delivered to a device. The main idea behind PWM is to vary the width of pulses in a square wave while keeping the frequency constant. This is achieved by adjusting the duty cycle of the signal.

    The duty cycle is the ratio of the time the signal is in the high state to the total cycle time. In this implementation, PWM is used to control the luminous intensity of an LED.



This was a project carried out for the "Digital Communications" course at my university.

Thank you for reading!