Sunday 10 November 2013

8051 SIMULATORS

Introduction:

Simulator is software which will execute the program and show the results exactly to the program running on the hardware, if the programmer found any errors in the program while simulating the program in the simulator, he can change the program and re-simulate the code and get the expected result, before going to the hardware testing. Programmer can confidently dump the program in the hardware when he simulated his program in the simulator and got the expected results.
8051 controller is most popular 8-bit controller which is used in large number of embedded applications and many programmers writing programs according to there application. So to test there programs in the software simulators are a way. Simulators will help the e are programmer to understand the errors easily and time taken for the testing is also decreased.
 These simulators are very useful for students because they need not to build the complete hardware for testing there program and validate there program very easily in an interactive way.

List of 8051 Simulators:

The list of simulators is given below with there features:

MCU 8051: MCU 8051 is an 8051 simulator which is very simple to use and have an interactive IDE (Integrated Development Environment). It is developed by Martin Osmera and most important of all is that it is completely free. There are many features for this IDE they are
  • It supports both C and assembly language for compilation and simulation
  • It has in-built source code editor, graphical note pad, ASCII charts, Assembly symbol viewer etc. Also supports number of 8051 IC’s like at89c51, A89S52, 8051, 8052, etc.
  • It will support the certain electronic simulation like LED, 7segment display, LCD display etc. which will help in giving the output when you interface these things to the hardware directly.
  • It has having tools like hex decimal editors, base converters, special calculator, file converter, inbuilt hardware programmer etc.
  • It has syntax validation, pop base auto completion etc.
You can download this tool from http://sourceforge.net/projects/mcu8051ide/files/ .

EDSIM 51: This is a virtual 8051 interfaced with virtual peripherals like 7 segment display, motor, keypad, UART etc. this simulator is exclusively for students developed by James Rogers,. The features of this simulator are
  • Have virtual peripherals like ADC, DAC with scope to display, comparator etc.
  • Supports only assembly language
  • IDE is completely written in JAVA supports all the OS.
  • Completely free and with user guide, examples, etc.
You can download this simulator from the http://www.edsim51.com/index.html .

8051 IDE: This simulation software is exclusively for windows operating system (98/xp). The features of this simulator are
  • Text editor, assembler, and software simulate in one single program.
  • Has facilities like Break point setter, execute to break point, predefined simulator watch window etc.
  • It is available in both free version and paid version.
You can download this tool from http://www.acebus.com/win8051.htm .

HTE 8051: HTE 8051 is an 8051 simulator developed for IBM computers. This simulator is mainly used in the DOS environment and uses Intel HEX file for the simulation. We can set break points, step by step execution etc. it provides color display and has tools like hex calculator variable screen display and help window. You can download this software from this webpage: http://www.hte.com/html/8051sim.htm.

MIDE-51: MIDE-51 is a simulator from opcube. It has almost all the feature has mentioned in the  above IDE’s. You can download this software from http://www.opcube.com/home.html#MIDE51 .

KEIL: KEIL is the most popular software simulator. It had many features like interactive IDE, supports both C and assembly languages for compilation and simulation.  You can download and get more information from http://www.keil.com/c51/.

Software
Version
Webpage
JSIM-51
Free version
http://home.arcor.de/jensaltmann/jsim-e.htm
BIPOM
Enterprise version
http://www.bipom.com/8051dev_down.php
Atuana
Enterprise version
http://sol.gfxile.net/atanua/features.html
Rigel
Free version
http://www.rigelcorp.com/
GSIM 51
Free version
http://gsim51.sourceforge.net/
J51
Free version
http://j51-8051-java-simulator.winsite.com/
Pinnacle
Enterprise version
http://www.4shared.com/rar/5tP9KhjY/pinnacle_52.html

2 X 16 LCD INTERFACE WITH AVR MICROCONTROLLER

Circuit Diagram of Interfacing 16X2 LCD to AVR Microcontroller:

