I would like to assure a cleaner interrupt input into digital pin 2 on an Uno.
Source is a Honeywell combo LED -PhotoDiode HOA1405-002 which I'm setting up as a remote Tachometer on a machine tool whose spindle speed I'd like to monitor. I get good signals out of the PhotoDiode which are either 1.7 volts or 4.6 volts depending on whether it's seeing black or white stripe on pinwheel it's watching.
There is some noise in the system at higher speeds and i thought I could clean up the pulses with a 74HC14. But no joy. I'm powering it with 4.8v from the Uno 5 volt bus and all the connections are good.
I fed the pulses into the 1A input and get a steady .128 volts out of the inverted output 1Y. No output pulses at all.
A constant "low" on the output of the IC means the opto transistor is not pulled to ground far enough.
Could be not enough LED current and/or collector pullup resistor too low in value.
Make sure you ground all the IC's unused INPUTS.
How much LED current (voltage and resisor value).
What is the value of the collector (pullup) resistor.
What is the spindle speed and diameter (where the markings are).
How many black/white fields (one white, one black?).
Are they equal in size.
What is the sensor distance.
Leo..
An external schmitt trigger should not be needed.
This opto should be fast enough (15usec) for very high rpm detection.
How you use and how you position an opto is very important.
Leo..
These are all useful thoughts. Leo, you are right about sensor position. I made a bracket for the Honeywell which permits it to slide toward and away from the pinwheel. I found best distance by adjusting sensor position while monitoring output voltage while moving pinwheel from black to white. This is how I got the 4.6v/1.7v. Pinwheel is a printed disk adhered to top of spindle drive pulley. It has 6 black stripes which look symmetrical. Spindle speed varies from 0 to 2860 rpm.
Learning that the AVR digital pin has a schmitt trigger suggests what I've been trying was a waste of time.
I apologize for having raised this question without having the opportunity to work through the suggestions due to trip to Europe for month. I plan to buy an oscilloscope when I get home which should help me track down why output searches a bit more than i would have expected.
Thanks to each of you for your advice. I'll report in when I get home and have had time to fool with this further.
Your problem is bounce or noise. You can't remove those with a Schmitt trigger. You need a debounce routine. That's code.
An oscilloscope would give you the picture, but knowing just what your maximum spindle speed and chopper count are would permit some suggestions on how to code this.
{And do not get sidetracked with fantasises of interrupts! }
Oh yes - you are mucking about with interrupt code. No wonder it's all fouled up!
How much are you doing in the interrupt routine? If your doing a lot of processing code then maybe the ISR is missing pulses?
The AVR's have a comparator pin mode that may help with positioning what voltage an ISR fires at as 1.7V is pretty close to datasheet max for low level. Nick Gammon has a good write-up on the subject here.
The rise and fall time is 15µs each. If we add some time for a stable signal, say 5µs when high and low, then the total period is 40µs, representing a maximum frequency of 25kHz.
Does the pinwheel look something like this having a dark/light ratio of 50%?
To take advantage of the sensor's highest speed, I would configure it close to the test conditions in the datasheet where IF=20mA and RL=1000Ω
EDIT
I get good signals out of the PhotoDiode which are either 1.7 volts or 4.6 volts depending on whether it's seeing black or white stripe on pinwheel it's watching.
1.7V is 0.34 Vcc, which is too close to the 0.3 Vcc threshold and it also suggests a weak signal is present. The circuit above should give strong signal with near full voltage swing.
Comparators might be the more general solution if you can't get the system stable otherwise. It's convenient that the output voltages from your sensor are near logic levels, but you can't always rely on it. For example if the off-level was 0.9V and the on-level was 1.5V this wouldn't work as a digital input.
Noise could be an issue too, if you added a comparator noise in the system might show up as multiple pulses when it transitions from black to white (which means you can't generally use this as an interrupt as Paul__B said)
An oscilloscope is a really useful tool, but your pulse rate is low enough that you can measure the waveform using the on-chip ADC
The following test sketch will give you some values over the serial port, if you dump these into Excell you have a waveform. Note the serial code is slow, it has to be run separately, and the values returned will be out of 256 not 1024
unsigned char buffer[1024];
for (int i = 0; i < 1024; i++)
{
buffer[i] = analogRead(analogue pin) >> 2; // pack this into 8-bits
}
for (int i =0; i < 1024; i++)
{
Serial.println((int)buffer[i]);
}
Yes very sure. That is not on any digital pin it is part way through the sleep circuit and is the only Schmitt Trigger on the entire chip so to say it is on all digital inputs is totally and utterly the reverse of the truth.
Grumpy_Mike:
Yes very sure. That is not on any digital pin it is part way through the sleep circuit and is the only Schmitt Trigger on the entire chip so to say it is on all digital inputs is totally and utterly the reverse of the truth.
your statement != true
You should really look at the datasheet before posting a reply.
justone:
You should really look at the datasheet before posting a reply.
I did, where else have you looked at it and misunderstood this point?
There are three mentions of the word Schmitt Trigger in the data sheet, on pages 79, 81 and 321. These refer to the Schmitt Trigger inside the Alternate Port Functions. There is no mention of a Schmitt Trigger on the normal digital inputs.
Note that the hysteresis is 0.05 VCC which is very small and of no real practical use on a slow rise noisy trigger.
Grumpy_Mike:
I did, where else have you looked at it and misunderstood this point?
There are three mentions of the word Schmitt Trigger in the data sheet, on pages 79, 81 and 321. These refer to the Schmitt Trigger inside the Alternate Port Functions. There is no mention of a Schmitt Trigger on the normal digital inputs.
Note that the hysteresis is 0.05 VCC which is very small and of no real practical use on a slow rise noisy trigger.
My god you really don't know how to read a datasheet.
Saying that the hysteresis is 0.05 VCC is the real clincher.