Sunday 9 May 2010

Blogger Buzz: Blogger integrates with Amazon Associates

Blogger Buzz: Blogger integrates with Amazon Associates

Thursday 23 April 2009

Reversing a String

;8086 program to reverse the entered string

data segment
msg1 db "Enter the string: $"
msg2 db 0ah,0dh,"Reversed string is: $"
ent db 0dh,0ah,"$"
str1 db 100 dup(?)
rev db 100 dup(?)
data ends

print macro msg
lea dx,msg
mov ah,09h
int 21h
endm

read macro
mov ah,01h
int 21h
endm

code segment
start:
mov ax,data
mov ds,ax

mov bx,0000h
lea si,str1
print msg1

L1:
read
mov [si],al
inc bx
inc si
cmp al,0dh
jnz L1


dec si
mov cx,bx
lea di,rev

L2:
mov al,[si]
mov [di],al
inc di

dec si
dec cx
jnz L2

print msg2
add si,bx

mov cx,bx
print ent

L3:
mov dl,[si]
mov ah,02h
int 21h
dec si
dec cx
jnz L3


en:

mov ah,4ch
int 21h
code ends
end start

;Program ends Here

querrymail@gmail.com

Getting an Input from Keyboard and Displaying it

;8086 program to get an Input from Keyboard and Displaying it

data segment
msg db "Enter a character: $"
msg1 db 0dh,0ah, "The Entered character is:$"
data ends
print macro msg
lea dx,msg
mov ah,09h
int 21h
endm
read macro
mov ah,01h
int 21h
endm
display macro
mov ah,02h
int 21h
endm
code segment
start:
mov ax,data
mov ds,ax
print msg
read
mov bl,al
print msg1
mov dl,bl
display
mov ah,4ch
int 21h
code ends
end start

;Program Ends Here

querrymail@gmail.com

Display a Message on DOS Prompt

This 8086 program compiled in MASM compiler displays the word welcome on the screen.

;Program Starts Here

msg1 db "hello$"
data ends
code segment
start:
mov ax,data
mov ds,ax
lea dx,msg1
mov ah,09h
int 21h
mov ah,4ch
int 21h
code ends
end start

;Program Ends Here

data segment

querrymail@gmail.com

Electronic Rain Guage

CIRCUIT DESCRIPTION

Electronic rain gauge can measure the rainfall of a day. The circuit consists of a sensing section, Micro controller section and a display section.

Sensing section

The sensing section includes a uniform cylindrical collector, 9V dc battery, the voltage regulator IC 7805 and the NOT gate IC 4069N. The 9V DC battery and 7805 regulator provide VCC supply of +5V. The connecting wires are used as the sensors. We use 7 wires and are cut 1cm apart and the longest wire is connected from VCC. fixed at the bottom base of the collector by drilling. Rest of six sensing wires are also fixed 1 cm apart from the base by drilling for recording 5cm and above rainfall and these wires are connected to corresponding inputs of the 6 NOT gates.



If there is no rain, collector is empty and no high signal is at the input of NOT gates. When the water level of collector reaches 1 cm, then the VCC wire at the base and first sensing wire fixed at 1 cm of collector is shorted. Now a high signal (+5V) reaches the input of the first NOT gate. Thus the output of the gate becomes low (zero) Similarly when water level at 2 cm of collector, second sensing wire also got connection with the VCC. Now out put of corresponding not gate also come low. Since the capacity of our rain gauge is 6 cm when the water reaches the top of the collector all the sensing wires are connected with VCC. Now all the inputs of NOT gates are feed from VCC. , out put will become low.

Micro controller section

In the rain gauge we use PIC 16F877A micro controller. It is clocked by crystal oscillator for getting maximum operating Frequency of 20 MHz. It also get supply from the same +5V VCC. Here D port is assigned as input port and C as the out put port.

The output from the NOT gates are connected to the input port lines. ie. out put of the 1st Not gate is connected to Port line D0 , Second gate to D1, like wise 6th gate to D5. All the D ports are set initially. When no rain, there is no change of out put from the NOT gate and initial condition of the D port remains as such; ie. all are set.

