Tuesday, 31 July 2012

Stepper Motor Interface to Microcontroller

CONNECTION :

There are actually many ways you can interface a stepper motor to your controller, out of them the most used interfaces are:

  1. Interface using L293D - H-Bridge Motor Driver
  2. Interface using ULN2003/2004 - Darlington Arrays

We will dicuss both connection techniques one by one. The above mentioned methods need 4 controller pins for interface.

Connecting Unipolar stepper using L293D

As you see in the circuit above the four pins "Controller pin 1",2,3 and 4 will control the motion and direction of the stepper motor according to the step sequece programmed in the controller.


Connecting Unipolar stepper using ULN2003/2004


As already discussed in case of L293D, Here in this circuit too the four pins "Controller pin 1",2,3 and 4 will control the motion and direction of the stepper motor according to the step sequece sent by the controller.

 

Connecting Bipolar Stepper Motor

As we have studied that, Bi-polar stepper motors has 2 different coils. The step sequence for Bipolar stepper motor is same as that of unipolar stepper motors. The driving circuit for this require an H-Bridge as it allows the polarity of the power applied to be controlled independently. This can be done as shown in the figure below:
Now we have seen the methods for connecting stepper motors with your microcontroller. So keeping these circuits in mind,we will now look at the programming of microcontroller to control stepper motors.

PROGRAMMING :

►Programming Full step Sequence

►C Programming
I am assuming that stepper motor is connected at Port 1.0 to Port 1.3. Adjusting the delay will increase or decrease the speed of the motor. Here just for demonstration i have taken some delay, you can change it as you want.
CODE:
#include <REG2051.H>.
#define stepper P1
void delay();

void main(){
while(1){
stepper = 0x0C;
delay();
stepper = 0x06;
delay();
stepper = 0x03;
delay();
stepper = 0x09;
delay();
}
}

void delay(){
unsigned char i,j,k;
for(i=0;i<6;i++)
for(j=0;j<255;j++)
for(k=0;k<255;k++);
}



►Assembly Programming

CODE:
org 0H

stepper equ P1

main:
mov stepper, #0CH
acall delay
mov stepper, #06H
acall delay
mov stepper, #03H
acall delay
mov stepper, #09H
acall delay
sjmp main

delay:
mov r7,#4
wait2:
mov r6,#0FFH
wait1:
mov r5,#0FFH
wait:
djnz r5,wait
djnz r6,wait1
djnz r7,wait2
ret
end

The working of the above code can be seen in the demo animation below.


►Programming Half step Sequence

►C Programming
Just the main routine changes rest everything remains same, i mean same delay routine.

CODE:
void main(){
while(1){
stepper = 0x08;
delay();
stepper = 0x0C;
delay();
stepper = 0x04;
delay();
stepper = 0x06;
delay();
stepper = 0x02;
delay();
stepper = 0x03;
delay();
stepper = 0x01;
delay();
stepper = 0x09;
delay();
}
}



►Assembly Programming
Here also the main routine changes rest everything remains same.


CODE:
main:
mov stepper, #08H
acall delay
mov stepper, #0CH
acall delay
mov stepper, #04H
acall delay
mov stepper, #06H
acall delay
mov stepper, #02H
acall delay
mov stepper, #03H
acall delay
mov stepper, #01H
acall delay
mov stepper, #09H
acall delay
sjmp main


The working of the above code can be seen in the demo animation below.







►Programming for Bipolar Stepper Motor

►C Programming
CODE:
void main(){
while(1){
stepper = 0x08;
delay();
stepper = 0x02;
delay();
stepper = 0x04;
delay();
stepper = 0x01;
delay();
}
}



►Assembly Programming
CODE:
main:
mov stepper, #08H
acall delay
mov stepper, #02H
acall delay
mov stepper, #04H
acall delay
mov stepper, #01H
acall delay
sjmp main

source :

PIC and EEPROM Programmer

