Problem interface between ISD1820 Voice Recorder/Arduino Uno

My sketch is running two functions simultaneously when they should be consecutive. I don’t seem to be getting an End of Message signal back from the voice recorder. But the program should do nothing until it does.

What I am trying to do is
1 Push Button
1a. Send signal to start voice recorder
2.Have voice recorder say its speech
2a. Do nothing until get EOM.
2b. Receive End Of Message signal
3. Wait Random time
4. Play tone
5. Operate a relay.

Components
Arduino Uno
Relay module ( no ID number on it)
Nuvoton ISD 1800 Series
Single Chip, Single message, voice record/playback device. (1820PY)

I have a number of issues may or may not be related.

  1. Can receive the EOM signal when I just test the voice recorder, but not receiving it when I hook the components together.

2.Two subroutines operate simultaneously when they should be consecutive.
The voice recorder starts its talk but also the tone sounds at the same time. The tone should not start until the recorder has sent an EOM signal back to the arduino, and waited a random time.

The programming faults I feel I have are.

  1. Receiving the EOM signal in the proper manner ie analog signal on analog pin?
    and conditioning the signal to be used by the arduino. If I expect a low signal from recorder, how is the arduino dealing with this? Incorrect programming statements?

  2. The "While " function may not be used in the correct manner.

  3. Am I mixing analog and digital signals and expecting it to work?

  4. Am I incorrectly programming the “test for a low signal”?

  5. My conversion from analog to digital is faulty.

The End Of Message signal is a high to low appearing on the LED output of the voice recorder. The Voice Recorder LED flashes on at the EOM. This can be seen in the video.

Below is the section of the sketch I feel is the problem area. However I will attach the complete sketch as well as a picture of the circuit diagram, a link to a short video showing the simultaneous actions and the data sheets for the ISD1820. (sorry don’t know how to make hyperlink.)

Below this code I shall put the monitored output as I added a number of print lines to try to find where the sketch was failing. I had no luck but I’m hoping a more experienced person on this forum can find my errors.

Thank you in advance for all help received.

Link to Video

Link to Data Sheet

