DC Motor Control with Microcontroller ATmega8535

  • Sabtu, 31 Juli 2010
  • Posted by Learn Electronic

At mega 8535 microcontroller can use control dc motor that is on pin d where there have PWM control. DC motor can rotate because of the induction when the motor is connected to the DC voltage source. DC motor control with microcontroller if it is done more easily than without the microcontroller. We can change the direction of rotation of DC motor directly by changing the polarity of the voltage source. To change the speed of DC motors can be done by changing the size of a fox-voltage source. Control with a microcontroller as well as principled, but with an automated system. We do not have to change the cable from the motor to the battery if you want to change the direction of rotation, we just provide the logic 0 or 1 to the microcontroller is performed on the program in the microcontroller. To change the velocity is also easier because we simply use the existing PWM feature on the microcontroller. Maybe there are still many who do not know what PWM

PWM (Pulse Width Modulation) is a technique to get the effect of the analog signal from a digital signal to falter. PWM can be generated using only digital i / o which functioned as an output.


 In the example above the waves, the comparison between high signal (1) and low signal (0th) is the same. Above the wave is said to have 50% duty cycle. Duty cycle is the ratio between the width of high signal (1) the overall width of the cycle (cycle). If the PWM wave amplitude is 5 volts, then the average stress (as if to analog) that we get is 2.5 volts. Here's an example of wave PWM with duty cycle 10%, if the amplitude of wave 5 volts then we will get the average analog voltage 0.5 volts.


In  ATMEGA8535 have two way control PWM, the PWM can be generated from the first port input / output is enabled as output. The second is to utilize the facilities of the function of the PWM timer / counter which has been provided. With this facility, the timing of the process of high / low digital signal will not disrupt the sequence of other programs being executed by the processor. In addition, by using this facility to enter how many servings we lived on and off time period on a wave PWM registers. OCR1A, OCR1B and OCR2 is register a place set PWM duty cycle.
 
The following schematic DC Motor Control with Microcontroller ATmega8535 of my own, please trace itself, or if you want to please make my request in the comments section below ini. Click image to enlarge......


I separate the circuit into three main sections so that it is easy to understand and analyze our series, namely the minimum system, motor drivers, and motors (as a major expense). The minimum system the same as in my previous posting, the next part of the driver. in fact we can directly connect the microcontroller to the motor without a driver, this can be done if the motor that we use a small motor. we need a big motor for the drivers, these drivers can be made also with the MOSFET (often called the H-Bridge), we can use a more practical ie L298 driver ic, ni ijenis drivers able to control two motorcycles and also features the legs to control the PWM .
For our experiment we only use a single dc motor alone, here are photos from the series that I created.



For the program you can see below. Use the AVR Studio software (after AVR studio also install WinAVR is installed so that it AVRstudio supports the C language, because the standard AVRstudio using assembly language). To download your program can use the USB downloader downloader atapun series which has also been my post. The following program


#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>

#define    DDR_motor    DDRD    //DDR untuk Motor
#define    PORT_motor    PORTD    //PORT untuk Motor

#define en_ka         5        // Enable L298 untuk motor kanan
#define dirA_ka     2        // Direction A untuk motor kanan
#define dirB_ka     3        // Direction B untuk motor kanan
#define pwm_kanan    OCR1A

void delay_ms(int ms)
{for (int i=0;i<ms;i++){_delay_ms(1);}}

void maju(unsigned int pwm)
{
PORT_motor |=(1<<dirA_ka);        //motor maju
PORT_motor &=~(1<<dirB_ka);
pwm_kanan=pwm;                    //pwm motor kanan
}

void mundur(unsigned int pwm)
{
PORT_motor |=(1<<dirB_ka);        //motor maju
PORT_motor &=~(1<<dirA_ka);
pwm_kanan=pwm;                    //pwm motor kanan
}


int main (void)
{

DDR_motor=0xFF;
PORT_motor=0x00;


    TCCR1A= (1<<WGM11)|(1<<WGM10)|
            (1<<COM1A1)|(0<<COM1A0)|
            (1<<COM1B1)|(0<<COM1B0);
           
    TCCR1B= (0<<WGM13)|(1<<WGM12)|
            (0<<CS12)|(0<<CS11)|(1<<CS10);
    TCNT1=0x0000;
    OCR1A=0;
    OCR1B=0;
    sei( );


while(1)
{
mundur(1000);
delay_ms(5000);
maju(700);
delay_ms(3000);

}
}

