Drive LED or Opto-isolators with AVR

This might be seem very simple to many of you, but I still get questions about simple microcontroller interfacing. So I will put a thread of notes about interfacing AVR microcontrollers to devices like LED’s, relays, I2C, etc. As you might know Diodes require pretty small current. This current depends on diode type and can be from 3mA up to 20mA and more. Working voltage is from 1.5 to 4V. One AVR pin can sink up to 20mA of current; it is convenient to connect diode directly to it with current limiting resistor. Never connect diode to pin without resistor – you may damage your AVR as your current may exceed the 20mA limit!

Continue reading

K-Type Thermocouples reviewed

A thermocouple is a sensor that generates an electrical potential related to the temperature. The operating principle of the sensor is base on the fact that any electrical junction between two different metals generates an electrical potential that depends on the temperature and the metals that are used. The principle applies equally well if three metals are used. In that case, there are two junctions in series, and the net potential results from the series addition of the two individual potentials. For example, if a copper iron junction is in series with an iron-tin junction, the net potential is the same as for a copper-tin junction. However, that is only true if both junctions are at the same temperature. The K-Type thermocouple is usually made of Chromel (+) and Alumel(-). The voltage generated from this sensor is 4mV/100°C. The max temperature can thermocouple withstand is 1000°C without any damage. How…

Continue reading

Gauss-Zeidel optimization routines

This is simplest optimization routines. Using this algorithm optimization parameters are changed separately in each step. Only one parameter can be changed in one step while other are helt as constants. Xk+1=Xk+ΔXk , k=0,1,2,… ΔXk step of parameter Xk. Parameter is changed until function growth is noticed, and then next parameter follows and so on. After cycle with all parameters is completed, then step is changed to half of its value and repeat cycle again. Optimal point searching ends when there is no function increase and last point is held as optimal point. Lets see how it works with following function: Its plot: Using MATLAB script we get results bellow. In each picture start coordinates are different. Start coordinates. x=150; y=200; Start coordinates x=50; y=150; Other example Start coordinates x=10; y=10; Start coordinates x=100; y=200; Third example Start coordinates x=10; y=10; Start coordinates x=50; y=200; Matlab script: close all; clear…

Continue reading

Impulse signal distortion in transmission line

Today most electronic equipment consists of signal generators and processing units. These units are connected with transmission lines. These lines have big influence in signal distortions. On these lines depends transmition lines stability. Let’s see how transmition lines affect transmitted signals. (G- signal generator; Za– output impedance; I- signal receiver Zb– input impedance; L- transmission line length; Z0– Line impedance. When line is tuned and without losses then input voltage: Ub(t) = ZbE(t-t)/(Za + Zb) E(t)- generators signal amplitude; t– signal delay in line. t =l/v ; l- line lenght; v- signal speed. If line is not tuned up, then there are distortions in line because of reflections in line: If signal E(t) is step function: Then signal in line exit in discrete time moments will be: U(0) = p; U(t) = p*(1+pb) U(2t) = p*(1+pb+pa*pb) U(3t) = p*(1+pb+pa*pb+pa*pb^2); U(4t) = p*(1+pb+pa*pb+pa*pb^2+pa^2*pb^2); U(5t) = p*(1+pb+pa*pb+pa*pb^2+pa^2*pb^2+pa^2*pb^3) … where Depending on reflectance…

Continue reading

Flash vs. EEPROM

There are many questions about Flash and EEPTOM differences. Well these are two different technologies converging together. Flash technology was created to replace mass storage media. Requirements for Flash were minimum power consumption and high number of write cycles. Information written in flash memory is usually in blocks at a time. EEPROM was originally designed to store configuration information or store programs to be boot loaded by microcontrollers or other devices. EEPROMS usually are smaller capacities and can be programmed in smaller information quantities like bytes or bits (serially). Read time is shorter than from Flash but EEPROM has less write cycles. But recently these differences are disappearing as technologies are catching up. So this should explain why in microcontrollers like Atmega128 is more convenient to write data to EEPROM than to Flash. If you would like to store data in flash you would have to rewrite whole sector of…

Continue reading

Life-giving to Atmega8

I have got two atmegas from my friend. He stated that they are burned and can be thrown to garbage. He also mentioned that they stopped responding after they were programmed. So I asked him to give those to me to try them. I had in my mind, that this is a result of bad usage of security bits. There is always confusion in these bits, because security bits are programmed by writing ‘0’ values and unprogramed with ‘1’. I didn’t really expected to make them working again as my friend did quite rude experiments with them. What can I say – he was right by saying they are burned. Bu I guess some of you will like to see what I was doing in order to recover them. I decided that he unprogrammed all four security bits ( CKSEL0, CKSEL1, CKSEL2, CKSEL3 )by writing ‘1’ to them. This situation…

Continue reading