Archives for 

microcontroller

What is the Minimum System on the Microcontroller?

avr minimal circuit

avr minimal circuit

The minimum system circuit of a microcontroller is a series of minimal so the microcontroller can work.

ATmegga AVR chip is equipped with an internal oscillator and thus no need external crystal for CPU clock source in order to save costs.

AVR microcontroller minimum system is very simple, just connect the VCC and AVCC to the DC +5V power supply voltage. Then GND and AGND with the ground. No need an additional crystal and reset pin is not connected to anything. With this circuit, AVR microcontroller has been able to work normally, but you can not reset the microcontroller manually. If you want to activate the reset pin with a button to trigger it, then connect the reset pin on your microcontroller with pull circuit made up of a 10k resistor and capacitor 10uF.

This circuit works for all AVR microcontroller family as ATMega8535, ATMega8, ATmega32, ATmega16 and others.

If you want to use larger crystals from 8MHz to your microcontroller circuit, then you can use an external crystal. You can see a more complete circuit on this page or this one.

Atmega8 Datasheet and the Explanation of The Input Output Pin Features

atmega8 microcontroller pin features

atmega8 microcontroller pin features

In this article described the hardware features of the AVR ATMega atmega 8 that is devoted to the type of PDIP, so for other types (QFN / MLF, TQPF) please refer to the specific datasheet only.

In addition to functioning as an input/output pins, a pin on AVR microcontroller can concurrently as other functions. For example at the AVR ATMega 8 microcontroller, PORTD.2 is an input / output pins, but this pin can also function as a trigger channel “external interrupt 0”. For more details, please follow the following explanation:

Description pin features on ATMega 8:

-VCC: supply voltage Microcontroller
-Ground: Ground

– Port B is a port i / o 8bit with internal pull-up resistors on each pin.
– Buffer on port B AVR ATMega8 have the capacity to absorb (sink) and distribute (sorce)
– Lodging in PB.6 can be used as a crystal input (inverting oscillator amplifier) and input to the internal clock circuit depends on the setting of fuse bits (currently set software downloader / programmer) is used as a clock source.
– Especially for PB.7 port can be used as a crystal output (inverting oscillator amplifier output) depends upon the setting of fuse bits are used to select the clock source.

– If the clock source is the internal oscillator (internal clock, then PB6 and PB7 pin can be used as input / output (I / O pin) or if using Asyncronousu Timer / Counter2 then PB6 and PB7 (TOSC2 and TOSC1) used for counter input channels.

– PORTC.0 – PORTC.5 are input / output ports with internal pull-up resistor for each pin. Buffer in this PORT has the capacity to absorb (sink) and distribute (sorce). In addition, the PORTC in atmega8 microcontroller can function as port ADC (analog to digital converter).

– Reset / PORTC.6, is a pin that can function as a reset pin on the microcontroller program cycle. By way RSTDISBL fuse bit set as “unprogramed” and will be active when it gets a signal “low”. But if RSTDISBL set as “programed” then portC.6 will be used as input / usual output pins.

-PORTD.0 – PORTD.7 are input / output ports with internal pull-up resistor for each pin. Buffer Portc have the capacity to absorb (sink) and distribute (sorce).
– AVCC is the supply voltage pin for the analog to digital converter (ADC). Note: PORTC.5 and PORTC.6 using digital VCC supply voltage.
– Aref is an analog reference voltage pin for ADC

AVR Microcontroller Architecture

avr architecture

avr architecture

AVR microcontroller has some parts that are divided into:

  • ALU (Arithmetic Logic Unit) is a processor for executing the program code that is appointed by the counter program.

  • Program memory is a flash memory to store programs in the form of a memory address and program code in the memory address.
  • Program Counter (PC) is a component to show the address of the program memory. So that ALU can make the execution of programs that exist in the address.

  • General Purpose Working Registers (GPR) is a register that has 8-bit space. GPR will execute program code each instruction in the ALU involving GPR.
  • Static Random Access Memory (SRAM) is RAM that hold the temporarily data. SRAM also has a memory address of the usual RAM. Last address of an SRAM depends on the capacity of SRAM and is already defined in the header file with the name RAMEND. So, to make the stack (the last address of SRAM) we can use RAMEND.

  • Internal pheripheral is an internal module in a microcontroller such as channel input / output, external interrupts, timers / counters, USART, EEPROM, and others. Each of these modules have internal port registers which control the internal module.

**) Pict from mouser,com

AVR ATMega8 Schematic Circuit with Eagle Software

avr-atmega8-minimum-system-schematic-circuit

avr-atmega8-minimum-system-schematic-circuit

ATMega8 Schematic Circuit (Minimum system) is a support circuit for the microcontroller.

Without this support circuit, the microcontroller will not be able to work.

Minimum system for microcontrollers consist of several components. The components are : crystal, capacitors, and the reset circuit (consisting of resistors and capacitors).

