The project “Morse Code CODEC” is composed of two major parts, encoder and decoder. The encoder takes input from Hyperterm and translates this input into morse code, to be output as sound. This audio output will be driven through a standard speaker. The decoder takes the audio output produced by the encoder and translates or decodes the morse code message back to its original form and displays the message back to hyperterm. The decoder uses a uni-directional microphone as the input mechanism for the morse code that it is to translate. Through a analog to digital conversion, it is able to translate the message.
We planned to create an encoder and decoder functions, which operate independently from each other. This idea came around as we thought and discussed about information transfer and how over times, compression, codecs, and signal speed has changed, and we though about one of the most basic, yet still used codec: Morse code. The encoder takes normal alphabet inputs from hyperterm, and creates a string consisting of 0, 1, 2, and 3 to encode the alphabet. This is because the Morse code consists of four different types of outputs. The “dit” (short signal 1 in our code), the “dah” (long signal, 3 times the length of the dit, 2 in our code), letter space (same length as the dit, to distinguish the end of a letter, 0 in our code), and word space (7 times the length of the dit, used to distinguish ends of words, 3 in our code). From this string that we made, we control the length of the signal set to be about 720Hz. Outputting a signal at 720Hz on the Mega32 was easy: it was something we did for a different lab. However, the hard part was the decoder, which on the other hand, takes samples of sound signals through a microphone, filters and digitizes the signal with a threshold value, and depending on the lengths of the signals, creates a string consisting, of again, 0,1,2, and 3, which is decoded into the alphabet to be displayed on hyperterm. To parse the microphone signal, we needed to use a buttersworth filter to be implemented within the MCU. This incurred some trade off, as a very accurate calculation lagged our output, as it lagged the whole MCU, which we used matlab’s butter function to calculate the coefficients for. We have made it so that the amount that the MCU can decode at a time is very limited (couple of words). In the end, we were able to have everything run concurrently and smoothly, with ISR’s implemented with different timers. The decoder, as will be explained later, ran in multiple steps, required the system to calculate much faster than the system sampling what the microphone picked up, but this also ran well since we restricted the sampling rate.
Block Diagram follows:
Encoder
Morse code is a method of transmitting letters, numbers, and symbols using a series of pulses, dots(“dit”) and dashes(“dah”). A dah is equal to three dits in terms of pulse length. The space between two symbols is equal to one dit of silence and the space between words is equal to seven dits of silence. The length of the pulses and the silence are all relative to the length of the dit. For this particular project, the length of the dit is set to 0.5 seconds. Below is a table of the morse code representation of letters and numbers. Circles represent the dits and rectangles represent the dahs.
The encoder takes an input from hyperterm, such as “hello world”, and interprets the string by assigning each symbol and blank space its proper morse code representation. The information is then stored into another array, which consist of only 0,1,2, and 3.
0 letter space
1 dit
2 dah
3 word space
After this translation, this array of digits 0-4 is processed to produce the appropriate length of pulses to represent the original string that was input to hyperterm. The audio output uses the Direct Digital Synthesis technique generating sine wave bursts. Timer0 fast PWN mode is used and we are able to set the length of the pulses accordingly. We used a simple RC circuit to low filter the analog signal and the output of the lowpass filter will go the audio input of a speaker device. Below is the schematics of the filter.
The way which the audio output is driven is based on Lab 2, which is the DTMF dialer. It is basically the same concept. The way that the string input is taken from Hyperterm is based on Lab 3, which the security system. Whenever, “enter” is pressed in Hyperterm, the string preceding it gets stored into an array r_buffer.
We tried making the length of the dit pulse shorter so that the length of everything else would become shorter. However, this would mean a higher sampling rate, which would lead to the need for more memory to store these samples. When trying this, it was realized that making the pulses shorter would lead to the program running out of memory. Hence, this idea was abandoned and we kept to the 0.5 second length for the dit.
Decoder
The decoder was a bit more tricky, since this involved taking in the signal and converting it into a form that could be later converted and process to Morse code. We decided to take 200 samples at a time, place them in an array, filter them with a buttersworth filter, digitize the result with a threshold, and parse into the pseudo Morse code convention that we used for encoding.
For example, a second degree buttersworth filter for lower bound 700, upper bound 740, sample rate of 4kHz would produce a filter response like this:
We wrote our function, so the item in index n of the array is updated with values from indices n, n+1, n+2, n+3, and n+4. Since the value in index n+1 depends on values in index n+1, n+2, n+3, n+4, and n+5, making it causal. Once we filter the whole array, we sum all the values in indices 0 to 190 (since the values in the last few indices will not be filtered), and place them in a different array. This new array will then consist of the sum of filtered values from 200 samples, and so the values will be high if the signal is there, and low if the signal is not present. We then digitize the array by making the content equal to 1 if the value is above a threshold (high value), and 0 if the value is below a threshold (low value). This gives us an array consisting of 1’s and 0’s, where there is a 1 at the presence of a signal.
We have then made a parsing code, where if this digitized string has a 0, the last few values are reviewed. By inspecting the sum of the values of the last few indices, the duration for which the signal was present can be measured (if there are lots of consecutive 1’s in the previous signals, the signal was probably a dah, if it is short, then a dit). Also, we count the number of consecutive 0’s, and if they are substantially long, this will constitute as either a letter or word space. We then use the reverse of the encoding algorithm to decode the pseudo Morse code (with out conventional 0, 1, 2, and 3) to convert into alphabet to be shown on Hyperterm.
We parse and filter on the same array since the memory was way too limited to use separate arrays for this purpose. Also, the filter was making with 2 digit integer approximations to make the calculation faster (we divided by 100 later to adjust the values), since when we used exact values with floats, the MCU lagged so much that the output wave form did not come out cleanly.
There are two essential aspects to the hard ware. One is the filter for processing the output to pass it through to the speaker. The other is for the microphone. We took a close look at the data sheet for the microphone that we ordered (WM-65A103, a Panasonic Unidirectional Microphone), and saw that the microphone needs a driving voltage. Also, we saw that the output of the microphone was very small. To solve these problems, we have constructed a circuit shown below:
This circuit involves the driving voltage for the microphone, a high pass filter, and an operational amplifier to boost the signal. The microphone is paired with a 2 kΩ resistor, to supply the driving voltage. We also used a high pass filter with a 0.01 μF capacitor and a 30 kΩ and 51 kΩ resistor (totaling to 81 kΩ) to suppress all frequency noises below approximately 200Hz
We chose this value from the given that the outlet AC alternates at 60Hz, and this is the prominent noise source. Then we passed the filtered signal through an LMC7111, to amplify the signal. We played around with the gain value, and found that a gain of approximately 100 (101 to be exact) is useful for our cause. Although the microphone signal is still not as high for external sound, we cannot make the gain too high, since there is a limit with the frequency cut off and gain. The gain, is simply 1+R3/R2, which is 1+(100kΩ/1kΩ) = 101. This enters the ADC converter.
The other circuit is the same as that used in LAB2 with the DTMF dialer, with a low pass filter.
As mentioned earlier when we have floating point operations, the sound outputted by the encoder has lagged, and the wave form became distorted. We have resolved that issue, and the encoder and the decoder ran concurrently without a problem. We have placed a second silence before the sound was outputted, but on purpose so we don’t miss anything as we tested, and changed the volumes. As for the decoding, with a few exceptions, the Morse Code signal has been decoded back to it’s original signal.
The outputted and recorded sound waves are very accurate, as we checked the input and output wave forms on the oscilloscope. Since the device consists of speakers and microphones, the only safety issue that we needed to pay attention to was the output of the speakers, and nothing went wrong with that. The only interference that we could have had was the Morse code playing loudly on the speakers, but to prevent that, we used earphones as means of outputting sounds.
Our encoder/decoder device is very easy to use, and can be used as a tool/method for some people to aurally practice learning Morse code by listening to what they typed, and the other way around too.
Our results for this project represent the general concepts and methods behind morse code. It was generally successful but not completely accurate. Our pulses are a bit longer than typical standard morse code pulses. This is because shorter pulses demand a higher sampling rate, which in term means more memory. One of the problems in our project is the amount of memory available on the Mega32. Hence with longer pulses, we were able to sample at a lower rate and hence store less date. The pitch of the morse code is also not the typical pitch you would hear. We are not much concerned about this because it is not something of great importance in demonstrating the morse code concept. The microphone on the decoder is uni-directional, hence it does not take in speaker output very well. We instead used a uni-directional earpiece to input the morse code into the microphone. But overall, the project was successful and worked.
If we were to take this project one step further, possible improvement might include:
1. adding external memory to all transmission of long strings
2. making pulses shorter
3. change the pitch of the morse code
4. adding a tap button so the user can directly input the morse code to the decoder
5. add human voice to the decoder so each decoded word gets spoken
We did not reuse anyone else code. We used bits and pieces of our low code from previous labs for some of the elements. In general, morse code is not a system that is patented so anyone could use it. We do not think there are any commercial opportunities for this project since morse code is pretty obsolete in today’s society. Better and more accurate ways of communication has developed to replace the old morse code technology.
IEEE Code of Ethics
1. to accept responsibility in making decisions consistent
with the safety, health and welfare of the public, and to disclose promptly
factors
that might endanger the public or the environment;
Our project is 100% safe and does no harm to the
environment.
2. to avoid real or perceived conflicts of interest whenever possible, and to
disclose them to affected parties when they do exist;
There are no conflict of interest issues
3. to be honest and realistic in stating claims or estimates based on available
data;
We were honest about all aspects of the project and did
not over-exaggerate or under-exaggeerate claims.
4. to reject bribery in all its forms;
No bribery involved
5. to improve the understanding of technology, its appropriate application, and
potential consequences;
Our project is intended to explore the morse code
technology.
6. to maintain and improve our technical competence and to undertake
technological tasks for others only if qualified by training or
experience, or after full disclosure of pertinent limitations;
This project was selected for the improvement of
technical competence in morse code.
7. to seek, accept, and offer honest criticism of technical work, to acknowledge
and correct errors, and to credit properly the contributions
of others;
We took all criticisms seriously and sought help
whenever necessary.
8. to treat fairly all persons regardless of such factors as race, religion,
gender, disability, age, or national origin;
We treated everybody fairly under all situations.
9. to avoid injuring others, their property, reputation, or employment by false
or malicious action;
We did not hurt anyone in anyway.
10. to assist colleagues and co-workers in their professional development and to
support them in following this code of ethics.
We helped other whenever necessary
This entire project abided by the IEEE code of ethics. We created something that cannot harm or destroy other devices or the environment any way. We were honest in pointing out flaws and shortcoming of our project and did not fabricate any of the data. There was no bribery involved. The purpose of the project was for a better understanding of the morse code technology. We accepted comments and criticisms and tried to improve upon what we have already one. We treated every person involved fairly and gave proper credit to all individuals involved. When needed, we sought advice and help from teaching assistants, instructors, and fellow classmates. Overall, this project has not potential to inflict injuries or any type of harm to anyone. The only conceivable way of causing harm to others is to misuse the power supply in a harmful way. The electrical circuits in this project are very standard and will not misperform under normal conditions. Overall, this project does exactly what it intends to do, which is promote the understanding of the morse code technology without causing adverse effects on others
Commented Program Listing
Parts List and Costs
Parts |
Quantity |
Cost/part |
Total Cost |
MEGA32 |
1 |
$8 |
$8 |
STK500 |
1 |
$15 |
$15 |
P9964-ND(MIC) |
1 |
$2.08 |
$2.08 |
White board |
1 |
$6 |
$6 |
Total |
$31.08 |
Tasks
Task |
Steven |
Yoshio |
Encoder |
X |
X |
Decoder |
X |
X |
Amplifier |
|
X |
Report |
X |
X |
References
Data Sheets
Vendor Sites
Referenced Code
ECE 476 Spring '06 Lab 2
ECE 476 Spring '06 Lab 3
Picture of Breadboard
Picture of entire system
Oscilloscope Output of Encoder
Top: Oscilloscope Output of Encoder
Botton: Microphone Input