In this project we are building a JDM programmer that can handle PIC12, PIC16 and PIC18 family microcontrollers and some popular 24C family EEPROMs. The programmer also provides ICSP feature that allows In-Circuit Serial Programming.  So if you desire, you will not have to carry your MCU each time when you reprogram it. The circuit is connected to the PC via serial port and no external power supply is needed. On the other hand, if you want to use it with a laptop that do not provide RS232 connection, using the circuit with a USB to RS232 converter may not give a proper result.

Supported Devices

EEPROM:  24C01A, 24C02, 24C04, 24C08, 24C16, 24C32, 24C64/65, AT24C128, AT24C256, AT24C512, M24C128, M24C256, 24C515, PCF8572 or 8572 = 24C01, PCF8582 or 8582 = 24C02, PCF8592 or 8592 = 24C04, SDA2506, SDA2516, SDA2526, SDA2546, SDA2586, SDA3506, SDA3516, SDA3526, 4C016 == 24C01, GRS-003 == 24C02, GRN-004 == 24C04, GRN-008 == 24C04, GRX-006 == 24C04, GRX-007 == 24C04, KKZ06F == 24C01, BAW658049 == 24C02, BAW57452 == 24C02, M8571 == 24C02, X24C0

Microchip PIC: 12C508, 12C508A, 12C509, 12C509A, 12CE518, 12CE519,12C671, 12C672, 12CE673, 12CE674,12F629, 12F675, 16C433, 16C61, 16C62A, 16C62B, 16C63, 16C63A, 16C64A, 16C65A, 16C65B, 16C66, 16C67,16C71, 16C72, 16C72A, 16C73A, 16C73B, 16C74A, 16C74B, 16C76, 16C77,16F73, 16F74, 16F76, 16F77,16C84, 16F83, 16F84, 16F84A, 16C505,16C620, 16C620A, 16C621, 16C621A, 16C622, 16C622A, 16CE623, 16CE624, 16CE625, 16F627, 16F628, 16F628A, 16F630, 16F676, 16C710, 16C711, 16C712, 16C715, 16C716, 16C717, 16C745, 16C765, 16C770, 16C771, 16C773, 16C774, 16C781, 16C782, 16F818, 16F819, 16F870, 16F871, 16F872, 16F873, 16F874, 16F876, 16F877, 16F873A, 16F874A, 16F876A, 16F877A, 18F242, 18F248, 18F252, 18F258, 18F442, 18F448, 18F452, 18F458, 18F1320, 18F2330, 18F432

Building the Programmer

As you see the circuitry contains a few components listed below.

Component List

T1, T2 : BC337 Transistor
D1, D4, D5, D6 : 1N4148 Diode
D3 : 6V2 Zener Diode
D2 : 5V1 Zener Diode
R3, R4 : 1K8 1/4W Resistor
R1 : 10K 1/4W Resistor
R2 : 1K5 1/4W Resistor
X1 : DB9 PCB Mount Female Connector
C1, C2 : 100uF 16V Electrolytic Capacitor
SV1 and SV4 : 40 Pin Machine Tooled IC Socket
SV2, SV3 : 20 Pin Machine Tooled IC Socket
SV5 (ICSP) : 6 Pin Header Connector9
L1, L2, L3 : LED (L1: GREEN, L2: RED, L3: YELLOW)

The PCB file is provided in pdf format. You can apply it to the board by using the ironing method.
Click here to download the schematic and the PCB layout files.



Assembling the components is straightforward. The only trick is shown in the photo. Before soldering the 40 pin socket, you must cut the plastic bridges between the sides. Another issue, don't forget to solder the diode (D6) and the jumper under the sockets first.




Here is the final. If you don't miss any short-circuits, you will see the red LED will bright up when you connect the programmer to the serial port. Now it is ready to use. You may use ICPROG and WinPIC to start programming your PICs or EEPROMs.

LED Indications; Yellow:Clock ,  Red:Power , Green:Program



Placement


Placement is shown in the figure below.

Don't forget! Wrong placement may defect your IC, programmer or computer. 

