Custom optical encoder RPM sensor PLED&phototransistor vs IRs lifespans - Page 1
Forum section: electronics / projects

author: eneuro
author_rank: Super Contributor
timestamp: July 01, 2014, 09:35:13 pm
content: Hello,For one of my projects I needed custom optical encoder to sense alternator RPM speed.I've decided to use PLED & phototransistor and connected it to tiny AVR pin change interrupt.I'd like to be able to sense up to 10000 RPM speed.I've made black & silver paints on alternator rotor (looks like gray on red bottom-I will repaint it to white I think to get better reflection of white PLED light) with some kind of arc holes on rotor diameter.It looks like those dark arc holes absorb and disperse PLED light, so even without any painting (with only one silver mark on red rotor) I was able to detect onxoscopeall 6 rotor moveing parts with maximum on this silver painted and we can see on this scope that rotor slows down on the right.I do not need Gray's code output from this encoder and exact rotor position, but estimate rotor RPM to adjust alternator output power and optimise internal rotor coil current, so no dedicated encoders needed.This alternator with encoder inside will be in aluminium case so no visible day light interference, but just wondering if using IR receiver with IR source I could get longer lifespans of those IR elements than PLED powered by about 6mA?Are there any good IRs with long lifespans dedicated for optical encoders?BTW: When looked for example into TSOP48?? IR receivers datasheet it looks like they have built in filters and respond to given IR frequency, but I do not like strobe IR source to IR receivers optimum frequency, so maybe this PLED&phototransistor is not so bad?

author: dannyf
author_rank: Super Contributor
timestamp: July 01, 2014, 10:59:33 pm
content: QuoteYou will have to consider the line resolution of the encoder (ppr).At 1MIPS for the mcu, I think you can comfortably read about 10k pps. The math after that is easy.Anything this side of 10ma would mean practically infinite life span.

author: rob77
author_rank: Super Contributor
timestamp: July 01, 2014, 11:26:04 pm
content: actually it's not 10kpps.... it's 10k rpm (seconds versus minutes)but if it yields 6 pulses per revolution then 10k rpm x 6 = 60k pulses per minute = 1k pulses per second.1kpps = too easy for a 1mips microso no problem at all.regarding the IR vs led => no one can tell you which one will last longer... on paper it might be the IR, but in real life - including all the vibrations - no one can tell for sure. so go ahead with what you already got and you'll see

author: Kremmen
author_rank: Super Contributor
timestamp: July 02, 2014, 06:13:29 am
content: I recently made an add-on RPM counter for CNC mills capable of counting up to 65k rpm. I had good success using the Omron IR detectors, both reflective and fork style. Not sure about their tolerance for contamination though. I guess the engine space is considerably more dusty and wet environment so attention needs to be paid for that in any case.

author: Rerouter
author_rank: Super Contributor
timestamp: July 02, 2014, 09:53:43 am
content: I've done similar inside the arduino ide (atmega328 at 16Mhz), but using an edge interrupt on INT1, and the interrupt incrementing a 16 bit int, was able to happily capture up to ~240KHz, and display it on a 2x16 lcd,as far as lifetime for the product, you will find that an oil like film forms on most parts of the car engine, and being near a rotating mass, dust will stick, for petrol i have had more luck off either the ignition coil pack or breaking into one of the alternator poles,

author: dannyf
author_rank: Super Contributor
timestamp: July 02, 2014, 11:10:06 am
content: If you care about just counts, not direction, you can use one of the clocks for that. Another clock could provide the time base then you have rpm information.For exposed applications, optical reading isn't the greatest. You can look into abs designs and see what other options there are.

author: eneuro
author_rank: Super Contributor
timestamp: July 02, 2014, 09:50:18 pm
content: Thank you very much for hints apropos possible lifespans differencies.Quote from: Kremmen on July 02, 2014, 06:13:29 amIt is "second life" of this alternator and It will not be used in dusty, oils environment, but in clean electric vehicle (HPV) projectI've described most of the changes I've made to this alternator (after tunning)there:eevblog: Magneti Marelli alternator 3 phase rectifier ROD1B 0206 maximum voltage ratings?It has disabled oryginal voltage regulator and I had to add RPM sensor in my custom alternator controller to do tricky output power controll based on its input rotor speed.Quote from: dannyf on July 01, 2014, 10:59:33 pmAccording to Atmel ATTiny85 data sheet:QuoteSo, this tinny DIP8 RISC ATTiny85 switched to 8MHz internal clock has a lot of processing powerI have system clock configured on AVR timer @ frequency 10 kHz and while pin change interrupt is handled, pin change interrupts are disabled to avoid too many noise PCIs if any. They are enabled again at the end of each 0.0001s by system clock handing ISR routine.Just designed PCB op-amp based for signal postprocessing of this optical encoder output.Now I'm testing LM324 based small PCB for this task.PCI pin from this PCB is connected to alternator controller's AVR pin change interrupt.I've simulated this PCB in simple electronics circuit application to choose proper resistors.It looks like it works:This isxoscopemicrophone wave (with input capacitor in my mic interface) so op-amp output is slightly different, but pulses are clear and visible.Now it is time to write a few lines of code and see if I will be able to sense 10000 RPM speed using this simple encoder: PLED&phototransistor with op-amp at output stageI have 3 high pulses per rotation, so 6 pin changes.10000 RPM it is close to 167 Hz, so rotation time 0.006 s (6 ms) @ this maximum RPM speed.In 6 ms period of time, my microcontroller system clock timer ISR running @ 10kHz will be called 60 times and additionaly pin change interrupt routines 6 times.It looks like there is a lot of time to compute moveing averaged RPM speed and for other tasks like current & voltage sensing and driving alternator rotor coil with 10kHz fast PWM using another timer of this monster Atmel AVR ATTiny85

