Receiving and Cross-checking Morse code

saurabhp:
i cant process/cross check the received morse...

help me here....what i was thinking of doing was, after receiving the morse, i will save those received letters in an array. then i just have to compare one array with the pre-programmed array.

That's why I gave the hint to Google "c++ strcmp()" earlier. (Did you do it?) It compares two char arrays.

saurabhp:
can you give me a idea how to do that...?

Well, then I have to ask you, "modeling" in what form? Code? Pseudocode? MatLab? We're confused because you said you weren't programming.

aarg:
Well, then I have to ask you, "modeling" in what form? Code? Pseudocode? MatLab? We're confused because you said you weren't programming.

by modelling i mean 3D model in cad software like solid works, auto cad etc...i make a model in cad, and then make a prototype using that model i made in cad...

OldSteve:
That's why I gave the hint to Google "c++ strcmp()" earlier. (Did you do it?) It compares two char arrays.

ok...

so that function will also check the sequence of the letters...
so i have to give the output of the receiving code i.e. the morse letters to the function and it will compare...!!

i get it now....
but can that function be directly used in arduino sketch..?
i will give it a try...

saurabhp:
but can that function be directly used in arduino sketch..?

Yes. Arduino code is C++

OldSteve:
Yes. Arduino code is C++

Thanks i will try to incorporate that into my sketch...

if i face problems doing that i will ask for you again...
thank you...

saurabhp:
Thanks i will try to incorporate that into my sketch...

if i face problems doing that i will ask for you again...
thank you...

Don't ask for me specifically. Just describe the problem, post your code and ask for help. Someone will hopefully try to help, but not necessarily me.
(And no more private messages please. See my signature below.)

It really grates on my nerves to see the tokens described as "dots" and "dashes". :astonished:

Paul__B:
It really grates on my nerves to see the tokens described as "dots" and "dashes". :astonished:

Yeah, me too. Should be "dits" and Dahs"!

Paul

Paul_KD7HB:
Yeah, me too. Should be "dits" and Dahs"!
Paul

Dits and dahs are used more in the US. That's not universal worldwide though. Better known as dots and dashes here in Australia, and possibly England as well. Both are valid and accepted. It really just depends on where you live, like colour vs color etc etc

standardized sequences of short and long signals called "dots" and "dashes",[1] or "dits" and "dahs", as in amateur radio practice.

Morse code

Edit: I'll have to correct myself here. I thought dits and dahs were more a US thing, but further reading found the real difference.
They're called dots and dashes when written, but vocalised "dit" and "dah" since adaptation to radio communications.

When Morse code was adapted to radio communication, the dots and dashes were sent as short and long pulses. It was later found that people become more proficient at receiving Morse code when it is taught as a language that is heard, instead of one read from a page.[4]

To reflect the sounds of Morse code receivers, the operators began to vocalize a dot as "dit", and a dash as "dah". Dots which are not the final element of a character became vocalized as "di". For example, the letter "c" was then vocalized as "dah-di-dah-dit".[5][6]

So when writing, "dots" and "dashes" are perfectly acceptable as I see it.

If your code is machine sent, you might first write a program to get a histogram of intervals. I'd tally up the silent intervals and the light-active intervals for ten minutes or so. From that, you have a way to determine what's a dot, what's a dash, what's the interval between dots and dashes, between characters, and between words. That's a little statistical exercise, but I think any decent engineer needs to deal intelligently with statistics.

If this comes from a machine, you'll probably have clearly defined intervals. If the code is human generated, then the dots, dashes, gaps, etc. won't be so clean. But if you have a limited word set you need to deal with, you then have some extra information to deal with. Even then, at that point you're tackling a fairly difficult statistical estimation problem, for which there are numerous potential techniques. There are hundreds of books devoted to information recovery from imperfect data. You might look up something on Kalman filtering, or maybe least squares techniques. Picking up new knowledge like this is all part of the game for engineers.

OldSteve:
Don't ask for me specifically. Just describe the problem, post your code and ask for help. Someone will hopefully try to help, but not necessarily me.
(And no more private messages please. See my signature below.)

Thank you so much for helping me with that...i was able to read about concatenation and use compare together to complete and verify the received morse..
Thanks to everyone for help.

I have a small problem i need help with..
i have programmed 4 pro micro boards with this code

#define THRESHOLD    (600)
#define MAX_SAMPLES  (5)