You may use a ZIF socket instead according to your needs.
Source : circuit-projects 

Monday, 30 July 2012

Embedded Systems Video Lecture Course


Here are videos for an Embedded systems course.
the course is divided into 37 lectures.

Lecture -1 Embedded Systems: Introduction 

Lecture - 2 Embedded Hardware 

Lecture - 3 PIC: Instruction Set 

Lecture - 4 PIC Peripherals On Chip 

Lecture - 5 ARM Processor 

Lecture - 6 More ARM Instructions 

Lecture - 7 ARM: Interrupt Processing 

Lecture - 8 Digital Signal Processors 

Lecture - 9 More on DSP Processors 

Lecture - 10 System On Chip (SOC) 

Lecture - 11 Memory 

Lecture - 12 Memory Organization 

Lecture -13 Virtual Memory and Memory Management Unit 

Lecture - 14 Bus Structure

Lecture - 15 Bus Structure 2 

Lecture - 16 Bus Structure - 3 Serial Interfaces 

Lecture - 17 Serial Interfaces 

Lecture - 18 Power Aware Architecture 

Lecture - 19 Software for Embedded Systems 

Lecture - 20 Fundamentals of Embedded Operating Systems 

Lecture - 21 Scheduling Policies 

Lecture - 22 Resource Management 

Lecture - 23 Embedded - OS 

Lecture - 24 Networked Embedded System 

Lecture - 25 Networked Embedded Systems - II 

Lecture - 26 Network Embedded System III 

Lecture - 27 Network Embedded System IV 

Lecture - 28 Designing Embedded Systems 

Lecture - 29 Designing Embedded Systems - II

Lecture - 30 Designing Embedded Systems- III

Lecture - 31 Embedded System Design - IV 

Lecture - 32 Designing Embedded Systems - V 

Lecture - 33 Platform Based Design 

Lecture - 34 Compilers for Embedded Systems 

Lecture - 35 Developing Embedded Systems

Lecture - 36 Building Dependable Embedded Systems 

Lecture - 37 Pervasive & Ubiquitous Computing 

These videos are available on the following link:

Sunday, 29 July 2012

Tutorial series for arduino

Arduino language tutorial (Lesson 2)

LESSON 2 :

Using a Pushbutton to Control the LED

To monitor the state of a switch, there’s a new Arduino instruction that you’re going to learn: the digitalRead()function.
digitalRead()checks to see whether there is any voltage applied to the pin that you specify between parentheses, and returns a value of HIGH or LOW, depending on its findings.

assemble the circuit as shown where the switch is connected to digital pin number 7 :

// Example 02: Turn on LED while the button is pressed

