BACKGROUND
Description
Basically used for control actions.It is used to control the operation of machine using fixed program that is stored in ROM/EPROM and that does not change over the life time.
Sensor
1. Infrared sensor
Then all you have to do is to pick-up the reflected IR light. For detecting the reflected IR light, we are going to use a very original technique: we are going to use another IR-LED, to detect the IR light that was emitted from another led of the exact same type!
As you know This is an electrical property of Photo Voltaic Cells(Light Emitting Diodes (LEDs)) which is the fact that a led Produce a voltage difference across its leads when it is subjected to light. So By using this property you can measure the distance of an object
for more details visit the link given bellow which can five you an idea how to interface sharp sensor with Micro controller.
Advantages of IR Sensor:
1. Easily available in Market.
2. Easy to interface.Disadvantages of IR Sensor:
1. Higly influenced by Environmental Noises like Ambient light, radiations etc.
2. Audio sensor
SWITCH:
Toggle switch:
· Max 232
Working of the system
How to send a SMS message with F-Bus?
frame sent to my Nokia 3310 (showed as a Hex dump) 98 Bytes:
1E 00 0C 02 00 21 00 01 00 01 02 00 0A 91 89 25 00 01 20 00 00 00 15 00 00 00 24 0A 91 49 62 95 22 68 00 00 00 00 A7 00 00 00 00 00 00
41 66 51 4A 05 E9 40 49 29 68 5A 1C 56 A5 49 6A 16 84 0C 4E 41 C2 62 D1 09 12 4A 8B C1 65 91 D8 50 00 43 00 xx xx
Byte 0: F-Bus Frame ID. We are on Cable (0x1E)
Byte 1: Destination address.
Byte 2: Source address.
Byte 3: Message Type or ‘command’. 0x02 (SMS Handling).
Byte 4 & 5: Message length. In our case it is 0x0021 bytes long or 83 bytes in decimal.(SMS) Short Message Service Frame Header
Byte 6 to 8: Start of the SMS Frame Header. 0x00, 0x01, 0x00
Byte 9 to 11: 0x01, 0x02, 0x00 = Send SMS Message
Byte 12: SMS Centre number length. 0x07 is 7 bytes long. This includes SMSC Number Type and SMS Centre Phone Number
Byte 13: SMSC number type e.g. 0x81-unknown 0x91-international 0xa1-national
Byte 14 to 23: (Octet format) SMS Centre Phone Number In this case +9825001002
(TPDU) Transfer Protocol Data Unit
Byte 24: Message Type
In our case it is 0x15 = 0001 0101 in binary. The message is SMS Submit, Reject Duplicates, and Validity Indicator present.
Byte 25: Message Reference if SMS Deliver & Validity Indicator used (Not used in this case).
Byte 26: Protocol ID. Refer to GSM 3.40 – 9.2.3.9 TP-Protocol-Identifier (TP-PID)
Byte 27: Data Coding Scheme.
Byte 28: Message Size is 0x33 in hex or 51 bytes long in decimal. This is the size of the unpacked message.
Byte 29: Destination’s number length.
Byte 31 to 40: (Octet format) Destination’s Phone Number
Byte 41: Validity-Period Code. Time period during which the originator considers the short message to be valid.
Byte 42 to 47: Service Centre Time Stamp
The SMS Message (SMS-SUBMIT)
Byte 46 to78 : This is the SMS message packed into 7 bit characters. SMS Point-to-Point Character Packing .
("ALERT : IR SECURITY HAS BEEN BREAKED"
41 66 51 4A 05 E9 40 49 29 68 5A 1C 56 A5 49 6A 16 84 0C 4E 41 C2 62 D1 09 12 4A 8B C1 65 91 D8 50)
Byte 79: Always 0x00
The F-Bus usual ending
Byte 80: Packet Sequence Number
Byte 81: Padding Byte – String is old and requires to be even!
Byte 82 & 83: Odd & even checksum bytes.
Project Source Code
Project Source Code
###
PROGRAM ;------------------------------------------------------------- ;--------------------DECLARATION------------------------------ SEN_IR EQU P1.0 ;IR input SEN_LDR EQU P1.1 ;LDR input SEN_AUD EQU P1.2 ;AUDIO input SEN_FIRE EQU P1.3 ;TEMPERATURE SENSER input SEL_SC EQU P1.4 ;EN/DES serial communication SEL_PORP EQU P1.5 ;selection Phone/PC SEL_LED EQU P1.6 ;EN/DES LED SEL_CHEAKMC EQU P1.7 ;cheak microcontroller LED_IR EQU P0.1 ;IR output LED_LDR EQU P0.2 ;LDR output LED_AUD EQU P0.3 ;AUDIO output LED_FIRE EQU P0.4 ;FIRE output P1_BITS EQU 20H BIT_IR EQU 00 ;0 = IR OFF , 1 = IR ON BIT_LDR EQU 01 ;0 = LDR OFF , 1 = LDR ON BIT_AUD EQU 02 ;0 = AUD OFF , 1 = AUD ON BIT_FIRE EQU 03 ;0 = FIRE OFF , 1 = FIRE ON BIT_SC EQU 04 ;0 = Serial Communication ON, 1 = Serial Communication OFF BIT_PORP EQU 05 ;0 = Phone in USE , 1 = PC in USE BIT_LED EQU 06 ;0 = LED in USE , 1 = LED not in USE BIT_CHEAKMC EQU 07 ;0 = Do not CHEAK Microcontroller , 1 = CHEAK Microcontroller BIT_PW EQU 08 PW_BITS EQU 22H ;My actual idea is to set/reset bit after comparing pressed key and offset password. ;so at end of the routine i just need to cheak PW_BITS.if it's zero then pw is ;correct otherwise not.initially i set PW_BITS to FFH and then reset individual ;bits according to password. SIZE EQU R0 PW_REG_SEL EQU R1 D1 EQU R2 D2 EQU R3 D3 EQU R4 D4 EQU R5 ;------------------------------------------------------------- ;----------------------PROGRAM------------------------------- ORG 0000H LJMP 05FFH ORG 0013H LJMP INT_ACCOR ;INT1 by Lead Per Key Keypad ;---------------------------------------------------------------- ;--------------------DATA SECTION------------------------------- ORG 0039H SIZE_PW: DB 08H ;Size of DATA_PW ORG 0040H DATA_PW: DB '1','7','2','9','2','5','1','9' ;Predefined Password ORG 00FFH SIZEC_IR: DB 53H ;Size of DATAC_IR ORG 0100H DATAC_IR: DB 1EH,00H,0CH,02H,00H,21H,00H,01H,00H,01H,02H,00H,0AH,91H,89H,25H,00H,01H,20H,00H,00H,00H,15H,00H,00H,00H,24H,0AH,91H,49H,62H,95H,22H,68H,00H,00H,00H,00H,0A7H,00H,00H,00H,00H,00H,00H,41H,66H,51H,4AH,05H,0E9H,40H,49H,29H,68H,5AH,1CH,56H,0A5H,49H,6AH,16H,84H,0CH,4EH,41H,0C2H,62H,0D1H,09H,12H,4AH,8BH,0C1H,65H,91H,0D8H,50H,00H,43H,00H,3EH,28H ;DATA_IR for Cellphone ORG 019FH SIZEP_IR: DB 25H ;Size of DATAP_IR = 37 Desimal ORG 01A0H DATAP_IR: DB 'A','L','E','R','T',' ',':',' ','I','R',' ','S','E','C','U','R','I','T','Y',' ','H','A','S',' ','B','E','E','N',' ','B','R','E','A','K','E','D',' ' ;DATA_IR for PC ORG 01FFH SIZEC_LDR: DB 53H ;Size of DATAC_LDR ORG 0200H DATAC_LDR: DB 1EH,00H,0CH,02H,00H,21H,00H,01H,00H,01H,02H,00H,0AH,91H,89H,25H,00H,01H,20H,00H,00H,00H,15H,00H,00H,00H,25H,0AH,91H,49H,62H,95H,22H,68H,00H,00H,00H,00H,0A7H,00H,00H,00H,00H,00H,00H,41H,66H,51H,4AH,05H,0E9H,40H,4CH,0A2H,14H,34H,2DH,0EH,0ABH,0D2H,24H,35H,0BH,42H,06H,0A7H,20H,61H,0B1H,0E8H,04H,09H,0A5H,0C5H,0E0H,0B2H,48H,04H,00H,43H,00H,5FH,57H ;DATA_LDR for Cellphone ORG 029FH SIZEP_LDR: DB 26H ;Size of DATAP_LDR = 38 Desimal ORG 02A0H DATAP_LDR: DB 'A','L','E','R','T',' ',':',' ','L','D','R',' ','S','E','C','U','R','I','T','Y',' ','H','A','S',' ','B','E','E','N',' ','B','R','E','A','K','E','D',' ' ;DATA_LDR for PC ORG 02FFH SIZEC_AUD: DB 55H ;Size of DATAC_AUD ORG 0300H DATAC_AUD: DB 1EH,00H,0CH,02H,00H,23H,00H,01H,00H,01H,02H,00H,0AH,91H,89H,25H,00H,01H,20H,00H,00H,00H,15H,00H,00H,00H,27H,0AH,91H,49H,62H,95H,22H,68H,00H,00H,00H,00H,0A7H,00H,00H,00H,00H,00H,00H,41H,66H,51H,4AH,05H,0E9H,40H,0C1H,2AH,31H,0F9H,04H,4DH,8BH,0C3H,0AAH,34H,49H,0CDH,82H,90H,0C1H,29H,48H,58H,2CH,3AH,41H,42H,69H,31H,0B8H,2CH,12H,01H,00H,43H,00H,0BH,1DH ;DATA_AUDIO for Cellphone ORG 039FH SIZEP_AUD: DB 28H ;Size of DATAP_AUD = 40 Desimal ORG 03A0H DATAP_AUD: DB 'A','L','E','R','T',' ',':',' ','A','U','D','I','O',' ','S','E','C','U','R','I','T','Y',' ','H','A','S',' ','B','E','E','N',' ','B','R','E','A','K','E','D',' ' ;DATA_AUDIO for PC ORG 03FFH SIZEC_FIRE: DB 54H ;Size of DATAC_FIRE ORG 0400H DATAC_FIRE: DB 1EH,00H,0CH,02H,00H,22H,00H,01H,00H,01H,02H,00H,0AH,91H,89H,25H,00H,01H,20H,00H,00H,00H,15H,00H,00H,00H,26H,0AH,91H,49H,62H,95H,22H,68H,00H,00H,00H,00H,0A7H,00H,00H,00H,00H,00H,00H,41H,66H,51H,4AH,05H,0E9H,40H,0C6H,0A4H,0B4H,08H,9AH,16H,87H,55H,69H,92H,9AH,05H,21H,83H,53H,90H,0B0H,58H,74H,82H,84H,0D2H,62H,70H,59H,24H,02H,00H,43H,00H,0E7H,49H ;DATA_FIRE for Cellphone ORG 049FH SIZEP_FIRE: DB 27H ;Size of DATAP_FIRE = 39 Desimal ORG 04A0H DATAP_FIRE: DB 'A','L','E','R','T',' ',':',' ','F','I','R','E',' ','S','E','C','U','R','I','T','Y',' ','H','A','S',' ','B','E','E','N',' ','B','R','E','A','K','E','D',' ' ;DATA_FIRE for PC ORG 04FFH SIZEC_PW: DB 52H ;Size of DATAC_PW ORG 0500H DATAC_PW: DB 1EH,00H,0CH,02H,00H,20H,00H,01H,00H,01H,02H,00H,0AH,91H,89H,25H,00H,01H,20H,00H,00H,00H,15H,00H,00H,00H,24H,0AH,91H,49H,62H,95H,22H,68H,00H,00H,00H,00H,0A7H,00H,00H,00H,00H,00H,00H,41H,66H,51H,4AH,05H,0E9H,40H,0D0H,2BH,68H,5AH,1CH,56H,0A5H,49H,6AH,16H,84H,0CH,4EH,41H,0C2H,62H,0D1H,09H,12H,4AH,8BH,0C1H,65H,91H,08H,00H,43H,00H,34H,38H ;DATA_PW for Cellphone ORG 059FH SIZEP_PW: DB 25H ;Size of DATAP_PW = 37 Desimal ORG 05A0H DATAP_PW: DB 'A','L','E','R','T',' ',':',' ','P','W',' ','S','E','C','U','R','I','T','Y',' ','H','A','S',' ','B','E','E','N',' ','B','R','E','A','K','E','D',' ' ;DATA_PW for PC ;--------------------------------------------------------------- ;------------------------PROGRAM RETURNS------------------------ ORG 05FFH MOV SP,#30H ;appx 30h to 50h is expected for stack(allow stack to scrach the scrach) ;cheaked LCALL INITIALIZATION LCALL CHEAK_SELECTION MAIN: LCALL CHEAK_MC LCALL CHEAK_INPUT LCALL UPDATION LCALL OUTPUT JMP MAIN ;----------------------------------------------------------- INITIALIZATION: ;to make sure 00h to 7fh(accept 33H to 2FH,cause of stack) is clear ;cheaked MOV PSW,#00H MOV R0,#7FH LOOP_I1: MOV @R0,#00H DEC R0 CJNE R0,#33H,LOOP_I1 DEC R0 DEC R0 DEC R0 DEC R0 LOOP_I2: MOV @R0,#00H DEC R0 CJNE R0,#00H,LOOP_I2 MOV IE,#10000100B ;Enable INTERRUPT,Enable INT1 for LPK MOV P0,#00H ;making p0 an output port MOV P1,#0FFH ;making p1 an input port MOV A,#0FFH MOV P0,A ;that's why LEDs SETs at startup RET ;----------------------------------------------------------- CHEAK_SELECTION: ;cheaked MOV A,P1 ANL A,#0F0H MOV P1_BITS,A ;20H is Bit-Addressible (Starting) RET ;----------------------------------------------------------- CHEAK_MC: JNB BIT_CHEAKMC,NO_MC MOV A,#55H CHK_MC: LCALL DELAY_500mS RR A MOV P0,A JMP CHK_MC NO_MC: RET ;-------------------------------------------------------------- CHEAK_INPUT: ;No CLR A instruction so LED Activated by just Push baton ;cheaked LOOP_CI: MOV A,P1 ANL A,#0FH JZ LOOP_CI RET ;----------------------------------------------------------- UPDATION: ;to merge the old SELECTION data(on P1_DATA) and new SENSER data(on A) to P1_BITS ANL P1_BITS,#0F0H ;to cheak continouse input update ORL A,P1_BITS ;to put current selection and current input data MOV P1_BITS,A ;after this instruction P1_BITS having full data of Port 1 RET ;----------------------------------------------------------- OUTPUT: ;cheaked JB BIT_SC,SKIP_OP1 CALL SERIAL_COMM SKIP_OP1: JB BIT_LED,SKIP_OP2 CALL START_LED SKIP_OP2: RET ;----------------------------------------------------------- ;-------------SERIAL COMMUNICATION ROUTINE------------------ SERIAL_COMM: LCALL INITIALISE_SERIAL LCALL CHEAK_SERIAL LCALL SEND_SERIAL RET ;----------------------------------------------------------- INITIALISE_SERIAL: MOV TMOD,#20H ;TIME 1 ,MODE 2 MOV TH1,#0FDH ;9600 Boudrate MOV SCON,#50H ;8 Bit,1 Stop Bit,Recive Enable RET ;----------------------------------------------------------- CHEAK_SERIAL: ;cheaked JB BIT_PORP,SKIP_CELLPHONE LCALL CHEAK_SERIALC SKIP_CELLPHONE: JNB BIT_PORP,SKIP_PC LCALL CHEAK_SERIALP SKIP_PC: RET ;---------------------------------------------------------------- CHEAK_SERIALC: ;cheaked JNB BIT_IR,SKIP_IRC CLR A MOV DPTR,#SIZEC_IR MOVC A,@A+DPTR MOV SIZE,A MOV DPTR,#DATAC_IR RET SKIP_IRC: JNB BIT_LDR,SKIP_LDRC CLR A MOV DPTR,#SIZEC_LDR MOVC A,@A+DPTR MOV SIZE,A MOV DPTR,#DATAC_LDR RET SKIP_LDRC: JNB BIT_AUD,SKIP_AUDC CLR A MOV DPTR,#SIZEC_AUD MOVC A,@A+DPTR MOV SIZE,A MOV DPTR,#DATAC_AUD RET SKIP_AUDC: JNB BIT_FIRE,SKIP_FIREC CLR A MOV DPTR,#SIZEC_FIRE MOVC A,@A+DPTR MOV SIZE,A MOV DPTR,#DATAC_FIRE RET SKIP_FIREC: JNB BIT_PW,SKIP_PWC CLR A MOV DPTR,#SIZEC_PW MOVC A,@A+DPTR MOV SIZE,A MOV DPTR,#DATAC_PW RET SKIP_PWC: RET ;------------------------------------------------------------ CHEAK_SERIALP: ;cheaked JNB BIT_IR,SKIP_IRP CLR A MOV DPTR,#SIZEP_IR MOVC A,@A+DPTR MOV SIZE,A MOV DPTR,#DATAP_IR RET SKIP_IRP: JNB BIT_LDR,SKIP_LDRP CLR A MOV DPTR,#SIZEP_LDR MOVC A,@A+DPTR MOV SIZE,A MOV DPTR,#DATAP_LDR RET SKIP_LDRP: JNB BIT_AUD,SKIP_AUDP CLR A MOV DPTR,#SIZEP_AUD MOVC A,@A+DPTR MOV SIZE,A MOV DPTR,#DATAP_AUD RET SKIP_AUDP: JNB BIT_FIRE,SKIP_FIREP CLR A MOV DPTR,#SIZEP_FIRE MOVC A,@A+DPTR MOV SIZE,A MOV DPTR,#DATAP_FIRE RET SKIP_FIREP: JNB BIT_PW,SKIP_PWP CLR A MOV DPTR,#SIZEP_PW MOVC A,@A+DPTR MOV SIZE,A MOV DPTR,#DATAP_PW RET SKIP_PWP: RET ;------------------------------------------------------------- SEND_SERIAL: ;simply send data loaded from DPTR location of size SIZE ;cheaked LOOP_SS: CLR A MOVC A,@A+DPTR SETB TR1 MOV SBUF,A REPEAT: JNB TI,REPEAT CLR TI INC DPTR DJNZ SIZE,LOOP_SS ;-------------------------------------------------------------- ;------------------------LED ROUTINE---------------------------- START_LED: ;inverse logic,due to low power output MOV A,#0FH ANL A,P1_BITS ;after this ACC having only senser data XRL A,#0FFH ;to invert MOV P0,A RET ;------------------------------------------------------------------- ;-------------------"LEAD PER KEY" KEYPAD ROUTINE------------------- INT_ACCOR: LCALL INITIALIZE LCALL GET_KEY ;ENTER and EN_DES_SEC is merged with GET_KEY RETI ;------------------------------------------------------------------- INITIALIZE: MOV P0,#00H ;making OUTPUT port MOV P2,#0FFH ;making INPUT port MOV PW_REG_SEL,#08H ;whole REG BANK 2 is dedicated to store 8 byte PW MOV PW_BITS,#0FFH ;by prog going to make it 00h if pw is true SETB P0.0 ; SETB P0.1 ; SETB P0.2 ; SETB P0.3 ; CLR P0.4 ;blue LED ON (Keypad is active) SETB P0.5 ;yellow LED OFF (you have pressed a key) SETB P0.6 ;green LED OFF (right Password) SETB P0.7 ;red LED OFF (wrong password) RET ;------------------------------------------------------------------- GET_KEY:NOP ;as Expert Programmer Writes MOV D3,#07H ;This 14 lines have dissipate 6 hours of my peak efficient time. LOOP2:DEC D3 ;but when i got it ,it feels like god... MOV D2,#0FFH ;My actual idea was to use timer as interrupt ,so that if user dint LOOP1:DEC D2 ;press any key in 5 second then program say getout . MOV D1,#0FFH ;but the problem arise when i come to know that in one interrupt CHEAK:MOV A,D1 ;routine(INT1) i cant use other interrupt(TIMER0)(RETI is must b4 other imterrupt)... JZ LOOP1 ;so that i need to create a applet(small program) in such a way that MOV A,D2 ;actes as VIRTUAL TIMER,mean to say i want to cheak input continuasly JZ LOOP2 ;any continue cheaking time and when reach to 5 second virtual interrupt MOV A,D3 ;can be generated and come out of infinite loop. JZ TIMES_UP ; DEC D1 ;"Nohing could be Possible ,Untill Tried" MOV A,P2 ; -this's also orignal once.. JZ CHEAK ; CLR P0.5 LCALL DELAY_1S ;to indicate key press(as programmer view,to set delay to prevent double key press) SETB P0.5 CJNE A,#01H,GOTO2 MOV @PW_REG_SEL,#31H ;key-1 ('1') GOTO2: CJNE A,#02H,GOTO3 MOV @PW_REG_SEL,#32H ;key-2 ('2') GOTO3: CJNE A,#04H,GOTO4 MOV @PW_REG_SEL,#33H ;key-3,4,6 ('3','4','6') GOTO4: CJNE A,#08H,GOTO5 MOV @PW_REG_SEL,#35H ;key-5 ('5') GOTO5: CJNE A,#10H,GOTO6 MOV @PW_REG_SEL,#37H ;key-7 ('7') GOTO6: CJNE A,#20H,GOTO7 MOV @PW_REG_SEL,#39H ;key-9 ('9') GOTO7: CJNE A,#40H,GOTO8 MOV @PW_REG_SEL,#30H ;key-0,8 ('0','8') GOTO8: CJNE A,#80H,GOTO9 CALL ENTER ;ENTER key has been pressed(the only way to come out of loop,accept "times up") GOTO9: INC PW_REG_SEL CJNE PW_REG_SEL,#10H,GET_KEY MOV PW_REG_SEL,#08H JMP GET_KEY TIMES_UP: ;the prog never suppose to come here in regular routine !! ;MAKE RESET HERE ;if time will be up then and only it force to come here... RET ;------------------------------------------------------------------- ENTER: MOV PW_REG_SEL,#08H MOV DPTR,#DATA_PW ;MOV BIT_SETTER,#0FEH ;it'll be used for setting PW_BITS by use of rotation LOOPE: CLR A MOVC A,@A+DPTR XRL A,@PW_REG_SEL JNZ AS_IT_IS MOV A,PW_BITS ANL A,#0FEH MOV PW_BITS,A AS_IT_IS: INC PW_REG_SEL INC DPTR MOV A,PW_BITS RR A MOV PW_BITS,A CJNE PW_REG_SEL,#10H,LOOPE ;EN_DES_SEC: MOV A,PW_BITS JZ OK ;if the pw bits(PW_BITS) is 00h then pw is right o/w wrong LCALL WRONG_PW JMP WAY_OUT OK: LCALL RIGHT_PW ;not expected to return WAY_OUT: POP B ;hahaha...this may be considered as my favourite two POP B ;lines in the whole code i've developed.. ;footnote:-i've skipped orignal RET by popping two times.. RET ;----------------------DELAY HANDLERS----------------------- ;Crystal Used : 11.0592 MHz (hard to find at my City) ;Using serial comm so No Option At All....... DELAY_10mS: ;Actuly ((256*2)+1)*19*1.085 uS = 10.57 mS MOV D1,#19H DLOOP1A:MOV D2,#0FFH DLOOP2A:DJNZ D2,DLOOP2A DJNZ D1,DLOOP1A RET DELAY_500mS: ;creates delay for 0.5S MOV D3,#04H DLOOP3B:MOV D2,#0FFH DLOOP2B:MOV D1,#0FFH DLOOP1B:DJNZ D1,DLOOP1B DJNZ D2,DLOOP2B DJNZ D3,DLOOP3B RET DELAY_1S: ;creates delay for 1S MOV D3,#07H DLOOP3C:MOV D2,#0FFH DLOOP2C:MOV D1,#0FFH DLOOP1C:DJNZ D1,DLOOP1C DJNZ D2,DLOOP2C DJNZ D3,DLOOP3C RET ;-----------------------------------------------------------
END
###
Circuit Diagrams
Filed Under: Electronic Projects
Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.