Pull down resistor not working how I think it should  - Page 1
Forum section: electronics / beginners

author: tom g
author_rank: Newbie
timestamp: February 25, 2020, 04:30:11 am
content: Hi I am working on a project to measure the RPM of my lathe using one of those light gate sensors from a printer. I am using a Node Mcu board to measure the pulses and display the result to an spi oled screen.However, when I compare the result i get from my device to the result from a commercial rpm meter the device is measuring too low. At first I suspected the code but now I think that the signal from the sensor is not falling low enough and the interrupt is missing pulses. The signal oscillates between 3.3v and 2.6v which i don't think is low enough but the mcu seems to be triggering on some of the pulses.I tried using a pull down resistor to bring the pin low when it is not reading high from the sensor but it pulled both the high and the low values down (I tried resistor values between 1k and 40k). Is there a better way to achieve this ? I included an oscilloscope trace and a sketch of the circuitThanks

author: Tom45
author_rank: Frequent Contributor
timestamp: February 25, 2020, 04:33:03 am
content: Do you know the output circuit of the sensor?

author: tom g
author_rank: Newbie
timestamp: February 25, 2020, 04:37:40 am
content: its one of those led light gates i think its just an led and a photo sensor (transistor ?)

author: Brumby
author_rank: Unknown
timestamp: February 25, 2020, 04:43:03 am
content: That does not tell us a lot.Do you have a part number for this sensor?

author: ahbushnell
author_rank: Frequent Contributor
timestamp: February 25, 2020, 04:49:46 am
content: https://www.digikey.com/products/en/sensors-transducers/optical-sensors-reflective-logic-output/556?k=reflective+sensor&k=&pkeyword=reflective+sensor&sv=0&pv16=376802&sf=1&FV=1205%7C421129%2C-8%7C556%2C69%7C411897&quantity=&ColumnSort=0&page=1&stock=1&pageSize=100For the LED put a resistor in series.Use a pull up resistor on the output.Or look around on Digikey (or Mouser).

author: Tom45
author_rank: Frequent Contributor
timestamp: February 25, 2020, 05:10:44 am
content: The pull down resistor is between your D3 input and ground?How did you decide on the value of the 1K resistor on the power lead? Without knowing anything else about your device, I would suspect that the 1K resistor shouldn't be there. To be safe, you might try a 1K resistor from D3 to ground, and reduce the 1K resistor to 470. If that seems to improve things, try reducing it further.

author: tom g
author_rank: Newbie
timestamp: February 25, 2020, 05:21:28 am
content: It came from a scrap printer so i don't have a part number or a data sheet. Its one of the three pin gate type where the wheel passes between the two sensors i believe that its just an led and photo transistor i used a YouTube video to workout how it worksi have attached an image below of what i think the internal circuit looks like (sorry for the quality of the sketch im just using Libre office draw). It appears to be producing the right number of pulses when i do the math on the frequency from the scope it matches what i get with the commercial meter i was using

author: Tom45
author_rank: Frequent Contributor
timestamp: February 25, 2020, 05:44:18 am
content: Your circuit diagram is almost certainly wrong.First, what is the voltage across the 1K resistor? That will tell you the current draw. The 3.3 volts probably feeds only the LED as in your diagram. Experiment with reducing the 1K resistor until you have somewhere in the neighborhood of 5 to 10 ma of current through the LED.I suspect that your diagram needs to be changed to swap the transistor's emitter and collector.The emitter is tied to ground and the collector goes to the output pin.Then connect a resistor from 3.3 volts to the line connecting the output pin, the collector in the updated diagram, and the D3 input. Start with something safe like 10K. That would limit the collector current to less than 0.3 ma.

author: tom g
author_rank: Newbie
timestamp: February 25, 2020, 06:06:11 am
content: You were right 1k was too high i tried 470 and that helped a bit then I tried without any and there was a fizzing noise and a bad smellbut i have some other sensors and I worked down to 100 which gets me down to 0.2v which I think should be low enough. So the problem was that I was not lighting the LED enough?Thanks for your help

author: JustMeHere
author_rank: Frequent Contributor
timestamp: February 25, 2020, 06:09:20 am
content: The RPM sensors in computer fans need a pull up. Please check to see you're pulling in the correct direction.

author: Tom45
author_rank: Frequent Contributor
timestamp: February 25, 2020, 01:55:25 pm
content: Quote from: tom g on February 25, 2020, 06:06:11 am0.2 volts across 100 ohms is 2 ma. A pretty low current for an LED. A 47 ohm resistor would probably be about right.You still need to add the pull up resistor from the output pin to 3.3 volts. Best to start big with 10K and see what your scope trace looks like. I suspect something between 1K and 10K would be good.

author: ahbushnell
author_rank: Frequent Contributor
timestamp: February 25, 2020, 03:54:44 pm
content: Quote from: tom g on February 25, 2020, 05:21:28 amI assume you have a resistor in series with the LED or there is an internal resistor?Andy

author: Tom45
author_rank: Frequent Contributor
timestamp: February 25, 2020, 05:44:10 pm
content: Quote from: ahbushnell on February 25, 2020, 03:54:44 pmHe had a 1K resistor, and now the 100 ohm.

author: frogg
author_rank: Regular Contributor
timestamp: February 25, 2020, 07:48:36 pm
content: Just a thought, but isn't it usually prudent to use a simple isolation and amplification stage in these types of circuits?I guess the assumption here is that the "on" current across the series resistor is high enough to trigger the MCU's interrupt?

author: james_s
author_rank: Super Contributor
timestamp: February 26, 2020, 02:52:37 am
content: Quote from: tom g on February 25, 2020, 06:06:11 amOf course it did, assuming that's the current limiting resistor in series with the LED. Obviously you need a resistor there to limit the current to around 5-10mA typically. You don't need a datasheet for the sensor, they're all virtually identical, nothing in them besides an IR LED and a phototransistor.There is no pulldown resistor in your schematic, you will need to post a more complete schematic before anyone can really help.