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.

Special push buttons with microcontrollers

Status
Not open for further replies.

john120

Banned
Full Member level 5
Joined
Aug 13, 2011
Messages
257
Helped
11
Reputation
22
Reaction score
10
Trophy points
1,298
Visit site
Activity points
0
Hello every body,I have an equipment which I am repairing it has special buttons (I attached the photo here),wen you push a button and you measure to see if the resistance is 0;some time you find some Kilo-ohms others you find infinite.

The circuits in use which is interfaced to a microcontroller is also attached;can you let me know how I can read those push buttons.



Thanks.
 

Attachments

  • File.zip
    24.4 KB · Views: 73

looks like a standard keypad switch. These usually have a dome switch underneath, or a carbon resistive contact against the PCB.
Chances are that its just got a bit dirty and some cleaning is required. Carbon-tetra-chloride ( CCl4) used to be popular for such purposes.
 

looks like a standard keypad switch. These usually have a dome switch underneath, or a carbon resistive contact against the PCB.
Chances are that its just got a bit dirty and some cleaning is required. Carbon-tetra-chloride ( CCl4) used to be popular for such purposes.

Thanks for the response,unfortunately iI do not think that it is a problem of durty because the buttons are new and they are not attached directly to a pcb they are linked by a wire .
I think there are some other properties.
 

Oh, in that case a better picture(s) or other clues would be useful. I cannot see your proteus files. Maybe you can post a jpg instead ?
 

The buttons are just ordinary TACT switches and when button is pressed the corresponding uC pin to which the switch is wired becomes high. You need to check if pin is high with a debounce delay.

Example C code, If switch is connected to RB0 then


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//mikroC Code
 
#define SW1 PORTB.F0
 
 
if(SW1){
   Delay_ms(50)
   if(SW1){
      //Do what you want here
   }
}
 
 
//MPLAB C18 or Hi-Tech or XC8 C Code
 
#define SW1 PORTBbits.RB0
 
if(SW1){
   _delay_ms(50)
   if(SW1){
       //Do something     
   }
}

 

The buttons are just ordinary TACT switches and when button is pressed the corresponding uC pin to which the switch is wired becomes high. You need to check if pin is high with a debounce delay.

Example C code, If switch is connected to RB0 then


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//mikroC Code
 
#define SW1 PORTB.F0
 
 
if(SW1){
   Delay_ms(50)
   if(SW1){
      //Do what you want here
   }
}
 
 
//MPLAB C18 or Hi-Tech or XC8 C Code
 
#define SW1 PORTBbits.RB0
 
if(SW1){
   _delay_ms(50)
   if(SW1){
       //Do something     
   }
}




Hello ;thanks for your response;see what I have as the schematic I want to use those push buttons in my program.

Thanks,you can help me by let me know the technique used for reading those buttons.As you see the schematics I am using proteus to simulate.

View attachment Schematic.zip
 

Attachments

  • other.pdf
    12.6 KB · Views: 77
  • File.zip
    24.4 KB · Views: 56

I have already mentioned the code. If your are using AVR Studio or Atmel Studio then change #define SW1 PORTB.F0 to #define SW1 PINC0. This is for switch 1. Write similar codes for SW2, SW3, SW4.
 

I have already mentioned the code. If your are using AVR Studio or Atmel Studio then change #define SW1 PORTB.F0 to #define SW1 PINC0. This is for switch 1. Write similar codes for SW2, SW3, SW4.

Hello I don't want to use the Atmel micrococontroller I want to keep the circuit as I showed you but repalce the AT90S8515 buy a PIC16F877A with the buttons connected on its PORTA.

With the structure ( Post #6 schematic.zip)which I posted previuosly,is it possible that the microcontroller is active on high/low when the push button is pressed?

Thanks.
 

When button is pressed the pins become high. Use the Code I gave in post #5. It is for PIC. It uses PORTB. If you want to use other port then Change the port name and add TRISx settings.
 

Thanks for your response ,with the schematic I posted above schematic.zip;before pushing the buttons,the voltage is 0.150 but when I push a button the voltage becomes 0.450 to 0.824 Volts;I think this might be used to detect that a button has been pushed;I am trying to use the ADC but the voltage which is being displayed on the LCD is not the same with what I am reading with voltmeter.

From your codes I think always the PIC will be reading 0 so with those analog input I think the buttons can be detected;can you plz help me to read those few volts of 0.450V;I tried also to read it by multiplying by 10 but it is not going.

Thanks
 

You don't need any adc to read the switch. If multiple switches are connected to the same pin then adc is used to detect the switch pressed and for that each button will place a different voltage at the adc input pin. For your circuit you need to use digital input pin to read the switches and I have already given the code for one switch. Write similar code for the other switches. For my code when button is pressed pin becomes 1 (high) and depending upon that some code is executed. The voltage at the digital input pin should be >= VIH for a high condition.
 

You don't need any adc to read the switch. If multiple switches are connected to the same pin then adc is used to detect the switch pressed and for that each button will place a different voltage at the adc input pin. For your circuit you need to use digital input pin to read the switches and I have already given the code for one switch. Write similar code for the other switches. For my code when button is pressed pin becomes 1 (high) and depending upon that some code is executed. The voltage at the digital input pin should be >= VIH for a high condition.

Thanks for your response,but I don't know whether you saw the diagram I posted on post#6 where I demonstrated to you how the connections are realized and also my circuit is first implemented on a project board,I think the codes you give are applied on the buttons which when pressed and you measure the resistance between its two pins you get 0 or near 0 ohms,my case is that the push button when pressed it has a high resistance of 4.7Kohm and more so tthe digital input is not accepting I used it but not running.

Thanks.
 

Remove the resistors between buttons and uC pins.


I removed but there i no effect.
Notice the schematic of switch I represented above was used on the device which I am repairing
That one was using AT90S8515 (The switch was on port C) and then this one I want to use PIC16F877A on portA

I am asking my self if there are no special features of ATmel because I don't know how to program them.

Thanks
 

I'm looking at your schematic "sch1proteus.emf" and I cannot for the life of me understand what Q1 is supposed to achieve...
As far as I can see, whenever you push any of the buttons, Q1 will turn on and short out your power supply.
Try removing Q1 and see what result you get.

Is it possible that this transistor should actually be connected up a little differently so that when you push a button the circuit powers up rather than being shorted out ?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top