IR Question not directly related to Teensy 3

Status
Not open for further replies.
I will test the 4 transistor circuit also this week while I wait for the capacitors to arrive. Not sure if the capacitor version will work, because I couldn't get the good capacitors

I was thinking of making R9 5 ohm or what ever is needed not to blow the LED and get max range
I will make R12 XXX ohm (to be decided) to get the lowest possible range to make sure the IR signal doesn't bounce in a dark room.

This will make the product available for indoor and outdoor laser tag/skirmish. I will then look at what I want to R11 and R10.

Does that sound like a plan?
 
That'll work. Note that you can still enable more than 1 channel at once to get higher current, but if the resistor ratios are 2:1 or more, it won't actually make much difference -- your range depends on the sqrt(current), so 50 % more current only gives ~22 % more range.

If you want uniform 'steps' from just enabling 1 channel at a time, the optimal ratio between R's is cube_root(R12/R9) (when you have 4 channels like you have here).
 
I created a spreadsheet that I can use to play around with. I should have time this week to write the code and see what it does and I will have to go buy a bunch of different resistors

https://docs.google.com/spreadsheet/ccc?key=0AjYcEd1WlkqCdGYtNmhXV3ViOGswd2VGbm9KY0ktWGc&usp=sharing

Looking at the datasheet they start at 1mA in the one graph and 1V in another so I assume that is probably the minimum the LED needs to light up. I will probably need to make sure I can produce at least that much power just before the battery doesn't have enough power for the processor anymore. The LifePo4 battery seems to be flat at 2.5V. So I am thinking I need to look at what resistor I need when the battery is at +-2.6V and I want 1V 1mA at the LED. Seems I need to have a 1800 ohm resistor. This will take alot of playing around in a dark small room, bigger dark room and out in the open. In my spreadsheet I have 15 ohm and 30 ohm and then 1800 ohm and 2700 ohm. This gives me 3 settings for outdoor and 3 settings for indoor. That is about equal to other manufacturers where they normally have 4 settings. So I will at least be better there with an extra two settings. The 2700 ohm resistor will give me the minimum power when the battery is full. Seems I will need to create a battery monitoring circuit and then as the battery drops I change the range setting automatically. I don't think anybody else in the world does that. Lots of code, great for marketing :)
 
I built the circuit and started testing it. Currently I am using resistors I have at home, all 470 ohm. I am also using my PS 3 remote control for power. The 1.5V * 2 AA batteries don't seem to deliver much so it also keeps the circuit safe. I am still waiting for my batteries from Hobbyking. When I measure amps on the IR LED I get 60 uA max. When measuring amps on the resistors on the side of the collectors of the transistors I don't see any amps, probably not doing it right.

White/Yellow wires are negative. I ran out of black, they are in use in other circuits. Strange how they supply so few black wires for negative in these wire packs, but tons of other colours

http://www.flickr.com/photos/92380311@N04/8958044189/
http://www.flickr.com/photos/92380311@N04/8958041847/
 
With the 4 transistor circuit, there are 16 possible current combinations (including all off).

If you're only going for 3 short range and 3 long range settings, it should be possible with only 3 transistors and careful selection of the resistors.
 
I see the problem I had with the circuit was the test circuit I built into it. I was shorting out, because of the red test LED's and their power supply. I removed their power and I could test the resistors. Tonight I will remove the LED's since I know the circuit is working now. I will change the code tonight so that I can pulse more than one transistor and see if the message comes out correct.

I would like as many range settings as I can get. I will know more as I do more testing and when I get my real batteries. In this setup, using 470 ohm resistors my range is really short. No bounce in a small dark room. We will see if I maybe need one of the pins used for range for something else. I have all my pins planned


Off topic for this thread, but just excited to share. Using every pin on the Teensy now. Need to remove the headers from my other Teensy's on my breadboards and turn them around so that I can get to the bottom pins. I think when I am done I need to send you a kit or two Paul, just supply your own Teensy :)

My pin use
Ground to 12
LCD 1
WEAPON CHANGE
Sound 2 (future)
IrReceivePin
Muzzle BLUE_LED
Muzzle GREEN_LED
IrSendPin
Muzzle RED_LED
MOSI (LCD 3)
Sound 1
RF TX
RF RX
LCD 7
LCD MISO (LCD 9)