author: dannyf
author_rank: Super Contributor
timestamp: July 02, 2014, 10:12:02 pm
content: Quote3 ppr, at 10K pps -> 3k rps, or 180krpm -> your alternator will likely disintegrate way before that kind of rotational speed.If you really are just trying to measure speed not direction, think about using TxCKI pins instead - they are much faster and draws no cpu processing power.

author: eneuro
author_rank: Super Contributor
timestamp: July 03, 2014, 09:13:54 am
content: Quote from: dannyf on July 02, 2014, 10:12:02 pmI've rather non-destructive testing (NDT) methods to speed up alternators and verify its RPM speed using video stream and yellow marks or scopeThis is old video before its voltage regulator was disabled.I've no idea how did you get this 180k RPMMaximacalculations leads to 1kHz for pin changes rate, but NOT rotor RPM speedQuote

author: dannyf
author_rank: Super Contributor
timestamp: July 03, 2014, 11:03:00 am
content: QuoteIt is very simple. You will figure it out.QuoteOr you can do the calculation the other way around.The same basic math.

author: DJohn
author_rank: Regular Contributor
timestamp: July 03, 2014, 03:28:22 pm
content: You're approaching the same problem from different directions, which is probably where the confusion comes from.Eneuro is calculating what the controller will have to deal with in actual use: the spinny bit spins at 10krpm, calculate calculate, that's 1k pin changes per second. That's well under what the controller can do, so all is good.Dannyf is calculating how fast it would have to spin for it to be beyond what the controller can deal with. If the controller can reasonably be expected to handle 10k pulses per second, calculate calculate, it would have to spin at more than 180krpm to exceed that (it's actually 200krpm - you've lost some to rounding). That's well over what it will be, so all is good.

author: Rufus
author_rank: Super Contributor
timestamp: July 03, 2014, 05:02:06 pm
content: Kingbright make some small and cheap SMT reflective IR sensorshttp://www.kingbright.com/attachments/file/psearch/000/00/00/KTIR0711S(Ver.13).pdfThey seem quite nice apart from having a huge spread of gain.

author: eneuro
author_rank: Super Contributor
timestamp: July 03, 2014, 07:06:27 pm
content: Quote from: DJohn on July 03, 2014, 03:28:22 pmI know that I do not need more than 10000 RPM, while this enecoder hardware has builtin capacitor and it will limit maximum possible RPM close to this given RPM speed.There is no problem at all with software-just wrote a few lines of code and of course basic math have to workQuoteIt outputs nice 8 bits of computed frequency in Hz using pin change interrupts with another timer system clock in 0.0001 second steps, sof=1/Tleads tof=10000/dt_ms10, wheredt_ms10in number of those 0.0001 second long steps between my software clock.It is clear that rotor pushed by hand slow downs from 3 Hz (00000011) to 2 Hz (00000010) as we can see on thisxoscopeconnected to this test pin encoded in Morse like 0s & 1s (one is 3 times longer than zero).It's time to connect this alternator to something that can spin it to 10000 RPM and see what I getUpdate: I was not able spin this alternator to 10k RPM using method shown on my wideo without motor connected directly to rotor-It was about 5000 RPMI've added moveing average of rotation period and changed frequency calculation to be able detect <1Hz rotations and now I'm ready using faster IR sensors measure RPM close to 100 000 RPM and still detect lower than 1 Hz2304 RPM (38.4 Hz) now looks like this onxoscope.It will be fun solder a few ICs add I2C LCD and have nice small custom Hz/RPM meterers.Quote from: Rufus on July 03, 2014, 05:02:06 pmFor this project this PLED&phototransistor encoder is ok, but it would be nice to be up to date with IR chips too, while for other project where visible light can interfere with encoder PLED diode will not work.In thisEEVblog #637 – Omni Directional Laser Barcode Scanner TeardowninterestingReflective Interrupter: SFH 9202is built in into this scanner, howeverDigiKey.com: SFH 9202shows it as not available, but its response time 30us-40us looks good and it looks like it hasQuoteso everything we need to sense RPM speedWhere to get this thing?Maybe something else, but with IR emiter & phototransistor in one IC like this SFH 9202?Update: Sorry did not nottice that this KTIR0711S looks like has IR emiter & and IR sensor, so thanks it looks good too