Data Transmission: After you are done with the sensor and its instrumentation amplifier the next step transmitting the data read by the MCU from the sensor. For the transmitter I am using a simple to use and widely available 434MHz low power transmitter. Also the sensor transmits raw adc values to the receiver. This enables calibration and scaling of the sensor data at the receiver end.
The 434MHz ASK transmitter and is cheap and easy to interface. However, the cheapness of price brings along with it some limitations like absence of a UART, error correction, framing of data, channel congestion/contention or to put simply, the device lacks a protocol stack. The lack of features cannot be just glossed over and are required to be tackled. So I let the software fill in that gap and approached the problem programatically.
Since this kind of transmitters are fairly common and easy to find, it is but natural that they find common use in our day to day life. As a result for my receiver, my transmitters data transmission should stand out from the rest and should not be swamped by other transmitter. Hence I decided to use PWM modulation to encode my ones and zeros’s .
I hooked up my receiver’s data output port to an oscilloscope and found out that most of the background noise (unwanted data transmissions) had small pulse widths, so I decided to go for large pulse widths for PWM. However a larger pulse width effectively translates into slower data transmission and also higher power consumption. But both of these did not matter much as I intended to transmit data once a minute.
The next step was to do framing of data and error detection (1 bit error detection and recovery possible but recovery not implemented). Framing of data was achieved by sending a slightly larger pulse at the start and end of data transmission and in between bytes.
I will try to explain encoding of data by an example. Assume that we want to transmit raw ADC value 512 as read by the MCU. Since the maximum possible value transmitted by the MSP MCU is 1024 (10 bit ADC), the transmitted value has four digits.
So the first step is to break the received value into 4 individual digits.
Splitting 512(0512) we get
Ones = 2 Tens=1 Hundreds=5 Thousands=0
Second thing to note that each of the individual can have a range of integer value from 0 to 9, though the thousands place can only toggle between o or 1, as value cannot be greater than 1024. Thereafter I encoded each individual bit into a 4 bit binary value, thus 0512 gets encoded as
0=0000 5=0101 1=0001 2=0010
Now to give a 1 bit error detection/ correction , the resultant bit value for each digit was complemented and added to the original bit value to generate a 8 bit number. Thus each byte has a set of complementary bit value.
|Digit||Bit Value||C’pmntd Bit Value||Resulting Int|
From above we can arrive at a simple formula to transmit a a digit (n) we have to transmit (15*(n+1)). Data is transmitted in multiples of 15 and thus if read value is not a multiple of 15 , Houston we have an error!
Effectively to transmit a 10 bit number we are actually going to transmit a 32 bits (8bits x 4 digits) + framing bits. This might seems to be an unnecessary overkill and yes its is, but then I wanted a simple solution to rather than a complex mathematical one like.