Instrumentation & Control Engg. Section Electrical Engineering Department Ahmedabad , Gujarat
Arithmetic Operations Logic Operations Conditions Loops Both Assembly language and C language
Input Devices Switch Push-button, POT Sensors (temperature, strain gauge, level) (mV) Touchscreen Keypad matrix Infrared (PIR motion sensor) Camera PING Sensor RPM Measurement IR sensor LM35 Etc….
Output Devices LED Seven Segment LED Matrix LCD Motor (DC, AC, Servo, Stepper) Relay Solenoid Valve Etc…
RFID Tag and Reader GSM Module GPS module Motor Driver
MOV P0,#83H // Initializing push button switches and initializing LED in OFF state. READSW: MOV A,P0 // Moving the port value to Accumulator. RRC A // Checking the vale of Port 0 to know if switch 1 is ON or not JC NXT // If switch 1 is OFF then jump to NXT to check if switch 2 is ON CLR P0.7 // Turn ON LED because Switch 1 is ON SJMP READSW // Read switch status again. NXT: RRC A // Checking the value of Port 0 to know if switch 2 is ON or not JC READSW // Jumping to READSW to check status of switch 1 again (provided switch 2 is OFF) SETB P0.7 // Turning OFF LED because Switch 2 is ON SJMP READSW // Jumping to READSW to read status of switch 1 again. END
#include //including sfr registers for ports of the controller #include //Can be download from bottom of this article //LCD Module Connections sbit RS = P0^0; sbit EN = P0^1; sbit D4 = P2^4; sbit D5 = P2^5; sbit D6 = P2^6; sbit D7 = P2^7; //End LCD Module Connections void Delay(int a) { int j; int i; for(i=0;i<a;i++) { for(j=0;j<100;j++) { } void main() { int i; Lcd4_Init(); while(1) { Lcd4_Set_Cursor(1,1); Lcd4_Write_String("electroSome LCD Hello World");
for(i=0;i<15;i++) { Delay(1000); Lcd4_Shift_Left(); } for(i=0;i<15;i++) { Delay(1000); Lcd4_Shift_Right(); } Lcd4_Clear(); Lcd4_Set_Cursor(2,1); Lcd4_Write_Char('e'); Lcd4_Write_Char('S'); Delay(2000); }
#include //including sfr registers for ports of the controller #include //LCD Module Connections sbit RS = P0^0; sbit EN = P0^1; sbit D0 = P2^0; sbit D1 = P2^1; sbit D2 = P2^2; sbit D3 = P2^3; sbit D4 = P2^4; sbit D5 = P2^5; sbit D6 = P2^6; sbit D7 = P2^7; //End LCD Module Connections //Keypad Connections sbit R1 = P1^0; sbit R2 = P1^1; sbit R3 = P1^2; sbit R4 = P1^3; sbit C1 = P1^4; sbit C2 = P1^5; sbit C3 = P1^6; sbit C4 = P1^7; //End Keypad Connections void Delay(int a) { int j; int i;
for(i=0;i<a;i++) { for(j=0;j<100;j++) { } char Read_Keypad() { C1=1; C2=1; C3=1; C4=1; R1=0; R2=1; R3=1; R4=1; if(C1==0){Delay(100);while(C1==0);retu rn '7';} if(C2==0){Delay(100);while(C2==0);retu rn '8';} if(C3==0){Delay(100);while(C3==0);retu rn '9';} if(C4==0){Delay(100);while(C4==0);retu rn '/';} R1=1; R2=0; R3=1; R4=1; if(C1==0){Delay(100);while(C1==0);retu rn '4';} if(C2==0){Delay(100);while(C2==0);retu rn '5';}
if(C3==0){Delay(100);while(C3==0);retur n '6';} if(C4==0){Delay(100);while(C4==0);retur n 'X';} R1=1; R2=1; R3=0; R4=1; if(C1==0){Delay(100);while(C1==0);retur n '1';} if(C2==0){Delay(100);while(C2==0);retur n '2';} if(C3==0){Delay(100);while(C3==0);retur n '3';} if(C4==0){Delay(100);while(C4==0);retur n '-';} R1=1; R2=1; R3=1; R4=0; if(C1==0){Delay(100);while(C1==0);retu rn 'C';} if(C2==0){Delay(100);while(C2==0);retu rn '0';} if(C3==0){Delay(100);while(C3==0);retu rn '=';} if(C4==0){Delay(100);while(C4==0);retu rn '+';} return 0; }
void main() { int i=0; char c,p; Lcd8_Init(); while(1) { Lcd8_Set_Cursor(1,1); Lcd8_Write_String("Keys Pressed:"); Lcd8_Set_Cursor(2,1); Lcd8_Write_String("Times:"); while(!(c = Read_Keypad())); p=c; while(p==c) { i++; Lcd8_Set_Cursor(1,14); Lcd8_Write_Char(c); Lcd8_Set_Cursor(2,7); Lcd8_Write_Char(i+48); Delay(100); while(!(c = Read_Keypad())); } i=0; Lcd8_Clear(); }
#include sbit relay_pin = P2^0; void Delay_ms(int); void main() { do { relay_pin = 1; //Relay ON Delay_ms(1000); relay_pin = 0; //Relay OFF Delay_ms(1000); }while(1); } void Delay_ms(int k) { int j; int i; for(i=0;i<k;i++) { for(j=0;j<100;j++) { }
#include #define relayport P2 void Delay_ms(int); void main() { do { relayport = 0xFF; //All relays On Delay_ms(1000); relayport = 0x00; //All relays Off Delay_ms(1000); }while(1); } void Delay_ms(int k) { int j; int i; for(i=0;i<k;i++) { for(j=0;j<100;j++) { }
A Stepper Motor is a brushless, synchronous DC Motor. It has many applications in the field of robotics and mechatronics. The total rotation of the motor is divided into steps. The angle of a single step is known as the stepper angle of the motor. There are two types of stepper motors Unipolar and Bipolar. Due to the ease of operation unipolar stepper motor is commonly used by electronics hobbyists. Stepper Motors can be easily interfaced with a microcontroller using driver ICs such as L293D or ULN2003.stepper motors L293DULN2003 Unipolar stepper motors can be used in three modes namely the Wave Drive, Full Drive and Half Drive mode. Each drive have its own advantages and disadvantages, thus we should choose the required drive according to the application and power consumption.
In this mode only one electromagnet is energized at a time. Generated torque will be less when compared to full drive in which two electromagnets are energized at a time but power consumption is reduced. It has same number of steps as in the full drive. This drive is preferred when power consumption is more important than torque. It is rarely used. Wave Drive Stepping Sequence StepABCD
In this mode two electromagnets are energized at a time, so the torque generated will be larger when compared to Wave Drive. This drive is commonly used than others. Power consumption will be higher than other modes. Full Drive Stepping Sequence StepABCD
Half Drive In this mode alternatively one and two electromagnets are energized, so it is a combination of Wave and Full drives. This mode is commonly used to increase the angular resolution of the motor but the torque will be less, about 70% at its half step position. We can see that the angular resolution doubles when using Half Drive. Half Drive Stepping Sequence StepABCD
#include void delay(int); void main() { do { P2=0x01; //0001 delay(1000); P2=0x02; //0010 delay(1000); P2=0x04; //0100 delay(1000); P2=0x08; //1000 delay(1000); } while(1); } void delay(int k) { int i,j; for(i=0;i<k;i++) { for(j=0;j<100;j++) {} }
#include void delay(int); void main() { do { P2 = 0x03; //0011 delay(1000); P2 = 0x06; //0110 delay(1000); P2 = 0x0C; //1100 delay(1000); P2 = 0x09; //1001 delay(1000); } while(1); } void delay(int k) { int i,j; for(i=0;i<k;i++) { for(j=0;j<100;j++) {} }
#include void delay(int); void main() { do { P2=0x01; //0001 delay(1000); P2=0x03; //0011 delay(1000); P2=0x02; //0010 delay(1000); P2=0x06; //0110 delay(1000); P2=0x04; //0100 delay(1000); P2=0x0C; //1100 delay(1000); P2=0x08; //1000 delay(1000); P2=0x09; //1001 delay(1000); } while(1); } void delay(int k) { int i,j; for(i=0;i<k;i++) { for(j=0;j<100;j++) {} }
#include void delay(int); void main() { do { P2=0x01; //0001 delay(1000); P2=0x04; //0100 delay(1000); P2=0x02; //0010 delay(1000); P2=0x08; //1000 delay(1000); }while(1); } void delay(int k) { int i,j; for(i=0;i<k;i++) { for(j=0;j<100;j++) {} }
Control Signals and Motor Status P2.0/IN1P2.1/IN2Motor Status LOW Stops LOWHIGHClockwise HIGHLOWAnti-Clockwise HIGH Stops
#include void delay(void); sbit motor_pin_1 = P2^0; sbit motor_pin_2 = P2^1; void main() { do { motor_pin_1 = 1; motor_pin_2 = 0; //Rotates Motor Anit Clockwise delay(); motor_pin_1 = 1; motor_pin_2 = 1; //Stops Motor delay(); motor_pin_1 = 0; motor_pin_2 = 1; //Rotates Motor Clockwise delay(); motor_pin_1 = 0; motor_pin_2 = 0; //Stops Motor delay(); }while(1); } void delay() { int i,j; for(i=0;i<1000;i++) { for(j=0;j<1000;j++) { }
A servo motor uses servo mechanism, which is a closed loop mechanism that uses position feedback to control the precise angular position of the shaft. Stepper Motors, which is an open loop system can also be used for precise angular control. But Servo Motors are preferred in angular motion applications such as robotic arm. Moreover controlling of servo motors are very simple, easy and needs no extra hardware like stepper motor.servo motorStepper Motorsstepper motor It uses Pulse Width Modulated (PWM) waves as control signals. The angle of rotation is determined by the width of the pulse at the control pin. The servo motor used here is having angle of rotation from 0 to 180 degrees. We can control the exact angular position by varying the pulse between 1ms to 2msPulse Width ModulatedPWM
#include sbit motor_pin = P2^0; void Delay(unsigned int); void Delay_servo(unsigned int); void main() { motor_pin = 0; do { //Turn to 0 degree motor_pin = 1; Delay_servo(50); motor_pin = 0; Delay(1000); //Turn to 90 degree motor_pin=1; Delay_servo(82); motor_pin=0; Delay(1000); //Turn to 180 degree motor_pin=1; Delay_servo(110); motor_pin=0; Delay(1000); }while(1); } void Delay(unsigned int ms) { unsigned long int us = ms*1000; while(us--) { _nop_(); } void Delay_servo(unsigned int us) { while(us--) { _nop_(); }
THANK YOU