Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Light control system for smart home

Status
Not open for further replies.
part four which is the last part is to use USART(Universal Asynchronous Receive and Transmit) where by the lights can be turned on or off, and the blinds can be closed or opened by the user using computer interface. The cable i will be using is RS232 to conect the computer and the circuit. That is the input comes from the computer interface. i would be glad if u can provide me with the reliable materials of USART or links.
 
birdman0 i thought it was internet problems yesterday while i tried to download the link about (PIR232) but even today after downloading it, when i open the pdf it says the file is damaged. could you please post it again. but as for the UART.asm file i have download it and it is alright
 
In page 3 it is stated what happens if the body passes infront of the sensor, so what i want to know is how much output voltage does the sensor output if there is a body passing in front of the sensor. i need that output voltage so that i can make ADC and turn on the LED. In page 5 it says output mv(2)= 3900, does it mean it output 3.9 volts. if that is the case will i be correct to say if the ouput voltage is creater than 2.5 volts it means there is motion detected hence i can turn on the LED and the code will still be the same as that one where i used the light sensor.
 
hi birdman0_0 i think before monday i will show you the code i wrote using USART its because im still working on how to turn a unipolar stepper motor clockwise and anti clockwise direction. Besides that i have to read about USART and understand how it works
 
please take a look at this link Jones on Stepping Motor Types
it says to rotate the unipolar motor continuously, we just apply power to the two windings in sequence. Assuming positive logic, where a 1 means turning on the current through a motor winding. in the code below i have applied this sequence :Winding 1a 1000100010001000100010001
Winding 1b 0010001000100010001000100
Winding 2a 0100010001000100010001000
Winding 2b 0001000100010001000100010


but the motor does not rotate as animated GIF of figure 1.2 . what is wrong with the code

Code:
;Author : LEBOHANG MAPHOTHOANE
;PROGRAM FUNCTION:turning motor


	list		P=16F877a

    include    "P16F877a.inc"
                __config 0x3D18	
	;errorlevel -302, -207;suppress message 302 from the list
 ;Declarations:

 	CBLOCK 20h   ; Temporary storage                 
                 pos
                 dc1
                 dc2
                 delay
              ENDC



     
      
	org		0x0000
	goto Start	

;Program Start:

Start
    call Init             ;sets the values of ADCON0 and ADCON1 
                                       ;initialize porta

Main           
           
    ;clockwise 
       movlw b'0001'
       movwf PORTB
       call wait
       clrf PORTB

       movlw b'0100'
       movwf PORTB
       call wait
       clrf PORTB

       movlw b'0010'
       movwf PORTB
       call wait
       clrf PORTB
       
       movlw b'1000'
       movwf PORTB
       call wait
       clrf PORTB
       goto Main
       

wait     movlw   4	     ; Outer loop iteration count
	      movwf   dc1		
dl1	      clrf    dc2            ; Initialize inner loop
dl2	      nop
	      nop
	      decfsz  dc2,F         
	      goto    dl2
	      decfsz  dc1,F
	      goto    dl1
	      return







;Subroutines:
            
Init


              clrw                    ; Zero.

              movwf   PORTB           ; Ensure PORTB is zero before we enable it.
              bsf     STATUS,RP0      ; Select Bank 1
              movlw   0xF0            ; Set port B bits 0-3 as outputs
              movwf   TRISB           ; Set TRISB register.           
                                                               
              bcf     STATUS,RP0      ; Select Bank 0
                           
    
    
 
   
    return

    END
 
the program when i built it on Mplab it says zero errors.I used ISIS 7 Professional to construct circuit diagram and when i run it, the motor do not rotate the way i want it to rotate, it rotates one step about 30 degrees and it stops, but i want it to rotate continuously until i stop it
 
circuit.jpg The circiut diagram looks like this. can u try it and upload my code and see if it will work
 
:)i have figured the problem, the delay subroutine was not correct. now that i have corrected the delay subroutine at lest it can turn 180 degrees clockwise
Code:
;Author : LEBOHANG MAPHOTHOANE
;PROGRAM FUNCTION:turning motor


	list		P=16F877a

    include    "P16F877a.inc"
                __config 0x3D18	
	;errorlevel -302, -207;suppress message 302 from the list
 ;Declarations:

 	CBLOCK 20h   ; Temporary storage                 
               
                 dc1
              
                
              ENDC



     
      
	org		0x0000
	goto Init	

;Program Start:

;Start
 ;   call Init             ;sets the values of ADCON0 and ADCON1 
                                       ;initialize porta
 
wait      movlw   5    ; Outer loop iteration count
d11	      movwf   dc1		 

	      decfsz  dc1,F         
	      goto    $-1
	      return



;Subroutines:
            
Init


              clrw                    ; Zero.

              movwf   PORTB           ; Ensure PORTB is zero before we enable it.
              bsf     STATUS,RP0      ; Select Bank 1
              movlw   0xF0            ; Set port B bits 0-3 as outputs
              movwf   TRISB           ; Set TRISB register.           
                                                               
              bcf     STATUS,RP0      ; Select Bank 0
            
 
   
Main           

    
clockwise 
;1-----------------------
       movlw b'0001'
       movwf PORTB
       call wait

       movlw b'0100'
       movwf PORTB
       call wait
   
       movlw b'0010'
       movwf PORTB
       call wait
   
       movlw b'1000'
       movwf PORTB
       call wait
      ; goto Main


      end
 
birdman0 i want to make a simple comuter interface which looks like that one on the picture. if i click the box (clockwise) then the motor must rotate clockwise or if i click anticlockwise then the motor must rotate anticlockwise. im not sure which programing software i must use between visual studio C++ or axampp to make such interface. i have read about USART and how to send data through rs232 cable.i think these two diagrams can easily explain to you what im trying to say. i want to control the motor on the circuit board using computer where by connection between the computer and the circuit board is made by rs232 serail cable
 

Attachments

  • cpu.jpg
    cpu.jpg
    13.1 KB · Views: 198
  • CPU1.jpg
    CPU1.jpg
    46.2 KB · Views: 227
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top