Ground to 13
LCD 2
Team RED_LED
Team GREEN_LED
Motor control
DC (LCD 4)
SD CARD FAT (LCD 5)
Team BLUE_LED
RELOAD BUTTON
LCD BACKLIGHT BUTTON
TRIGGER
CS (LCD 6)
LCD 8



28 to A12
IR SEND 1
IR SEND 2
LOW POWER LED
CAPACITIVE HAND SWITCH


DISTANCE MEASURE



29 to A10
IR SEND 3
IR SEND 4
LCD 10 Backlight
SECOND RELOAD
SECOND TRIGGER

Temp sensor
Tilt sensor
Battery voltage measurement
 
I ran out of black, they are in use in other circuits. Strange how they supply so few black wires for negative in these wire packs, but tons of other colours

Usually the electrons don't care which color wire they are in, but you can never be too careful !
 
My setup so far. Sound and range on IR are working. I contacted the sound module company to find out how much the sound chips are, maybe I can build a tripple module so that I can play 3 sounds at the same time
http://www.flickr.com/photos/92380311@N04/9014521243/
http://www.flickr.com/photos/92380311@N04/9015716368/

I don't have the correct resistors yet, was focussing on getting things to work before I ordered the right resistors

I am testing with a 5 ohm resistor on R9. Wow, the light is bright when I use the video camera. When I place the multimeter over the 5 ohm resistor it measures 01.23 mA. When I place it on the LED it measures 01.85 mA. I doubt that it is 1.85 mA, but if it wasn't then the pin would have been gone by now. That is too bright for +-1 mA. Maybe it is 18.5 mA. R2 reads 1.68 mA. All resistors, except R9 are 470 ohm 5% resistors. So I might be close to burning out another pin maybe if it is really close to hitting the 20 mA range

I was reading up about transistors and they say divide the current by 10 or 20 you want from the emitter and that is the current needed on the base to fully saturate. So if I want 100 mA I need 10 mA on the base. If I want 1000 mA on the emitter I need 100 mA on the base. Ofcourse that isn't possible, I will burn out the pins. So I am going to see if I can replace my transistors with Mosfets. I have 2N7000 mosfets that I use for my motor. I think I used them on the Arduino so they activated at 5V, still need to test if they activate at 3.3V
 
I was reading up about transistors and they say divide the current by 10 or 20 you want from the emitter and that is the current needed on the base to fully saturate. So if I want 100 mA I need 10 mA on the base. If I want 1000 mA on the emitter I need 100 mA on the base. Ofcourse that isn't possible, I will burn out the pins. So I am going to see if I can replace my transistors with Mosfets. I have 2N7000 mosfets that I use for my motor. I think I used them on the Arduino so they activated at 5V, still need to test if they activate at 3.3V

Beta is the parameter of a transistor that describes the ratio of collector current (similar to emitter current) to base current. A high beta device would generally work better. For home use (i.e. not high volume manufacturing), most devices you see will be better than a beta of 20.

MOSFETs will be better for this system, but you should look for 'logic level' FETs -- they have a lower threshold (turn on) voltage. Note that a FET doesn't turn on completely at the threshold votlage -- that's just the point where it begins to turn on substantially. With FETs, you won't need a R in series with the gate. A tradeoff between FETs and NPNs is that it is easier (generally) to calculate the voltages in an NPN circui, and so the currents you get will be determined mostly be the resistors you use -- with MOSFETs, the FET characteristic (and VGS) will also have a significant effect in your circuit -- you will get variations with temperature and supply voltage.
 
According to MarkT here http://forum.arduino.cc/index.php?topic=125728.0 I need to look for 4.5V on the Rds line
So this one might be the right one http://australia.rs-online.com/web/p/mosfet-transistors/4866337/
The pulse is much higher than what I need (40%)
It has 4.5V in the Rds line. I just don't know how many volts I need to get it to deliver 1A. Looking at the graphs 3.3V is maybe going to give me 0.2A so I might need a logic level converter between the Teensy and the Mosfets if I am reading the graphs correctly. The input of the logic converter will then be the 2.6V that I want to run at and the output will be 5V
 