see the main program, with a PWM motor will resign in 1000 over 5000ms (5 seconds) and then will forward denan PWM motor 700 for 3000ms (3 seconds). and the program will be repeated a maximum of motor-ulang.Kecepatan happen if we gave in 1000 and the minimum PWM value (motor stopped) if the PWM value of 0, see the main program, which is backward (1000) that mean the motor will spin backwards at top speed because the PWM is 1000
READ MORE - DC Motor Control with Microcontroller ATmega8535

PonyProg, serial device programmer

  • Selasa, 20 Juli 2010
  • Posted by Learn Electronic

If you are looking for a simple but powerful programmer you are right, it's here.
PonyProg is a serial device programmer software with a user friendly GUI framework available for Windows95/98/ME/NT/2000/XP and Intel Linux. Its purpose is reading and writing every serial device. At the moment it supports I²C Bus, Microwire, SPI eeprom, the Atmel AVR and Microchip PIC micro.
SI-Prog is the programmer hardware interface for PonyProg.
With PonyProg and SI-Prog you can program Wafercard for SAT, eeprom within GSM, TV or CAR-RADIO. Furthermore it can be used as a low cost starter kit for PIC and AVR. 

PonyProg works also with other simple hardware interfaces like AVR ISP (STK200/300), JDM/Ludipipo, EasyI2C and DT-006 AVR (by Dontronics).

0diggsdigg
PonyProg is a great software for flash memory programming. It supports a great variety of microcontrollers and other devices. Before using it you should check if your device is supported on the Official PonyProg 2000 Homepage. PonyProg 2000 is constantly updated and new devices are added.
The latest version is available on the Download Page.


So After you download and install it, you have to configure it for your hardware.
Go to   >> "Setup" >> "Interface Setup" 



Click on “Serial” if you are using AVR Serial port Flash programmer or “Parallel” if you are using AVR Parallel port Flash programmer. Next select “SI Prog I/O” (in case of serial) or “AVR ISP I/O” (in case of parallel).
Now click on “Probe” to check if your hardware is connected and working. If it says “Test Passed” it means your hardware is working with the configuration. If it says “Test Failed”, it means there is a fault in above configuration or your hardware.
Now click “OK”.
Then go to     >> “Setup” >> ”Calibration”. Click “Yes” on the next message box and wait for the “Calibration OK” confirmation.


Now Select “AVR micro” from the list of devices and select your AVR device from the next drop box.


Now load your hex file from the “Open Program Flash Memory File” button (1).

Then program the microcontroller by pressing the “Write Program Memory” button (2).

The Fuse bits of AVR microcontroller can be read and set by pressing the button with the lock (3).



Update: Its not always a good idea to use the latest version of PonyProg. I once updated from an older version and it started giving me "test failed" errors. So I went back to the older version and began working again. Latest versions are sometimes buggy so you should wait a while before updating.

If anybody wants any help with this stuff, just drop a comment or "Contact me". I'll be happy to help.
READ MORE - PonyProg, serial device programmer

Programming LCD AVR ATmega8535

  • Posted by Learn Electronic

This is an example programming C for interfacing microcontroler to LCD at AVR ATmega8535

#include
// Alphanumeric LCD Module functions
#asm
.equ_lcd_port=0x15 ;PORTC
#endasm
#include
//Declare your global variables here
Void main(void)
{
//Declare your local variables here
// Input/Output Ports initialization
// Port A initialization
// Func7=On Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTA=0x00;
DDRA=0x00;
// Port B initialization
// Func7=On Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTB=0x00;
DDRB=0x00;
// Port C initialization
// Func7=On Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTC=0x00;
DDRC=0x00;
// Port D initialization
// Func7=On Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0x00;
DDRD=0x00;
// Timer/Counter 0 Initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=FFh
// OC0 output: Disconnected
TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;
// Timer/Counter 1 Initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
// Timer/Counter 2 Initialization
// Clock source: System Clock
// Clock value: Timer 2 Stopped
// Mode: Normal top=FFh
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
MCUCR=0x00;
MCUCSR=0x00;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;
LCD module initialization
lcd_init(16); //initialization LCD
lcd_gotoxy(0,0); //locate position in 0,0
//columns 0, lines 0
lcd_puts(“Hallo…”); //display string Hallo…
lcd_gotoxy(0,1); //locate position
//columns 0, lines 1
lcd_putsf(“My name is Rico”); //display string
while (1)
{
// Place your code here
};
}
READ MORE - Programming LCD AVR ATmega8535