void GetEomSignal (){   //watch for EOM signal from recorder

Serial.println("just testing EOM here");
// read the input on analog pin 1:
 int eomState = analogRead(eomPin);

 Serial.print("eomState is ");
  Serial.println(eomState);
 //  Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltage = eomState * (5.0 / 1023.0);
  //delay (10);
  Serial.print ("voltage b4 is   ");
  Serial.println(voltage);
   while(analogRead(eomPin) ==0);   { 
                   //DO I NEED TO WAIT TO SEE THE LOW SIGNAL? .IS IT TOO QUICK? Make it wait until receive Low signal, Shouldnt it wait here til it gets the LOw signal. Need LOW to return for next routine. But it will break out  before the low signal because already it is false. But other command !=0 wont work. What about ==1? but it is analog. That didnt work anyway.

     //digitalWrite(ledPin,LOW); // simulate playlpin here for testing purposes.
     
     Serial.println("waiting for low signal EOM"); }
     Serial.print ("voltage after is   ");
  Serial.println(eomPin);
      
        

  digitalWrite (playlPin, LOW);
  digitalWrite (ledPin, LOW);
  
Serial.println("eom sent. eom sent.eom sent.");
  } 
 // delay (1000); 
 void RandomStart (){

Monitored Output

The result if the line reads " while(analogRead(eomPin) ==1);"

waiting for button press
waiting for button press
waiting for button press
just testing here
00button pushed
playl high
led on
returned from debounce routine
move to subroutine get eom
just testing EOM here
eomState is 1023
voltage b4 is 5.00
waiting for low signal EOM
voltage aft is 15
eom sent. eom sent.eom sent.
random start subroutine getting delay time
The Random Number is = 2255
Back from random delay, now go play beeps
start beeps
finish beeps go back
debounce val1_
0debounce val2_
0waiting for button press
waiting for button press
waiting for button press
waiting for button press

The result if the line reads " while(analogRead(eomPin) ==1);"

waiting for button press
waiting for button press
waiting for button press
just testing here
00button pushed
playl high
led on
returned from debounce routine
move to subroutine get eom
just testing EOM here
eomState is 1023
voltage b4 is 5.00
waiting for low signal EOM
voltage aft is 15
eom sent. eom sent.eom sent.
random start subroutine getting delay time
The Random Number is = 1958
Back from random delay, now go play beeps
start beeps
finish beeps go back
debounce val1_
0debounce val2_
0waiting for button press
waiting for button press
waiting for button press
waiting for button press

The result if the line reads " while(analogRead(eomPin) !=0);"

waiting for button press
waiting for button press
just testing here
00button pushed
playl high
led on
returned from debounce routine
move to subroutine get eom
just testing EOM here
eomState is 1023
voltage b4 is 5.00

Arduino Forum Sketch.txt (6.09 KB)

   while(analogRead(eomPin) ==0);   {
                   //DO I NEED TO WAIT TO SEE THE LOW SIGNAL? .IS IT TOO QUICK? Make it wait until receive Low signal, Shouldnt it wait here til it gets the LOw signal. Need LOW to return for next routine. But it will break out  before the low signal because already it is false. But other command !=0 wont work. What about ==1? but it is analog. That didnt work anyway

It is silly to think that comments must all be on one line.

/* Multi-line comments can look like this */

// Or, multi-line // comments can // look like this.

Why do you think that you need to wait for an analog value to go to 0? Waiting for 1 isn't any smarter.

Hi Paul, I thank you for your reply, That is my whole issue. I'm looking for a voltage of 0.4 or below but I cant see it and I dont know how to code to get it. Do you have any helpful tips on how to do this? Or could you explain why the the "While" function is not working and getting the two functions occurring together? Where am I I going wrong in the coding?

That schematic - the LED is the wrong way round an you do not seem to have connected the Arduino ground to the 0V. That would mean the analogue input would be floating.

Thanks Mike,
I live and learn every day. Good pick up.
Any clue as to why the tones start immediately the button is pushed? Considering they should not go until the other functions have completed.

Considering they should not go until the other functions have completed.

I can't see that in the code.

The code seems convoluted for what it has to do, you need to detect the change in the button not the level. So keep a record of the last time it changed and only trigger action when this time is different from last time.

Thanks Mike, I'm not sure what you mean as to waiting for a change in the button. At the moment , the start of the sketch seems to work as it should. ie. Button gets pressed, it sends a signal to start the voice recording. That works fine. What should happen after that is the sketch should wait and do nothing until it detects the End of Message signal back from the Voice Recorder board. When it gets this, the program moves on to the delayed time then the tones should start. What is happening is the tones start immediately the button is pushed. ( along with the voice recording). So , somewhere the sketch is not waiting, or it is getting a low signal back on the analog pin.( Maybe the floating voltage issue.) But I don't really know enough about the programming to know how to go about getting the right type of signal, then using it to trigger an event.

Yes, very convoluted, I'm just taking bits of code I've found that do a particular job and sticking it in there. Highly likely there is shorter code but I don't know enough to be able to do that yet.

I'm looking for a voltage of 0.4 or below

That corresponds to some reading from the analog pin. What reading is that?

So , somewhere the sketch is not waiting, or it is getting a low signal back on the analog pin.( Maybe the floating voltage issue.) But I don't really know enough about the programming to know how to go about getting the right type of signal, then using it to trigger an event.

You've modified the code (or we are wasting our time) but not posting it. Only you know what your code looks like.

You have WAY too much code for someone that does not know what kind of information to expect.

Create a sketch that does nothing but read and print the value read from the EOM pin, every 100 milliseconds. When you can see a relationship between the values and some observed (or expected) phenomenon, then you can make the Arduino do something other than print to the serial monitor - like turn an LED on when the value goes above the threshold and turn it off when the value goes below the threshold.

You add code one TESTED bit at a time.

The trick in programming is to write little and test often. You should build up a program in very small steps. Break things down into functions an check them.

I'm not sure what you mean as to waiting for a change in the button.

You don't want to do something when the button is pressed, you actually want to do it when it becomes pressed. That is it is pressed now but was not pressed the last time you looked.

This will help with overall planning.

http://forum.arduino.cc/index.php?topic=261445.0

Hi Paul and Mike, Thanks for your input,

Paul,

You've modified the code (or we are wasting our time) but not posting it. Only you know what your code looks like.

Im not sure if you are talking about my full sketch which is attached as Arduino Forum Sketch.txt? And no I have not modified it.

The last thing I wish to do is waste anyones' time. I have tried to supply as much info as possible from day one.

I do like your and Mikes comments in regards to creating short WORKING "functions" then move on to next part. Yes, The parts that work correctly and individually are the "Button Push", the "Start voice Speech" , the "RAndom Delay ( number generator)" and the "Play Tones"

Button is pushed, speech starts, this is how it should work and it does. The part where I am receiving the End of Message isn't working OR the WHILE statement isn't working. As I am getting the tones playing as the speech starts when the tones should ONLY play AFTER the End of Message signal is received.

Paul, I had tested getting the EOM back as a stand alone test. And it appeared to be working. ( I posted a monitor snapshot in original post.

just testing EOM here eomState is 1023 voltage b4 is 5.00 waiting for low signal EOM voltage aft is 15 eom sent. eom sent.eom sent

But it didn't work properly when it was hooked with everything else.

When I first read up on this, I thought my calculations were correct in the way I used an analog signal to trigger an event. If 1023 = 5v then 15 is =.04v definitely a "low"

But the "While" statement isnt working in that the sketch should wait until the message has finished before it sends the EOM.

Is my mathematics flawed? And my WHILE statement used incorrectly?

Thank you Mike and Paul for your continued input.

Wow, you've had this problem for a long time, @RustyDemon9. I thought I'd seen it before. You started a thread on this very subject back in April:- Voice recorder with Arduino , probs with End of Message signal, subroutines.

Yes, Mike,

And still looking for answers. Im having a go at rewriting that section of the sketch around the return of the EOM signal. To see if it changes anything. But still don't know why the two functions operate at the same time when they should be consecutive. Ie the WHILE statement is being ignored. Or its getting the low signal at first cycle of the program causing the program to move on before the speech is finished.

Print out the while variable and see if the values are correct. The only thing that makes a while not appeared to work is the value it is testing.

RustyDemon9:
Yes, Mike,

And still looking for answers.
Im having a go at rewriting that section of the sketch around the return of the EOM signal. To see if it changes anything. But still don’t know why the two functions operate at the same time when they should be consecutive. Ie the WHILE statement is being ignored. Or its getting the low signal at first cycle of the program causing the program to move on before the speech is finished.

I just replied once, but deleted my post because I was on the wrong track. :blush:
I’ll try again.

One thing wrong is that you end the ‘while’ statement with a semicolon before the curly bracket, so this line will only execute after EOM goes high:-

Serial.println("waiting for low signal EOM");

Also using == 0 in an analogue read is problematic because of potential noise issues. I recommend something like < 10, or use that pin as a digital input.

Grumpy_Mike:
Also using == 0 in an analogue read is problematic because of potential noise issues. I recommend something like < 10, or use that pin as a digital input.

That’s exactly what I suggested in the previous post that I deleted. (I realised I was on the wrong track, so stopped to read through the datasheet.)

It’s actually a digital output that’s being monitored for the EOM, the “Record LED” output, assuming that he’s doing it properly:-

Record LED output: The RECLED output is LOW during a record cycle. It can be used to drive an LED to provide feedback that a record cycle is in progress. In addition, RECLED pulses LOW momentarily when and End-of-Message (EOM) or end-of-memory marker is encountered in a playback cycle.

So it appears that this pin is high during playback, going low briefly when the EOM marker is encountered.

A ‘digitalRead()’ is more appropriate if he wants to wait for the EOM:-

while(digitalRead(eomPin)==1)     // Wait for EOM marker
{
    // More stuff here?
}

Yes even a digital output when read with an analogue signal is never zero. If you look at the specs of most digital outputs they can be up to 0.5V when a low.

Mike and Steve, Thank you very, very much for your advice and experience.

What you say about the "While" statement makes sense in light of what is occurring.

One thing wrong is that you end the 'while' statement with a semicolon before the curly bracket, so this line will only execute after EOM goes high:-

The speech plays, the signal is high, the "While" sees the high and moves on to the Tone Function. And because the cycle is so fast it appears they play simultaneously. I feel you have hit the nail on the head there. Awesome

And the EOM being a digital signal,

It's actually a digital output that's being monitored for the EOM,

I had no idea, I assumed it was analog. I must admit Ive never looked at specs for Digital Outs and always thought they would be a 0v when low. But this is fantastic. You both have shed a brilliant light onto this problem.

I will amend the sketch and post back. Thanks again