const int LED = 13;                              // the pin for the LED
const int BUTTON = 7;                       // the input pin where the pushbutton is connected
int val = 0;                                           // val will be used to store the state of the input pin
void setup() 
{
pinMode(LED, OUTPUT); // tell Arduino LED is an output
pinMode(BUTTON, INPUT); // and BUTTON is an input
}
void loop()
{
val = digitalRead(BUTTON);                       //read input value and store it 
// check whether the input is HIGH (button pressed)
if (val == HIGH) 
{
digitalWrite(LED, HIGH); // turn LED ON
else 
{
digitalWrite(LED, LOW);
}
}

in this sketch the LED is on when the switch is pressed but when the switch is released the LED is turned off (i.e. the LED is on as long as the switch is pressed )

NOW we want to change this sketch so that the LED is on when the switch is pressed and still on even if the switch is released and when the switch is pressed again the LED is turned off .
in this case we want to store the state of the LED ( for example when the LED is off assign a variable with zero and when the LED is on assign this variable with 1) as shown in the following sketch :

// Example 03A: Turn on LED when the button is pressed and keep it on after it is released 

const int LED = 13;                                  // the pin for the LED
const int BUTTON = 7;                           // the input pin where the pushbutton is connected
int val = 0;                                               // val will be used to store the state of the input pin
int state = 0;                                            // 0 = LED off while 1 = LED on
void setup() 
{
pinMode(LED, OUTPUT);              // tell Arduino LED is an output
pinMode(BUTTON, INPUT);        // and BUTTON is an input
}
void loop() 
{
val = digitalRead(BUTTON);                     // read input value and store it
// check if the input is HIGH (button pressed) and change the state
if (val == HIGH) {
state = 1 - state;
}
if (state == 1) {
digitalWrite(LED, HIGH);                               // turn LED ON
} else {
digitalWrite(LED, LOW);
}
}

Now go test this code. You will notice that it works … somewhat. You’ll find that the light changes so rapidly that you can’t reliably set it on or off with a button press.

because the time you press the button the sketch is executed thousands of times and the state of the LED is changed thousand times so we want to detect only the change in the voltage applied to the pin (i.e the positive edge change of the button and this can be done by the following sketch ) :
// Example 03B: Turn on LED when the button is pressed and keep it on after it is released
// Now with a new and improved formula!

const int LED = 13;                           // the pin for the LED
const int BUTTON = 7;                 // the input pin where the pushbutton is connected
int val = 0;                                      // val will be used to store the state of the input pin
int old_val = 0;                                 // this variable stores the previous value of "val"
int state = 0;                                   // 0 = LED off and 1 = LED on
void setup()
{
pinMode(LED, OUTPUT); // tell Arduino LED is an output
pinMode(BUTTON, INPUT); // and BUTTON is an input
}
void loop()
{
val = digitalRead(BUTTON);            // read input value and store it yum, fresh

// check if there was a transition
if ((val == HIGH) && (old_val == LOW)){
state = 1 - state;
}
old_val = val;                       // val is now old, let's store it
if (state == 1) {
digitalWrite(LED, HIGH);           // turn LED ON
} else {
digitalWrite(LED, LOW);
}
}

END OF LESSON 2




- Reference : O'REILLY  Getting Started with Arduino by Massimo Banzi  , 2nd Edition.

Saturday, 28 July 2012

Arduino language tutorial (Lesson 1)

Introduction :

This is an easy tutorial about how to write sketches ( codes ) for arduino platform .
Arduino is an open source physical computing platform based on a simple input/output (I/O) board and a development environment that implements the Processing language.

Getting Started :

Arduino is composed of two major parts: the Arduino board, which is the piece of hardware you work on when you build your objects; and the Arduino IDE, the piece of software you run on your computer. You use the IDE to create a sketch(a little computer program) that you upload to the Arduino board. The sketch tells the board what to do.
Look at the Arduino UNO board: you’ll see a black chip with 28 “legs”—that chip is the ATmega328, the heart of your board.
The board consists of the following :
>> 14 Digital IO pins (pins 0–13)
>> 6 Analogue In pins (pins 0–5) These dedicated analogue input pins take analogue values (i.e., voltage readings from a sensor) and convert them into a number between 0 and 1023.
>> 6 Analogue Out pins (pins 3, 5, 6, 9, 10, and 11)These are actually six of the digital pins that can be reprogrammed for analogue output using the sketch you create in the IDE

The Software (IDE)

The IDE (Integrated Development Environment) is a special program running on your computer that allows you to write sketches for the Arduino board in a simple language.
the code that you have written is translated into the C language (which is generally quite hard for a beginner to use), and is passed to the avr-gcc compiler, an important piece of open source software that makes the final translation into the language understood by the microcontroller.
you can download the IDE software from the following link (it's free open source software ) :
after installing the software and running it the following window appears , here we will write the code,verify it (check that it is correct ) and upload it to the board.
Now we are ready to write arduino sketches.

Lesson 1 :

any code or sketch in arduino consists of three main parts.
1- In the first part we declare the variables and constants we use in our program.(Declaration part)
2- In the second part we define the inputs and the outputs used in our sketch. (Initialization part )
3- The main program the microcontroller always executes. ( Main code)

we will illustrate Arduino language by a simple example which is the Blinking (flashing ) LED.
the LED will be connected to pin13 in the arduino board as shown :
Here is the code :
///////////////////////////////////////////////  part 1 /////////////////////////////////////////
// Example 01 : Blinking LED
const int LED = 13; // LED connected to digital pin 13
////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////// part 2 ///////////////////////////////////////////
void setup()
{
pinMode(LED, OUTPUT); // sets the digital pin as output
}
///////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////// part 3 //////////////////////////////////////////
void loop()
{
digitalWrite(LED, HIGH); // turns the LED on
delay(1000); // waits for a second
digitalWrite(LED, LOW); // turns the LED off
delay(1000); // waits for a second
}
///////////////////////////////////////////////////////////////////////////////////////////////////

The Code, Step by Step
const int LED = 13;                               // LED connected to digital pin 13
>> const int means that LED is an integer number that can’t be changed (i.e. a constant) whose value is set to 13. We are using this command to specify that the LED we’re blinking is connected to the Arduino pin 13.

pinMode(LED, OUTPUT);                      // sets the digital pin as output
>> pinMode tells Arduino how to con-figure a certain pin. Digital pins can be used either as INPUT or OUTPUT. In this case, we need an output pin to control our LED, so we place the number of the pin and its mode inside the parentheses.
INPUT and OUTPUT are constants in the Arduino language. (Like variables, constants are assigned values, except that constant values are predefined and never change.)

loop() is where you specify the main behaviour of your microcontroller. It will be repeated over and over again until you switch the board off.

digitalWrite(LED, HIGH);                           // turns the LED on
>> digitalWrite()is able to turn on (or off) any pin that has been configured as an OUTPUT. The first argument (in this case, LED) specifies which pin should be turned on or off (remember that LED is a
constant value that refers to pin 13, so this is the pin that’s switched). The second argument can turn the pin on (HIGH) or off (LOW).

delay(1000);                                                  // waits for a second
>> delay() basically makes the processor sit there and do nothing for the amount of milliseconds that you pass as an argument. Milliseconds are thousandths of seconds; therefore, 1000 milliseconds equals 1 second. So the LED stays on for one second here.

digitalWrite(LED, LOW);                           // turns the LED off
This instruction now turns off the LED that we previously turned on.

delay(1000);                                                // waits for a second
Here, we delay for another second. The LED will be off for one second.

Then the Main program is repeated again and again until the power is switched off the board .

END OF LESSON 1




- Reference : O'REILLY  Getting Started with Arduino by Massimo Banzi  , 2nd Edition.

GO TO :

LESSON 1
LESSON 2
LESSON 3
LESSON 4

MathWorks Announces Built-in Simulink Support for Arduino

With one click, engineers run Simulink control system and signal processing algorithms in hardware

MathWorks today announced that Simulink models can now run directly on Arduino, BeagleBoard, and LEGO MINDSTORMS NXT platforms. These popular, low-cost devices are widely used in academia for hands-on teaching of robotics, mechatronics, audio signal processing, computer vision, and other engineering applications. Simulink models can run standalone on these hardware platforms or in tandem with a connected PC.
“Simulink built-in support for hardware is a big boost to project-based learning,” said Dr. Farid Golnaraghi, professor and director of Mechatronic Systems Engineering at Simon Fraser University. “Our engineering students who learn control theory by creating and running models in Simulink can now easily test and tune their algorithms on hardware, without knowing embedded systems.”
“Multifunction microprocessor boards are a tremendous learning resource,” said Tom Gaudette, principal academic evangelist at MathWorks. “Adding targeted support was a logical step, given the widespread use of Model-Based Design with Simulink in engineering schools and industry. With Simulink and a low-cost Arduino, BeagleBoard, or LEGO MINDSTORMS NXT robot, a student can learn industry best practices for DSP, robotics, and mechatronics design.”
Simulink provides built-in support for the following platforms:
  • Arduino Uno and Mega 2560 microcontroller boards for robotics, mechatronics, and hardware-connectivity tasks
  • BeagleBoard-xM single-board computers for audio, video, and digital signal processing
  • LEGO MINDSTORMS NXT robotics platform for robotics applications
Simulink built-in support for hardware is available in MathWorks Release 2012a, including MATLAB and Simulink Student Version.


Visit www.mathworks.com/products/simulink/simulink-targets for additional information.

Friday, 27 July 2012

Make your own Arduino

Within a few minutes you can have a fully working Arduino platform to work with as you will see in this tutorial.

Step 1 : Components

With a few inexpensive parts and a solderless breadboard you can quickly and easily build your own Arduino.
The example below shows how to hook up the components on your breadboard. We will go into further detail throughout this project.
Figure 1-1: Breadboard Arduino with USB programming ability.

Step 2 : Setting Up Power

The first thing you need to do is set up power. With your breadboard and components in front of you... let's get started!
With this step, you will be setting the breadboard Arduino up for constant +5Volts power using a 7805 voltage regulator.
Figure 1-2: Power setup with LED indicator.
In order for the voltage regulator to work, you need to provide more than 5V power. A typical 9V battery with a snap connector would work just fine for this.
Power is going to come into the breadboard where you see the red and black + and squares. Then add one of the 10uF capacitors. The longer leg is the Anode (Positive) and the shorter leg is the Cathode (Negative). Most capacitors are also marked with a stripe down the negative side.
Across the empty space on the breadboard (the channel) you will need to place two hook-up wires for positive (red) and ground (black) to jump power from one side of the breadboard to the other.
Now add the 7805 voltage regulator. The 7805 has three legs. If you are looking at it from the front, the left leg is for voltage in (Vin) the middle leg is for ground (GND) and the third leg is for voltage out (Vout). Make sure the left leg is lined up with your positive power in, and the second pin to ground. 
Coming out of the voltage regulator and going to the power rail on the side of the breadboard you need to add a GND wire to the ground rail and then the Vout wire (3rd leg of the voltage regulator) to the positive rail. Add the second 10uF capacitor to the power rail. Paying attention to the Positive and Negative sides.
It’s a good idea to include an LED status indicator which can be used for troubleshooting. To do this you need to connect the right side power rail with the left power rail. Add positive to positive and negative to negative wires at the bottom of your breadboard.
Figure 1-3: Left and Right Power Rail Connections.
Having power on the left and right power rail will also help to keep your breadboard organized when providing power to the various components.
Figure 1-4: For the LED status indicator, connect a 220& resistor (colored as: red, red, brown) from power to the anode of the LED (positive side, longer leg) and then a GND wire to the cathode side.
Congratulations, now your breadboard is set up for +5V power. You can move onto the next step in the circuit design.

Step 3 : Arduino Pin Mapping


Now we want to prepare the ATmega168 or 328 chip. Before we begin, let’s take a look at what each pin on the chip does in relationship to the Arduino functions. NOTE: The ATmega328 runs pretty much the same speed, with same pinout, but features more than twice the flash memory (30k vs 14k) and twice the EEPROM (1Kb vs 512b).
Figure 1-5: Arduino Pin Mapping
The ATmega168 chip is created by Atmel. If you look up the datasheet you won’t find that the above references are the same. This is because the Arduino has its own functions for these pins, and I have provided them only on this illustration. If you would like to compare or need to know the actual references for the chip, you can download a copy of the datasheet at www.atmel.com. Now that you know the layout of the pins, we can start hooking up the rest of the components.

Step 4 : Component Hook Up


To start, we will build the supporting circuitry for one side of the chip and then move on to the other side. Pin one on most chips has an identifier marker. Looking at the ATmega168 or 328 you will notice a u-shaped notch at the top as well as a small dot. The small dot indicates that this is pin 1.
Figure 1-6: Supporting circuitry pins 15-28
From the GND power bus, add a jumper wire to pin 22. Next, from the positive power bus, add jumper wires to pin 20 (AVCC - Supply voltage for the ADC converter. Needs to be connected to power if ADC isn't being used and to power via a low-pass filter if it is (a low pass filter is a circuit that cleans out noise from the power source, we aren't using one)
Then add a jumper wire from the positive bus to pin 21 (Analog reference pin for ADC).
On the Arduino, pin 13 is the LED pin. Note that on the actual chip the pin is number 19. When uploading your sketch code and for all projects you will still reference this as Pin 13.
To hook up the LED, add a 220& resistor from GND to the cathode of the LED. Then from the anode of the LED add a jumper wire to pin 19.
Now we can move onto the other side of the chip. You are almost finished!

Figure 1-7: Supporting circuitry pins 1-14
Above the ATmega168 chip near the pin 1 identifier, place the small tact switch. This switch is used for resetting the Arduino. Right before you upload a new sketch to the chip you will want to press this once. Now add a small jumper wire from pin 1 to the bottom leg of the switch then add the 10K resistor from power to the pin 1 row on the breadboard. Finally add a GND jumper wire to the top leg of the switch.
Add power and GND jumpers to pin 7(VCC) and pin 8 (GND). Add the 16MHz clock crystal to pin 9 and 10 and then the two .22pF capacitors from pins 9 and 10 to GND. (See note below for alternative method).
Your basic breadboard arduino is now complete. You could stop right here if you wanted to and swap an already programmed chip from your Arduino board to the breadboard, but since you came this far, you might as well finish off by adding some programming pins. This will allow you to program the chip from the breadboard.
NOTE: Instead of using the 16MHz clock crystal, you can use a 16 MHz ceramic resonator with built-in capacitors, three-terminal SIP package. You will have to arrange your breadboard a little differently, the resonator has three legs. The middle leg will go to ground and the other two legs will go to pins 9 & 10 on the ATmega168 chip.
 
Referring to Figure 1-7, locate a spot where you have 6 columns on the breadboard that are not in contact with anything else. Place a row of six male header pins here.
With the breadboard facing you, the connections are as follows:
GND, NC, 5V, TX, RX, NC, I am also calling these pins 1,2,3,4,5,6. From your power bus rail, add the GND wire to pin 1 and a wire from power for pin 3. NC means not connected, but you can connect these to GND if you want to.
From pin 2 on the ATmega168 chip, which is the Arduino RX pin, you will connect a wire to pin 4 (TX) of your programming headers. On the ATmega168 chip, pin 3 Arduino TX gets connected to pin 5 (RX) on your header pins.
The communication looks like this: ATmega168 RX to Header Pin TX, and ATmega168 TX to Header Pin RX.
Now you can program your breadboard Arduino. 

Step 5 : Programming Options

The first option is to buy a TTL-232R 3.3V USB – TTL Level Serial Cable. These can be purchased at www.adafruit.com  or www.ftdichip.com  
The other two options, which I prefer are to buy one of two breakout boards from www.SparkFun.com. They are:
  • FT232RL USB to Serial Breakout Board, SKU: BOB-00718 (This option takes up more space on your breadboard)
  • FTDI Basic Breakout - 3.3V SKU: DEV-08772 (This option, and using right angle male headers works the best out of all three because it is secured better on the breadboard)

Double check your connections, make sure your 9V battery is not connected and hook up your programming option.  Open up the Arduino IDE and in the Example sketch files, under Digital, load the Blink sketch.
Under the file option Serial Port, select the COM port that you are using with your USB cable. i.e. COM1, COM9, etc.
Under the file option Tools/Board, select either:
  • Arduino Duemilanove w/ATmega328
  • Arduino Decimila, Duemilanove or Nano w/ATmega128
(depending on which chip you are using with your breadboard Arduino)
Now press the upload icon and then hit the reset button on your breadboard. If you are using one of the SparkFun breakout boards, you will see the RX and TX lights blink. This lets you know that the data is being sent. Sometimes you need to wait a few seconds after pressing the upload button before pressing the reset switch. If you have trouble, just experiment a little with how fast you go between the two.
This sketch if uploaded properly will blink the LED on pin 13 on for one second, off for one second, on for one second… until you either upload a new sketch or turn off the power.
Once you have uploaded the code, you can disconnect the programming board and use your 9V battery for power.

Step 6 : PCB Files


the PCB files can be downloaded from the following link :

Origninal tutorial by:
instructables

Thursday, 26 July 2012

Arduino Simulator

Simulator for Arduino is the most full featured Arduino Simulator available at the present time
The benefits and features of an Arduino Simulator are:
  • The ability to teach and demonstrate the inner workings of an Arduino sketch
  • Test out a sketch without the hardware, or prior to purchasing hardware
  • Debug a sketch

Download the free version below with a short delay timer on loading a sketch, and when ready upgrade to the Pro Version. Simulator for Arduino Pro Version is currently used in Many countries over six continents. The download consists of a zip file containing a setup.exe file which installs an exe file, help files, images and examples. It is designed for the Arduino Uno or Mega and does the following:
  • Steps through the program line by line. If a new line is selected, the program will continue from that point.
  • Performs digitalWrite, digitalRead and PinMode for pins 0-53
  • analogRead for pins 0-16 and analogWrite for digital pins 0-53
  • Emulates Serial, LCD output, Ethernet, Servo, SD card, EEPROM, SoftSerial,SPI, Wire
  • If,while,for,switch, do whileloop functionality
  • Subroutines (multi-level) with arguments
  • View variables in real-time
  • Step Into, Step Over, Step Out of or Run mode
  • Ability to edit sketch or open in Arduino IDE
  • Tabs for separate files in the sketch
  • Context-sensitive help
  • 2 and 4 line LCD support only with improvised CGRAM
  • 2 dimensional arrays (without initialisation)
  • BreakPoint now with a conditional option
  • load custom libraries automatically after setting the Library Directory
  • Change the font, size and style of the Simulator
  • Advanced watch for easy variable viewing
  • Minimize mode for demo/training
  • Limited support for custom libraries
  • Limited support for pointer and structures
 here is a datasheet for how to use the simulator :
simulator for arduino datasheet





Download the Latest free version here

Arduino Simulation using Proteus

This post will teach you how to simulate arduino sketches using proteus.
The sketch will be written using arduino 0017 edition and you can download it from the following link :
http://arduino.cc/en/Main/Software

We will simulate a simple sketch which flashes a LED.

Here is the sketch to be  :
// example 01 : blinking an LED
const int LED = 13;   // LED connected to pin 13
void setup()
{
  pinMode(LED,OUTPUT);
}

void loop()
{
  digitalWrite(LED,HIGH);
  delay(1000);
  digitalWrite(LED,LOW);
  delay(1000);
}

Steps :

1- After writing the sketch press verify to compile the code.
     (Be sure to select  arduino duemilanove or nano w/atmega328 board from tools tab )
2- And you will find that a new folder named applet has been created this folder containing the .hex file to be simulated using proteus.
3- Build the following schematic using proteus as shown in the following figure :
    ( The crystal used has a frequency 16Mhz)

4-Double click on the microcontroller to load the hex file.
5 Then adjust the CKSEL and clock frequency as shown in the following figure :

Here is a link containing the arduino files and the simulation file :
http://www.mediafire.com/?t2i8s2x4346fnyf\

Download this tutorial in PDF HERE

ATmega 16 problem PC2 to PC5 always high

I have about 5 atmega 16 microcontrollers with PC2 to PC5 pins are always high even if i programmed them as outputs and make PORTC=0x00.this problem occurs when the JTAG interface is enabled in ATmega 16.

To get rid from this problem you have to disable the JTAG.

Here I disablled the JTAG interface using the avr studio and STK500 board.

Steps :

1- Connect the STK500 board through usb .

2- Press on the connect icon as shown in the following picture :

3- Select the STK500 board and auto in the port as shown :

4-  Be sure that atmega 16 microcontroller is selected in the main tab

5- In the fuses tab disable the JTAG interface by unchecking the JTAGEN fuse and the press program at the bottom as shown in the figure :