I wrote a decoder (not for Arduino though) that used, in effect, a linked list of character values and it works really well but I think the method Grumpy_Mike has described is easier to understand for someone who's just starting to program. The way that you have the sender and receiver hooked together means you don't have to worry too much about noise on the incoming signal. I wouldn't use a separate function to send each letter, but it's your project and you have to do something yourself.ĭecoding is whole different problem, but if you get the transmission timing right and set up the decoder properly you can increase or decrease the transmission speed and still have the decoder figure it out. So, your code should be more like this: #define DIT_LENGTH 100įYI the way to convert a morse code speed in words per minute (WPM) into the length of a dit in milliseconds is simply: Between letters there's another space that is 3 dits long and the word space is 7 dits long. From that, a dah is 3*dit and the silence between them is also one dit long. The unit of time for morse code is based on the length of the "dit". The timing of your morse code transmission isn't very good. T->pCallSign = pC //start of next segment of callsign *pM = '\0' //terminating null for Morse Buffer *pM = delay //overwrite with delay at end of callsign PC //advance to next letter to be translated *-pM = '\3' //overwrite with an inter-letter pause *pM = '\1' //store duration of inter-element pause *pM = MC //store duration of this Morse element For each Morse element (dot or dash) of the character Get pointer to next character's Morse sequence string/ While the next call sign character is not a semicolon T->Key = FALSE //set morse key to the off state If((int delay = (int)*pC ) Key = TRUE //set morse key to the on stateĭelay = -delay //reverse its sign (make it positive)} T->Repeat = (int)*pC //Nº of times it is to be repeated T->Pitch = (int)*pC //audio frequency of keying tone Use the arrow up and down to type letters (think old-school arcade game record) use left and right to move cursor back and forward. This program allows you to type in letters, numbers, and symbols. PC = t->CallSign //reset ptr to start of callsign data Now you can type in a sentence on arduino using the Phi-1 shield's keypad and play it in Morse code. If(*pC = '\0') //if we've reached end of callsign data *pM = t->pMorse //ptr to start of stn's Morse string *pC = t->pCallSign, //ptr to start of next callsign segment *pMC, //ptr to Morse element in MorseCode The code for each letter is expressed as timer Array letters of the Morse Code alphabet where t = ptr to Tx Data structure of stn currently being keyed The following function gets the next callsign segment from CallSign and sets it up as a string of Morse Code timer durations in Morse: Ok but I needed Morse Code transmitter for my flight simulator it takes input from a database and it chucks it out.
0 Comments
Leave a Reply. |