Phototransistors novice question for flight simulator

Thread Starter

expataviator

Joined Nov 21, 2020
6
Hi, I am very close to novice and fully expect this to be a shockingly simple question for you experts!

I am building a home flight simulator with an Arduino Mega and one function is to change the autopilot heading. I have this working with a simple rotary encoder which connects two Arduino pins to ground as it rotates. (The software already figures out which way the encoder is being turned.)
simv.png


I recently bought an old piece of real aircraft avionics, and the encoder is different. It instead uses an infrared encoder with a serrated wheel passing between a sensor.

collin.png

I emailed manufacturer and they said this is the datasheet. https://www.ttelectronics.com/TTEle...les/Optoelectronics/Datasheets/OPB822-826.pdf

(Note I intend to disregard all the other PCB inside this unit as I only need the buttons/encoders.)


So now my questions are
1. Will this even work? it seems to contain two photo transistors. When IR light makes it tot the transistor will currently flow from the collector to the emitter and effectively 'ground' the Arduino pins just like the mechanical encoder I am currently using?
2. How do I power the IR LED's without blowing them. I know I need a resistor but I don't know which to use. I see values in the datasheet I know belong in the ohms law formula but am afraid to get this wrong.

Here is my amateur diagram built on what I found in the data sheet showing what I THINK I need to do....
plAN8mvxSMK6AnpeT5ozTw.png
 

Thread Starter

expataviator

Joined Nov 21, 2020
6
Hi, I am very close to novice and fully expect this to be a shockingly simple question for you experts!

I am building a home flight simulator with an Arduino Mega and one function is to change the autopilot heading. I have this working with a simple rotary encoder which connects two Arduino pins to ground as it rotates. (The software already figures out which way the encoder is being turned.)
View attachment 223062


I recently bought an old piece of real aircraft avionics, and the encoder is different. It instead uses an infrared encoder with a serrated wheel passing between a sensor.

View attachment 223063

I emailed manufacturer and they said this is the datasheet. https://www.ttelectronics.com/TTEle...les/Optoelectronics/Datasheets/OPB822-826.pdf

(Note I intend to disregard all the other PCB inside this unit as I only need the buttons/encoders.)


So now my questions are
1. Will this even work? it seems to contain two photo transistors. When IR light makes it tot the transistor will currently flow from the collector to the emitter and effectively 'ground' the Arduino pins just like the mechanical encoder I am currently using?
2. How do I power the IR LED's without blowing them. I know I need a resistor but I don't know which to use. I see values in the datasheet I know belong in the ohms law formula but am afraid to get this wrong.

Here is my amateur diagram built on what I found in the data sheet showing what I THINK I need to do....
View attachment 223061
Forgot to say it’s the OPB822 on the data sheet
 

Sensacell

Joined Jun 19, 2012
2,684
Shoot for ~ 20 mA through the LED - R = around 180 ohms assuming a 5V supply.

You should include pullup resistors on the Phototransistor Collectors, around 50K ohms- it goes between 5V and the Collector.
(unless the input pin already has internal pullups enabled?)

Check the voltage as you rotate the encoder, it should swing between ~0.5 and 4.8V approx if it's working
 

Thread Starter

expataviator

Joined Nov 21, 2020
6
Thank you so much for your reply. So just to make sure I am understanding, like this...? I have a feeling Arduino already has pull up on its pins but I'm not 100% sure.



Also, I dont think I have 180 ohm, but I have some 220. Does it have to be exact (I realize this sounds like another novice question)
 

Attachments

djsfantasi

Joined Apr 11, 2010
7,229
Thank you so much for your reply. So just to make sure I am understanding, like this...? I have a feeling Arduino already has pull up on its pins but I'm not 100% sure.



Also, I dont think I have 180 ohm, but I have some 220. Does it have to be exact (I realize this sounds like another novice question)
The Arduino has internal pullups, but they have to be enabled in your code. In the setup() section, you have to define your pin like this.

pinMode(yourPin,INPUT_PULLUP);​
 

Thread Starter

expataviator

Joined Nov 21, 2020
6
The Arduino has internal pullups, but they have to be enabled in your code. In the setup() section, you have to define your pin like this.

pinMode(yourPin,INPUT_PULLUP);​
Ah ok, I'm relying on someone else's code to facilitate the interaction with the simulator so I'll drop the author an email to check.
 
Top