I have a discussion with a friend about the push button I have on my application. These push button are connected to ground through a 10 k resistor. And when activated they are connected to + 5 V through a 2 k resitor.
He tell that not a good choice : the best one is to reverse that connection (innactive mode to + 5 V through the 10 k).
Can you tell me what is the choice for a good electronics guy ?
A pull down is normally required (10k in this case) but no other resistors are required.
It sounds like any momentary SPST switch will do so long as it meets other criteria you might have such as size, temperature range, operating force etc.
The configuration for a switch is either an active low or active high using either a pull up or pull down resistor arraignment. See the images. Your choice of which one to use depends on the logic circuit it is being coupled to.
please check the attached schematic. You might use one pullup or one pulldown resistor to change level when pressing a pushbutton. Your method means one wasted resistor and absolutely no function. (Check S3 wiring)
The press button is connected to PORTB to control the stepper motor (I am unable to find the good English word : "fin de course" in French).
So I am using to many resistors... I will modify my scheme accordingly.
I see also some example where there is a capacitor between the PORTB and Ground (if the default is Ground). When is that necessary (push button are not on the same CI at a distance of 1 or 2 meters for example) ?
The literal meaning of 'fin de course' is end of travel, but depending on the context, it might be better translated as 'limit switch' — if that is indeed its function.
Presser sur « CLOSE » pour fermer de 0.1 mm, puis sur « OPEN » jusqu’au contact fin de course ( test à effectuer 2x )
I have run into problems using a pull down resistor and a switch to +5 V, as well as a debounce capacitor. Immediately after the switch is pressed the capacitor can draw a lot of current as it charges, pulling down the +5 V supply and causing problems with the rest of the circuit(microcontroller reset). Adding a smaller value high side resistor (I used 330 ohm) will prevent this from happening.
Maybe this is not necessary if you have a better power supply circuit.