USB Downloader for AVR microcontroler (ATMega 8535,16,32)

  • Posted by Learn Electronic

 For programming the AVR microcontrollers, Atmel has provided special software that can be downloaded from the Atmel website. Software is AVRStudio. This software uses assembly language as the language of instrumentality. AVRStudio addition, there are some third party software that can be used to create programs on the AVR. These third-party software using high level programming language like C, Java, or Basic. To make removal from the computer into a chip, can be used several ways such as using JTAG cable or using artificial Atmel STK.

However, you also can use the schematic circuit above to make a downloader ATMega microcontrollers based USB ports. Here is my USB downloader which I successfully created. Imade the USB ASP Downloader based ATMega8. hopefully can help you.


READ MORE - USB Downloader for AVR microcontroler (ATMega 8535,16,32)

AVR Setup Programming your chip

  • Posted by Learn Electronic

What is a program?
When code is compiled into a windows program, its turned into "binary" which means its not human-readable (which is tough for machines to understand), instead it is machine-readable. Under windows, these programs (often called applications or executables) are often named ending with .exe (for example notepad.exe or winword.exe), on Macs, they are often named ending with .App (although the Finder hides it).
For microcontrollers, binary files end in .hex (short for Intel Hex Format) There are other formats possible, but this is pretty much standard.
Your compiler will generate a .hex file from code, and then all you have to do is transfer that .hex program to the chip!
What is flash?
As discussed in What is it?, the AVR chip has a small amount of flash memory in it. That memory is where the program is stored. When the chip starts up (you give it power) it starts running whatever program is in the flash. So all we have to do is figure out how to write to that flash
A good way to think about flash is to examine it as you probably are familiar with it. Flash storage is also used in MMC/SD cards, which are commonly used in MP3 players or digital cameras. If you look at the bottom of a card, you'll see little gold fingers. These are the interface pads.

If you look up in the MMC card specification, you'll find out that these are what the 7 pins are for. (SD/high speed cards may have extra pads, but that standard was added later because the existing standard was considered too slow for big megapixel cameras)
Pin # Pin Name Pin Function
1 #CS Chip Select (Activate)
2 SI Serial In
3 GND Ground
4 VCC Power
5 SCK
Data Clock
6 Not connected Not connected
7
SO
Serial Out
The power and ground pins are used to connect power to the chip. The Chip Select pin is used to tell the chip that it should wake up, Serial In pin is used to send data to the card, Serial Out is how data is sent from the card and Data Clock is how we tell the card how fast we want data to be stored or retrieved. Data is pushed in an out of the chip one bit at a time, so if the clock rate is 100KHz that means that 100,000 bits are transferred per second.
When you want to retreive or store data on a flash card all you have to do is stick the card into a flash card reader. The reader then has a driver on your computer which lets you simply drag files onto a picture on your screen and it does all the hard work of sending the data to the card.
OK, so what does this have to do with a programmer? Well, the microcontroller is like the flash card and the card reader is like the programmer. When you stick the chip into the programmer (or, more likely, the programmer cable into the circuit board that contains the chips) it allows the software on your computer to talk to the chip through the programmer. Usually you can just give a simple command like 'send this program over' and the programmer will do all the hard work of programming and verifying the data
In-System Programming interface
Every AVR has a set of pins that are the programming pins, you just have to connect the programmer to those pins in the right order and presto you are ready to program it. Unfortunately, nearly every chip has a different pinout so its imperative that you look in the datasheet for the correct pins.
For example, I'm a big fan of the ATtiny2313 chip, so lets open up the 'summary' datasheet (its only a dozen pages long instead of the standard 250. The first page has all sorts of information about what is in the chip.
Quick Quiz : How much EEPROM does the chip have? How about flash storage? RAM?
The second page has pinouts. We will be dealing with the PDIP package (Plastic Dual In-line Package) which is the kind that looks like this:
The pinout is reproduced here
The chip has 20 pins. Look carefully and you'll notice 6 of these pins are equivalent to the SD/MMC card pins. There is a power pin (VCC) and a ground pin (GND), there is also an SCK pin (its called UCSK for some reason) a Serial Out pin (MISO - Master In Serial Out ) and a Serial In pin (MOSI - Master Out Serial In). The only thing is doesnt have is a /ChipSelect pin. Instead it has a /RESET pin, which acts in a similar way. When the /RESET pin is at a postive voltage (the same voltage as VCC) the chip runs the program, when the /RESET pin is at ground (the same voltage as GND) then the chip stops and listens for programming instructions on the programming pins.
All SD cards have the same fingers in the same place so that when you slide it into the card reader, the right pads are connected. AVR programming works in a similar way. Instead of pads, the chip is often placed in a circuit board which has header pins that the progammer plugs into, the header pinout is standardized so that any programmer can be used once the header is wired up correctly.
There are two standards for AVR in-system programming:
The left is the 6-pin header standard, the right is the 10 pin standard, the headers look like this:
Here is an example photo showing what it looks like when the chip is wired up with a 6-pin header
The black mark on the PCB and header indicate pin #1. You can trace the wires to correllate the pins of the chip to the pins of the header and verify for your self that this breadboard is correct.
READ MORE - AVR Setup Programming your chip