Circuit Explanation:
  • Well this is not different from the way interfacing the LCD to 8051 or PIC microcontroller. The crystal oscillator will provide the clock to the microcontroller. The capacitors connected to the crystal will act as filters and help the crystal to resonate and oscillates to its parallel resonate mode.
  •  The potentiometer which is connected to the pin 3 and pin2 of LCD will help to adjust the contrast of the LCD. The 4, 5 and 6 pins of LCD that is Register select, Read/write and Enable pins are connected to the PD0, PD1 and PD2 pins of Atmega16. The data pins of LCD are connected to the pins of 33 to 40 pins of Atmega16.

Programming ATMEGA16 for Interfacing with 16X2 LCD:

It very important how the data is send to the LCD and how the command is send to the LCD, suppose if you are sending data to the LCD, then you have to make the ENABLE pin of 16×2 LCD pin to low before sending the data, when you think the data you want send is ready make the ENABLE pin again high that is 1 in coding language. If you make ENABLE pin high then only LCD will work.
 Just by making the ENABLE pin high will not work, you have make REGISTER SELECT pin (RS pin) also high so that LCD will accept that it a normal data which has to be displayed on the screen of LCD, if you forgot to make RS pin high it eventually think that user is sending it a command and make it self ready to act according to the command like making cursor to move, clearing the data on the LCD, changing the cursor position etc.
 Last but not least another pin you need to worry of read/write pin, we all know that for any device the basic functionality start with read and write, reading the data and writing the data is main and important function for any peripheral or system. here in the LCD while sending the data for displaying you have to make the R/W pin low, so that LCD will under stand that data should be written on the LCD screen and act accordingly.
Just sending the data and displaying it will not complete the task; arrangement of data in understandable way is the important and crucial task for the programmer. You can arrange the data in the LCD or making the LCD to work according to your wish, can be done by sending the commands or special functions to the LCD, you may think that what type of commands are needed to work for LCD, commands for cursor position, increasing or decreasing the contrast, making the cursor to change line like from first line to second line etc.  To send a command to the LCD you need to make pins high and low just like sending the data. For sending the command you need to make the ENABLE PIN high, REGISTER SELECT pin (RS pin) low that is 0 in programmer terms, and read/write pin (R/W pin) high, you need to remember this configuration for sending the command.

Different commands and there hexadecimal code generally used by the programmer while displaying the data.

SNO
Instruction for LCD
Hex code
1
If you want to display content in one line in 5x7 matrix
0x30
2
If you want to display content in two line in 5x7 matrix
0x38
3
If you display 4 bit data in one line in 5x7 matrix
0x20
4
If you display 4 bit data in two line in 5x7 matrix
0x28
5
entry mode
0x06
6
To clear the display without clearing the ram content
0x08
7
Making the cursor on and also display on
0x0E
8
Making the cursor off and also display off
0x0C
9
Displaying the data on cursor blinking
0x0F
10
Shifting complete display data to left side
0x18
11
Shifting complete display data to right side
0x1C
12
Moving cursor to one place or one character left
0x10
13
Moving cursor to one place or one character RIGHT
0x14
14
Clearing the complete display including RAM DATA
0x01
15
Set DDRAM address on cursor position
0x80+add

If we want to talk in brief for displaying data in LCD
  • E=1; enable pin should be high
  • RS=1; Register select should be high
  • R/W=0; Read/Write pin should be low.
For sending command to LCD
  • E=1; enable pin should be high
  • RS=0; Register select should be low
  • R/W=1; Read/Write pin should be high.
When you are passing a string, its better use a string pointer and increment the pointer, if you are incrementing a pointer it will automatically go the next address of the variable in which you can store your character which you wanted to display. See the below example.
 
void write_string(unsigned char *str)   //store address value of the string in pointer *str
{
int i=0;
while(strng[i]!=’\0′)  // loop will go on till the NULL character in the string 
               {
                              lcd_write(strng[i]);// sending data on LCD byte by byte
                              i++;
               }
               return;
}

Code for Interfacing the LCD to ATMEGA16:

#include<avr/io.h>
#include<util/delay.h>
LCD DATA port----PORT B
signal port------PORT D
               rs-------PD0
               rw-------PD1
               en-------PD2
