Unprofessional review of AVR simulators

I would like to go through AVR few Atmel AVR microcontroller software simulators. You can find many AVR simulators out there like simulavr, simulavrxx, avrora VMLAB, Proteus, AVRStudio… some of them are open source or freeware other commercial. I want to go through what I have tried and what I liked best. AVRStudio My list starts with AVR studio. This is not only as simulator, but the whole IDE for writing and debugging AVR applications. AVRStudio includes assembler and simulator. From AVR Studio 4 there is also plugin supported for GCC compiler. If you have WINAVR toolset installed in you computer, AVR studio automatically detects the GCC compiler and you can start developing AVR applications using C language in AVRStudio environment. Also you get ability to simulate C code and view microcontroller peripheral performance. The only external hardware I could spot is AVR LCD Visualizer. If you want to simulate some hardware like 24Cxx memories, UART, buttons. It is pretty hard to simulate them, because the only way to do this is by changing registry values in I/O view. AVRStudio is ideal tool for Assembly program development and debugging. AVRStudio is free to use. Proteus VSM This package (https://www.labcenter.co.uk) takes…

Continue reading

ADC on AVR using on chip comparator

Not all AVR microcontrollers come with built in ADC. But there is a way of building one using on chip comparator and timer counter. The comparator compares voltages on +v (Ain0) and -v (Ain1) inputs. If voltage in Ain0 pin is greater than in Ain1 then comparator ACO is set to ‘1’ otherwise it is ‘0’. Bellow you see AVR comparator circuit. The working of this ADC is as follows. First PB0 is set to ‘0’ in order to discharge capacitor. Then PB0 is programmed as input with no pull-ups and Timer is started to count. The capacitor starts charging to 5V through 10k resistor. When voltage on capacitor becomes greater than in input Vin, the comparator state switches to ‘1’. Program detects this and stops the timer counter and accumulated count is proportional to the input voltage Vin. So if Vin is greater, then timer counts more, and if Vin is less then timer counts less. Just one thing! The voltage on capacitor rises not linearly but exponentially. But if we restrict the input to the range of like 2.5V then this voltage raise can be considered as linear. In a example RC time constant is 1ms and capacitor…

Continue reading

Understanding Timing diagrams of digital systems

Timing diagrams are the main key in understanding digital systems. Timing diagrams explain digital circuitry functioning during time flow. Timing diagrams help to understand how digital circuits or sub circuits should work or fit in to larger circuit system. So learning how to read Timing diagrams may increase your work with digital systems and integrate them. Bellow is a list o most commonly used timing diagram fragments: Low level to supply voltage: Transition to low or high level: Bus signals – parallel signals transitioning from one level to other: High Impedance state: Bus signal with floating impedance: Conditional change of on signal depending on another signal transition: Transition on a signal causes state changes in a BUS: More than one transition causes changes in a BUS: Sequential transition – one signal transition causes another signal transition and second signal transition causes third signal transition. As you see timing diagrams together with digital circuit can completely describe the circuits working. To understand the timing diagrams, you should follow all symbols and transitions in timing diagrams. You can find plenty of symbols in timing diagrams. It depends actually on designer or circuit manufacturer. But once you understand the whole picture, you can…

Continue reading

Control motor PWM schematic

In general there are two ways to control DC motor speed: by varying supply voltage and pulse width modulation (PWM). First control method is not convenient especially in digital systems. It requires analog circuitry and so on. Second motor speed control method is very convenient for digital systems, because all control is made using only digital signals. As you already know PWM (Pulse Width Modulation) is all about switching speed and pulse width (duty cycle). Duty cycle is ratio of signal time ON/T. T is period of signal. In above diagram you see two signals. First duty cycle is about t1/T=1/3 and another’s duty cycle would be about t2/T=2/3. And notice the period of signals are the same. If we apply these signals to switching transistor we would get control over effective voltage across motor: Vefective=(tON/T)*Vcc; Where tON-signal on time over one period T. In this way you can control motor speed using microcontrollers PWM output or if you need you may use simple control motor PWM schematic constructed using IC555 timer circuit: Without going too deep in to 555 timer’s performance analysis I can mention that duty cycle can be changed using potentiometer RV1. The period of signal won’t…

Continue reading

Programming AVR fuse bits – oscillator settings

I guess many of you were confused when programming AVR fuse bits. I get many newbie questions like “I programmed Atmega8 but it doesn’t work”. Then my standard answer is: “Did you touch configuration bits?” and if yes, then I am almost 90% sure that he did it wrong. Most of them understands wrongly that programmed fuse bit in configuration should be left unchecked and opposite. Let’s take a look at widely used programming software – PonyProg. First thing you do before programming chip is set configuration bits (Atmega8 in picture): The first attention should be paid to clock sources. There are Four bits controlling Atmega8 clock sources: CKSEL0, CKSEL1, CKSEL2, CKSEL3.

Continue reading

Small note on how to start LCD in 4 bit mode

When LCD is working in 4 bit mode, then data has to be sent by nibbles – portions of 4 bits. Just remember that first goes high nibble then follows lower one. Each nibble has to be strobed with control signal E separately. Following list is describing how to start LCD in 4 bit mode: Wait for 15 ms after power is switched on; Write 00000011 (0x03) to LCD; Wait for 5 ms; Write 00000011 (0x03) to LCD; Wait for 160 us; Write 00000011 (0x03) to LCD; Wait for 160 us; Write 00000010 to enable 4 bit mode (after this command start sending in nibbles); Set interface length; Turn off display (0x00 and 0x08 nibbles); Write 00000001 (0x00 and 0x01 in nibbles) to clear display; Set cursor move direction by setting cursor bits; Enable display; After initialization is complete you may write any character or command to it.

Continue reading

Connect LCD to Atmega using 3 wires

After I implemented interfacing LCD to ATmega8 using 2 wires https://scienceprog.com/interfacing-lcd-to-atmega-using-two-wires/ I decided to make another one example but with 3 wires. Using 3 wires makes control much simpler as it is easier to control data flow to shift register. Here I used the same super cheap 74HC164 serial in parallel out register. LCD to shift register is connected in 8 bit mode. LCD strobe pin E is controlled with Atmega PC2 pin. Register is clocked with PC1 and data is transferred with PC0 pin. Notice, that I used same data line (PC0) to control LCD RS pin. RS pin is controlled in this way: after 8 bits are sent to shift register, then enable data line by setting ‘1’ (PC0) without clocking and after this LCD E pin is strobed. For more details take a look at my source code at the end of article. If there is any questions, don hesitate to ask. Source code:3 Wire LCD interface to ATMEGA

Continue reading