Sunday, October 17, 2010

Emacs - Keyboard functions

Emacs is one of the best software system that can use for text based operations. More details can be found here.
Anyway, I was summarized control keys for my use.
Note:

"M" for ALT key and "C" for CTRL key in the key board.

---------------------------------------------
C-v = move forward by page
M-V = move backward by page
C-l = Center the cursor
--------------------------------------------

C-p = previous line
C-n = next line
C-f = forword by character
C-b = backword by charactor
--------------------------------------------

M-f = forword move by word
M-b = Backword move by word
--------------------------------------------

C-a = Move to begining of line
C-e = Move to end of line
M-a = Move to begining of sentence
M-e = Move to end of sentence
--------------------------------------------

M-< = To bigining of the document
M-> = To end of the document
--------------------------------------------

C-u 8 C-f = Move by 8 charactors
C-u 8 C-v = Move by 8 lines
--------------------------------------------

C-g = cancel previous commands
--------------------------------------------

C-x 1 = Maximize current window
--------------------------------------------

C-u 8 * = Insert 8 "*" marks
--------------------------------------------

C-d = delete char after the curser
M- = Kill the word before curser
M-d = Kill the word after cursor
C-k = kill by the end of line
M-k = Kill by the end of Sentence
--------------------------------------------

C- --> Move to other end --> C-w = kill the marked area
--------------------------------------------

C-y = paste the last killed text in current curser position
M-y = replace the pasted text with before last kill
--------------------------------------------

C-x u = Undo. Can use repititive way
C-_ = Same as undo
--------------------------------------------

C-x C-f = Find a file
C-x C-s = Save the file
C-x C-c = Save changes and kill Emacs
C-z = Suspend Emacs temparaly and go to Shell. Resume by "fg"
--------------------------------------------

C-x C-b = List all buffers
C-x b = switch between buffers
C-x s = save buffers (Ask)
--------------------------------------------

M-x = Run commands
Ex: Replace String:
M-x repl s
--------------------------------------------

M-x recover file
--------------------------------------------

M-x text mode --->> Mode change commands
--------------------------------------------

C-s = search -> type word -> When again press C-s -> Goto Next
--------------------------------------------

C-x 2 = split window by 2
C-M-v = Scroll the second window
C-x o = Move cursor to sencon window wise visa
C-x 4 C-f = open different file in second window
--------------------------------------------

= Recursive mode escape
--------------------------------------------

Monday, November 23, 2009

Interfacing with DS 18 B 20 Digital Thermometer



DS18B20PAR is 3 pin digital thermometer with all necessary features to measure temperature upto 12 bit resolution. This use one wire protocol, so it is easy to wire. But, bit difficult to interface. This IC operates with Parasite-Power(bus powered) and so we need only two wires. For more information and free samples, refer

http://www.maxim-ic.com/quick_view2.cfm?qv_pk=2813

This is the mcu code to read and write data from this chip.

Hardware over view.....

** Use PIC18F452 with 12MHz oscillator.
** Refer the top image for hardware connections
** Use Mikro Electronika C compiler
----------------------------------------------------------------------------------
#define set_A(var,bitnum) (var)|=(1<<(bitnum))
#define res_A(var,bitnum) (var)&=~(1<<(bitnum))

short reset_ow()
{
short r;
set_A(TRISA,5); // pull up disable
res_A(TRISA,4); // data pin as o/p
res_A(PORTA,4); // put bus to low
Delay_us(500);
set_A(TRISA,4); // i/p
Delay_us(70); // wait for response
if(PORTA & 0x10) // if bus is still high,
{
r=0;
}
else
{
r=1;
}
Delay_us(500);
return r;
}
/////////////////////////////////////////////////////////////////////////////////////
void write_ow(unsigned short data)
{
short x;
set_A(TRISA,5); // pull up disable
//set_A(TRISA,4); // pull up disable
res_A(TRISA,4); // data pin as o/p
for(x=0;x<8;x++)
{
if(data & 0x01) // write 1 time slot
{
res_A(PORTA,4); // put bus to low
Delay_us(10);
set_A(PORTA,4); //release the bus to high
Delay_us(60);
}
else // write 0 time slot
{
res_A(PORTA,4); // put bus to low
Delay_us(70);
set_A(PORTA,4);
}
Delay_us(2); // recovery time
data=data>>1; // next data bit
}
}
/////////////////////////////////////////////////////////////////////////////////////
unsigned short read_ow()
{
unsigned short res=0,x=0,y=0;
set_A(TRISA,5); // pull up disable
for(x=0;x<8;x++)
{
res_A(PORTA,4); // put bus to low
res_A(TRISA,4); // data pin as o/p
Delay_us(2);
set_A(TRISA,4); //release the bus to high & data pin as i/p
Delay_us(10);
if(PORTA & 0x10) // if bus is high,
{
y=1< }
else
{
y=0;
}
res=res | y;
Delay_us(50);
}
return res;
}
/////////////////////////////////////////////////////////////////////////////////////
void pullup()
{
set_A(PORTA,5);
res_A(TRISA,5); // RA 5 as o/p
}
////////////////////////////////////////////////////////////////////////////////////
void main()
{
unsigned short j=0;

unsigned int temp=0,f=0;

ADCON1 = 0xFF;

while(1)
{
reset_ow();
write_ow(0xCC); //skip ROM
write_ow(0x44); // convert
pullup();
Delay_ms(800);

reset_ow();
write_ow(0xCC); //skip ROM
write_ow(0xBE); // read search pad
j=read_ow();
temp=read_ow();

temp <<= 8;
temp = temp + j; // Form the result you can get this as temparature

Delay_ms(200);
}
}
/////////////////////////////////////////////////////////////////////////////////////