*/
#define LCD_DATA PORTB                //LCD data port
#define ctrl PORTD
#define en PD2                         // enable signal
#define rw PD1                       // read/write signal
#define rs PD0                     // register select signal
void LCD_cmd(unsigned char cmd);
void init_LCD(void);
void LCD_write(unsigned char data);
int main()
{
DDRB=0xff;                                  // setting the port B
DDRD=0×07;                                // setting for port D
init_LCD();                                 // initialization of LCD
_delay_ms(50);                        // delay of 50 mili seconds
LCD_write_string(“hello world”);                      // function to print string on LCD
return 0;
}
void init_LCD(void)
{
LCD_cmd(0×38);                            // initialization of 16X2 LCD in 8bit mode
_delay_ms(1);
LCD_cmd(0×01);                                 // clear LCD
_delay_ms(1);
LCD_cmd(0x0E);                        // cursor ON
_delay_ms(1);
LCD_cmd(0×80);                     // —8 go to first line and –0 is for 0th position
_delay_ms(1);
return;
}
void LCD_cmd(unsigned char cmd)
{
LCD_DATA=cmd;
ctrl =(0<<rs)|(0<<rw)|(1<<en);
_delay_ms(1);
ctrl =(0<<rs)|(0<<rw)|(0<<en);
_delay_ms(50);
return;
}
void LCD_write(unsigned char data)
{
LCD_DATA= data;
ctrl = (1<<rs)|(0<<rw)|(1<<en);
_delay_ms(1);
ctrl = (1<<rs)|(0<<rw)|(0<<en);
_delay_ms(50);
return ;
}
void LCD_write_string(unsigned char *str)             //store address value of the string in pointer *str
{
int i=0;
while(str[i]!=’\0′)                               // loop will go on till the NULL character in the string
{
LCD_write(str[i]);                            // sending data on LCD byte by byte
i++;
}
return;
}

Automatic Water Tap (Faucet/Valve) Controller

As you may well know, automatic control for a water tap can significantly reduce water consumption to some extent. Besides, automatic faucets can eliminate cross-contamination by keeping hands and germs away from commonly-used surfaces.
Presented here is a simple electronic circuit which can control the valve operation by sensing valid-movements with the help of a Passive Infrared (PIR) motion sensing module. In practice, automatic taps are presence sensors and not motion sensors. They employ “Active Infrared” technology which senses “presence” and not “movement” of objects. However, here an unorthodox “Passive Infrared” technology is used to realize the 6VDC powered smart faucet controller circuit!

Schematic of the Water Valve Controller Circuit



Smart Valve Controller is a combination of four key components:
  • motion sensor with control electronics
  • solenoid valve
  • power source
  • and the faucet
As stated, at the heart of the circuit is a Passive Infrared (PIR) module. PIR sensor is a pyroelectric device that detects motion by measuring changes in the infrared levels emitted by surrounding objects. Pyroelectric devices, such as the PIR sensor, have elements made of a crystalline material that generates an electric charge when exposed to infrared radiation. The changes in the amount of infrared striking the element change the voltages generated, which are measured by an onboard amplifier.

pir sensorThe device contains a special filter called a Fresnel lens, which focuses the infrared signals onto the element. The PIR Sensor requires a ‘warmup’ time in order to function properly. This is due to the settling time involved in ‘learning’ its environment. this could be anywhere from 10 to 60 seconds. During this time there should be as little motion as possible in the sensors field of view. There is a variable resistor (P1) on the PIR sensor module to control the ‘ON’ delay time for the sensor. Turning this variable resistor clockwise will give longer ‘ON’ delay time while turning anticlockwise will reduce the ‘ON’ delay time. The PIR sensor has distance range of approximately 3 to 7 meters. It is possible to adjust distance of detection with the help of the second variable resistor (P2) on the PIR sensor module.