Robot info

  • Posted by Learn Electronic

FIRST Robotics began in 1989 as a way of encouraging students to choose careers in math, science and technology, while also building their life skills and instilling a spirit of "gracious professionalism" and humility in its participants. Without "chest thumping" or "sticky-sweet platitudes," as the site explains, young people engage in competitions where they build robots.

The Junior FIRST LEGO league is for 6-9 year olds. The FIRST LEGO league targets younger children ages 9-14, while the FIRST Robotics Competition helps high school age students. The FIRST Tech Challenge provides more affordable robotics technology to high school students. More than 137,000 kids participated in last year's program, spanning across 42 countries from Germany and the UK to Turkey and Israel.FIRST Robotics founder Dean Kamen is an inventor, physicist, engineer and entrepreneur. He is perhaps best known for inventing the Segway Human Transporter, an environmentally friendly short distance travel solution. He's also developed the HomeChoice portable dialysis machine (Baxter Healthcare) and the Independence IBOT 4000 mobile robot system (Johnson & Johnson).

He's currently working on a water purification system that promises to provide clean drinking water to 1.1 billion people around the world. For his efforts, he's received the Heinz Award in Technology, the National Medal of Technology presented by President Clinton (2000) and the Lemelson-MIT Prize (2002), among others.

For 2009, the FIRST Robotics Competition will be called "Lunacy" to celebrate the 40th anniversary of our moon landing and will be held in Atlanta April 16-18. This year's autonomous robots will be restricted by size and weight (no more than 5 ft tall, no wider than 38 inches, no deeper than 28 inches and no heavier than 150 lbs) and must be able to pick up orbit balls (2-point moon rocks, empty cells and 15-point super cells) and transfer them into a trailer hitched to their opponent's robot in just two minutes and fifteen seconds.

While 80-90% of the teams participating this year will be returning from previous years, there are 300 rookie teams joining as well. Of course, even given the charitable contributions, each team will likely need to come up with $9,000 - $10,000 to cover meals, transportation, lodging, food, robot parts and lab fees.


The Baby Boomers grew up fascinated by the Space Race and the emergence of heroic astronauts as role models. Today's youth are more into computers. Even so, television shows like "Mythbusters," "Build It Bigger" and battling robot competitions are trying to intrigue young people to look to physics, engineering and technology. 
READ MORE - Robot info

Robot In Our Life

  • Posted by Learn Electronic

What is a robot?
 There’s no precise definition, but by general agreement a robot is a programmable machine that imitates the actions or appearance of an intelligent creature–usually a human. To qualify as a robot, a machine has to be able to do two things: 1) get information from its surroundings, and 2) do something physical–such as move or manipulate objects.

The word robot comes from the Czech word robota, meaning drudgery or slave-like labor. It was first used to describe fabricated workers in a fictional 1920s play by Czech author Karel Capek called Rossum’s Universal Robots. In the story, a scientist invents robots to help people by performing simple, repetitive tasks. However, once the robots are used to fight wars, they turn on their human owners and take over the world.

