Monday, 17 September 2012

MICROCONTROLLER

INTERNAL ROM
Internal ROM occupies the code address space from 0000H to 0FFFH  (Size = 4K byte)
Program addresses higher than 0FFFH will automatically fetch code bytes from external program memory
Code bytes can also be fetched exclusively from an external memory by connecting the external access pin (EA) to ground

Stack and Stack Pointer (SP)
SP is a 8-bit register used to hold an internal RAM address that is called the “top of the stack”
Stack refers to an area of internal RAM that is used in conjunction with certain opcodes to store and retrieve data quickly
SP holds the internal RAM address where the last byte of data was stored by a stack operation
When data is to be placed on the stack, the SP increments before storing data on the stack so that the stack grows up as data is stored
As data is retrieved from the stack, the byte is read from the stack, and then the SP decrements to point to the next available byte of stored data
SP = 07H  after reset

Internal Memory
A functioning computer must have memory for program code bytes, commonly in ROM, and RAM memory for variable data that can be altered as the program runs
8051 has internal RAM (128 bytes) and ROM (4Kbytes)
8051 uses the same address but in different memories for code and data
Internal circuitry access the correct memory based on the nature of the operation in progress
Can add memory externally if needed

Data Pointer (DPTR)

DPTR is a 16-bit register
DPTR is made up of two 8-bit registers: DPH and DPL
DPTR holds the memory addresses for internal and external code access and external data access
  (eg. MOVC  A,@A+DPTR       MOVX  A,@DPTR        MOVX  @DPTR,A )  
DPTR is under the control of program instructions and can be specified by its 16-bit name, or by each individual byte name, DPH and DPL
DPTR does not have a single internal address; DPH and DPL are each assigned an address (83H and 82H)

PC is a 16-bit register
PC is the only register that does not have an internal address
Holds the address of the memory location to fetch the program instruction
Program ROM may be on the chip at addresses 0000H to 0FFFH (4Kbytes), external to the chip for addresses that exceed 0FFFH
Program ROM may be totally external for all addresses from 0000H to FFFFH
PC is automatically incremented (+1) after every instruction byte is fetched

FLAGS
Flags are 1-bit registers provided to store the results of certain program instructions
Other instructions can test the condition of the flags and make decisions based on the flag states
Flags are grouped inside the program status word (PSW) and the power control (PCON) registers for convenient addressing
Math flags: respond automatically to the outcomes of math operations (CY, AC, OV, P)
User flags: general-purpose flags that may be used by the programmer to record some event in the program (F0, GF0, GF1)

Wednesday, 7 March 2012

Locker









cls
@ECHO OFF
title Folder Locker
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Locker goto MDLOCKER
:CONFIRM
echo Are you sure u want to Lock the folder(Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren Locker "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End
:UNLOCK
echo Enter password to Unlock folder
set/p "pass=>"
if NOT %pass%== type your password goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Locker
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md Locker
echo Locker created successfully
goto End
:End




Create your locker for folders.

Steps:
Open a notepad paste the above code and save as "xyz.bat" file.
Change the password while saving.

LED Brightness adjustment

How to Vary the Brightness of an LED

This is a simple project we're going to do so that we can vary the brightness that an LED gives out. We can make the LED shine very bright or we can make it shine dimly.
To do this, all we do is take a 9-volt battery and connect to a 470Ω resistor which is in series with a 100K potentiometer connected to an LED. We use a protection diode in this circuit so that if the 9-volt battery is inserted the wrong way, the LED can be protected from reverse current. But if you don't have this, it's ok. Just be more careful.
Vary brightness of an LED
Parts Needed
-9-volt Battery
-Protection Diode
-470Ω resistor (or any resistor within this proximity)
-100K Potentiometer
-An LED
The schematic of the circuit is shown below: This is now a more real life like representation of the circuit:

This is how the circuit works. When the potentiometer is turned all the way to the side where it has a resistance of near 0Ω, the LED shines the brightest because the circuit has the least amount of resistance at this point, so it produces the greatest amount of current, which is fed into the LED. Now as we begin turning the potentiometer to the other side so that its resistance begins to increase, the LED begins getting dimmer and dimmer until it finally goes out completely.
Similarly, we could start with the potentiometer turned the other direction in which it has a resistance of about 100KΩ. At first, the LED gives out no light. However, when we turn the potentiometer so that the resistance decreases, we eventually begin to see the LED light shine dimly. As we keep turning the potentiometer, decreasing its resistance, the LED shines brighter and brighter until it reaches its brightness point when the potentiometer is turned all the way so that its resistance is near 0Ω.
The reason we have the 470Ω resistor in the circuit is so that when the potentiometer is turned so that it outputs almost 0Ω, the LED isn't blown out. If the 470Ω resistor wasn't there, the resistance of the circuit would be extremely low, and so thus a high current would be produced in the current. The current would be too great for the LED to handle and would blow out the LED. The fixed 470Ω resistor is necessary so that the lowest resistance the circuit reaches is at least 470Ω so that too much current isn't produced.