#define BAUD         (100.0)
#define WAIT         (5.0)
#define AVG_LONG     (BAUD*3.0/WAIT)
#define AVG_SHORT    (BAUD*1.0/WAIT)
#define AVG_NEWWORD  (BAUD*7.0/WAIT)
#define MINIMUM      (AVG_SHORT/4.0)

#define MAX_PATTERN  (64)

#define NUM_CODES    (54)

char key[100] = "XARDUINOTRANSMITANDRECEIVE";
char Catination[100] ;
int count = 26;
int k=0; 
int dummy;

//                            0        10        20        30        40        50
//                            0123456789012345678901234567890123456789012345678901234
static const char *letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,?'!/()&:;=+-_\"$@";

// 1 represents a dot and 0 represents a dash.

static const char *codes[NUM_CODES] = {
  "10",      // A, codes[0]
  "0111",    // B, codes[1]
  "0101",    // C
  "011",     // D
  "1",       // E
  "1101",    // F
  "001",     // G
  "1111",    // H
  "11",      // I
  "1000",    // J
  "010",     // K
  "1011",    // L
  "00",      // M
  "01",      // N
  "000",     // O
  "1001",    // P
  "0010",    // Q
  "101",     // R
  "111",     // S
  "0",       // T
  "110",     // U
  "1110",    // V
  "100",     // w
  "0110",    // x
  "0100",    // y
  "0011",    // z
  "00000",   // 0
  "10000",   // 1
  "11000",   // 2
  "11100",   // 3
  "11110",   // 4
  "11111",   // 5
  "01111",   // 6
  "00111",   // 7
  "00011",   // 8
  "00001",   // 9
  "101010",  // .
  "001100",  // ,
  "110011",  // ?
  "100001",  // '
  "010100",  // !
  "01101",   // /
  "01001",   // (
  "010010",  // )
  "10111",   // &
  "000111",  // :
  "010101",  // ;
  "01110",   // =
  "10101",   // +
  "01110",   // -
  "110010",  // _
  "101101",  // "
  "1110110", // $
  "100101",  // @, codes[54]
};


int top=0;

int samples[MAX_SAMPLES];
int si=0;
int mi=0;
int total=0;

int c=0;
int is_on=0;


char pattern[MAX_PATTERN];
int pi=0;


void setup() {
  Serial.begin(9600);

  pinMode(13,OUTPUT);
  for(int i=0;i<MAX_SAMPLES;++i) {
    samples[i]=0;
  }
  for(int i=0;i<MAX_PATTERN;++i) {
    pattern[i]=0;
  }
}


void loop() {
  int volume=analogRead(0);
  
  total -= samples[si];
  samples[si] = volume;
  total += samples[si];
  if( mi < MAX_SAMPLES ) mi++;
  si = (si+1) % MAX_SAMPLES;
  int average = total / mi;
  
  if( top < average ) top = average;
  
  
  int x = 10.0 * (float)(average-THRESHOLD)/(float)(top-THRESHOLD);
  if(x<0) x=0;
  if(x>10) x=10;
  
  if(x>1) {
    // noise!
    if(is_on==0) {
      // noise has just started.
      if( c > MINIMUM ) {
        
        // Was the silence a new word or a new letter?
        if( c > (AVG_NEWWORD+AVG_SHORT)/2.0 ) {
          pattern[pi]=0;
          findLetter();
          // new word, extra \n
          Serial.println();
          // start counting - and . all over again.
          pi=0;
        } else if( c > (AVG_LONG+AVG_SHORT)/2.0 ) {
          pattern[pi]=0;
          findLetter();
          // start counting - and . all over again.
          pi=0;
        }

      }
      // remember noise started
      is_on=1;
      c=0;
    }
  } else {
    // silence!
    if(is_on==1) {
      // silence is new
      if( c > MINIMUM ) {
        
        if( c > (AVG_LONG + AVG_SHORT)/2.0 ) {
          Serial.print('-');
          pattern[pi++]='0';
        } else {
          Serial.print('.');
          pattern[pi++]='1';
        }
      }
      // remember silence started
      is_on=0;
      c=0;
    }
  }

  c++;
  
  delay(WAIT);
}