For your purposes, think of a MOSFET as a variable resistor. When the gate is less than the threshold, the resistance is infinite. As the gate goes higher than the threshold, the resistance decreases (equation is approx. R = Rmin/(VGS-VTHRESHOLD)). In addition, there is a maximum current it will conduct -- this varies significantly with gate voltage, and but for your circuit you need to ensure you have enough VGS that this is never a constraint -- therefore, you may need to buy a FET rated at (say) 30 A max, think of this really as a parameter related to the resistance, not that you should only used it in applications running that much current. The other expensive FET above may be more suitable for you -- notice that it is a 'logic level' device.
 
Thank you. I started searching on Digikey for more logic level parts and then search for each part on RS to see if they have it. If RS has it I am keeping the details about the part and then I will go through each one to look at the stats

Does the Rds resistance mean anything to me?
What does this mean? Rds 4 ohm @ 1A, 10V or 8 ohm @ 100mA, 2.8V
 
RDS is the resistance between drain and source -- this is the resistance that changes from infinity to lower value as the gate voltage is increased. It does change slightly with drain current, but that shouldn't matter for your application -- so 4 ohm @ 1 A, 10 V means that the FET looks like a 4 ohm resistor with 10 V on the gate -- in fact it won't change more than a few % if the current is 1 A, 2 A, or 1 mA.
 
Am I reading this right?
Figure 1 on page 3
http://docs-asia.electrocomponents.com/webdocs/0791/0900766b807910ef.pdf

If I have an input of 1V to 10V at the Drain and I have an input of 2.7V at the gate I can get > 10A at the source? That might be a bit too much :) What will the voltage be at the source? I have a feeling the Rds has something to do with that and I am probably going to lose something somewhere


Yes you are, but your system isn't like that ! Remember in a FET, the same current flows into the drain as flows out the source. With 2.7 V, the FET looks like at 0.03 ohm resistor. So--yes--if you have 1 V on the drain and 0 V on the S, you'd have 30 A flowing; in your system, the LED and other components would limit the current, so you wouldn't actually have 1 V between D and S -- think of a resistor divider -- one element is your LED + real resistors, the other is the RDS of the FET.
 
I think I found my mosfet
http://docs-asia.electrocomponents.com/webdocs/0791/0900766b807913a6.pdf


It is available, always a big + :)
It is 0.68c
2.5V on gate allows 700mA
2.6V on gate allows 800mA.
2.7V on gate allows 900mA.

LED typical V = 2.6V with a max of 3V and 1A so I will be below the 3V and 1A and right on the typical V if I have a 2.6V circuit

So I am thinking get the regulator that will give me 2.6V. It might switch off at 2.7V from the batteries. That might also be the minimum discharge I want to push the batteries to**. I can run the Teensy from 2.6V and then power the gate from the Teensy with 2.6V - losses. Supply the mosfet drain with 2.6V from the regulator and get 2.6V - losses from the source into the LED.


** p.s.
Some say you can even take the batteries down to 2V. I will have to test what the charger is happy with that I have, I know I discharged before too far down and it didn't want to charge the batteries anymore. I had to charge them as lead acid and then as a different type and only after that could I charge them as LifePo4.
 
I was reading up about transistors and they say divide the current by 10 or 20 you want from the emitter and that is the current needed on the base to fully saturate. So if I want 100 mA I need 10 mA on the base. If I want 1000 mA on the emitter I need 100 mA on the base.

First, you can buy a NPN transistor with beta higher than 10 to 20.

The other approach that works well is using 2 transistors in a darlington configuration. You can also buy darlington transistors (2 inside), but for rapid switching it's sometimes better to have 2 separate transistors so you can add a resistor to the emitter-base connection that would be inaccessible if you use a single package with both transistors inside.

Of course that isn't possible, I will burn out the pins. So I am going to see if I can replace my transistors with Mosfets. I have 2N7000 mosfets that I use for my motor. I think I used them on the Arduino so they activated at 5V, still need to test if they activate at 3.3V

You can use mosfets, but they add many other design challenges. In addition to the higher voltage required (already mentioned here), the mosfet gate is essentially a capacitor. If you need the mosfet to turn on or off rapidly, it can be challenging to charge or discharge that capacitor rapidly. Even though the mosfet needs virtually zero current to remain on, very large pulses of current can be needed to go from off to on rapidly.

From this discussion, it sounds like you're tempted to use the mosfet as a voltage controlled resistor. That is a very challenging design. The main problem is very tiny changes in voltage result in substantial changes in resistance, and the exact voltage where that change occurs varies with temperature and is different from one mosfet to another, even among two identically labeled parts from the same batch.

