Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

momentary to latch with interlock

Status
Not open for further replies.

7102

Newbie level 6
Joined
Jul 13, 2012
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,386
hi,

i have 3 momentary inputs that 3 inputs will be given to 89c51.

i want to know how to convert these momentary inputs to latch and also i need interlock between these 3 inputs.

7102.
 

C or ASM???

basically you need and extra bit for each input...
as far as i understand,
when you press input 1, you SETB the corresponding memory bit 1, and CLEAR the other two bits...
when you press input 2, you SETB the corresponding memory bit 2, and CLEAR the other two bits...
when you press input 3, you SETB the corresponding memory bit 3, and CLEAR the other two bits...
when you release any input.. well, you do nothing...
of course you use the memory bits instead the inputs for further work...
Code:
bit b1,b2,b3; // your memory bits
sbit in1 @ P1^0; //sorry i'm rusty in C51
sbit in2 @ P1^1; //
sbit in3 @ P1^2; 

...
//in code
// say all the inputs are active low...
if (!in1){
 b1=1;
 b2=0;
 b3=0;
} else if (!in2){
 b1=0;
 b2=1;
 b3=0;
} else if (!in3){
 b1=0;
 b2=0;
 b3=1;
}

//in the rest of the code.. use b1,b2,b3 instead of in1in2,in3...
 

thanks for your reply.

if input1 is high i will get input1 in the output & same for other two input.

if any two input is high i want only one output

for ex: input 1 & 2 is high i want input 2 at the output & same for all the combination.

Can u please help me with assembly code because i am new to C.


7102.
 

sadly I can't understand the logic you want to achieve....

do you still want to latch the output?
the input 3 has higher priority than 2 and 1? and also input 2 has higher priority than 1?
this is what I understand:
logic-state.png

this is programmed in ASM like this:
Code:
mod51

input1 EQU P1.0 ; //again, i'm rusty in A51
input2 EQU P1.1 ;
input3 EQU P1.2 ;

output1 EQU P3.5 ; //this ports are only examples...
output2 EQU P3.6 ;
output3 EQU P3.7 ;

; init the code so inputs are inputs and outputs are in low state at first...


...

;le code:
latcher:
  jnb input3, notinp3
  setb output3
  clr output2
  clr output1
  sjmp endlatcher
notinp3:
  jnb input2, notinp2
  clr output3
  setb output2
  clr output1
  sjmp endlatcher
notinp2:
  jnb input1, notinp1
  clr output3
  clr output2
  setb output1
;  sjmp endlatcher ;dummy...
endlatcher:
  ; end your code here... it its a routine, put a RET or something

place this in the main loop of your program and don´t forget to initialize properly...
 

thanks for your valuable reply,

let me explain the concept,

i will have 3 inputs & 3 outputs.

I have 3 momentry switch say A,B & C.

if switch A is pressed then the output has to be A=1,B=0 & c=0.

if switch B is pressed then the output has to be A=0,B=1 & c=0.

if switch C is pressed then the output has to be A=0,B=0 & c=1.

as i am using momentry switch i need to latch the output.

and also if any 2 switch is pressed at a time
say switch A & B then the output has to be A=0,B=1 & C=0.

say switch C & B then the output has to be A=0,B=1 & C=0.

say switch C & A then the output has to be A=0,B=1 & C=0.

if all the 3 switch is pressed then also i need A=0,B=1 & C=0.


thanks,
7102.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top