top of page

Search Results

125 items found for ""

  • Arduino_KEYPAD | SimpleMechatronics| Simple MECHATRONICSsimple mechatronics

    Introduction to Matrix Keypad : Matrix Keypads normally available in 4x4 buttons or 4x3 buttons formats. By using matrix keypad(s) the number of pins used for Arduino for input can be reduced and also aesthetic. A matrix keypad is equivalent to connecting push button switches in matrix form and connecting each pin (out of 2) of the button to a row and a column. So, when a button is pressed on the keypad, the connected row and column of the button are shorted. The concept of button connections in a keypad is shown here for easy understanding. The pinouts of 4x3 and 4x4 standard keypads are shown here. You may confirm it, by using continuity tester (refer video) . Testing a keypad before using in a project is advisable. ​ Connecting Matrix Keypad : All the pins ( 7 or 8 ) of matrix keypad should be connected to Arduino board. ​ The test circuit diagram used to connect a 4x4 keypad to arduino board is shown here. In case of 4x3 keypad, connection between column_4 of keypad and A0 of arduino is not required. ​ A 4 x 4 matrix keypad is used here for explanation . Working with Matrix Keypad : The pinouts are divided in to rows and column connections as shown above, the row connections are treated as voltage inputs, sequentially, one by one and the voltages are read from column connections, to know the button contact status. The row and column connections may be reversed for voltage inputs and reading button status. To understand working principle of a matrix keyboard, 4 pins of Arduino are configured as outputs and connected to 4 rows. Again, 3 or 4 (based on columns) pins of Arduino are configured as inputs and set to logic high by default. ​ Now, using for loop , one row out of four, is set to logic low, sequentially and remaining three rows are set to logic high. Then, start scanning the status (logic levels) of all the column pins sequentially. ​ If any button linked to the particular row is pressed, then the column connected to the pressed button is also pulled low (logic low), where as remaining columns are set to high, by default. Now, read the row number and column number to know the button number. If no button is pressed throughout the for loop , then no column is set to logic low. ​ This process continues, whenever you want to read the keypad status, which is called as a function readKeypad , in our Arduino sketch. ​ Sketching for Matrix Keypad : The full sketch is explained for 4x4 in magenta coloured text. For 4x3 keypad, relative code is marked with green colour. Comments are included wherever required, for easy understanding. ​ The value of pressed button may be viewed using Serial Monitor, const int nRows = 4; //4 number of Rows const int nCols = 4; // = 3; //4 or 3 number of Columns // assign text on buttons to an array for 4 rows and 4 columns char keys[nRows][nCols] = { {'1','2','3','A'}, {'4','5','6','B'}, {'7','8','9','C'}, {'*','0','#','D'} }; // assign text on buttons to an array for 4 rows and 3 columns char keys[nRows][nCols] = { {'1','2','3'}, {'4','5','6'}, {'7','8','9'}, {'*','0','#'} }; const int pRows[nRows] = { 9, 8, A5, A4}; //Arduino pins of 4 Rows const int pCols[nCols] = {A3, A2, A1, A0}; //Arduino pins of 4 Columns const int pCols[nCols] = {A3, A2, A1}; //Arduino pins of 3 Columns ​ void setup() { pinMode(LED_BUILTIN, OUTPUT); // pin no 13 by default Serial.begin(9600); // start Serial connection with 9600 baud rate for ( int i=0; i<nRows; i++ ) pinMode(pRows[i], OUTPUT); // set all rows as output mode for ( int i=0; i<nCols; i++ ) { pinMode(pCols[i], INPUT); // set all columns as input mode digitalWrite(pCols[i], HIGH); // set all columns to high, by default } } ​ char readKeypad () // important function used to read the button press status { for ( int r=0; r<nRows; r++ ) { for ( int i=0; i<nRows; i++ ) digitalWrite(pRows[i], HIGH); // initially set all rows to high digitalWrite(pRows[r], LOW); // set one row, i.e., r, as logic low delay(1); for ( int c=0; c<nCols; c++ ) { if (digitalRead(pCols[c])==LOW) // read the status of all columns return ( keys[r][c] ); // and return the key text, if logic low } } return 0; // return null, if no key is pressed } ​ void loop() { char key = readKeypad (); // call the function in the main loop ​ if (key) // check for key is pressed { digitalWrite(LED_BUILTIN, HIGH); // glow the on-board LED Serial.print ("Key pressed = " ); // send the text to serial Serial.println(key); // send the key text value to serial delay(250); digitalWrite(LED_BUILTIN, LOW); // set the on-board LED off } } ​ The readKeypad function is the important function, which reads the status of a button press and returns the text value, if any button is pressed or returns null value, if no button is pressed. ​ The LED_BUILTIN is used to indicate that a button is pressed on keypad. The delay(250) is included to avoid multiple key press status, when a button is pressed, which may be adjusted as per individuals's requirement.

  • AVR_TWI | SimpleMechatronics| Simple MECHATRONICSsimple mechatronics

    AVR - TWI: Read Before: Micro-controller Communications >> TWI / IIC / I2C: TWI (Two Wire Interface) is also called IIC or I2C or IsquaredC (Inter Integrated Circuit) Protocol, which is frequently used for communication in AVR micro-controllers. ​

  • mcuIO | SimpleMechatronics| Simple MECHATRONICSsimple mechatronics

    microcontroller - INPUT AND OUTPUT Input and Output (I/O) of a micro-controller is the main and basic concept to be understood before programming. Micro-controllers use Registers (Seperate RAM or Part of RAM assigned for the I/O data. status etc.) to send or receive data to/from the external pins. So, these Registers has to be programmed to function the pins as digital input or digital output or analog input or analog output etc. Some Registers are used as buffer to send or receive the data. ​ Digital Input and Output: Almost all the pins may be used as either digital output or digital input signal pins. The direction of signal (i.e., input or output) has to be declared once in the specific Register, before using the pin for the purpose. The reading (for input) or writing (for output) of signal may be used any number of times throughout the program by reading from or writing to the specific register(s). If the pin is set as output, then the pin number and signal high/low will be passed as arguments (parameters) to the function. In case, same pin is set as input, the pin number is set as argument (parameter) to the function and the function returns the value, high/low, at that instant (or moment). Analog Input or Output : Some of the micro-controllers support Analog Input and/or Analog Output. Similar to Digital Input and Output, Analog Input or Output should be declared and initiated once, using some specific set of commands, before calling the function to read or write Analog value. Some of the pins only support Analog Input or Output, which are marked for ADC/DAC pins (unlike Digital Input/Ouput). ​ Analog to Digital Converter (ADC) : The micro-controller reads Analog input in volts, that is applied at the pin set as Analog Input and converts it to digital code. The digital code size or accuracy varies from 8 bit to 16 bit. So many types of algorithms are used to convert the Analog input to Digital data, depending on the micro-controller. ​ Digital to Analog Converter (DAC) : Some micro-controllers support DAC, which will send a specific analog voltage as per the digital data set in the specific register. The required registers has to be initiated before using DAC functions of the micro-controller. ​ Pulse Width Modulation (PWM) : PWM is a ouput feature supported by some micro-controllers. The output is similar to digital output, but, the time of HIGH signal and time of LOW signal, continuously varies, which depends on the values set in the PWM control register(s). By using this feature, the speed of a DC motor or brightness of a light etc., may be varied without changing the supply voltage to them. The allowed amount of current flow through the pins of a micro-controller is very less, which may be approximately 3mA (please refer datasheet of particular micro-controller). So, the micro-controller may drive an LED through a current limiting resistor. To drive heavy loads like motors, coils, relays etc., a transistor or MOSFET or driver IC has to be used. There is every chance to damage the micro-controller, if heavy current (more than the limit) are flowing through the pin(s). ​ The syntax and keywords may vary for the micro-controller and IDEs (integrated Development Environments) used for programming. ​

  • ICs | SimpleMechatronics| Simple MECHATRONICSsimple mechatronics

    ic As the name suggests, An Integrated Circuit (IC), is a summation of electronic elements of a functional circuit available in small package. ​ Integrated Circuit (IC) is also called as Chip or Microchip or Silicon Chip, In other words, IC is a small semiconductor wafer, usually made of silicon, on which multiple tiny transistors, resistors, diodes, capacitors etc., are fabricated to form a useful or functional circuit, which is enclosed in a plastic or ceramic material with the connecting pins on its periphery (or surface). An IC can do following functions in single or combination of counter, timer, amplifier, voltage regulation, oscillator, memory, ADC, DAC , arthematics etc. A microprocessor or a micro-controller also falls under IC catagory. Integration: The complexity and functionality of an IC depends on the number of transistors and associated electronic components used on a silicon wafer. The following is the types of integration and associated number of transistors used in the IC. ICs are available in various packages with specific name. The package name indicates the size, shape, position of pins, pin out format etc. ​ All Micro-Processors, Micro-Controllers, Voltage Regulators, Op-Amps etc., are ICs (Integrated Circuits) only

  • SleekVoltmeter | SimpleMechatronics| Simple MECHATRONICSsimple mechatronics

    Sleek Voltmeter-cum-Battery monitor The simple circuit presented here can measure DC voltage from 0V to +50V in a sleek enclosure with independent power supply option. The circuit may be used to monitor the voltage of battery (up to 12V battery). The power supply for the circuit may be derived from a general purpose 9V battery (or 8V to 12V DC power source). ​ATTINY85 is eight pin MCU sufficiently powerful for the project, with 8KB flash + 512B RAM + 512B EEPROM and 1MHz default clock frequency, is heart of the system. The MCU continuously measures Voltage through its one of the ADC pins (ADC3). The ADC values are processed by the MCU and converted to Voltage value, then displayed on OLED accordingly. ​ OLED display is small display of 0.96” size, 5VDC supply, I2C connector, with 128x64 pixel resolution. It has 4 pins, out of which 2 for power supply, 1 for serial data (SDA pin) and 1 for the clock (SCL pin). The value is displayed in one row only using big font. To display the text in big font, the code is set for 32 pixel height and 24 pixel width. The Voltmeter of the circuit can measure and display maximum voltage up to 50Volts DC. If the voltage exceeds 50V DC, the display shows moving squares, which indicates OVERFLOW. To protect the MCU ATTINY85, the measurement should be limited to 50V. Refer full circuit diagram: Working of the circuit : When SW1 is switched ON, the 9VDC from the battery is step-down to 5VDC by voltage regulator IC 7805, which is the power supply for the MCU,ATTINY85 and OLED. All the pixels of the OLED (display) will glow for a while, as a self test and then blank screen for a while. Then, the program enters in a loop to read voltage at ADC pin (pin 2 of IC2) and displays the voltage accordingly. Initial Setup : Once the PCB is ready (general purpose PCB is used here), write/burn SleekVoltMeter.HEX to the MCU ATTINY85, using any AVR programmer and insert it to its IC base on the PCB. Otherwise, the SleekVoltMeter.HEX may be written to the MCU ATTINY85, using in-system programmer also. Connect 9V battery (or other DC source less than 12V), connect jumper J1, then switch on SW1. Once, the voltage is displayed on the OLED, adjust the VR1 to match the displayed voltage with the source voltage. Now, disconnect the testing voltage source. Now, the circuit is ready for use, which can read and display DC voltage upto 50V when jumper J1 is removed or display Source Battery voltage up to 12V battery with jumper J1 is connected. The OLED (display) automatically refreshes for every 2 to 3 seconds of measurement, for clearing display distortions, if any. Enjoy . . . Have a nice day. List of Important Components used in the Project: ATTINY85, AVR micro controller (8pin) OLED module, 0.96" size, 128x64 pixels, IIC controlled (4pin) 7805, 5VDC output regulator IC (3pin) 20K trimpot Doides 1N4007, 1Amp capacity (or equivalent) Capacitors: 10uF electrolytic , 0.1uF disc capacitor SPST switch Resistances: 3.3K, 10K, 33K (all 0.25W) LED 3mm size, yellow and red 9V battery or other DC source Miscellaneous : PCB, wires, jumpers, IC base etc. click the link / attachment to download the file and rename as SleekVoltmeter.HEX , then upload to ATMEGA8 using any suitable AVR programmer. SleekVoltmeter.HEX For source code (in C-language), (SleekVoltmeter.C) please send message through contact form . The code will be sent to your e-mail.

  • INSTRUMENTS | SimpleMechatronics| Simple MECHATRONICSsimple mechatronics

    INSTRUMENTS The instruments necessary for Make-at-Home projects are listed below with comment as Basic or Important or Optional keyword, which means that, BASIC : very much required and affordable IMPORTANT : having this tool is advantageous OPTIONAL : may be purchased later STEEL RULE: A measuring scale made up of Stainless Steel is generally called as Steel-rule. The steel rules are generally available in standard lengths of 150mm (15cm) or 300mm (30cm) or 500mm (50cm) or 1000mm (1m). ​ The steel rules are more comfortable for measuring lengths, than plastic scales. The steel rules are also helpful to cut general purpose PCBs, card boards, plastic sheets, foam sheets etc., while making cabinets for circuits. ​ The most convenient and useful size is 300mm (12") steel rule shown below. (BASIC) ELECTRICAL TESTER : The electrical tester, seems to be a small screw driver, is one of the important tool for testing the presence of mains power supply. It is also useful to check leakage of mains power (phase line) to any component of the circuit( like transformer core, output lines etc.). You have to connect the tip (test probe) of the electrical tester to the mains (phase) and touch the other end. A light in the transparent sleeve glows to indicate the presence of the high voltage. This is very useful tool to check the leakage into your circuit, if the circuit is connected to mains power. (BASIC) CONTINUTITY TESTER : A continuity tester, as its name implies, tests the continuity between two ends of conductors (wires). It is simple in construction and usage. One end of the continuity tester holds a small battery, an LED and resistance in series, with a probe. The other end is connected to another probe with a flexible wire. When the two probes are connected to two ends of conductor to be tested, the LED glows, if there is no breakage , in between, else the LED does not glow, if there is dis-continuity in the conductor. (BASIC) MULTI-METER : The highly used and useful instrument in electronics is, no doubt, a Multi-meter. As the name implies, the multi-meter can be used for testing multiple parameters and its values ​ The following parameters can be tested, using a general/standard multi-meter. 1) AC volts 2) DC volts 3) DC current 4) Resistance 5) Continuity (with beep) etc. ​ Some multi-meters have more features than listed above, like; 1) Frequency 2) Transistor 3) Capacitance 4) Inductance etc. ​ The selection of parameters with accuracy and range of values varies for the multi-meters. The price of a multi-meter depends on the number of features / parameters it can measure and accuracy in displaying the measures value. Again, the price is also dependent on selection of range, like manual selection or auto selection. ​ As a novice, a basic model with manual selection multi-meter is sufficient for the purpose. (BASIC) For an expert, more features / parameters with higher accuracy and auto range selection is preferred. (IMPORTANT) ​ A manual range selection and auto range selection multi-meters are shown below as reference: LOGIC PROBE : A Logic probe is very useful instrument to know the status of digital circuits and its behavior by reading input and output of any component in a circuit. The power supply for the logic probe is used from the circuit under test and the test probe is touched to the required point on the circuit to know the logic state. LED indicators are used to show the logic state on the logic probe. Some logic probes can save the logic data, which may be used for analysing it afterwards. (IMPORTANT) OSCILLOSCOPE : An Oscilloscope is very useful instrument to know the wave-forms. But, it is costly instrument and requires basic knowledge in electronics. It is not required for the new learners (novice). It becomes essential for experts to have exact behavior of output w.r.t. input signals. (OPTIONAL) The secret of getting ahead is getting started. - Mark Twain

  • About Me | SimpleMechatronics| Simple MECHATRONICSsimple mechatronics

    About . . . Myself... When I have gone through the internet, I got an idea to develop this blog, which will explain about electronics, mechatronics and simple projects in one place from basics to make-at-home projects in easily understandable way. ​ I tried my level best for easy explanation of the concepts, keeping novice in mind. ​ I am very grateful to all the Author(s) of Simple Mechatronics, who supported me in developing this website / blog. ​ Thanks for your support. ​ -SBM ​

bottom of page