To make a mosfet-as-resistor application work in a practical application, you would probably need an opamp and carefully designed feedback loop that senses the current and controls the mosfet voltage. It's not impossible, but quite difficult. Aside from just the challenge of designing any opamp circuit (other than the very standard ones), a huge problem is the opamp's ability to drive the capacitive gate of the mosfet. Many opamps can't drive large capacitance at all. Even if they can, perhaps by a series resistor, placing a mosfet in the feedback loop adds significant phase shift which causes the feedback to become unstable. Usually circuits like that have very creatively designed feedback loops where the sensed current effects the opamp feedback at low frequency, but at higher frequency a second feedback path without the extra phase shift is used for stability. That can make the feedback stable, but then the whole system can have strange response to changes, so it requires very careful analog design. Definitely not a good beginner electronics project! In fact, it's so difficult that mosfets are very rarely used that way.

However, it is relatively easy to build a voltage-to-current circuit with an opamp and a NPN transistor, or even without an opamp (as previously discussed) if you're willing to accept a limited voltage range and some inaccuracy from the not-always-0.7 base-emitter voltage.

There are a lot of difficult trade-offs in an analog circuit design. I still believe the 3 or 4 transistor circuit mentioned earlier, with each transitor's emitter to ground and binary-weighted resistors between each collector and the LED is probably the simplest and easiest to accomplish your goals. The low beta value problem is fairly easy to solve, either by buying a better transistor or using 2 in darlington mode.
 
Last edited:
Thank you. I will read up more about the darlington mode and low beta value. I would like to keep it as simple as possible and the current design does work. I just need more power captain :)
 
You have 2 requirements which tend to conflict -- 1: you want to turn on and off quickly, and 2) you want variable currents. Ultimately these tend to require separate circuits -- one to determine the value of current and one to switch this on and off.

Given that you only have a small set of distinct current values (and little experinence in analog circuit design !), your safest approach would be to go with Paul's 1st suggestion -- for each value of current you need, use a R and a FET to GND. Drive each FET directly from a T3 I/O port. Since your currents are << 1 A, actually nearly any FET would do -- you just need its RDSON significantly less than the value of the R you are using (and at the 3.x VGS you can drive the FET to) so that variations in FET characteristics, temperature, and T3's supply V don't cause additional variations.

Now, if you find that you need currents in an integer set of ratios, you can save a few components and do a binary-weighted set of R's: So for 7,6,5,4,3,2,1,0, you would use R's in a 4:2:1 ratio, and drive the 3 ports with the binary value corresponding to the current level you want.
 
My other conflicting requirements are to use what I call the brain (component containing the bulk of the electronics) in an indoor gun, outdoor small/medium/large gun, respawn box, domination box, night games, wireless headset and I want to be able to swap a brain from a component that is broken, e.g. respawn box is broken, replace its brain with that of a spare gun. The different tasks for the brain need different ranges, e.g. pair headset with a gun I need ultra low range so that a player doesn't pair to another gun by accident and so on

The problem is if I use low ohm resistors I will have full power on the LED and the full power brain/LED can't be used indoor or with night games, because the signal bounces too much. I don't know how to have a brain that can work for indoor and outdoor and night games and the headset, except if I build different brain components for the specific task, but then if someone buys the outdoor brain they will have problems playing night games. Operators that run games indoor normally don't run outdoor, but outdoor go everywhere. Also having different brain components made will cost more when placing orders and there is a chance of a wrong brain going into the wrong product

I received my batteries today. They have a minimum V of 2V and a maximum of 4.2V. I was thinking of the idea of two different regulators so that I could run the gun off one battery without vibration or two batteries with vibration, but then I have to give up using full capacity and add complexity. So I will just use the batteries in series and I am going to look at a regulator that I can supply with 8.4V and get 3.8V. 3.8V out means it will probably switch off when the batteries reach around 4.1V. The 3.8V will be enough for the Teensy, LED's and the eInk screen that I want to maybe rather use. I need to test and make sure the sound card can work at 3.8V. I will probably change to a 3V vibration motor. Then I can also use 3.3V mosfets or if I can find low beta value transistors maybe use them.

I think I am moving forward, everything is just so confusing, trying to cram so much info in such a short time

Have to say again, thank you very much for your help guys. Without you this would have not gone further than just code.
 
Status
Not open for further replies.
Back
Top