// saved as 1s and 0s.  Find the matching code in the list
// then find the matching printable character.
// print '?' if nothing is found
void findLetter() 
{
  int i,j;
  
  // go through all the codes  
  for(i=0;i<NUM_CODES;i++) 
  {
    
    if(strlen(pattern) == strlen(codes[i]) && strcmp(pattern,codes[i])==0) 
    {
      // match!
      Serial.print(' ');
      Serial.println(letters[i]);
      
     if(strcmp(pattern,codes[23])==0)
      {
        dummy = 1;
      }
        if(dummy==1)
        {
          Catination[k] = letters[i];
          k++ ;
          if (k==count)
           {
             k = 0;
             dummy = 0;
             Serial.print("strings are equal");
             Serial.print(Catination);
             if (strcmp(Catination,key )== 0 )
              {
                digitalWrite(13,HIGH);
                delay(1000);
                digitalWrite(13,LOW);
              }
           }
        }
       return;
      }
     }
    Serial.print('?');
}

and i will be connecting these 4 boards to an arduino uno board at different digital pins(as digital input pins)...

so to power all the boards together i have a 5V 8Amp power supply...
i think that 8Amp is too much for the boards to handle...

can i get help with understanding the amount of current i can supply the boards..?

and what is the internal resistance of one board...using that information i can calculate the resistance i need to connect to reduce the amp supplied..

i know the internal resistance for the uno board...but i cant find any information on the pro micro boards..

i have planned to connect all boards in parallel to keep the voltage constant, but the current is what worries me...
please help

saurabhp:
so to power all the boards together i have a 5V 8Amp power supply...
i think that 8Amp is too much for the boards to handle...
can i get help with understanding the amount of current i can supply the boards..?

This is a misunderstanding on your part. The boards will only draw as much current as they need. As long as the power supply can comfortably provide more current than will be needed by the boards, you're good-to-go. Provided the voltage is correct, even an 80A power supply would be good. :slight_smile:
Just look at our mains power. In my country, it can provide up to 10A at a power point, but you can connect a light bulb or a heater, and each will only draw the current that it needs.

what is the internal resistance of one board...using that information i can calculate the resistance i need to connect to reduce the amp supplied..
i know the internal resistance for the uno board...but i cant find any information on the pro micro boards..
i have planned to connect all boards in parallel to keep the voltage constant, but the current is what worries me...
please help

You have nothing to worry about, as mentioned.

OldSteve:
You have nothing to worry about, as mentioned.

so it doesnot matter if i connect them in parallel to the 8amp supply...they will take only the required current....and will not burn out because of excess current...

the voltage is going to be constant as they will be connected parallel across the 5V supply..

so the only thing i need to worry about is the output that i take from the I/O pins...it should not exceed 40mA..(recommended).

or i dont need to worry about that either..?

so it doesnot matter if i connect them in parallel to the 8amp supply

Correct

it should not exceed 40mA..(recommended).

A current of 40mA is the point where damage starts to be done so consider 20 to 30mA as the maximum to use.

Grumpy_Mike:
Correct
A current of 40mA is the point where damage starts to be done so consider 20 to 30mA as the maximum to use.

can you help me with something..

i will be connecting the following to my arduino

  1. 1 photodiode
  2. 1 470 kOHM variable resister

but my arduino is connected to 5V 8amp power supply.
do you think that the arduino will draw more than 20mA..?

saurabhp:
do you think that the arduino will draw more than 20mA..?

Yes, probably about 50 mA.

  1. 1 photodiode

The technical expression for this is "it draws bugger all"

  1. 1 470 kOHM variable resister

More correctly expressed as 470K, where is this? Is it feeding the analogue input? If so it is a bit large for that especially if you are switching the analogue channel you read. You should be using a 10K pot.

In terms of current this will be 5 / 470 103 = 10uA which is more current than 1), this amount of current is called "sod all" current.

but my arduino is connected to 5V 8amp power supply.

The current capability of a power supply has no effect on the current drawn by the Arduino unless your supply is not capable of supplying the current. Which as Paul says is going to be in the region of 50mA, that is 0.05 Amp.

Grumpy_Mike:
The current capability of a power supply has no effect on the current drawn by the Arduino unless your supply is not capable of supplying the current. Which as Paul says is going to be in the region of 50mA, that is 0.05 Amp.

but if it draws more than 20mA the arduino can get damaged...!

and my analogue pin is only in input mode and the resister works fine with the code.

i am more worried about the arduino being burnt..

but if it draws more than 20mA the arduino can get damaged...!

No.

If an Arduino pin is connected to a load that is greater than 40mA then the pin can get damaged. There is absolutely nothing in that list that is connected to an output. Arduino inputs take bugger all current, you can't make an input take anything significant in terms of current.

i am more worried about the arduino being burnt..

More worried than what?
The current drawn by a pot is not coming from the Arduino's processor. The pot is too high, if you think it is fine then you have not tested it correctly. Do not mistake functionality for correct design.