Thursday, November 19, 2009

Browser Compatibility Problem Solved !!



In some web sites need to enter the password to log in. And when you type the password, it will display as dots.(Instead of showing the password characters). This password mask will done by the changing input field type.
------------------------------------------------------------------------------
<input name="pw" value="" type="passowrd"/>
------------------------------------------------------------------------------
This will appear normal input field in a html page. But, when you type something on it, it will show as dots.
But, we need to display the text "Password" inside this box and when user click on this, the text should clear. Clearing stuff can be done by java script easily. But problem is this.

If we need to display the text inside the text box, we can do this.
--------------------------------------------------------------------------------
<input name="pw" value="Password" type="passowrd" />
--------------------------------------------------------------------------------
ohhhh... Then it will display as dots !!!

Then what can I do ? One option is change the type from "text" to "password" from java script..
Yes. It works on Firefox. But on internet explorer ???

What a ugly browser is ? IE doesn't support on this dynamic field change !!! Then try to clone nodes and replace parent. It works, but reverse is not !!!

This is the simplest solutioncc to over come in such problems... Use dummy field !!!

----------------------------------------------------------------------------

<input name="pwd_dummyfield1" style="width: 140px;" id="pwd_dummyfield1" value="Password" onfocus="changePassword(true,'passWord_-3','pwd_dummyfield1');" type="text">

<input name="passWord_-3" style="width: 140px; display: none;" id="passWord_-3" onblur="changePassword(false,'passWord_-3','pwd_dummyfield1');" type="password">

<script type="text/javascript">
function changePassword(change,id,dummyid)
{
var dummy = document.getElementById(dummyid);
var actual = document.getElementById(id);

if(change)
{
dummy.style.display = 'none';
actual.style.display = 'block';
actual.focus();
}
else
{
if(actual.value.length == 0)
{
dummy.style.display = 'block';
actual.style.display = 'none';
}
}
}
</script>
-------------------------------------------------------------------------------------

SONY TY voltage regulation problem



I have SONY KV-G 21 type 21 inch color TV, which was bought by my father 10 years ago. It works well for us more than, with small repairs. But from month ago, it had ugly fault. Sometimes, the image reduces from horizontal and stretch vertical and sound get stuck.

Unfortunately, when I remove the cover and try to test it...... Oh fault is not there and TV works fine !!!! What a headache. But, after two or three days, same story comes again..... OOOOHHHH..

In last Sunday, again I remove the back cover, and test the TV. I detect some sudden voltage drop form both 15V and 115V power supply outputs. According to the power supply design, 115V line is fully regulated, but it was 108V at that time !!!

Ohhhh.... This may happen with over loading, but my multi meter reading shows it's not. Then fault should be either primary side of the SMPS or in the secondary side.. The TV designers use STR-S 6707 as off line SMPS.

I just check the voltage across the opto isolater PC123 from secondary side, it varies.... It must be, but cannot present voltage if the supply is less than 115 V. !!! Nothing to say, the fault is in the SE115 - error amp IC. I just replace it and all come normal :-)

Wednesday, November 18, 2009

Nuwan's Home

This is my first post on blog :-) I will use this blog for recovered technical and related posts. Most of them will be related with electronics and micro controller related things. As well as I will put some important notes related with any area.....