View previous topic :: View next topic |
Author |
Message |
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Mon Sep 21, 2009 1:48 am Post subject: Input and Output Components |
|
|
An AVR is no different from any other electronic device. You need to read the specs in the AVR datasheet to know what is acceptable for input and output.
In general its good practice to put resistors in series with input lines, and usually capacitors to ground too, to prevent high input voltages and/or spikes reaching the processor. How much depends heavily on how big the input voltage you expect, and also how fast you want the input to switch. If you only work with equal or less than power supply voltage, then you dont usually need any resistors, but its still good practice to include them. AVR processors have internal pullups available on the input lines, set on by switching the port to high when the direction is set to input. These are often all you need to read the status of a switch line. But be aware that they are not well controlled. The pullup resistance is around 50-100 K, yes, a 2:1 variation is possible. Often this does not matter.
The specs will also tell you how much output load you are allowed, and what output voltage to expect at that load. Typically you can drive about 10 ma out of a processor port pin safely. 20 ma is usually possible, with some voltage drop, and not all pins on one port on at once. It has been common practice to use inverted logic on outputs, ie set the line high to disable an output, low to turn on. The reasons for this are largely historical. You can adopt any convention you like, even different for different port lines. AVRs are nice in that you can source or sink about the same current, so it does not usually matter which convention you use.
If you drive relays, you nearly always need a transistor, and a diode across the relay to catch the turn-off spike.
Your opto-coupled device will draw some current, maybe even around 10-20 ma, depending on the opto, so you will see significant voltage drop. That may be ok.
An unloaded output pin should drive very close to supply voltage when high, or ground when low, as measured by a high-impedance meter.
General purpose transistors will switch at least 100 KHz, you might need faster ones for 250 KHz, depending on how you drive them.
I would suggest you read the Atmel datasheets, and probably some electronics textbooks ( or Web articles ) to get up to speed on basic electronics again. And of course you can always ask questions here. _________________ Adrian Jansen
Computer language is a framework for creativity |
|
Back to top |
|
|
WanaGo
Joined: 15 Aug 2008 Posts: 111
|
Posted: Mon Sep 21, 2009 2:46 am Post subject: |
|
|
Thanks.
Are you however able to point me towards a fast switching transistor, suitable for switching 5V @ 250kHz? To drive opto isolated input.
I have BC337/BC338 's at home - I looked at the datasheet, but couldnt see what specifically said the frequency they could switch at...
In the BC337 datasheet it does say:
fT, Current Gain Bandwidth Product, Test Condition(VCE=5V, IC=10mA, f=50MHz), Typical 100 MHz
Is that what I am looking at?...
Is this capable of switching at 100Mhz?? If so, then I dont nee to look any further - but I didnt realise a standard general purpose transistor would switch that fast.
Thanks |
|
Back to top |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Mon Sep 21, 2009 4:45 am Post subject: |
|
|
Gain bandwidth product roughly means that at 100 MHz the gain is 1. But that does not mean that at 1 MHz the gain is 100, although it is a starting point. But transistors are not by any means that simple. However there are plenty of switching transistors which will work at 250 KHz, just pick one from whatever parts source you use.
Even the BC337 would probably work, depending on how you drive it. Try it and see, then if it does not, find a faster one.
You will need a relatively high current drive, and also capability to sink current to turn the base off quickly, so a low resistance from the AVR to the base. Just guessing, 10 ma drive would probably work, so around 5 volt / 0.01 amp = 500 ohm in series would be a good starting point. _________________ Adrian Jansen
Computer language is a framework for creativity |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|