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 ever thermocouples have a drawback. It is because connecting thermocouple to circuit creates addition junctions between different metals who generate additional potentials. Generally speaking measuring thermocouple potential output is measuring not direct function of absolute temperature, but a difference between temperature at measurement point and temperature at the connection point.…

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 all; clc; [X,Y] = meshgrid(-100:1:100, -100:1:100); Z =3*exp(-((X.^2)/78000) -((Y.^2)/20000))-5*exp(-(((X+31).^2)/123) -(((Y+20).^2)/5000)); xx=100; yy=100; contour3(Z,20); hold on; % figure(2); mesh(Z); % figure % plot3(X,Y,Z) X=70; Y=100; X1=0;Y1=0; X0=X; Y0=Y; z=160; figure(1); plot(X,Y,’r*’), hold on; X=X-xx; Y=Y-yy; TT1 =3*exp(-((X.^2)/78000) -((Y.^2)/20000))-5*exp(-(((X+31).^2)/123) -(((Y+20).^2)/5053)); for i=1:50 z=z/2; X=X-z; Z2 =3*exp(-((X.^2)/78000) -((Y.^2)/20000))-5*exp(-(((X+31).^2)/123) -(((Y+20).^2)/5053)); if Z2>=TT1 TT=Z2; X1=X;…

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 coefficients and their signs distortions can differentiate or integrate: Real model using MathCAD was implemented to see how signal looks like on exit depending on parameters. Below you see used algorithm structure used in modeling: Algorithm Part 1 Algorithm Part 2 One of results using trapezoid signal: In exit we…

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 128 bytes in order to store one byte. But if you consider to store bigger information chunks Flash can be good choice too. For more information you might consider reading https://www.embedded.com/98/9801spec.htm

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 means that Atmega8 has to be clocked from external clock signal. I supposed to program those bits to work atmega normally with quartz resonator.

Continue reading

SkinSeg – segmentation of melanoma

SkinSeg is a simple tool used for skin lesion segmentation. This program was developed by Intelligent Systems laboratory students: L. Xu, M. Jackowski, A. Goshtasby, C. Yu, D. Roseman, S. Bines, A. Dhawan, A. Huntley. Their method is working similarly as in my earlier experiment with the MATLAB pigmented lesion boundary tracing algorithm. The first image is converted to intensity image, and then the lesion edges are detected. ant test results: The more informative description you can find here The program can be downloaded from here: https://www.cs.wright.edu/people/faculty/agoshtas/skinseg.zip  This version of the Skin Cancer Segmentation program (skinseg) runs on the Windows 95/NT platforms. Make sure all files reside in the same directory after extraction. No setup program is required to install skinseg on your machine. To run, execute the program skinseg.exe.

Continue reading