If you think robots are mainly the stuff of space movies, think again. Right now, all over the world, robots are on the move. They’re painting cars at Ford plants, assembling Milano cookies for Pepperidge Farms, walking into live volcanoes, driving trains in Paris, and defusing bombs in Northern Ireland. As they grow tougher, nimbler, and smarter, today’s robots are doing more and more things we can’t –or don’t want to–do.
Robots have been with us for less than 50 years, but the idea of inanimate creations to do our bidding is much, much older. The ancient Greek poet Homer described maidens of gold, metallic helpers for the Hephaistos, the Greek god of the forge. The golems of medieval Jewish legend were robot-like servants made of clay, brought to life by a spoken charm. Leonardo da Vinci drew plans for a mechanical man in 1495.
But real robots wouldn’t become possible until the 1950’s and 60’s, with the invention of transistors and integrated circuits. Compact, reliable electronics and a growing computer industry added brains to the brawn of already existing machines. In 1959, researchers demonstrated the possibility of robotic manufacturing when they unveiled a computer-controlled milling machine. Its first product: ashtrays.

Public fascination with robotics peaked in the early 1980’s, spurred in part by movies like Star Wars, which featured robots C3-PO and R2-D2 as helpful sidekicks to the their human masters. But interest sagged in a few short years as people discovered that getting robots to do things that we think of as easy–like moving across a cluttered room–is surprisingly difficult.
Today, robots are enjoying a resurgence. As computer processors are getting faster and cheaper, robots can afford to get smarter. Meanwhile, researchers are working on ways to help robots move and "think" more efficiently. Although most robots in use today are designed for specific tasks, the goal is to someday make universal robots, robots that are flexible enough to do just about anything a human does–and more.

Just name a boring or dangerous job; somewhere, a robot is probably doing it.  As mechanical workers, robots are ideal for jobs requiring repetitive, precise movements. Human workers need a comfortable working environment, salaries, coffee breaks, sleep, and vacations. Robots don’t. Human workers get bored doing the same thing over and over, boredom that leads to fatigue and costly mistakes. Robots don’t get bored.
Ninety percent of robots work in factories, and more than half are at work making automobiles. Car factories are so highly automated that most of the human workers are there mainly to supervise or maintain the robots and other machines. Robots assemble car body panels and weld them together, finish and paint the car bodies, and stack and move partially completed cars. 

Another example of a factory job done by robots is arranging chocolates in boxed assortments. Guided by a computer vision system, a robotic arm can locate a piece of chocolate on a moving conveyer belt, gently pick it up and turn it to the proper orientation, then deposit it in a specific location within a box on another moving conveyer belt. Sure, it’s a task that almost anyone could do. . .but could you do it 20,000 times over the course of an eight-hour shift?

 Robots are being put to a wider variety of manufacturing uses each day. In the computer industry, robots solder tiny wires to semiconductor chips. "Pick and place" robots insert integrated circuits onto printed circuit boards; these are used in all kinds of electronics, from radios to microwaves. Robots are also at work making and packaging drugs, textiles, and foods.
Certain dangerous jobs are best done by robots. Bomb disposal is one of these. Guided remotely using video cameras, robots like the Mini-Andros can be sent to investigate–and defuse–possible bombs. (See sidebar.)
Robots also venture into dangerously polluted environments, such as chemical spills and radioactive "hot zones" in nuclear power plants. Robug III is a spider-like robot specially designed to explore areas where extreme radiation would quickly kill a human. The need for a robot like Robug III was made clear during the Chernobyl accident in 1986. An explosion and fire ripped apart a nuclear reactor and released dangerous radioactive material into the air, making rescue and containment work nearly impossible.


READ MORE - Robot In Our Life

History Of Microcontroller

  • Posted by Learn Electronic

A microcontroller (sometimes abbreviated µC or uC) is a small computer on a single integrated circuit containing a processor core, memory, and programmable input/output peripherals. Program memory in the form of NOR flash or OTP ROM is also often included on chip, as well as a typically small amount of RAM. Microcontrollers are designed for embedded applications, in contrast to the microprocessors used in personal computers or other general purpose applications.

Microcontrollers are used in automatically controlled products and devices, such as automobile engine control systems, implantable medical devices, remote controls, office machines, appliances, power tools, and toys. By reducing the size and cost compared to a design that uses a separate microprocessor, memory, and input/output devices, microcontrollers make it economical to digitally control even more devices and processes. Mixed signal microcontrollers are common, integrating analog components needed to control non-digital electronic systems.

Some microcontrollers may use four-bit words and operate at clock rate frequencies as low as 4 kHz, for low power consumption (milliwatts or microwatts). They will generally have the ability to retain functionality while waiting for an event such as a button press or other interrupt; power consumption while sleeping (CPU clock and most peripherals off) may be just nanowatts, making many of them well suited for long lasting battery applications. Other microcontrollers may serve performance-critical roles, where they may need to act more like a digital signal processor (DSP), with higher clock speeds and power consumption.