When water level rises to 1 cm the out put of first NOT gate become low and low signal reaches the port D0 and it is reset. (ie. Become zero). Similarly when water level at 2 cm the out put of second NOT also become low and gradually port D1, is reset. This will continue up to the capacity of the gauge. Ie. When water reaches top level then out put of all NOT gates will be zero and, the ports D0,D1,D2,D3,D4,D5 are set.



Display Section


Display section include 16 x 2 LCD. The LCD contrast is adjusted by using a 10K port. Here LCD is interfaced with PIC 16F877A. In spite of assigning Port C as out put the port A is also assigned as output by resetting it. Now from Port C connections are made to LCD for data part and from port A connections are made for control part ie. Port A2 is connected to the 4th Pin (RS pin) of LCD to Select command or data register, and A5 is connected to 6th pin (E Pin) to disable or enable LCD. Port C0 to C4 are connected to LCD for display data part.


PIC 16F877A and LCD are interfaced and programmed such that, LCD should display the required information about the rain fall. LCD is 16 x 2, the first line of LCD is made permanent display as “RAIN GAUGE”, using program. Second line is for display information about rain fall. The PIC is [ programmed such a way that, when port D is in unchanged stage ie. all are set then LCD will display LOW/NO RAIN. When port D0 become Low (Zero) then “1 cm Rain” will be displayed on LCD. Similarly when D1, is reset, then LCD will display “2cm Rain”. Likewise when water level reaches top of the collector, all D0.,D1,D2,D3,D4 and D5 Ports are reset, then it is programmed such that “Heavy rain” will be the display.

Thus sensor section, PIC section and display section, perform their work synchronically to display the accurate rainfall and do its duty as a “Electronic Rain Gauge”.

Program

;Program Starts Here

#include <16F877a.h>
#include
#include
main()
{ char no[]="Low/No ",hi[]="Heavy ",cm[]=" cm ",clr[]=" ";
char po[]="Rain Guage",ra[]="Rain";
int val,set,i;
trisd=0xff;
lcdinit();
///misc
go(0);
printc(po);
delay_ms(300);
ra2=0;
for(i=0;i<5;i++)
{
portc=0x1c;
ok();
delay_ms(500);
}
for(i=0;i<3;i++)
{
portc=0x18;
ok();
delay_ms(500);
}
for(i=0;i<4;i++)
{

portc=0x8;
ok();
delay_ms(500);
portc=0x0C;
ok();
delay_ms(1000);
}
portc=1;
ok();
ra2=1;
///end
// position 0, 1... first row, 64,65,....Second row
go(3);
printc(po);

while(1)

{


// delay_ms(1000);
val=portd;

switch(val)
{
case 0xfe:
printc(clr);
go(67);
printh(1); //1
printc(cm);
printc(ra);
break;
case 0xfc:
printc(clr);
go(67);
printh(2);
printc(cm);
printc(ra); //2
break;

case 0xf8:
printc(clr);
go(67);
printh(3);
printc(cm);
printc(ra); //3
break;
case 0xf0:
printc(clr);
go(67);
printh(4);
printc(cm);
printc(ra); //4
break;
case 0xe0:
printc(clr);
go(67);
printh(5);
printc(cm); //5
printc(ra);
break;
case 0xc0:
printc(clr);
go(67);
printh(6);
printc(cm); //6
printc(ra);
break;
case 0x80:
printc(clr);
go(67);
printc(hi); //7
printc(ra);
break;

default:
printc(clr);
go(67);
printc(no); //No
printc(ra);
}
}
}

;Programmed in C
;Program Ends Here

Source: We got this idea from EFY Magazine.

PC Based Oscilloscope Using Matlab


Visit this link:

http://www.mathworks.com/matlabcentral/fileexchange/13165

You can download a .zip file. Unpack and use the oscilloscope.
But it uses your PC's sound card as interface. And also its frequency range is limited to 20Hz-20kHz. Higher frequencies can damage your sound card.


Octave: Open Source Alternative for Scilab



Octave, a freely redistributable software, is used for numerical computation with an interactive environment. Students pick up the basics quickly, comfortably using it within just a few hours. High-level language application intended primarily for numerical computations and other numerical experiments using a language that is compatible with Matlab. It is customizable with user-defined functions written in Octave's language or C++, C, Fortran or others.


For more:

http://www.osalt.com/octave

querrymail@gmail.com