November 08, 2024, 06:00:14 AM

info about PIC-MT board

Started by pablitomassa82, October 07, 2013, 01:23:05 PM

Previous topic - Next topic

pablitomassa82

Hi,
i'd like to understand the layout of the buttons of the PIC-MT board.
I'm a novice of MCU programming, in general i know that a button if generally connect to the ground and a pin of MCU. The pin of MCU is in general connected to 5v with pull up resistor.
In the pic-mt board is not in this way and i don't understand how to use it
thanks
Paolo

Stanimir5F

Hi Paolo!

The reason for this kind of layouts it to be placed more buttons using less pins on the microcontroller. In this case for 6 buttons we use 3 pins instead of 6 (for each button different pin). In general for N buttons are needed ~sqrt(N) pins.
The idea behind this circuit is this:
We have 3 pins on the CPU associated with the buttons and when we scan their condition one of them is output (in this case HIGH output) and the other two are inputs (with pull-down). Depending on the level of the inputs we can judge the condition of two of the buttons. Then we make the next one output and the other two input. Again their level will show us the condition of other two buttons, and the same procedure the third pin make it output.
For example (in the case with PIC-MT):
We make RB0 to HIGH output. RB1 and RB2 are pull-down inputs so their normal state is LOW.
For example let's say we press button 1. Then the circuit between RB0 and RB1 is closed (look at the schematic) and so when you check the state of RB1 it will be HIGH because of the button, instead of LOW because of the pull-down.
But if we press button 4 the circuit between RB0 and RB1 won't be closed because the diode D5 is in opposite direction. Instead of that we can check the state of button 6 (the circuit between RB0 and RB2) will be closed.

In the schematic of PIC-MT you can check the state of the buttons this way:
RB0 - Output (high); RB1, RB2 - Inputs
RB1 = 1 ==> button 1 pressed; RB1 = 0 ==> button 1 released;
RB2 = 1 ==> button 6 pressed; RB2 = 0 ==> button 6 released;

RB1 - Output (high); RB0, RB2 - Inputs
RB0 = 1 ==> button 4 pressed; RB0 = 0 ==> button 4 released;
RB2 = 1 ==> button 2 pressed; RB2 = 0 ==> button 2 released;

RB2 - Output (high); RB0, RB1 - Inputs
RB0 = 1 ==> button 3 pressed; RB0 = 0 ==> button 3 released;
RB1 = 1 ==> button 5 pressed; RB1 = 0 ==> button 5 released;

Check the updated example (https://www.olimex.com/Products/PIC/Development/PIC-MT/ Buzzer, relay, buttons) on the web that includes the buttons demo.

If you have any further questions I will try to help as much as I can.

Stan, Olimex
May the Source be with You!

serkan90

#2
@Stanimir5F: It is a very good idea to connect the 6 switches with the microcontroller in PIC-MIT board but my question is: as you explain that we can make one pin output and then we can find the status of two buttons. Is it is possible to scan the key pressed at any time among the 6 switches like the in case of keypad?

circuit board assembly

Stanimir5F

I'm not sure what do you mean by "any time".
If you mean using interrupt event... well there is interrupt function only on RB0 so even if it is possible, it will be available only for the buttons related with RB0. Otherwise you can call the function at the place where you need to scan their state but I'm not sure if that's what you are asking for.
May the Source be with You!