Académique Documents
Professionnel Documents
Culture Documents
MICROCONTROLLER
Introduction
Doing an electronic project is a creative and innovative idea for the developers,
first we have to choose the title of the project from the lot of available application
or from the developing application in research. Once the title is selected, the
developer designed the circuit from the available electronic sources. The basic
level circuit may be checked in the breadboard or using the general purpose PCB.
The advances level circuit may be simulated and may be verified using the
simulation tools.
The different components and the IC range from basic electronics device to the
very advanced ASIC. The different design and application level depends on the
requirement and cost. The design may be slowly based on the discrete circuit and
the programming chips. They may be microprocessor, microcontroller, embedded
system, VLSI, PLC.
Moreover one should construct the DC power source from the mains or can use the
batteries. The DC power required may be 5v.6v.9v.12v. etc. here we are
attempting to design and construct the project namely” AUTOMATED UNIFIED
SYSTEM FOR LPG USINGMICROCONTROLLER”
SYNOPSIS:
Gas sensor
Buzzer
Motor driver
GSM
Relay
Pic microcontroller
Dc power supply
Main switch
1.1. BLOCK DIAGRAM
BLOCK DESCRIPTION
In our project, we use a gas sensor to detect the leaked LPG. If found, then the
signal is immediately sent to the microcontroller. The controller sends a signal to
relay and motor driver .Then the signal was taken to process using relay ,in relay
whenever a coil energizes it will produce a output(i.e.. main switch will be OFF)
an the another output taken via by motor driver that is door. When signal comes to
drive a motor a door will be open automatically.
1.2. CIRCUIT DIAGRAM
Here in this project most of the operations are operated in 5V and 12V. So
we use 230V/12V potential transformer and 7805 regulator for 5V. Power supply
circuit consists of bridge rectifier, ripple filter, regulator and line filter. Bridge
rectifier is constructed using 1N4007 diode. Ripple filter is build around
1000uF/25V.
POWERSUPPLY SECTION
There are many types of power supply. Most are designed to convert high voltage
AC mains electricity to a suitable low voltage supply for electronics circuits and
other devices. A power supply can by broken down into a series of blocks, each of
which performs a particular function.
Power supplies made from these blocks are described below with a circuit diagram and a graph
of their output:
Transformer only
Transformer + Rectifier
TransforTransformer onlymer + Rectifier + Smoothing
Transformer + Rectifier + Smoothing + RegulatorTransformer only
The low voltage AC output is suitable for lamps, heaters and special AC motors. It
is not suitable for electronic circuits unless they include a rectifier and a smoothing
capacitor.
Transformer + Rectifier
The varying DC output is suitable for lamps, heaters and standard motors. It
is not suitable for electronic circuits unless they include a smoothing
capacitor.
The regulated DC output is very smooth with no ripple. It is suitable for all
electronic circuits.
Further information: Transformer | Rectifier | Smoothing | Regulator
2.4. RELAYS AND REED SWITCHES
1. Relays:
When the controlling current flows through the coil, the soft iron core is
magnetized and attracts the L-shaped soft iron armature. This rocks on its pivot
and opens, closes or changes over, the electrical contacts in the circuit being
controlled it closes the contacts.
In this circuit transistor BC547 is used as a switch. The control signal is given
to the base terminal of the transistor. The collector is attached to the relay coil.
Relays are electromechanical devices. There are two types of relays.
1. Normally closed
2. Normally opened
We are using normally opened type relay. When the controller output from the PC
is high the transistor will be in the ON state, so relay is energized. When the
output from the PC is low the transistor will be in the OFF state, so relay is de-
energized the valve will open. When the relay is de-energized the valve will close.
So according to the controller output the valve will open or close and
thuslevelismaintained.
2.5.PIEZOELCTRICBUZZER
The two series-connected diodes will drop approximately 1.4 volts, equivalent
to the combined Vbe forward voltage drops of the two transistors, resulting in a
scenario where each transistor is just on the verge of turning on when the input
signal is zero volts, eliminating the 1.4 volt "dead" signal zone that existed before.
Unfortunately, though, this solution is not perfect: as the transistors heat up from
conducting power to the load, their Vbe forward voltage drops will decrease from
0.7 volts to something less,such as 0.6 volts or 0.5 volts. The diodes, which are not
subject to the same heating effect because they do not conduct any substantial
current, will not experience the same change in forward voltage drop. Thus, the
diodes will continue to provide the same 1.4 volt bias voltage even though the
transistors require less bias voltage due to heating.
RELAY DRIVERS
Introduction:
The relay driver section gives signal to the relay and makes the relay to close
its contacts. As the relay has a small mechanical contact i.e.., a small metallic strip
the relay drier must have capacity to drive it. For this a special IC used which has
high signal carrying capacity and the IC used for this is IC ULN 2003
DARLINGTON ARRAY.
The IC ULN 2003 series are high voltage, high current Darlington drivers
comprised of seven NPN Darlington pairs.
All units feature integral clamp diodes for switching inductive loads.
Applications include relay, hammer, lamp and display (LED) drivers.
Features:
Pin Configuration:
The ULN2003 are high voltage, high current Darlington arrays each
containing seven open collector Darlington pairs with common emitters. Each
channel rated at 500mA and can withstand peak currents of 600mA. Suppression
diodes are included for inductive load driving and the inputs are pinned opposite
the outputs to simplify board layout.
These versatile devices are useful for driving a wide range of loads including
solenoids, relays DC motors; LED displays filament lamps, thermal print heads
and high power buffers.
ULN 2003 is supplied in 16 pin plastic DIP packages with a copper lead
frame to reduce thermal resistance. They are available also in small outline
package.
Schematic Diagram:
The schematic diagram consists of four diodes, two transistors and a set of
resistors. It has four terminals input, output, ground and common terminal. The three
terminals are given to three terminals of the relay and the input terminal is connected
to control logic circuit.
Maximum Ratings:
The table shows the maximum ratings of IC ULN2003 where it shows the
output voltage, maximum input voltage, operating temperature, storage temperature
etc..,
The circuit shown above is the test circuit of IC ULN2003. It has a pulse
generator which generates required signal to be given to the relay. As the relay
works on DC supply this pulse generator generates pure ripple free DC.
It also has a NOT gate which makes the relay to open its contacts when the
power is off or when the fault occurs or else when the supply is on spark occurs. To
avoid this we use a NOT gate and a diode connected parallel.
Relay:
Contact Specifications:
Introduction to Microcontrollers
Memory unit
Let add 3 more memory locations to a specific block that will have a built in
capability to multiply, divide, subtract, and move its contents from one memory
location onto another. The part we just added in is called "central processing unit"
(CPU). Its memory locations are called registers.
Representation of Bus
Input-output unit
Those locations we've just added are called "ports". There are several types
of ports: input, output or bidirectional ports. When working with ports, first of all it
is necessary to choose which port we need to work with, and then to send data to,
or take it from the port. When working with it the port acts like a memory location.
Something is simply being written into or read from it, and it could be noticed on
the pins of the microcontroller.
Serial communication
Timer unit
The timer block this can give us information about time, duration, protocol
etc. The basic unit of the timer is a free-run counter which is in fact a register
whose numeric value increments by one in even intervals, so that by taking its
value during periods T1 and T2 and on the basis of their difference we can
determine how much time has elapsed. This is a very important part of the
microcontroller whose understanding requires most of our time.
Watchdog
As the peripheral signals usually are substantially different from the ones
that microcontroller can understand (zero and one), they have to be converted into
a pattern which can be comprehended by a microcontroller.
• All single cycle instructions except for program branches which are two cycle
• Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable
operation
• Programmable code-protection
Peripheral Features
• Timer1: 16-bit timer/counter with prescaler, can be incremented during sleep via
external crystal/clock
• Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler
• Synchronous Serial Port (SSP) with SPI (Master Mode) and I2C (Master/Slave)
• Parallel Slave Port (PSP) 8-bits wide, with external RD, WR and CS controls
(40/44-pin only)
Pin layout of PIC16F877A
PIC 16F877A
Architecture of PIC16F877A
Memory organization
There are three memory blocks in each of these PICmicro MCUs. The
Program Memory and Data Memory have separate buses so that concurrent access
can occur.
The data memory is partitioned into multiple banks which contain the
General Purpose Registers and the Special Function Registers. Bits
RP1(STATUS<6>) and RP0 (STATUS<5>) are the bank select bits.
Each bank extends up to 7Fh (128 bytes). The lower locations of each bank are
reserved for the Special Function Registers. Above the Special Function Registers
are General Purpose Registers, implemented as static RAM.
The register file can be accessed either directly or indirectly through the File
Select Register FSR.
Special function registers
The Special Function Registers are registers used by the CPU and peripheral
modules for controlling the desired operation of the device. These registers are
implemented as static RAM. The Special Function Registers can be classified into
two sets; core (CPU) and peripheral.
Status register
The STATUS register contains the arithmetic status of the ALU, the RESET
status and the bank select bits for data memory. The STATUS register can be the
destination for any instruction, as with any other register. If the STATUS register
is the destination for an instruction that affects the Z, DC or C bits, then the write
to these three bits is disabled. These bits are set or cleared according to the device
logic. The TO and PD bits are not writable, therefore, the result of an instruction
with the STATUS register as destination may be different than intended.
OPTION_REG register
INTCON register
The PIE1 register contains the individual enable bits for the peripheral
interrupts.
PIR1 register
The PIR1 register contains the individual flag bits for the peripheral
interrupts.
PIE2 register
The PIE2 register contains the individual enable bits for the CCP2 peripheral
interrupt, the SSP bus collision interrupt, and the EEPROM write operation
interrupt.
PIR2 register
The PIR2 register contains the flag bits for the CCP2 interrupt, the SSP bus
collision interrupt and the EEPROM write operation interrupt.
PCON register
Direct Addressing
Indirect Addressing
Indirect unlike direct addressing does not take an address from an instruction
but makes it with the help of IRP bit of STATUS and FSR registers. Addressed
location is accessed via INDF register which in fact holds the address indicated by
a FSR. In other words, any instruction which uses INDF as its register in reality
accesses data indicated by a FSR register. Let's say, for instance, that one general
purpose register (GPR) at address 0Fh contains a value of 20. By writing a value of
0Fh in FSR register we will get a register indicator at address 0Fh, and by reading
from INDF register, we will get a value of 20, which means that we have read from
the first register its value without accessing it directly (but via FSR and INDF).
It appears that this type of addressing does not have any advantages over
direct addressing, but certain needs do exist during programming which can be
solved smoothly only through indirect addressing.
The INDF register is not a physical register. Addressing the INDF register
will cause indirect addressing. Indirect addressing is possible by using the INDF
register. Any instruction using the INDF register actually accesses the register
pointed to by the File Select Register, FSR. Reading the INDF register itself
indirectly (FSR = ’0’) will read 00h. Writing to the INDF register indirectly results
in a no-operation (although status bits may be affected).
I/O Ports
Some pins for these I/O ports are multiplexed with an alternate function for
the peripheral features on the device. In general, when a peripheral is enabled, that
pin may not be used as a general purpose I/O pin.
PORTD is an 8-bit port with Schmitt Trigger input buffers. Each pin is
individually configurable as an input or output. PORTD can be configured as an 8-
bit wide microprocessor port (parallel slave port) by setting control bit PSPMODE
(TRISE<4>). In this mode, the input buffers are TTL.
PORTE and TRISE Register
The Data EEPROM and FLASH Program Memory are readable and writable
during normal operation over the entire VDD range. The data memory is not
directly mapped in the register file space. Instead it is indirectly addressed through
the Special Function Registers (SFR). There are six SFRs used to read and write
the program and data EEPROM memory.
The EEPROM data memory allows byte read and writes. When interfacing
to the data memory block, EEDATA holds the 8-bit data for read/write and
EEADR holds the address of the EEPROM location being accessed. The registers
EEDATH and EEADRH are not used for data EEPROM access. These devices
have up to 256 bytes of data EEPROM with an address range from 0h to FFh.
Program memory access allows for checksum calculation and calibration
table storage. A byte or word write automatically erases the location and writes the
new data (erase before write). Writing to program memory will cease operation
until the write is complete. The program memory cannot be accessed during the
write, therefore code cannot execute. During the write operation, the oscillator
continues to clock the peripherals, and therefore they continue to operate When the
write completes, the next instruction in the pipeline is executed and the branch to
the interrupt vector address will occur
Program
#include <16F877A.h>
#device *=16
#device adc=10
#use delay(clock=10000000)
#fuses HS,NOLVP,NOWDT,PUT,NOPROTECT,BROWNOUT
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#byte PORTA = 5
#byte PORTB = 6
#byte PORTC = 7
#byte PORTD = 8
#byte PORTE = 9
int dsec = 0;
int disp= 0;
int disp_bk = 0;
//////modbus variable////////
int sim_mode = 0;
int16 HEARTBEAT = 0;
int16 PULSEFLAG = 0;
int16 SPEED = 0;
int16 VBRS1 = 0;
int16 VBRS2 = 0;
int16 VBRS3 = 0;
int msg = 0;
//int16 in_flag = 0;
//int16 spd_cnt = 0;
//int16 spd_stp = 0;
//int16 vbs_cnt = 0;
//int16 SEN_TIMER = 0;
#bit UP = PORTC.2
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////
void lcdready(void)
EN_LCD=0;
EN_LCD=1;
}*/
delay_us(500);
EN_LCD =0;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////
delay_ms(dsec);
////////////////////////////////////////////////////////////////////////////////
void lcdsetting(void)
delay_ms(1);
putc(0x0d);
putc(0x0a);
while(sec > 0)
delay_ms(1000);
sec = sec - 1;
}
void GSM_MSG(int msg)
lcdsetting();
dsec = 30;
printf(display,"MESSAGE...to ");
printf("AT+CMGF=1");
crlf(2);
printf("AT+CMGS=\"");
command(0xc0);
printf(display,"CELL:%s",FMR_CELL);
printf("%s",FMR_CELL);
printf("\"");
crlf(1);
crlf(0);
if(msg == 1)
{
printf("LPG LEAKAGE IS ");
crlf(0);
crlf(0);
crlf(0);
printf("**THANK YOU**");
crlf(0);
// crlf(0);
else
putc(0x1a);
delay_ms(1000);
command(0x80); // force cursor to beginning of 2st line
printf(display,"SENDING........");
delay_ms(1000);
lcdsetting();
#byte ADCON_0=0X1F
#byte ADCON_1=0X9F
int16 AI[8];
int i;
int16 avg_tot = 0;
SET_TRIS_A( 0xff );
setup_adc_ports(AN0_AN1_AN2_AN3_AN4);
setup_adc(ADC_CLOCK_INTERNAL);
for(i=0;i<chn;i++)
avg_tot = 0;
set_adc_channel(i);
select = 1;
read_adc(ADC_START_ONLY);
while(select == 1)
delay_us(1);
set_adc_channel(i);
select = 1;
read_adc(ADC_START_ONLY);
while(select==1)
{
delay_us(1);
set_adc_channel(i);
select = 1;
read_adc(ADC_START_ONLY);
while(select==1)
delay_us(1000);
set_adc_channel(i);
select = 1;
read_adc(ADC_START_ONLY);
while(select==1)
{
}
delay_us(1000);
AI[i] = avg_tot / 4 ;
/////////////////////////////////////////
VBRS1 = AI[0];
VBRS2 = AI[1];
VBRS3 = AI[2];
// SPEED = (int16)((float)AI[2]*0.14718);
RELAY1 = 0;
RELAY2 = 0;
RELAY4 = 0;
GSM_MSG(1);
delay_ms(1000);
RELAY4 = 1;
else
RELAY1 = 1;
RELAY2 = 1;
RELAY4 = 1;
}
}
////////////////////////////////////////////
lcdsetting();
dsec = 10;
delay_ms(2000);
lcdsetting();
dsec = 10;
printf(display,"DETECTION SYSTEM");
delay_ms(2000);
////////////////////////////////////////////
void main(void)
sim_mode = 0;
setup_adc_ports(AN0_AN1_AN2_AN3_AN4);
setup_adc(ADC_CLOCK_INTERNAL);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_32);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
enable_interrupts(INT_RTCC);
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
port_b_pullups(TRUE);
RELAY3 = 0;
RELAY4 = 0;
TITLE ();
lcdsetting();
dsec = 0;
for(;;)
RELAY1 = 1;
RELAY2 = 1;
// lcdsetting();
dsec = 10;
delay_ms(100);
readAIstatus ();
}
INTRODUCTION TO GSM WIRELESS MODEMS
4. GSM Modem:
A GSM modem is a wireless modem that works with a GSM wireless network. A
wireless modem behaves like a dial-up modem. The main difference between them
is that a dial-up modem sends and receives data through a fixed telephone line
while a wireless modem sends and receives data through radio waves.
Like a GSM mobile phone, a GSM modem requires a SIM card from a wireless
carrier in order to operate.
The number of SMS messages that can be processed by a GSM modem per minute
is very low -- only about six to ten SMS messages per minute.
4.1 GSM / GPRS Modem for GSM 900 / GSM 1800 / GSM 1900
Fig 4.1 SIMCOM GSM Based Modem
SIMCOM GSM based Modem with most of the functions taken care on
board is shown on the above figure.This GSM modem is a highly flexible plug and
play GSM 900 / GSM 1800 / GSM 1900 modem for direct and easy integration
RS232, voltage range for the power supply and audio interface make this device
perfect solution for system integrators and single user. Voice, Data/Fax,
SMS,GPRS, integrated TCP/IP stack,RTC and other features like the GSM /
GPRS.
Group 3, Class 1
Point-to-point MO & MT
SMS cell Broadcast
Text & PDU mode
Tricodec
Half rate (HR)
Full rate (FR)
Enhanced Full rate (EFR)
Noise reduction
4.6 INTERFACES :
Sensitive material of MQ-2 gas sensor is SnO2, which with lower conductivity in
clean air. When the target combustible gas exist, The sensor’s conductivity is more
higher along with the gas concentration rising. Please use simple electro circuit,
Convert change of conductivity to
correspond output signal of gas concentration.
The MQ-6 module is used in gas leakage detecting equipment in family and
industry, This module has high sensitivity to LPG, iso-butane, propane and LNG.
It can also be used to detect the presence of alcohol, cooking fumes, and cigarette
smoke.The module gives out the concentration of the gases as a analog voltage
equivalent to the concentration of the gases. The module also has an onboard
comparator for comparing against an adjustable preset value and giving out a
digital high or low. It can be easily interfaced with your Arduino or Raspberry
Pi.This is a simple-to-use MQ-6 Liquefied Petroleum, iso-butane, propane gas
Sensor module, suitable for sensing LPG (composed of mostly propane and
butane) concentrations in the air.
The MQ-6 can detect gas concentrations anywhere from 200 to
10000ppm.This sensor has a high sensitivity and fast response time. The sensor’s
output is an analog resistance. The drive circuit is very simple; all you need to do is
power the heater coil with 5V, add a load resistance, and connect the output to an
ADC.
Sensitive material of MQ-6 gas sensor is SnO2, which with lower conductivity in
clean air. When the target combustible gas exist, The sensor’s conductivity is more
higher along with the gas concentration rising. Please use simple electrocircuit,
Convert change of conductivity to correspond output signal of gas
concentration.MQ-6 gas sensor has high sensitity to Propane, Butane and LPG,
also response to Natural gas. The sensor could be used to detect different
combustible gas, especially Methane, it is with low cost and suitable for different
application.
FEATURES
Voltage: 5V
Detecting concentration :
200-10000 ppm LPG
iso-butane
propane
LNG
Analog and Digital Output
Digital Out is High or Low based on a adjustable preset threshold.
APPLICATIONS
Working
When the target combustible gas exist, The sensor’s conductivity is morehigher
along with the gas concentration rising. Please use simple electrocircuit,Convert
change of conductivity to correspond output signal of gas concentration.MQ-2 gas
sensor has high sensitivity to LPG, Propane and Hydrogen, also couldbe used to
Methane and other combustible steam, it is with low cost and suitablefor different
application. In order to make the sensor with better performance,suitable RL value
is needed:Power of Sensitivity body(Ps):Ps=Vc2×Rs/(Rs+RL)2
BUZZER
Operating voltage : 3 ~ 20 V dc
Current consumption : 14 mA
Rated voltage : 12 V dc
Tone : continuous
Weight : 4.5 g
SOFTWARE DETAILS
Introduction of MPLAB
The MPLAB X IDE is the new graphical, integrated debugging tool set for
all of Microchip’s more than 800 8-bit, 16-bit and 32-bit MCUs and digital signal
controllers, and memory devices.
Development Tools
The Mplab development tools for PIC offer numerous features and
advantages that help you quickly and successfully develop embedded applications.
They are easy to use and are guaranteed to help you achieve your design goals.
The MPLAB IDE and Debugger is the central part of the Microchip PIC
development tools. MPLAB offers a Build Mode and a Debug Mode.
In the MPLAB Build Mode you maintain the project files and generate the
application. MPLAB uses either the Hi-Tech or PIC ASM development tools. In
the MPLAB Debug Mode you verify your program either with a powerful CPU
and peripheral simulator that connects the debugger to the target system. The ICD2
allows you also to download your application into Flash ROM of your target
system.
Getting Started
The MPLAB IDE combines project management, make facilities, source code
editing, program debugging, and complete simulation in one powerful
environment. The MPLAB development platform is easy-to-use and helping you
quickly create embedded programs that work. The MPLAB editor and debugger
are integrated in a single application that provides a seamless embedded project
development environment. Use MPLAB to create your source files and organize
them into a project that defines your target application. MPLAB automatically
compiles, assembles, and links your embedded application and provides a single
focal point for your development efforts. When you use the MPLAB, the project
development cycle is roughly the same as it is for any other software development
project.
☞Create a project, select the target chip from the device database, and
configure the tool settings.
☞Debug the executable logic by watching program flow with the built-in
simulator or in real time with in-circuit emulators or in-circuit debuggers.
☞Make timing measurements with the simulator or emulator.
Create a Project
☞Create a project file and select a CPU from the device database.
☞Create a new source file and add this source file to the project.
Start MPLAB
In order to test the code, software or hardware is needed that will execute the
PIC micro instructions. A debug execution tool is a hardware or software tool that
is used to inspect code as it executes a program (in this case led_delay.c).
Hardware tools such as MPLAB ICE or MPLAB ICD 2 can execute code in real
devices. If hardware is not available, the MPLAB simulator can be used to test the
code. In this tutorial we can use MPLAB SIM simulator.
The simulator is a software program that runs on the PC to simulate the
instructions of the PIC micro MCU.
It does not run in “real time,” since the simulator program is dependent upon the
speed of the PC, the complexity of the code, overhead from the operating system
and how many other tasks are running. However, the simulator accurately
measures the time it would take to execute the code if it were operating in real time
in an application.
Note: Other debug execution tools include MPLAB ICE 2000, MPLAB ICE
4000 and MPLAB ICD 2. These are optional hardware tools to test code on the
application PC board. Most of the MPLAB IDE debugging operations are the same
as the simulator, but unlike the simulator, these tools allow the target PIC micro
MCU to run at full speed in the actual target application.
Additional menu items should now appear in the Debugger menu. Additional
toolbar icons should appear in the Debug Tool Bar.
MPLAB SIM is one of the debug engines that can be used with MPLAB.
The other debug engines are hardware devices, while MPLAB SIM is a software
program that runs on your PC. MPLAB SIM provides many of the same features as
in-circuit emulators and in-circuit debuggers. The difference is that both in-circuit
emulators and in-circuit debuggers allow the code to be run on actual silicon, and
also allow target application hardware to be functional while being debugged.
MPLAB SIM has features to simulate hardware interaction with other
signals and devices, and since it is running as software on the PC.
It has complete information about the internal state of the simulated chip at
each instruction. This is a little different from the hardware debuggers because,
while they are running code at full speed, they typically cannot monitor all
registers and all memory in real time.
Both MPLAB SIM and the hardware debuggers can do the traditional functions of
debuggers, but due to their differences, they can have unique features of their own.
This presentation will identify the functions and features of MPLAB SIM.
The debugger is a part of MPLAB IDE, and whether you are using MPLAB SIM,
MPLAB ICE or MPLAB ICD 2, most operations are exactly the same. This allows
you to develop code using the simulator, and then when your hardware is ready,
you can use a hardware debugger to further test your code in practice without
having to learn how to use a new tool.
☞Single Step through code to closely inspect how it executes. This allows the
engineer to go through code one instruction (or one C statement) at a time while
monitoring affected variables, registers and flags. Single stepping essentially
“zooms in” on code to ensure that it operates correctly in complex and critical
sections with ranges of variable values and under various test conditions.
Most debuggers also have additional features to help analyze and debug the
application.
☞Watch points group and monitor selected variables and memory locations
into a convenient, custom readout.
☞Trace buffers capture the streams of instructions executed and reveal the
contents of changing register values.
MPLAB SIM is a simulator, and as a result it has certain characteristics that make
it a unique debug engine. So the speed of the simulation is determined by,
☞How fast your PC executes,
☞Memory, and
In order to test the application on the simulator, stimulus signals can be applied to
pins and registers.
To evaluate performance, the simulator can log changing registers to files for
further analysis.
Select the simulator as the debug execution tool. This is done from the
Debugger>Select Tool pull down menu.
MPLAB SIM is selected as the debug engine from the Debugger menu. Note the
other functions on the debug menu, such as Run, Step, and Breakpoints.
Once a debug engine is selected, the toolbar is appended with some new icons for
running, halting, single stepping, and resetting the target.
The Status bar now shows some additional information.
☞The W register,
The toolbar icons, the menus, or the hot keys listed on the menus can be used to
execute the debug functions. Note that some are a little more complex, such as
Reset, which actually has four types of reset actions.
Once MPLAB SIM is established as the debug engine, whenever a project is built,
it is automatically loaded into the simulator’s program memory to be run and
tested.
One debug window is the source code window. This is actually the editor window,
and breakpoints can be set by clicking on a line with the right mouse button. Single
stepping with the source code window in focus will single step through the C
source lines. Since you are in the editor, changes can be done quickly, and the
project can be rebuilt.
ADVANTAGE:
Low cost
More effective
It is a safety process.
Automatically monitoring
APPLICATION: