Best way to read signal?

Hello, I am hacking my cassette deck so it can be controlled by an Arduino, I have the IR Remote control working but I want to check that the deck is playing or has stopped when it gets to the end of the tape. The deck has a photo-diode and rotating disc that gives a square wave of 0v to 4.25v as output.

Can anyone suggest the best way for me to tap into this signal so it can be read by the Ardunio without upsetting its functionality within the deck?

Thanks

Karl.

Just connect it to a digital input. The impedance is so high it will not affect the normal function. Make sure to connect the two grounds together.

Try connecting that output direct to an Arduino digital input via a series resistor. I would try 100K. Place the resistor at the Arduino end of the wire between it and the cassette deck. The Arduino will need to have a common ground with the cassette deck. If both are operating from the mains, then they probably already have a common ground.

The resistor serves two purposes:

  • If the grounds are not at quite the same potential, or you get transients on one of the ground, the resistor will protect the pin
  • The resistor will (hopefully) allow the cassette deck to work normally even when the Arduino is powered down

An alternative solution (better if it can be made to work) would be to use an opto isolator, however whether that is practical depends on how much current the photodiode arrangement can source or sink, which may not be very much.

If the pin you use is D2 or D3 (assuming Uno) then you can attach an interrupt routine to it which can be used to record the time of last change (just set a global variable to the result of millis().

The rest of the code can then see when the last change happened, and if too long ago (a second or two I guess) then you can deduce the spools are not turning.

With a high value series resistor like 100k you might be a little susceptible to noise, in which case a 1nF capacitor from the pin to ground would probably cure.

Hello,
thanks for the replies, very helpful.

I have used a 38K resistor and 1nF capacitor, I found that a 100K resistor prevented the fast-forward being detected. Here is a function I have written that tells me quite quickly that the cassette is playing:

boolean getPlayback2(int pin) {
  int stateChange = 0;
  int hear;
  for (unsigned int i=0; i < 300; i++) {
    hear = digitalRead(pin);
    delay(3);
    if (hear != digitalRead(pin)) {
      stateChange++;
    }  
  }  
//  Serial.println(stateChange);
  if (stateChange >= 2) {
    return true;
  }
  return false;  
}

Thanks again
Karl.

1nF capacitor

Why?

Grumpy_Mike:

1nF capacitor

Why?

Because MarkT suggested it, and I had some in the bits box.

its as scientific as that!

karl101:

Grumpy_Mike:

1nF capacitor

Why?

Because MarkT suggested it, and I had some in the bits box.

its as scientific as that!

I'm glad you got it working. In my original reply, I suggested:

Place the resistor at the Arduino end of the wire between it and the cassette deck.

precisely to avoid the noise pickup that MartT was worried about. The 1nF capacitor, in conjunction with the 100K resistor, was attenuating fast signals as well as any possible noise.