1
PlainDSP M2M Communication Protocol and Encoding This document describes the machine-to-machine (M2M) communication protocol and encoding using the PlainDSP audio kit.
Introduction The PlainDSP kit can be used to recognize frequency patterns, and therefore would be useful in M2M communication where audio signals are the exchanged energies. This same concept is used in many digital systems used in telecommunications and RF communication (e.g. frequency hopping). In this document we will learn how the PlainDSP kit can be utilized to acquire and process frequency patterns, and how this can translate into English text.
Hello World!
Contents Introduction .................................................................................................................................................. 1 Hardware ...................................................................................................................................................... 2 Concept ......................................................................................................................................................... 2 Channels, Tone Sequence Generation, and Encoding .................................................................................. 3 Channels .................................................................................................................................................... 3 Tone Sequence Generation ...................................................................................................................... 4 Encoding.................................................................................................................................................... 7 Arduino Code .............................................................................................................................................. 12
2
Hardware Here is what you’ll need: 1. 2. 3. 4. 5. 6.
Computer with Arduino Software and USB cable FL Studio Software (Demo version) Arduino Uno PlainDSP Audio Kit “m2m_comm_short.ino” program “Hello World.wav” file
Concept
Amplitude
There are many ways to accomplish this, but in this experiment a change in frequency will indicate a character. Frequency bands, or channels, will need to be allocated to distinguish the different letters.
C1
C2
C3
C4
…
Cn
Frequency For example, a change from frequency channel C1 to channel C2 could indicate a letter “A,” or whatever is choosen. In this experiment, an “ID1 frequency” (CID1) and an “ID2 frequency” (CID2) will be required to know when the character is being transmitted. The communication of a character is shown schematically:
C2
CID1
Frequency Start Sequence
CID2
C1
C2
Frequency
CID1
CID2
C1
C2
CID1
CID2
C1
Time T5 C2
Frequency
Frequency Data
Amplitude
C1
Time T4
Amplitude
CID2
Time T3
Amplitude
CID1
Time T2
Amplitude
Amplitude
Time T1
CID1
CID2
C1
C2
Frequency Stop
3
Channels, Tone Sequence Generation, and Encoding This section discusses the experimentation, and how to verify calculations
Channels The number of channels required for a total number of ASCII characters can now be calculated. The equation for this protocol is the following: 𝑇𝑜𝑡𝑎𝑙 𝑐ℎ𝑎𝑟𝑎𝑐𝑡𝑒𝑟𝑠 = (𝑁 − 2) ∗ (𝑁 − 3) where 𝑁 is the number of total channels needed. Two channels are reserved for the packet identification, which is how the (𝑁 − 2) term for the number of usable data channels comes to be. For each usable data channel, the two ID frequencies are reserved, and the two received data frequencies cannot be the same. This is where the (𝑁 − 3) term comes from. ASCII has a total of 256 characters, so that means a total of 256 = (𝑁 − 2) ∗ (𝑁 − 3) = 𝑁 2 − 5𝑁 + 6 → 𝑁 =
5 ± √(−5)2 − 4(1)(6) ≅ 19 𝑐ℎ𝑎𝑛𝑛𝑒𝑙𝑠 2(1)
are needed. In other words, 19 different frequency channels are needed to encode all 256 ASCII characters. This might be too much for our limited bandwidth, so instead 17 will be chosen, giving: 𝑇𝑜𝑡𝑎𝑙 𝐶ℎ𝑎𝑟𝑎𝑐𝑡𝑒𝑟𝑠 = (17 − 2) ∗ (17 − 3) = 210 𝑐ℎ𝑎𝑟𝑎𝑐𝑡𝑒𝑟𝑠 This will cover the majority of useful characters, but may be limiting for other applications. The following table shows how the frequencies, musical notes, and channels are related for this protocol, with measured data to show the used spectrum: Description Channel No. Best Note Estimate (Hz) Musical Note id 1 bit 1 587 D5 chan 2 2 932 A#5 chan 3 3 1245 D#6 chan 4 4 1568 G6 chan 5 5 1865 A#6 id 2 bit 6 2218 C#7 chan 7 7 2637 E7 chan 8 8 2960 F#7 chan 9 9 3322 G#7 chan 10 10 3729 A#7 chan 11 11 4186 C8 chan 12 12 4699 D8 chan 13 13 5274 E8 chan 14 14 5920 F#8 chan 15 15 6272 G8 chan 16 16 6645 G#8 chan 17 17 7040 A8
4
Tone Sequence Generation A difficult part of this is to use a tone sequence generator to transmit the message. In this experiment, FL Studio 11, a musical program, was used:
http://www.image-line.com/flstudio/
The demo version is used here, which cannot load saved files. It can, however, create and save FL studio files, and export the files to wav format. Here are some steps to begin with FL Studio 11: 1. Open FL Studio, and delete all of the current pattern instruments.
2. In the instruments panel on the left browse to Plugin presets > Generators > 3x Osc > Default, then click and drag that instrument to the pattern window
5
3. Now, Browse to View > Channel Settings, then click on the “PLUGIN” tab in the channel settings window. There are 3 oscillators shown with knobs. Turn the “VOL” setting fully CCW to leave only oscillator 1 working. This allows for a nice clean sine wave sound.
4. Click on View > Piano Roll
6
5. Make your first data packet! Send the letter “H” to the PlainDSP. Click on D5 then C#7 for our IDs, then F#7 and G6 to designate H (since these correspond to the channels 8 and 4, respectively), then finally click on C#7 again to end the packet. Your audio message should look like the following below:
6. Make sure the PlainDSP is plugged in, the m2m_comm.ino Arduino code provided is running, the serial port is opened, and make sure the speakers are turned up. Press the triangular “Play” button and notice the H is displayed!
7
Encoding Now that we have the audio channels in place, we can assign codes to the characters. This is a cumbersome process, but necessary. There are two data bits, so each two-pair code corresponds to a specific ASCII character. The number in each data field correspond to the channel detected by the PlainDSP. So, Having Data1=2 and Data2=3 means channel 2 (932 Hz) was detected first, and channel 3 (1245 Hz) was detected second. Data 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4
Data 2 3 4 5 7 8 9 10 11 12 13 14 15 16 17 2 4 5 7 8 9 10 11 12 13 14 15 16 17 2 3 5 7 8 9
ASCII Symbol NULL SOH STX ETX EOT ENQ ACK BEL BS HT LF VT FF CR SO SI DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US !
In Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
Description (Null character) (Start of Header) (Start of Text) (End of Text) (End of Transmission) (Enquiry) (Acknowledgement) (Bell) (Backspace) (Horizontal Tab) (Line feed) (Vertical Tab) (Form feed) (Carriage return) (Shift Out) (Shift In) (Data link escape) (Device control 1) (Device control 2) (Device control 3) (Device control 4) (Negative acknowledgement) (Synchronous idle) (End of transmission block) (Cancel) (End of medium) (Substitute) (Escape) (File separator) (Group separator) (Record separator) (Unit separator) (Space) (Exclamation mark)
8
4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 7 7 7 7 7 7 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8
10 11 12 13 14 15 16 17 2 3 4 7 8 9 10 11 12 13 14 15 16 17 2 3 4 5 8 9 10 11 12 13 14 15 16 17 2 3 4 5 7 9 10
" # $ % & ' ( ) * + , . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
(Quotation mark ; quotes) (Number sign) (Dollar sign) (Percent sign) (Ampersand) (Apostrophe) (round brackets or parentheses) (round brackets or parentheses) (Asterisk) (Plus sign) (Comma) (Hyphen) (Dot , full stop) (Slash) (number zero) (number one) (number two) (number three) (number four) (number five) (number six) (number seven) (number eight) (number nine) (Colon) (Semicolon) (Less-than sign) (Equals sign) (Greater-than sign ; Inequality) (Question mark) (At sign) (Capital A) (Capital B) (Capital C) (Capital D) (Capital E) (Capital F) (Capital G) (Capital H) (Capital I) (Capital J) (Capital K) (Capital L)
9
8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 10 10 10 10 11 11 11 11 11 11 11 11
11 12 13 14 15 16 17 2 3 4 5 7 8 10 11 12 13 14 15 16 17 2 3 4 5 7 8 9 11 12 13 14 15 16 17 2 3 4 5 7 8 9 10
M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
(Capital M) (Capital N) (Capital O) (Capital P) (Capital Q) (Capital R) (Capital S) (Capital T) (Capital U) (Capital V) (Capital W) (Capital X) (Capital Y) (Capital Z) (square brackets or box brackets) (Backslash) (square brackets or box brackets) (Caret or circumflex accent) (underscore , understrike , underbar or low line) (Grave accent) (Lowercase a ) (Lowercase b ) (Lowercase c ) (Lowercase d ) (Lowercase e ) (Lowercase f ) (Lowercase g ) (Lowercase h ) (Lowercase i ) (Lowercase j ) (Lowercase k ) (Lowercase l ) (Lowercase m ) (Lowercase n ) (Lowercase o ) (Lowercase p ) (Lowercase q ) (Lowercase r ) (Lowercase s ) (Lowercase t ) (Lowercase u ) (Lowercase v ) (Lowercase w )
10
11 11 11 11 11 11 12 12 12 12 12 12 12 12 12 12 12 12 12 12 13 13 13 13 13 13 13 13 13 13 13 13 13 13 14 14 14 14 14 14 14 14 14
12 13 14 15 16 17 2 3 4 5 7 8 9 10 11 13 14 15 16 17 2 3 4 5 7 8 9 10 11 12 14 15 16 17 2 3 4 5 7 8 9 10 11
x y z { | } ~ DEL Ç ü é â ä à å ç ê ë è ï î ì Ä Å É æ Æ ô ö ò û ù ÿ Ö Ü ø £ Ø × ƒ á í ó
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
(Lowercase x ) (Lowercase y ) (Lowercase z ) (curly brackets or braces) (vertical-bar, vbar, vertical line or vertical slash) (curly brackets or braces) (Tilde ; swung dash) (Delete) (Majuscule C-cedilla) (letter "u" with umlaut or diaeresis ; "u-umlaut") (letter "e" with acute accent or "e-acute") (letter "a" with circumflex accent or "a-circumflex") (letter "a" with umlaut or diaeresis ; "a-umlaut") (letter "a" with grave accent) (letter "a" with a ring) (Minuscule c-cedilla) (letter "e" with circumflex accent or "e-circumflex") (letter "e" with umlaut or diaeresis ; "e-umlaut") (letter "e" with grave accent) (letter "i" with umlaut or diaeresis ; "i-umlaut") (letter "i" with circumflex accent or "i-circumflex") (letter "i" with grave accent) (letter "A" with umlaut or diaeresis ; "A-umlaut") (Capital letter "A" with a ring) (Capital letter "E" with acute accent or "E-acute") (Latin diphthong "ae" in lowercase) (Latin diphthong "AE" in uppercase) (letter "o" with circumflex accent or "o-circumflex") (letter "o" with umlaut or diaeresis ; "o-umlaut") (letter "o" with grave accent) (letter "u" with circumflex accent or "u-circumflex") (letter "u" with grave accent) (Lowercase letter "y" with diaeresis) (letter "O" with umlaut or diaeresis ; "O-umlaut") (letter "U" with umlaut or diaeresis ; "U-umlaut") (slashed zero or empty set) (Pound sign ; symbol for the pound sterling) (slashed zero or empty set) (multiplication sign) (function sign ; f with hook sign ; florin sign ) (letter "a" with acute accent or "a-acute") (letter "i" with acute accent or "i-acute") (letter "o" with acute accent or "o-acute")
11
14 14 14 14 14 15 15 15 15 15 15 15 15 15 15 15 15 15 15 16 16 16 16 16 16 16 16 16 16 16 16 16 16 17 17 17 17 17 17 17 17 17 17
12 13 15 16 17 2 3 4 5 7 8 9 10 11 12 13 14 16 17 2 3 4 5 7 8 9 10 11 12 13 14 15 17 2 3 4 5 7 8 9 10 11 12
ú ñ Ñ ª º ¿ ® ¬ ½ ¼ ¡ « » ░ ▒ ▓ │ ┤ Á Â À © ╣ ║ ╗ ╝ ¢ ¥ ┐ └ ┴ ┬ ├ ─ ┼ ã Ã ╚ ╔ ╩ ╦ ╠ ═
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
(letter "u" with acute accent or "u-acute") (letter "n" with tilde ; enye) (letter "N" with tilde ; enye) (feminine ordinal indicator) (masculine ordinal indicator) (Inverted question marks) (Registered trademark symbol) (Logical negation symbol) (One half) (Quarter or one fourth) (Inverted exclamation marks) (Angle quotes or guillemets) (Guillemets or angle quotes)
(Box drawing character) (Box drawing character) (Capital letter "A" with acute accent or "A-acute") (letter "A" with circumflex accent or "A-circumflex") (letter "A" with grave accent) (Copyright symbol) (Box drawing character) (Box drawing character) (Box drawing character) (Box drawing character) (Cent symbol) (YEN and YUAN sign) (Box drawing character) (Box drawing character) (Box drawing character) (Box drawing character) (Box drawing character) (Box drawing character) (Box drawing character) (Lowercase letter "a" with tilde or "a-tilde") (Capital letter "A" with tilde or "A-tilde") (Box drawing character) (Box drawing character) (Box drawing character) (Box drawing character) (Box drawing character) (Box drawing character)
12
17 17 17 17
13 14 15 16
╬ ¤ ð Ð
206 207 208 209
(Box drawing character) (generic currency sign) (Lowercase letter "eth") (Capital letter "Eth")
Arduino Code Please see the following link for the Arduino code:
m2m_comm_short.zip Arduino Code