Quick question on pullups

neiltechspec

Senior Member
Anybody know the comparative pullup value between pins on 08M2 pins C.1 & C.2, are they the same or wildly different ?.

Or would I be better off using separate resistors, 47k for optical rx collector pullup to 5v.

Neil.
 

AllyCat

Senior Member
Hi,

The Microchip data sheet puts an enormously large tolerance (spread) on their value, with no reference to matching. Strangely they also specify them in terms of a current source, although they seem to adhere to Ohm's Law quite well.

But in my experience, they're "always" between about 30k and 35k, so I often use (and recommend) them.

Cheers, Alan.
 

neiltechspec

Senior Member
I tried with the pullups, but in daylight found they were too sensitive to ambien light, my fixed eternal 47k's were even worse.
So, ended up with 22k's & seems quite consistant now in room lighting.

Detection range is about 10mm which will be good for when I insert them into the N Guage track.

Neil.
 

AllyCat

Senior Member
Hi,

LDRs have quite a large active area, so you could just mask about half of it, or use a neutral density filter (e.g "borrowed" from a pair of sunglasses).

But personally, I'd be using an ADC input and adapting the threshold(s) to the ambient light level. Generally you've only got to add a READADC instruction, which doesn't take any longer to execute than most PICaxe operations.

Cheers, Alan.
 

neiltechspec

Senior Member
They aren't LDR's.
They are opto sensors with IR emitter & filtered NPN semiconductor (supposed to be less sensitive to ambient light).

Neil.
 

Eng460

Well-known member
Opto sensors are very different devices, and need a different pull-up resistor range to what is required for LDR.

Look up the data sheet for your device. I don’t know which one you are using, but I am using a similar device on my current project and have looked up the data sheet. It is worth reading through every page, as it has a wealth of information. Look for circuits on how the parameters are measured.

The data sheet gives guides to what collector current is required. Mine also has a little graph which shows that the response time is directly affected by that collector current. If your device is similar to mine, you might need nearer 1000 ohms to give the required response.

Test it on a breadboard and check with a voltmeter how much the output voltage varies between light and dark. Mine goes from about 1 volt when the transistor conducts (light on), to 4.99 V when the transistor is shaded. A 10 mm gap means ambient light will be more significant, but experiment to see what you get.

The one I am using (called a photo-interupter ) only has a 3 mm gap, and is not very sensitive to ambient light. Your 10 mm range might let in more ambient light, but you will get a better idea when you have the collector current in the right range.

Eng460
 

AllyCat

Senior Member
Hi,

Ah, your reference to interference from room lighting confused me. I believe those sensors use 940nm IR and I wouldn't expect to find that in normal artificial lighting. But a problem with phototransistors is that their sensitivity depends primarily on the current gain (hFE) of the transistors, which is very variable (between samples and temperature, etc.). As said, much will depend on the data sheet, but couldn't you reduce the LED current to lower sensitivity? However, it just confirms my view that it's best to use an adaptive ADC input, unless working rigidly to the data sheet.

Cheers, Alan.
 

neiltechspec

Senior Member
Artificial lighting isn't a problem. It's daylight. It may not be a problem when they are located between the tracks.

The main issue with my bench testing is - the test bench is in a loft conv with a large roof window.
Even with the blind drawn the ambient light is high.

The datasheet doesn't appear to be available. They are ebay devices with no markings, as I couldn't find anything
of a suitable size from usual suppliers.

Size of these is approx 6.5mm x 5mm x 6mm, they have to fit between N Guage tracks in a drilled / filed hole.
The device has four pins - Anode & Cathode for emitter and Emitter & Collector for sensor.

I checked the switching function with a scope.
 

Attachments

Buzby

Senior Member
Artificial lighting isn't a problem. It's daylight.
As the daylight varies, due to clouds, shadows, time of day etc., the output from the photo-diode or photo-transistor will move accordingly. This makes detecting a change due to a detected object tricky, as there is no 'constant' level to compare against.

You can compensate for this by turning the LED off, read value using ADC, turn LED on, read value again. The difference between these two values will be low if nothing is reflecting, and high if there is reflection.