And the crystal must be combined by two capacitors. The capacity of this capacitor should be in accordance with the AVR ATMega8 datasheet.

RESET pin on AVR ATMega8 must be pull up with a 4K7 ohm resistor and stabilized with ‘100nF capacitors’.

You have to make the pin as a downloader port. pin of the downloader port must meet a standard sequence. The pin sequence is: MOSI, MISO, SCK, RESET, GROUND.

This AVR ATMega8 schematic is made with the EAGLE software.

SG90 Tower Pro Servo Datasheet

servo-for-arduino-sg90-tower-pro

servo-for-arduino-sg90-tower-pro

One type of electric motor is a servo. Servo motor is used to make mechanical robotic or automated devices. Servo work based on the frequency signal from the controller (such as a microcontroller or arduino).

SG90 Tower Pro servo motor can also be controlled by a ruspberry pi.

You can plug this SG90 Tower Pro Servo straight onto the raspberry pi GPIO pins 4,6,8 without some extra wires. Pin 8 on the raspberry pi is normally the UART Tx pin, so your SG90 Tower Pro servo will not work properly if you connect it without disabling the UART before running the main program, You can search the instructions for how to disabling the UART on pin 8 from google.

sg90 tower pro servo cable pin

sg90 tower pro servo cable pin

Each servo motor cables have different pin configurations. Tower Pro SG90 servo has a three-pin cable. Red cable is wired VCC. Black/brown cable is a ground cable. While the orange cable is a signal cable.

You can find the SG90 Tower Pro servo tutorial and arduino uno source code here.

ATMega8535 Schematic Diagram

avr-atmega8535-minimum-system-schematic-circuit

avr-atmega8535-minimum-system-schematic-circuit

AVR ATMega8535 is a very popular microcontroller.

In the recent years, ATMega8535 has been displaced by the other microcontroller with a more complete feature like ATMega32, ATMega16 or ATMega128. Even, when Arduino offers ease (in the used and programming), the conventional Microcontroller becoming obsolete.

However, some users are still loyal to use the conventional microcontroller. And if you want to learn about the basics of the microcontroller, then you have to learn from the conventional microcontroller. You have to create an electronic circuit by yourself. And you have to find out all about the components used. After you finish creating the electronic circuits, then you will understand how the microcontroller’s minimum system so that it able works. And you will understand how a microcontroller work,  before you start programming it.

Like other microcontroller, we need some electronic components so that it able to work.

Crystal,some resistor and capacitor for the clock and the reset button. And don’t forget to provide the supply (VCC and GND) on the microcontroller board. You can make the ATMega8535 schematic diagram with the EAGLE software like the exsample above.

RS232 with MAX232 Schematics and Tutorial

RS232 is a serial communication standard that is used to connect peripherals to the peripherals. Also called the Path I / O (input / output).

The best example we often encounter is a connection between a computer with a modem, or a computer with a mouse can even also between the computer and the computer are all normally connected via the RS232 serial port. This standard uses several tools in its implementation. The most commonly used is a plug / connector DB9 or DB25. For RS232 with DB9 connector, typically used for mouse, modem, cashier registers, etc., while the DB25 connector, typically used for joystick games.

RS232 standards set by the Electronic Industry Association and Telecommunications Industry Association in 1962. 

The function of the serial RS232 port is for connecting / connections from one device to another device, or equipment standards concerning the communication of data between computers by means of computer peripherals. That other devices such as modem, mouse, cash registers and so forth. Serial RS232 port on a DB9 connector has a pin 9 units and the DB25 connector has a pin 25 pieces.

RS232 was made in 1962, long before the popular TTL IC, therefore the voltage level specified for RS232 has nothing to do with TTL voltage levels, and even can be said to be much different. TTL Serial communications work at a voltage of 5V to + 5V RS232 serial communication while working at a voltage of + 25V to -25V.

All microcontroller using TTL serial communications topologies. While some devices using RS232 serial topology. Therefore, you must create a device for connecting two different topologies so that both can communicate.

rs232 schematics tutorial with max232

rs232 schematics tutorial with max232

The circuit above is a TTL into RS232 serial converter or RS232 into TTL serial converter. So that the circuit can connect a microcontroller with RS232 devices such as modems or other devices. You can create a series of mini-RS232 converter IC MAX232 and some capacitors 1uF as shown following circuit. As an interface port, you can use a DB9 connector or just a pin header.

rs232-board-and-schematics-tutorial-with-max232

rs232-board-and-schematics-tutorial-with-max232

USBasp AVR Microcontroller Downloader Schematics

avr-microcontroller-schematics-downloader

avr-microcontroller-schematics-downloader

This USBasp downloader can be used on the AVR microcontroller families such as ATMega8, ATmega16, ATMega8535, ATmega32, ATmega128 and much more. Based on Atmega8 (or can also be used ATMega88) and some additional components.