Embedded design

A microcontroller can be considered a self-contained system with a processor, memory and peripherals and can be used as an embedded system.The majority of microcontrollers in use today are embedded in other machinery, such as automobiles, telephones, appliances, and peripherals for computer systems. These are called embedded systems. While some embedded systems are very sophisticated, many have minimal requirements for memory and program length, with no operating system, and low software complexity. Typical input and output devices include switches, relays, solenoids, LEDs, small or custom LCD displays, radio frequency devices, and sensors for data such as temperature, humidity, light level etc. Embedded systems usually have no keyboard, screen, disks, printers, or other recognizable I/O devices of a personal computer, and may lack human interaction devices of any kind. 
 
Interrupts 
 
Microcontrollers must provide real time (predictable, though not necessarily fast) response to events in the embedded system they are controlling. When certain events occur, an interrupt system can signal the processor to suspend processing the current instruction sequence and to begin an interrupt service routine (ISR, or "interrupt handler"). The ISR will perform any processing required based on the source of the interrupt before returning to the original instruction sequence. Possible interrupt sources are device dependent, and often include events such as an internal timer overflow, completing an analog to digital conversion, a logic level change on an input such as from a button being pressed, and data received on a communication link. Where power consumption is important as in battery operated devices, interrupts may also wake a microcontroller from a low power sleep state where the processor is halted until required to do something by a peripheral event.

Programs

Microcontroller programs must fit in the available on-chip program memory, since it would be costly to provide a system with external, expandable, memory. Compilers and assemblers are used to turn high-level language and assembler language codes into a compact machine code for storage in the microcontroller's memory. Depending on the device, the program memory may be permanent, read-only memory that can only be programmed at the factory, or program memory may be field-alterable flash or erasable read-only memory.

Other microcontroller features
 
 Microcontrollers usually contain from several to dozens of general purpose input/output pins (GPIO). GPIO pins are software configurable to either an input or an output state. When GPIO pins are configured to an input state, they are often used to read sensors or external signals. Configured to the output state, GPIO pins can drive external devices such as LED's or motors.

Many embedded systems need to read sensors that produce analog signals. This is the purpose of the analog-to-digital converter (ADC). Since processors are built to interpret and process digital data, i.e. 1s and 0s, they won't be able to do anything with the analog signals that may be sent to it by a device. So the analog to digital converter is used to convert the incoming data into a form that the processor can recognize. A less common feature on some microcontrollers is a digital-to-analog converter (DAC) that allows the processor to output analog signals or voltage levels.

In addition to the converters, many embedded microprocessors include a variety of timers as well. One of the most common types of timers is the Programmable Interval Timer (PIT). A PIT just counts down from some value to zero. Once it reaches zero, it sends an interrupt to the processor indicating that it has finished counting. This is useful for devices such as thermostats, which periodically test the temperature around them to see if they need to turn the air conditioner on, the heater on, etc.

Time Processing Unit (TPU) is a sophisticated timer. In addition to counting down, the TPU can detect input events, generate output events, and perform other useful operations.

A dedicated Pulse Width Modulation (PWM) block makes it possible for the CPU to control power converters, resistive loads, motors, etc., without using lots of CPU resources in tight timer loops.

Universal Asynchronous Receiver/Transmitter (UART) block makes it possible to receive and transmit data over a serial line with very little load on the CPU. Dedicated on-chip hardware also often includes capabilities to communicate with other devices (chips) in digital formats such as I2C and Serial Peripheral Interface (SPI).
 
 Higher integration

In contrast to general-purpose CPUs, micro-controllers may not implement an external address or data bus as they integrate RAM and non-volatile memory on the same chip as the CPU. Using fewer pins, the chip can be placed in a much smaller, cheaper package.

Integrating the memory and other peripherals on a single chip and testing them as a unit increases the cost of that chip, but often results in decreased net cost of the embedded system as a whole. Even if the cost of a CPU that has integrated peripherals is slightly more than the cost of a CPU and external peripherals, having fewer chips typically allows a smaller and cheaper circuit board, and reduces the labor required to assemble and test the circuit board.