An even better method is to use a pulsed transmitter and a tuned receiver. The principle is now to detect a frequency, not a level. This is how the commercialy available proximity detectors work.

Writing a tuned receiver in PICAXE BASIC might be possible, but it would be a challenge. Much quicker to get one ready-made !.

There are plenty circuits using the LM567 tone detector, a workhorse of many an Elektor circuit back in the day . Here is an example :

24070

The transmitter LED is driven at about 10KHz, and the IR receiver signal is capacitively coupled to the tone detector on pin 3. The tone detector only needs about 25mV signal amplitude at the correct frequency to 'lock on'. There is unlikely to be any other 10KHz source around, so the detector is tolerant against most kinds of interference.

( In that circuit above, I would replace the 2N3904 with a MOSFET, and put a gate resistor in. )

Cheers,

Buzby
 

AllyCat

Senior Member
Hi,

Yes, your sensors are a little smaller than the Vishay TCRT5000 which I am familiar with (they have a 5mm pitch between LED and PhotoTransistor so are about 10mm long). However they might be from the same "family" and have similar characteristics, so it's worth looking at the data sheet. That specification suggests an optimum collector current of 1mA, so the load resistor would indeed be a few kohms. But unless thermal leakage current is a problem (very unlikely) then I can't see why the phototransistor couldn't be run at 100 uA with the Weak Pullup Load.

The "trick" would be to apply an optical filter ("sunglasses") to only the phototransistor. Then the "intended" (LED) light and the "interference" (ambient daylight) would be attenuated by the same amount. A complication is that some materials have a very different transmissivity (Transparency) to Infra Red compared to Visible light. Also, that may be different between the 950 nm wavelength ("colour") of these (Vishay) sensors, compared with the peak of some other phototransistors around 750nm (it appears that there's a blocking "notch" in the atmospheric transmission of IR around 950 nm). Perhaps just test a few "convenient" optical filtering materials, such as a coat of acrylic paint, using the PICaxe READADC input to give a more qualitative (numerical) measurement.

Of course there's another complication, that when the train runs over the sensor, the ambient light will be reduced, but the reflected (IR) light will increase, so you need to ensure that you're measuring the correct thing. IMHO the only time it would be "inconvenient" to use an (adaptive) ADC input is if you wanted to trigger an interrupt directly.

Cheers, Alan.

PS: And you could modulate the IR light with the output from a PICaxe PWM pin, but I don't really think it really should be necessary.
 

neiltechspec

Senior Member
IN the final position when I mount them, they can / will be set below track level in a hole anyway.
So ambient daylight shouldn't be so much of an issue.

They don't seem to be affected by artificial LED room lighting much at all (due to light wavelength of course).

But I will look into / test using readadc just to see what it shows.
 

neiltechspec

Senior Member
Just tried a quick test using readadc10

Values are approx 800-900 in shade, varying between 100 to 250 when a reflective object placed in front,
and down to 27 when pointed at window with blind drawn.

So think I'm going to scrap the idea and go with hall effect sensors with a magnet mounted on a small wagon / coach.
Had some of those in the junk boxes somewhere, latching & non latching, no-latching being preferred.
Most modern locos have coreless motors so don't give much in the way of stray magnetic field.

Neil.
 

neiltechspec

Senior Member
A3144 seems to fit the bill, not magnet polarity dependant, non latching, built in schmitt triggerering,
work off 4.5v to 24v (I'm using 5v), Open Collector O/P. Datasheet readily available.

Not got any of those, but cheap enough to buy.

Neil.
 

Buzby

Senior Member
So think I'm going to scrap the idea ...
I wouldn't give up yet.

If you set up a rig that you can run a wagon over, it should be quite easy to determine the difference in readings between wagon and no-wagon, using the LED on/off technique in post #10, over a wide range of ambient lighting.

A solution that requires modification to your rolling stock seems a bit limited, as it will only respond to modified wagons. Also, the photoelectric method can easily be tested on-site just with your finger, no need for a magnet on a stick.

Cheers,

Buzby
 

neiltechspec

Senior Member
It's easy enough just to add a neodymium magnet to a few wagons / coaches.
I don't need to do all of them. Plus the sensors are tiny by comparison to optical.
Far easier setup / programming - they either work or they don't.
 
Top