USB connector as the interface with a computer and five pins as an interface with a microcontroller. The USBasp’s hardware is very easy to make. Once you finish making the hardware, you should fill the ATMega8’s memory with two firmware program that will be filled in eeprom microcontroller ATmega8.

After that, USBasp downloader has been ready for use. To download the program, you must compile into .hex file using BASCOM AVR or CAVR.

And you can transfer files with the .hex downloader software like avrdude, USBasp, khazama, PonyProg or other programs.

avr microcontroller BOARD schematics downloader

avr microcontroller BOARD schematics downloader

Source Code for Arduino Servo Control

tower-pro-sg90-servo-and-arduino-uno-wiring-cable-tutorial

tower-pro-sg90-servo-and-arduino-uno-wiring-cable-tutorial

Servo is one type of motor controlled by a frequency signal. However, some types of servo have different ways to control it. Because each type of servo have different degrees of movement.

For example, I use a servo Tower Pro SG90 and controlled using the Arduino UNO. Servo Tower Pro SG90 this has the following specifications (or you can read here for more details):

Tiny and lightweight with high output power. Servo can rotate approximately 180 degrees (90 in each direction), and works just like the standard kinds but smaller. You can use any servo code, hardware or library to control these servos. Good for beginners who want to make stuff move without building a motor controller with feedback & gear box, especially since it will fit in small places. It comes with a 3 horns (arms) and hardware.

Tower Pro SG90 Specifications :
Weight: 9 g
Dimension: 22.2 x 11.8 x 31 mm approx.
Stall torque: 1.8 kgf·cm
Operating speed: 0.1 s/60 degree
Operating voltage: 4.8 V (~5V)
Dead band width: 10 μs
Temperature range: 0 °C – 55 °C

 

Tower Pro SG90 Servo characteristic : Position “0” (1.5 ms pulse) is middle, “90” (~2 ms pulse) is all the way to the right, “-90” (~1ms pulse) is all the way to the left.

This is the Arduino Source Code for the Sweep Mode Servo :

#include <Servo.h>

Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created

int pos = 0; // variable to store the servo position

void setup()
{
myservo.attach(2); // attaches the servo on pin 2 to the servo object
}

void loop()
{
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}
}

Arduino Nano Datasheet and Tutorial

arduino-nano-configuration

arduino-nano-configuration

Arduino Nano is a function module which is very small but has a lot of advantages. The shape is very small so it is suitable to make a project that looks small. Arduino Nano is very special because of this support with breadboards. You can plug arduino and other electronic components in one breadborad. In the Arduino Nano 2.x version, still used avr ATmega168 microcontroller while the Arduino Nano 3.x version already used avr ATmega328 microcontroller.

arduino nano tutorial

arduino nano tutorial

Arduino Nano has features and functions similar to arduino Duemilanove. But Arduino Nano in different packaging. Arduino nano does not have a DC jack so that its power supplied through mini-B USB port or directly connect to the VCC pin and GND. Arduino Nano can be supplied with a voltage of 6-20V power source via USB mini-B port. Or you can provide a voltage of 5V on pin 30 (this voltage will not be adjusted by the regulator, so make sure you provide 5V voltage)

arduino nano pin configuration

arduino nano pin configuration

Arduino Nano Specifications:

MicrocontrollerAtmel ATmega168 or ATmega328
Operating Voltage (logic level)5 V
Input Voltage (recommended)7-12 V
Input Voltage (limits)6-20 V
Digital I/O Pins14 (of which 6 provide PWM output)
Analog Input Pins8
DC Current per I/O Pin40 mA
Flash Memory16 KB (ATmega168) or 32 KB (ATmega328) of which 2 KB used by bootloader
SRAM1 KB (ATmega168) or 2 KB (ATmega328)
EEPROM512 bytes (ATmega168) or 1 KB (ATmega328)
Clock Speed16 MHz
Dimensions0.73″ x 1.70″
Length45 mm
Width18 mm
Weigth5 g

 

 

arduino nano datasheet

arduino nano datasheet

In some cases, Arduino Nano has features that are more complete than arduino uno. Arduino Nano has 8 channel ADC (Analog to Digital Converter) while the Arduino Uno only has 6 channels. Through the RX and TX pins you can communicate serially with other devices. According datasheet ATmega328 AVR microcontroller, Arduino Nano has 2 pin interrupt, namely int0 and int1.

arduino nano pin input output configuration

arduino nano pin input output configuration

Overall, Arduino nano has 30 pins. The 8 pin of them (19-26 pin) are Analog pins (ADC). While the other 14 pins are Digital pins (Please see the picture above to see the position of digital and analog pins).

arduino nano connected to computer

arduino nano connected to computer

You have to write the source code for arduino nano on Arduino IDE sofftware. Then, you can download the program on an Arduino Nano using a USB-B cable.