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.

Switch connected to 74hc589

Status
Not open for further replies.

djc

Advanced Member level 1
Advanced Member level 1
Joined
Jan 27, 2013
Messages
402
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
India
Visit site
Activity points
4,554
Hi all,
I have connected 8 switches to 8 parallel inputs of 74hc589. I want to get the status of 8 switches. Here is my code
Code:
void clock_function()
{

//                     par_rck = 1;
//                     #asm("nop")
//                     par_rck = 0;
                     
                     par_sload = 0;
                     #asm("nop")
                     par_sload = 1;
                                       
                                        
                                          
                                        
                                        if(par_out==1){
                                        key_status[7]=1;
                                        }
                                        else{
                                        relay_44=0;
                                        }                                       
                                        par_sck = 1;              //G   Q7
                                        #asm("nop")            
                                        par_sck = 0;  
                                        
                                                                                
                                        
                                        if(par_out==1){
                                        key_status[6]=1;
                                        }
                                        else{
                                        relay_33=1;
                                        }                                      
                                        par_sck = 1;                //E  Q6
                                        #asm("nop")
                                        par_sck = 0;
                                        
                                        
                                        if(par_out==1){
                                        key_status[5]=1;
                                        }
                                        else{
                                        relay_22=1;
                                        }   
                                        par_sck = 1;               // E  Q5
                                        #asm("nop")
                                        par_sck = 0; 
                                        
                                        
                                        if(par_out==1){
                                        key_status[4]=1;
                                        }
                                        else{
                                        relay_11=1;
                                        }       
                                        par_sck = 1;                //E  Q4
                                        #asm("nop")
                                        par_sck = 0; 
                                        
                                        
                                        if(par_out==1){
                                        key_status[4]=1;
                                        }
                                        else{
                                        key_4++;
                                        }

                                        if(key_4==200){             
                                        key_status_44=1;
                                        //relay_44=1;
                                        }
                                        if(key_4==400){
                                        key_status_44=0;
                                        //relay_44=0;
                                        key_4=0;
                                        }
                                        par_sck = 1;                //D  Q3 
                                        #asm("nop")
                                        par_sck = 0;

                                                                             
                                        if(par_out==1){
                                        key_status[5]=1;
                                        }
                                        else{
                                        key_3++;
                                        }
                                        if(key_3==200){
                                        key_status_33=1;
                                        //relay_33=1;
                                        }
                                        if(key_3==400){
                                        key_status_33=0;
                                        //relay_33=0;
                                        key_3=0;
                                        }
                                        par_sck = 1;                //C    Q2 
                                        #asm("nop")
                                        par_sck = 0; 
                   
                                                                             
                                        if(par_out==1){
                                        key_status[6]=1;
                                        }
                                        else{
                                        key_2++;
                                        }
                                        if(key_2==200){
                                        key_status_22=1;
                                        //relay_22=1;
                                        }
                                        if(key_2==400){
                                        key_status_22=0;
                                        //relay_22=0;
                                        key_2=0;
                                        }
                                        par_sck = 1;                 //B   Q1
                                        #asm("nop")
                                        par_sck = 0; 
                        
                                        
                                        if(par_out==1){
                                        key_status[7]=1;
                                        }
                                        else {
                                         key_1++;                                     
                                        }
                                        if(key_1==200){
                                        key_status_11=1;
                                        relay_11=1;
                                        }
                                         
                                        if(key_1==400){
                                        key_status_11=0;
                                        relay_11=0;
                                        key_1=0;
                                        }
                                        par_sck = 1;                  //A   Q0
                                        #asm("nop");
                                        par_sck = 0;

}

Here i am looking for counter key_1 to key_4 to compete the count of 200 to change the switch variable status to 1 and count of 400 to change the switch variable status to '0'. But instead of  incrementing the variable i want it to change the status at once. Means if switch is pressed once corresponding variable status should  change. How to do that, please guide.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top