Likewise, there is a 2-position jumper point (JP) is included in the PIR sensor module. The sensor is active HIGH (LOW in idle state) when jumper is in either position. In “retrigger” (H) position, output remains HIGH when sensor is triggered repeatedly. In “normal” (L) position, output goes HIGH then LOW when triggered. Continuous motion results in repeated HIGH/LOW pulses.
Back side view of the PIR sensor module6VDC Solenoid Valve
The motion sensor with control electronics circuitry is very simple and self-explanatory. Output of the PIR sensor module (SEN1) is here connected to a ‘traditional’ monostable multivibrator (MMV) wired around the ubiquitous timer chip NE555 (IC1) . Output of IC1 controls the solenoid valve through a 6V electromagnetic relay attached to J1.
Two LEDs (LED 1 & LED2) are added as system status indicators. SPDT switch S1 is the “Auto/Manual” Mode Selector. “Push – to – On” switch S2 can be used for manual operation of the faucet. Prototype tested with four 1.5V AA cells (1.5Vx4 = 6V).

Note:
Remember to set delay time & detection range of the system as low as possible by adjusting the preset pots P1 & P2 of the PIR sensor module. Removing the fresnel lens, collimation and screening by means of a piece of a suitable electrical conduit with a length of 2 to 3 cm is not a bad idea to reduce the field of view of the PIR sensor module. Place the jumper (JP) in “Normal” mode!
Why a PIR sensor based design? PIR sensor is small, inexpensive, low power, rugged,is easy to interface with, and is easy to use. When motion is detected the PIR sensor outputs a high signal on its output pin, which can either be read by an MCU or drive a transistor to switch a higher current load.
Their best feature is that they don’t wear out!

Parts:
SEN 1: PIR sensor module
T1: BC547
LED1: 5mm Green
LED2: 5mm Red
D1: 1N4007
IC1: NE555
R1, R2: 1K
R3: 100K
R4: 470R
C1,C2: 100nF
C3: 100uF/16V
S1: SPST On/Off
S2: Push -To – On
J1: 2-Pin male header
Relay: 6VDC /SPST Electromagnetic Relay

Speed Control of DC Motor Using PWM

We use DC fans in many systems in our day to day life. For example, CPU fans, fume extinguishers and many more appliances which we make use of are operated by DC. Most of the times we will have a need to adjust the speed of the motors to our requirement. Although some systems have an automatic adjustment system for fan speed, not all systems possess this functionality. So, we will have to adjust the speed of our fan ourselves occasionally.

To adjust the speed of our fan manually, there are multiple ways to do that. We can adjust the speed by using a resistance in series with the motor. This is the simplest of all ways but it is not usually preferred because if we want to use any devices like microcontrollers or any other digital equipment for automating our DC fan speed, then this method will not work in general. A more efficient way to proceed is by using pulse width modulation technique to manage the speed of our DC motor.

Circuit Diagram of PWM Based DC Fan Controller:

 


In this circuit, the DC motor is operated by a 555 integrated circuit. The IC 555 in this circuit is being operated in astable mode. In this mode, the circuit can be used as a pulse width modulator with a few small adjustments to the circuit. The frequency of operation of the circuit is provided by the passive parameters of resistances and capacitances attached to it. The resistance between pin-7 and pin-8, the resistance between pin-6 and pin-7 and the capacitance between pin-2 and the ground govern the frequency of operation and duty cycle of the ic 555 in astable mode. The duty cycle is governed by the resistor which is in between pin-6 and pin-7 of the IC 555 timer. So, by taking advantage of the circuits working, we can change the 555 astable multivibrator into a pulse width modulator by using a variable resistor instead of a constant resistor in between pin-6 and pin-7.

One of the best things about this circuit is that we can make it work as an astable multivibrator with little hardware and by little cost which can save both the cost involved in making it as well as the space on the printed circuit board is saved. if we want a sophisticated pulse width modulator which works more accurately and which can have more adjusting capabilities, then it is better to use a microcontroller based pulse width modulator than the one which we are using now. However, the circuit or the application for which we are using a pulse width modulator is not so sensitive and hence does not demand so much of accuracy. In such a case, the circuit which we are using with a bare IC 555 is better as it saves our monetary as well as space resources in building the circuit.
The duty cycle of the circuit can be changed by changing the resistance between pin-7 and pin-6. If we increase the duty cycle, the speed of the motor increases and if we decrease the duty cycle, the speed of the motor decreases.