top of page

Search Results

125 items found for ""

  • Inductors | SimpleMechatronics| Simple MECHATRONICSsimple mechatronics

    Inductors (Coils): Inductor is an electric conductor in coil form (shape), which generates self inductance due to change in direction of flow of current through it. The property of inductor is inductance ( denoted by L in formulae) , which is measured in (units) Henrys. Since Henry is big unit, milli Henry (mH) is used in general Inductance: One Henry is defined as generating one volt by changing direction of one Ampere current in the coil at a rate of once per a second. ​ A magnetic field is produced in the coil due to change in direction of flow of current through the conductor and opposes the cause producing it may be called as Self Inductance . Choke used in a Tube-light set is a practical example for self inductance. ​ In case, the magnetic field produced by self inductance is effecting another coil surrounded by the first coil and producing voltage across the second coil, then is called Mutual Inductance . Transformer works on Mutual Inductance concept. ​ Inductor in DC circuits: Since the inductor works on change of direction of current flow through its conductor, there is no effect of inductance, if a constant uni-direction current flows through it. So, it has no effect in DC Circuits, except resistance caused by the conductor, which depends on the material property of the conductor. ​ One of the main use of Inductor (coil) in DC circuits is to prevent any signal or noise disturbance in DC line, if connected in series. Inductor in AC circuits: Inductors are highly used in AC circuits due to its self inductance with various frequencies. ​ As the frequency passing through the Inductor increases, it offers more resistance due to opposing nature of cause, which produces it. The resistance offered in AC signal across a Inductor (coil) is called Impedence marked as Z . So, for DC signal or power supply, a coil offers Zero impdence. Inductor - Mini Size: Now-a-days inductors (coils) are available as Concealed coils. Either the inductance value is marked on the surface or Colour band code used to identify the inductance value. The colour code is followed as per resistor color code and the units are milli Henrys (mH). ​ Two models of concealed inductors are shown here. These inductors are easy to fix on PCBs.

  • Arduino_TYPES | SimpleMechatronics| Simple MECHATRONICSsimple mechatronics

    Arduino: Introduction & TYPES If you are new to Arduino, just go through the page and successive pages. Just have a glance on the differences in the Arduino Boards. Initially, it is not possible to have full idea about all Arduino boards. Just read on . . . Arduino is a brand name and available as development boards for quick connection and programming. Many varieties of development boards are available from Arduino. Almost all Arduino boards use one AVR micro-controller IC (or chip) on its board, with boot-loader program (pre-loaded by default). In addition to the micro-controller, the board is generally equipped with a voltage regulator IC(s) and USB interface IC. The USB interface IC is useful to UPLOAD the program code and communicate external equipment using USB port (like PC). Now (for the time being), our discussion is made limited to Make-at-Home projects. We are explaining about the Arduino boards, which are easily available and easily used for our projects. Normally, Arduino boards operates between 7VDC to 12VDC (input at Vin pin) and a crystal is used for system frequency (for on-board micro-controller). The voltage regulator IC(s) convert input voltage available through DC jack, to 5VDC & 3.3VDC output voltages, which are available on the Arduino board. You may also directly connect 5VDC supply to 5V pin on Arduino board instead of 7 to 12VDC from DC jack. (refer images below) The basic data about the Arduino boards, which are frequently used in our projects, is listed below for quick reference. The pin outs are labelled and power supply pins are marked in red and blue colours for easy identification. Arduino UNO: Arduino UNO is one of the highly used Arduino boards. Most of the Arduino starters, use Arduino Uno board initially for learning. The ATMEGA328P micro-controller is used for Arduino Uno board. Small differences are observed in Arduino Boards, which are shown here. In case of PDIP, you may replace the micro controller (ATMEGA328P) and upload BOOT LOADER to the new micro-controller. ​ In case of CH340 IC is used for USB to Serial converter, then suitable driver has to be installed on your computer. The main pin-outs of Arduino UNO is shown below for easy identification and under standing. So, some pins are connected internally to work as one or more than one function. You have to write suitable code to control the particular pin for the required functionality. It is a general practice that the code written for Arduino is called as SKETCH. ​ The Arduino Uno board is programmed through USB type-B port (normally available for USB printers) and a separate DC power supply jack is available in addition to Vin pin. Arduino NANO: Arduino NANO board is bread-board friendly pin-outs, smaller in size and frequently used for Arduino projects. Due to its compactness with most of the required features and low-cost, it is loved by Arduino programmers. For Arduino Nano also, ATMEGA328P micro-controller is used. ​ The main differences w.r.t. Arduino Uno are: 1) mini USB socket for programming. 2) two extra ADC channels A6 & A7 3) positions of pin nos 0 & 1 are reversed 4) No DC jack is available. use Vin only for power input. Arduino MEGA: Arduino MEGA board is bigger in size and frequently used for Arduino projects, where more number of digital pins are required. Almost all features and pin-outs will match with Arduino Uno, where as extra pins are available for Arduino Mega. You may replace Arduino Uno with Arduino Mega, but, reverse may not be possible, if the program uses the extra pins. The ATMEGA2560 micro-controller is used for Arduino Mega board. You may expect explanation about some more types of Arduino boards in future . . . ​ SUCCESS is, when your SIGNATURE changes to Autograph. – Dr. A.P.J Abdul Kalam

  • AVR_USART | SimpleMechatronics| Simple MECHATRONICSsimple mechatronics

    AVR - USART: Read Before: Micro-controller Communications >> All AVR micro-controllers have Digital Input and Output Communcation, which is explained in AVR-GPIO . Some AVR micro-controllers have Analog-Digital Conversion, which is an important communication with the real world is explained in AVR-ADC/DAC . Now, we will go through some other important and frequently used communication methods, mostly Serial Coomucations, available for AVR micro-controllers. All AVR micro-controllers have Digital Input and Output Communcation, which is explained in AVR-GPIO . Some AVR micro-controllers have Analog-Digital Conversion, which is an important communication with the real world is explained in AVR-ADC/DAC . Now, we will go through some other important and frequently used communication methods, mostly Serial Coomucations, available for AVR micro-controllers. USART: USART (Universal Synchronous Asynchronous Receiver and Transmitter) : This is the highly used programmable, Full Duplex, serial communication available in AVR micro-controllers. The external pins marked as TX is used as Transmitter (data out) and RX is used as Receiver (data in). USART is a digital data FRAME FORMAT, transmitted and received by AVR micro controllers. The frame format contains one start bit, 5 / 6/ 7/ 8 / 9 data bits, [no/odd/even] parity bit and one or two stop bits. The digital data (in frame work) is transmitted at a particular frequency to match transmitter and receiver asynchronously (no clock pulse for matching). Where as, in synchronous transmission, one micro controller programmed as MASTER, sends clock pulse along with the data bits to match the frequency of transmission for other micro controller for processing. The frequency at which the serial data bits is transmitted is called as BAUD RATE. The Baud Rates are standard and may be programmed by you to set a standard baud rate, by programming UBRRH and UBRRL registers, which together is called UBRR register . A double speed option is also available for asynchronous mode. USART:Setting BAUD RATE: Some of the Standard Baud Rates are : 1200, 2400, 4800, 9600, 14400 and so on. One of the following formulae is used to set the value for UBRR register, where MCU_FREQ is the micro-controller clock frequency. ​ ubrr_value = ( MCU_FREQ / (2*baud_rate) ) -1; //for synchronous transmission ubrr_value = ( MCU_FREQ / (16*baud_rate) ) -1; //for asynchronous normal (single speed) transmission ubrr_value = ( MCU_FREQ / (8 *baud_rate) ) -1; //for asynchronous double speed transmission ​ now, set the ubrr_value to UBRR Register which is combination of UBRRH (contains 8 MSB) and UBRRL (contains 8 LSB) ​ UBRRH = ubrr_value>>8; // to set 8 MSB UBRRL = ubrr_value; // to set 8 LSB ​ For DOUBLE SPEED transmission, set U2X bit (bit 2) in UCSRA register, which is valid for asynchronous transmission only. ​ UCSRA |= (1<>8; // to set 8 MSB of ubrr_value UBRRL = ubrr_value; // to set 8 LSB of ubrr_value ​ UCSRC | = (1 <

  • DUMMY | SimpleMechatronics| Simple MECHATRONICSsimple mechatronics

    Science STEM Program Register Now FANTASTIC LIGHTS SHOP FANTASTIC LIGHTS SHOP Empower local families Join Our CSA "Testimonials are a great way to showcase positive feedback from others." Timberly Williams Once Small Robot's Base Frame is made, then, various control systems for Small Robot is developed and available below to select. BUDGET Friendly

  • StepperMotorTester | SimpleMechatronics| Simple MECHATRONICSsimple mechatronics

    Stepper Motor Tester Whenever there is a requirement to test a Stepper Motor performance or coil connection sequence, we need a stepper motor controller board, a variable DC power supply source, a logical signal generator ( or a microcontroller ) and separate power supply for logical system etc. Still this total circuit makes confusion with so many wire connections. The circuit used here is quick, low cost, handy, compact and requires only one DC power supply input. The stepper motor driver used here can handle up to 2A stepper motor. A4988 module (breakout board) is a small size, 2A bipolar stepper motor driver, which has on board adjustable current limiting, over current protection, short circuit protection and five micro-steps resolutions. The module can be operated from 8VDC to 35VDC for Stepper motor and 3VDC to 5.5VDC for logical system. Only two pin interface is used to control the direction and step of the stepper motor. ​ Refer full circuit diagram: Testing : Assemble all the components as per the above circuit on a PCB. Connect all jumpers J1 to J7. Connect 4 LEDs to the 4pin connector with 3.3K resistance in series for each LED. Connect DC power supply and switch ON the power switch. The 555 IC is connected as Astable multivibrator mode and generates pulses and the pulses are fed to the Step of A4988 module. The speed of the pulse train may be observed with the help of Blinker LED connected to pin 3 of 555 IC. Due to the input pulses to Step pin of A4988 module, the 4 LEDs glow in sequential pattern, indicates the circuit is working properly. By changing the variable resistance VR2, the speed of the LED pattern varies. With disconnecting and connecting Jumper J1, we can achieve two speeds of pulse trains from pin 3 of 555 IC and accordingly speed of the LED pattern. Usage : Switch OFF power supply, disconnect 4 LEDs and then connect (4 wires) a Stepper motor to the 4 pin connector. Now, switch ON the power supply to the circuit. Adjust VR1 to get the required voltage to the stepper motor, which may be measured at TP3 w.r.t. ground. The Stepper motor rotates in one direction (either CW or CCW). Now, disconnect the Jumper J6 and check that the motor rotates in opposite direction. By connecting and disconnecting jumpers J3, J4 and J5 the rotation of angle of the motor shaft varies for each step pulse input as described in the table below. ​ This circuit works upto 12VDC power supply. To use different power supply or more than 12VDC (upto 35VDC) to the stepper motor, disconnect Jumper J7 and connect +ve power to the TP3 pin and –ve power to ground line of the circuit. To control the stepper motor from other source, like microcontroller etc,. disconnect jumpers J2 and J6 then connect step control to TP1 and direction control to TP2 pins respectively. List of Components: 1 x LM338T Voltage Regulator 1 x 7805 5V regulator 1 x 555 Timer IC 1 x A4988 stepper motor driver module 3 x 1N4007 dioides 2 x 20K preset (volume control) 1 x 1K resistance 2 x 2.2K resistance 2 x 3.3K resistance 5 x 4.7K resistance 1 x 47uF 50V capacitor 1 x 22uF 16V capacitor 3 x 10uF 50V capacitor 1 x 2.2uF 16V capacitor 1 x 0.1 disc capacitor 1 x 0.01 disc capacitor 1 x 3mm red LED 1 x 3mm green LED 1 x 3mm yellow LED 1 x 2A(or more) SPST switch Berg strips, connectors, power supply, stepper motor etc. ALL THE BEST - ENJOY

  • AVR_ADC_DAC | SimpleMechatronics| Simple MECHATRONICSsimple mechatronics

    AVR - ADC (Analog to Digital Conversion) Almost all AVR microcontrollers have ADC (Analog to Digital Conversion) pins, except a few, like ATTINY 2313 / 4313 series. ​ The main concept of ADC is, a stair-case type reference voltage is generated in steps by the micro-controller internally and compares the signal / input voltage with the generated reference voltage. If the input voltage just crosses the reference voltage, then the step number in the stair case is noted and saved in to its related Register (ADC). Our code reads the related Register and process as per our requirement. RESOLUTION AND REFERENCE VOLTAGE SELECTION: So, the Resolution of the ADC value depends on the number of steps generated for a range of voltage. Normally AVR micro-controllers generate 1024 steps (equals to 2 to power 10) from 0VDC to Reference Voltage. So, the data shows 10 bit resolution of ADC. The Reference voltage may be Vcc voltage or separate external input voltage other than Vcc or fixed internal reference voltage ( like 1.2V). The reference voltage input may be selected by setting the required bits in the related register (ADMUX ). ​ Bits 7 & 6 of ADMUX are named as REFS1 and REFS0. The bit setting serves for various input reference voltages in combination as shown below: REFS1=0 and REFS0=0 means external voltage as reference at VREF pin. REFS1=0 and REFS0=1 means Vcc as reference and connect 0.1uF capacitor at VREF pin to ground. REFS1=1 and REFS0=1 means Internal Reference Voltage used as reference and connect 0.1uF capacitor at VREF pin to ground. ​ eg: assume that the reference voltage is set to 5VDC. then, the ADC divides it into 1024 steps, ranging from 0000 to 1023 digital values. so, each step of 5V (= 5000 milli Volts) is equals to 5000/1024 = 4.8828125 mV which is approximately equal to 5 milli Volts. ​ So, the ADC of AVR in this case cannot measure less than 5 milli Volt fraction, in other wards, the ADC value of output available in the Register is approximately multiples of 5 milli Volts (= 0.005V) ​ So, you should not expect less than 5 milli volt accuracy with the above settings. ​ Similarly, you may calculate and set your input. ​ Note/Tip: if the external input reference voltage is 1.023V, then the ADC value is directly proportional to the milli Volt signal input. (1 ADC unit = 1 milli Volt) ACCURACY AND speed of ADC conversion: ​ The accuracy of ADC for AVR micro-controller also depends on the speed of the comparision with the step voltage. You have to sacrifice accuracy to a little extent to get the conversion quickly. The accuracy is sufficiently good upto 200 KHz clock set for the ADC comparision. If the ADC clock speed is set more than 200 KHz, then little accuracy will lost in ADC conversion. The frequency dividing w.r.t. CPU clock is called Prescaling for ADC conversion. ​ ​ In case 8 bit conversion (0 to 255 steps) is suffiecient for your requirement, then the conversion may cross 200 KHz. ​ The clock speed may be set by division factor w.r.t. to the main CPU clock in related Register (ADCSRA ), i.e., ADC Control and Status Register A. The LSB bits of ADCSRA are names as ADPS2, ADPS1, ADPS0 and 16, 4 and 2 are the division factors respectively. The minimum division factor is 2 by default if all set to zeroes. ​ eg: if ADPS2=1, ADPS1=0 and ADPS0=1 means division factor is 16X2 = 32. ​ SELECTING CHANNEL FOR ADC conversion: ​ Normally, AVR micro-controllers have more than one ADC channel connected to specific pins to the exeternal world for ADC conversion. Internally the ADC processor is same for all the channels, but a multiplexer is used to select a specific pin at a time for conversion. ​ The multiplexing Register (ADMUX ) is not only used for selection of the particular pin, but also to select differential input and gain in some micro-controllers by setting the specific bits. The LSBs of the ADMUX are used for directly selecting the channel (or pin). ​ eg: set 000 to LSB of ADMUX , to select channel 0(pin ADC0), 001 for channel 1 (pin ADC1) etc. ​ READING ADC VALUE FROM THE REGISTER: ​ The ADC value, which is the digital value for the analog voltage / signal input is stored in Register (ADC ). The result is also available in ADCL and ADCH registers, which contains 8 LSB of the ADC and 8 MSB of ADC. The value may be directly read from the ADC register by setting / returning to the variable name set by you in the program. ​ eg: a = ADC; or return ADC; b = ADCL; or return ADCL; c = ADCH; or return ADCH; ​ The result of conversion of ADC is 10 bit resolution. i.e. it varies from 0000 to 1023. ​ If required, the result may be converted to 8 bit resolution by setting bit 5 (ADLAR) in ADMUX register as shown below: starting the adc: Before starting the Analog to Digital Conversion, the settings as required, as explained above to be processed in the program. Also, bit 7 ,ADEN (ADC enable), should be set (to 1). ​ Now, to start ADC for every loop, the bit 6 ,ADSC (ADC Start conversion) of ADCSRA should be set to 1. Then the Analog to Digital Conversion will start. On completion of conversion bit 4, ADIF (ADC Interrupt Flag) of ADCSRA will be set (to 1) and also ADSC will be reset (to 0). So, by checking the status of ADIF or ADSC bit in ADCSRA register, you will come to know the conversion status. Example code for adc: ​ //================================================= void initializeAdc ( ) { //SET DIVISION FACTOR FOR F_CPU TO GET ADC CLOCK FREQUENCY ADCSRA |= ( (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0) ); //ADPS2 divides by 16. ADPS1 divides by 4. ADPS0 divides by 2. ​ //SET REFERENCE VOLTAGE SOURCE ADCSRA |= ( (1 << REFS1) | (1 << REFS0) ); //set REFS1,REFS0 = 0,0 for Reference at AREF pin. // 0,1 for AVCC as Reference. 1,1 for Internal Reference Voltage. ​ // ENABLE ADC ADCSRA |= (1 << ADEN); } //================================================= int readAdc ( int channelno ) { // reset previous channel number upto 8 channels, if any. ADMUX &= (0b11111000); ​ // select current Channel number to read ADC. ADMUX = (channelno); // START conversion now. ADCSRA |= (1 << ADSC); // WAIT till conversion is complete while (ADCSRA & (1 << ADSC)); ​ // READ ADC value and return the function. return ADC; } //================================================= Note: ​ This is a general concept of ADC conversion in AVR micro controllers. Some small changes may be observed for each AVR micro-controller, which may be obtained from the data sheet specific to the micro-controller. ​ eg:for ATTINY micro-controllers have only 4 ADC channels and only two options for reference voltage selection. REFS0=0 means Vcc or REFS0=1 means 1.1V internal Voltage Reference. REFS1 is not available. ​ More controls are available while reading ADC of AVR micro controller. The specific ADC usage is available in programs and explained the specific concept and usage in the project. ​ << AVR: TYPES

  • AVR_GPIO | SimpleMechatronics| Simple MECHATRONICSsimple mechatronics

    AVR - GPIO (General Purpose Input Output): All AVR micro-controllers have GPIO pins, which are used for reading or writing digital data (either logic 0 or 1). You, as a programmer use the GPIO control so frequently in your programs and knowledge about GPIO is very essential before programming any micro-controller, including AVR. GPIO for AVR is controlled using respective Registers. Almost all AVR external pins may be configured as GPIO pins, except power supply pins etc. AVR identifies GPIO registers using Alphabet, like A, B, C, D . . . ​ A set of GPIO pins are grouped together (nomally 8 or less, depends on availability of external pins) and named as PORT_A, PORT_B, PORT_C, PORT_D . . . and so on. The GPIO oridentation, the number of ports and number of bits (maximum 8) depends on the micro-controller pins availability and its pinouts. So, each port and each bit in a port, may be configured as either Input or Output. If, a port or a bit of a port is configured as input , then it can read the logical value ( either 0 or 1) from the external pins. Similarly, if a port or a bit of a port is configured as output , then it can be (used to send ) set to the required logical value (either 0 or 1). ​ Before using the registers the following statement should be used in the program: #include // input and output header file The above statment should be declared globally in the program before using the registers and main function / method to identify the registers with its names explained below. ​ Many concepts are used to program GPIO. The programming / code explained below is directly accessing the register(s) and simple to understand. Programming AVR GPIO for DIRECTION: While programming GPIO, initially set the direction of data transifer (read / write) by setting the DDR (Data Direction Register) of the particular port, like DDRA for PORT_A, DDRB for PORT_B, DDRC for PORT_C. . . so on. You have to check the existance of particular port and number of pins for the selected micro-controller, before programming. ​ eg 1: write the following code (any one line) in your program to set 3 MSB (Most Significant Bits) as OUTPUT and 5 LSB (Least Significant Bits) as INPUT for PORT_A. So, note that, setting a bit to 1 for OUTPUT and 0 for INPUT. DDRA = 0b11100000; // Binary format for easy under standing DDRA = 0xE0; // Hexadecimal format ​ eg 2: write the following code (any one line) in your program to set 6 MSB as OUTPUT and 2 LSB as INPUT for PORT_B. DDRB = 0b11111100; // Binary format DDRB = 0xFC; // Hexadecimal format Programming AVR GPIO for OUTPUT: Once the direction of data transfer is set as OUTPUT in DDR register of the particular port and its bits (by setting 1s), then the actal data may be WRITTEN to its Ouput Register PORTA or PORTB or PORTC or PORTD . . . so on. The value to the register may be written as a whole ( all 8 bits, i.e., a byte ), or each required bit of the register. The value in the register reflects at the external pins of the micro controller connected to the register, named as port and its bits. ​ eg 1: write the following code (any one line) in your program to set all 8 bits (byte) in a single command / statement. So, note that, setting a bit to 1 in a port register is for logic HIGH and 0 for logic LOW, which reflects the value as output at the connected external pin of the micro-controller. PORTA = 0b11001000; // Binary format for easy under standing PORTA = 0xC8; // Hexadecimal format ​ eg 2: write the following code (any one line) in your program to set logic 1 for only one bit (PB2 or bit 2) of register PORT_B, without disturbing other bits in the PORT_B. Here, logic OR symbol ( | ), is used for the purpose. The | symbol is also called pipe key on keyboard and commonly used for logic OR in C, C++, Java etc. PORTB |= 0b00000100; // Binary format PORTB |= 0x04; // Hexadecimal format ​ eg 3: write the following code (any one line) in your program to set logic 1 for ANY bits (PC1, PC4 & PB7) of register PORT_C, without disturbing other bits in the PORT_C. Here also, logic OR symbol ( | ), is used, wherever the value of bits to be changed to 1. PORTC |= 0b10010010; // Binary format PORTC |= 0x92; // Hexadecimal format ​ eg 4: write the following code (any one line) in your program to set logic 0 for only one bit (PB4 or bit 4) of register PORT_B, without disturbing other bits in the PORT_B. Here, logic AND symbol ( & ), is used for the purpose. The & symbol is also called ampersand key on keyboard and commonly used for logic AND in C, C++, Java etc. PORTB &= 0b11101111; // Binary format PORTB |= 0xEF; // Hexadecimal format ​ eg 5: write the following code (any one line) in your program to set logic 0 for ANY bits (PD2, PD3 & PD6) of register PORT_D, without disturbing other bits in the PORT_D. PORTD |= 0b01001100; // Binary format PORTD |= 0x4C; // Hexadecimal format Programming AVR GPIO for INPUT: Once the direction of data transfer is set as INPUT in DDR register of the particular port and its bits (by setting 0s), then the actal (logical) data may be READ from external pins of the port, which is always available at its Input Register PINA or PINB or PINC or PIND . . . so on. The value of the register may be read as a whole ( all 8 bits, i.e., a byte ), or each required bit of the register. The value in the register reflects the logical value available at the external pins of the micro controller connected to the register. ​ eg 1: write the following code (any one line) in your program to read all 8 bits (byte) in a single command / statement. Here, always read FULL register (8 bits) named as PIN, then analyse the required bit(s) using logical operators. So, the external logical values are always available at registers PINA, PINB, PINC, PIND . . . etc., and you are reading the values, whenever is required while programming. unsigned char val = PINA; // unsigned char can hold 8 bits and PINA size is also 8 bits. int val = PINA; // int can hold 16 bits and PINA size is 8 bits ​ eg 2: write the following code (any one line) in your program to read only one bit (PB3 or bit 3) of register PORT_B and save it to a variable, for further processing. Here, logic AND symbol ( & ), is used for the purpose. unsigned char val = (PINB & 0b00001000); // Binary format unsigned char val = (PINB & 0x08); // Hexadecimal format ​ ​ eg 3: write the following code (any one line) in your program to read multiple bits (PC6 and PC1) of register PORT_C and save it to a variable, for further processing. Here also, logic AND symbol ( & ), is used for the required bits to read.. unsigned char val = (PINC & 0b01000010); // Binary format unsigned char val = (PINC & 0x42); // Hexadecimal format ​ Full Programming Code for AVR GPIO: Note the steps to start programming to access and control GPIO pins of AVR micro-controller as 1) include input and output header file and other required header files. 2) define by name for any required pins 3) start main function / method 4) set Data Direction Registers as per your requirement. 5) use Port registers. i.e., Read from Registers or Write to Registers 6) you may use loop to make it continuous operation(s). ​ eg 1: writing the code for sending high output to all bits of PORT_B and 3 LSB of PORT_A (you may change to any PORT, which is avialable for the selected AVR micro-controller) #include // input and output header file int main ( ) // start main function / method { DDRB = 0xFF; // set (all bits) Data Direction of PORT_B as output DDRA = 0b00000111; // set (3 LSB) Data Direction of PORT_A as output, remaining as input PORTB = 0xFF; // set (all bits) Data in PORT_B as high PORTA = 0x07; // set (3 LSB) Data in PORT_A as high return 0; // exit from main } Once you compile and write the HEX code to AVR micro-controller, then the external pins of PB0 to PB7 and PA0 to PA2, were set to logic high (about Vcc voltage of micro-controller), which may be tested with an LED (with series resistance) or using mult-meter in voltage mode. ​ eg 2: writing the code for reading input value from one port (POPRT_A) and send the same to another port (PORT_B) (you may change to any PORT, which is avialable for the selected AVR micro-controller) #include // input and output header file int main ( ) // start main function / method { unsigned char val; // use a variable to store the value read from the input port DDRB = 0xFF; // set (all bits) Data Direction of PORT_B as output DDRA = 0b00000000; // set (all bits) Data Direction of PORT_A as input while ( 1 ) // start a never ending loop { val = PINA; // read (all bits) from PORT_A save it to variable val PORTB = val; // write (all bits) value avialble in val to PORT_B } // end of while(1) loop and control goes to first statement in while loop. return 0; // exit from main } Once you compile and write the HEX code to AVR micro-controller, then the external pins of PB0 to PB7 are replica of PA0 to PA7, in logic levels. i.e., if any pin of PORT_A is set to high (connect to Vcc through a series resistance), like PA3, then same pin of PORT_B (PB3) also set to logic high (about Vcc voltage of micro-controller), which may be tested with an LED (with series resistance) or using mult-meter in voltage mode. SUMMARY: The main registers used to control, read and write the GPIO of the AVR micro controller are: DDRX, PINX, PORTX, where X is the port name A / B / C / D ... ​ for more details, refer at following link (courtesy:microchip): http://ww1.microchip.com/downloads/en/Appnotes/90003229A.pdf

  • mcuTimersCounters | SimpleMechatronics| Simple MECHATRONICSsimple mechatronics

    microcontroller - COUNTERS & TIMERS Almost all micro controllers have one or more inbuilt counters. They are either 8 bit or 16 bit counters. The input for the counters may be from either external pins or internal system clock through pre-scalars. The current counter value is always saved to a register in the micro-controller and may directly access the value at any time. ​ Delay is one of the commonly used timer function, which is single use timer and not so accurate when compared to the internal programmed timers. Delay works on counting the ticks of micro-controller system clock frequency. If the counter is programmed for external input , then the counter register may either increase or decrease by 1, by changing the logic (voltage) at the programmed pin of micro controller. You can access the value in the register and may show on a displaying device. This type of programming is useful for event counter project etc. In case, the counter is read for every one second and reset to zero after reading the current value, then the programming may be used as frequency counter project. For programming as internal counter , the counter should receive signal from system clock frequency through pre-scalar circuit. The pre-scalar divides the system clock frequency by the value set in the pre-scalar register. In case, the counter register is full (i.e., exceeds its capacity), then it resets and starts counting again. An Interrupt may be activated when the particular counter register is full and resets, which calls COUNTER OVERFLOW SERVICE ROUTINE . Every time the counter is full or overflown, the Interrupt service routine is called, where you may program do specific tasks. This Interrupt is very useful to get exact and fixed time period, to do some specific operations in loop at a particular time period. These are called Timers in micro-controllers. ​ These timers are used for data aquisition system, frequency generation, wave form generation etc.

  • Imp.ICs | SimpleMechatronics| Simple MECHATRONICSsimple mechatronics

    IMP. ICs PAGE IS UNDER CONSTRUCTION. ​ PLEASE ALLOW SOME TIME FOR COMPLETION. ​ SORRY FOR INCONVENIENCE CAUSED.

  • mcuMemory | SimpleMechatronics| Simple MECHATRONICSsimple mechatronics

    microcontroller - MEMORY MANAGEMENT Micro-controller (MCU) uses variety of memories, which are in-built. The size and purpose varies while execution of the program. RAM (Random Access Memory) : RAM is a volatile memory, which will be lost or reset when power is lost or Reset button of the MCU is pressed. The total RAM is logically subdivided into three parts. ​ The first part may be used used for accumulators, stack pointer, various address points used by the ALU (Arithmetic and Logic Unit) and control system. ​ The next part may be used for storing system process values, registers, status, flags used by control system. The left out part is the actual RAM used for the program variables. ROM (Read Only Memory ) : The ROM is non-volatile memory, means the data in the ROM will not be lost on power loss, unless overwritten by the programmer. The ROM is called FLASH MEMORY in micro-controllers. The Flash memory is logically divided into two parts. ​ The main part of Flash Memory is allocated tor the application program in binary code, which is loaded directly through the programmer. Some micro-controllers have option to lock the reading of the flash memory for protecting from copying by others. A small part of the Flash Memory is earmarked to save booting code or booting sequence at one of the extremes. EEPROM ( Elelctrically Erasable and Programmable Read Only Memory ) : This is also a ROM, but, it is used only to save variables either through the program or directly through the programmer. This is also non-volatile program. The values can be altered, if required, by the program. The EEPROM is useful to save settings, parameters which can be changed by the user while MCU is processing/working. Almost all compilers display the summary of actual Flash memory and RAM used for the program after compiling the code, which is useful to proper selection of Micro-controller (MCU).

  • SmartDesktopPowerSupply | SimpleMechatronics| Simple MECHATRONICSsimple mechatronics

    Smart All in 1 Desktop Power Supply The Smart All in One Desktop Power Supply is a dream project of an electronics hobbyist and also useful for the persons, who repairs electronic gadgets. The following features are available with the Smart All-in-1 Desktop Power supply: 1) + and - 3V 5V 8V 12V 15V Fixed DC supply 2) + and - 30V Variable/Adjustable DC supply 3) + and - 50V DC voltmeter and 5A ammeter 4) USB Port power supply (5VDC) for Arduino projects 5) ZENER METER for knowking actual voltage drop against zener or diodes 6) Continuity Meter to check wires, diodes, LEDs etc., 7) AC mains power supply socket and control switch 8) TRIAC controlled AC power supply 9) Convenient Soldering Stand placement 10) Flexible Focus light using 12VDC LED strip 11) Magnet placing for holding small screws etc. 12) Top flat space for keeping Multimeter and project items 13) Bottom slot for keeping frequently used items, like soldering related items etc. ​ The project uses multiple modules in one cabinet. Each module is explained separately in the website and the links for modules are available at the end of the page. ​ The connections and usage of the modules are shown and explained as separate circuit diagrams. Refer circuit diagrams used in the project: The A.C. mains wiring is one of the main circuit shown here. All the modules will receive power from mains. Here, two AC power sockets are provided. Power for one socket is controlled directly through a switch and another socket is through a switch and a Triac (BTA41) circuit. ​ LED indicators are provided each switch control to know the status of switch and output AC power at AC power sockets. ​ A transformer having dual outputs (24VAC-0-24VAC and 0-12VAC , 5A max.) is used for this project. ​ Separate bridge rectifiers and filter capacitors are used for the dual outputs to get -35V, +35v and +17V D.C. outputs (when no load condition). ​ Dual Variable DC output module and combined Voltmeter and Ammeter Module are used in the project, which are very useful to get positive and negative variable power supplies and the Voltage and Current values may be known instantly. A stepped D.C. power supply module is used to have -15V, -12V, -8V, -5V, -3V, +3V, +5V, +8V, +12V and +15V. ​ LM337 and LM317 circuits are used as prefix to reduce the incoming voltage from 35V to 20V for both positive and negative volages. ​ The rectfied 17V is used for power supply to Zener Meter, USB power supply (+5V, useful for Arduino boards), a 12V LED strip light (flexible focus light) and for simple continuity tester. ​ The Voltmeter-cum-Battery Monitor module is changed as Zener meter, by changing the maximum voltage reading value from 50V to 25V in the code. So, when the voltage is read from the +35VDC through 12K resistor, it displays squares. When an LED or diode or Zener (with reverse polarity) is connected across its terminals, the voltage drop across the component is displayed. click here for SHARED DUAL VARIABLE/ADJUSTABLE D.C. POWER SUPPLY. ​ click here for SIMPLIFIED BI-POLAR VOLT AMP METER. ​ click here for STEPPED DESKTOP D.C. POWER SUPPLY. ​ click here for SLEEK VOLTMETER -cum- BATTERY MONITOR ​ click here for SUPERB POWER CONTROLLER BTA41-600B (TRIAC CONTROL) For source codes (in C-language) for any or all modules , please send message through contact form . The code will be sent to your e-mail.

  • AVR_TYPES | SimpleMechatronics| Simple MECHATRONICSsimple mechatronics

    AVR - INTRODUCTION & TYPES If you are new to AVR micro controllers, just go through the page and successive pages. Just have a glance on the differences in the AVR micro controllers. Initially, it is not possible to have full idea about all micro controllers. Just read on . . . AVR is a brand name for micro controllers of MICROCHIP Corporation Inc (earlier Atmel Corporation Inc). Variety of microcontrollers are available from Atmel. Although, there is no certain full form for AVR, but normally it is known as A lf and V egard's R ISC (Reduced Instruction Set Computer Architecture) processor. Now (for the time being), our discussion is made limited to Make-at-Home projects. We are explaining about the micro-controllers, which are easily available and easily used for our projects. Normally, an AVR micro-controller operates between 1.8VDC to 5.5VDC and the clock frequency is dependent on the Supply voltage, i.e., higher voltage is required for higher clock frequencies. Almost all AVR micro-controllers used in our project uses 5VDC supply for the projects The basic data about the AVR micro-controllers, which are frequently used in our projects, is listed below for quick reference. The Power supply pins ( red and blue ) and programming pins ( pink ) are marked in pinouts for easy understaing. All the AVR micro-controllers discussed here are available with pre-calibrated internal clock frequency (1MHz by default). A crystal may be used externally to pins marked as XTAL1 and XTAL2 (or square frequency at CLK pin) and registers must be programmed accordingly. ATTINY 13: ​ ATTINY13 micro-controller is available in 8 pin PDIP (and other) package. It has following main features: ​ 1KB Flash memory (ROM) to hold the program 64 Bytes of SRAM and 64 Bytes of EEPROM 6 Digital Input/Ouput pins, maximum 10 bit ADC, 4 channels 8 bit timer/counter, 1 number PWM channels, 2 channels ​ Datasheet link (courtesy Microchip): http://ww1.microchip.com/downloads/en/DeviceDoc/doc2535.pdf ATTINY 25/45/85: ​ ATTINY 25/45/85 micro-controller is available in 8 pin PDIP (and other) package. It has following main features: ​ 2/4/8 KB Flash memory (ROM) to hold the program 128/256/512 Bytes of SRAM 128/256/512 Bytes of EEPROM 6 Digital Input/Ouput pins, maximum 10 bit ADC, 4 channels and more 8 bit timer/counter, 2 numbers PWM channels, 2 channels TWI communication USI communication ​ Datasheet link (courtesy Microchip): https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet.pdf ATTINY 24/44/84: ​ ATTINY 24/44/84 micro-controller is available in 14 pin PDIP (and other) package. It has following main features: ​ 2/4/8 KB Flash memory (ROM) to hold the program 128/256/512 Bytes of SRAM 128/256/512 Bytes of EEPROM 12 Digital Input/Ouput pins, maximum 10 bit ADC, 8 channels and more 8 bit timer/counter, 1 number 16 bit timer/counter, 1 number PWM channels, 2 channels TWI communication USI communication ​ Datasheet link (courtesy Microchip): http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7701_Automotive-Microcontrollers-ATtiny24-44-84_Datasheet.pdf ATTINY 2313/4313: ​ ATTINY 2313/4313 micro-controller is available in 20 pin PDIP (and other) package. It has following main features: ​ 2/4 KB Flash memory (ROM) to hold the program 128/256 Bytes of SRAM 128/256 Bytes of EEPROM 18 Digital Input/Ouput pins, maximum 8 bit timer/counter, 1 number 16 bit timer/counter, 1 number PWM channels, 4 channels TWI communication USI communication USART communication, Full Duplex ​ Datasheet link (courtesy Microchip): http://ww1.microchip.com/downloads/en/DeviceDoc/doc8246.pdf http://ww1.microchip.com/downloads/en/devicedoc/atmel-2543-avr-attiny2313_summary.pdf ATMEGA 8: ​ ATMEGA 8 micro-controller is available in 28 pin PDIP (and other) package. It has following main features: ​ 8 KB Flash memory (ROM) to hold the program 1 KB of SRAM 512 Bytes of EEPROM 23 Digital Input/Ouput pins, maximum 10 bit ADC, 6 channels in PDIP(8 in TQFP) 8 bit timer/counter, 2 number 16 bit timer/counter, 1 number PWM channels, 3 channels TWI communication SPI communication USART communication, Programmable ​ Datasheet link (courtesy Microchip): http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-2486-8-bit-AVR-microcontroller-ATmega8_L_datasheet.pdf ATMEGA 48/88/168/328: ​ ATMEGA 48/88/168/328 micro-controller is available in 28 pin PDIP (and other) package. It has following main features: ​ 4/8/16/32 KB Flash memory (ROM) to hold the program 512/1024/1024//2048 Bytes of SRAM 256/512/512/1024 Bytes of EEPROM 23 Digital Input/Ouput pins, maximum 10 bit ADC, 6 channels in PDIP (8 in TQFP) 8 bit timer/counter, 2 number 16 bit timer/counter, 1 number PWM channels, 4 channels TWI communication SPI communication USART communication, Programmable ​ Datasheet link (courtesy Mouser): https://www.mouser.com/pdfdocs/gravitech_atmega328_datasheet.pdf ATMEGA 16/32: ​ ATMEGA 16/32 micro-controller is available in 40 pin PDIP (and other) package. It has following main features: ​ 16/32 KB Flash memory (ROM) to hold the program 1/2 KB of SRAM 512/1024 Bytes of EEPROM 32 Digital Input/Ouput pins, maximum 10 bit ADC, 8 channels 8 bit timer/counter, 2 number 16 bit timer/counter, 1 number PWM channels, 4 channels TWI communication SPI communication USART communication, Programmable ​ Datasheet link (courtesy Microchip): http://ww1.microchip.com/downloads/en/devicedoc/atmel-8154-8-bit-avr-atmega16a_datasheet.pdf ​ http://ww1.microchip.com/downloads/en/DeviceDoc/doc2466.pdf http://ww1.microchip.com/downloads/en/devicedoc/doc2503.pdf SUMMARY: ​ Handling of packages other tan PDIP is difficult and need PCB with SMT. So, the pinouts are shown for PDIP only. Other package details and pinouts may be obtained from datasheets (link is provided at the end) . ​ Selection of a micro-controller depends on the memory requirement, communication system requirement, space availability, number of Input/Outputs, cost of the micro-controller etc. ​ 1) The AVR PDIP micro controllers generally available in 5 packages 8pin, 14pin, 20pin, 28pin and 40pin. ​ 2) All 28 pin micro-controllers have almost same pinouts, except memory capacity and communication methods. ​ 3) ARDUINO UNO uses ATMEGA328 with bootloader. AVR: ADC & DAC >>

bottom of page