A micro-controller is a single integrated circuit, commonly with the following features:
central processing unit - ranging from small and simple 4-bit processors to complex 32- or 64-bit processors
discrete input and output bits, allowing control or detection of the logic state of an individual package pin
serial input/output such as serial ports (UARTs)
other serial communications interfaces like I²C, Serial Peripheral Interface and Controller Area Network for system interconnect
peripherals such as timers, event counters, PWM generators, and watchdog
volatile memory (RAM) for data storage
ROM, EPROM, EEPROM or Flash memory for program and operating parameter storage
clock generator - often an oscillator for a quartz timing crystal, resonator or RC circuit
many include analog-to-digital converters
in-circuit programming and debugging support

This integration drastically reduces the number of chips and the amount of wiring and circuit board space that would be needed to produce equivalent systems using separate chips. Furthermore, and on low pin count devices in particular, each pin may interface to several internal peripherals, with the pin function selected by software. This allows a part to be used in a wider variety of applications than if pins had dedicated functions. Micro-controllers have proved to be highly popular in embedded systems since their introduction in the 1970s.

Some microcontrollers use a Harvard architecture: separate memory buses for instructions and data, allowing accesses to take place concurrently. Where a Harvard architecture is used, instruction words for the processor may be a different bit size than the length of internal memory and registers; for example: 12-bit instructions used with 8-bit data registers.

The decision of which peripheral to integrate is often difficult. The microcontroller vendors often trade operating frequencies and system design flexibility against time-to-market requirements from their customers and overall lower system cost. Manufacturers have to balance the need to minimize the chip size against additional functionality.

Microcontroller architectures vary widely. Some designs include general-purpose microprocessor cores, with one or more ROM, RAM, or I/O functions integrated onto the package. Other designs are purpose built for control applications. A micro-controller instruction set usually has many instructions intended for bit-wise operations to make control programs more compact. For example, a general purpose processor might require several instructions to test a bit in a register and branch if the bit is set, where a micro-controller could have a single instruction to provide that commonly-required function.

Microcontrollers typically do not have a math coprocessor, so floating point arithmetic is performed by software.
Volumes

About 55% of all CPUs sold in the world are 8-bit microcontrollers and microprocessors. According to Semico, over four billion 8-bit microcontrollers were sold in 2006.

A typical home in a developed country is likely to have only four general-purpose microprocessors but around three dozen microcontrollers. A typical mid-range automobile has as many as 30 or more microcontrollers. They can also be found in many electrical device such as washing machines, microwave ovens, and telephones.
READ MORE - History Of Microcontroller

What Is a Programmable Logic Controller (PLC)?

  • Senin, 19 Juli 2010
  • Posted by Learn Electronic

The automation of many different processes, such as controlling machines or factory assembly lines, is done through the use of small computers called a programmable logic controllers (PLCs). This is actually a control device that consists of a programmable microprocessor, and is programmed using a specialized computer language. A modern programmable logic controller is usually programmed in any one of several languages, ranging from ladder logic to Basic or C. Typically, the program is written in a development environment on a computer, and then is downloaded onto the programmable logic controller directly through a cable connection. The program is stored in the programmable logic controller in non-volatile memory.

Programmable logic controllers typically contain a variable number of input/output (I/O) ports, and are usually Reduced Instruction Set Computer (RISC) based. They are designed for real-time use, and often must withstand harsh environments on the shop floor. The programmable logic controller circuitry monitors the status of multiple sensor inputs, which control output actuators, which may be things like motor starters, solenoids, lights and displays, or valves.

This controller has made a significant contribution to factory automation. Earlier automation systems had to use thousands of individual relays and cam timers. In many cases, a PLC allows all of the relays and timers within a factory system to be replaced with a single controller. Today, programmable logic controllers deliver a wide range of functionality, including basic relay control, motion control, process control, and complex networking, as well as being used in distributed control systems (DCS).

Digital signals yield an on or off signal, which the programmable logic controller sees as Boolean values, those with only two states: true or false. Analog signals may also be used, such as those from devices like volume controls, and these analog signals can be seen by the programmable logic controller as floating point values. This is one way in which a computer can represent a rational number, but can be imprecise.

There are several different types of interfaces that are used when people need to interact with the programmable logic controller to configure it or work with it. It might be configured with simple lights or switches, or a text display. More complex systems might use a web interface on a computer running a supervisory control and data acquisition (SCADA) system.

Programmable logic controllers were first created to serve the automobile industry. The first programmable logic controller project was developed in 1968 for General Motors to replace hard-wired relay systems with an electronic controller.
READ MORE - What Is a Programmable Logic Controller (PLC)?