Jump to content

thedarkshade

Senior Members
  • Posts

    1421
  • Joined

  • Last visited

Posts posted by thedarkshade

  1. Hi everyone

     

    I've had this project on controlling the light intensity with a microcontroller, using phase control. I've build the zero-cross detector and the circuitry to interface with the light via an optocoupler (MOC3023) and a triac (BT138), but I'm a little stuck on the software. I'm using an on-board potentiometer to control the intensity and a 12bit ADC to get the digital value, but I think I can easily complete by having an 8bit value.

    So my point of concern is how do I change this 12bit value into an 8bit one?

    Any help at all would be greatly appreciated :)

     

    TDS

  2. Oh, and btw is there something like "8051 LCD command list" like the 'enter command' or 'backspace'?

    The ones I have above (move_left, move_right, del,...) I collected from several books I happen to have on microcontrollers, but I feel my project's lacking a taste of completeness.

  3. No no, I'm using pushbuttons on the board as keys.

     

    I got it to work lasht night actually. I seem to have been carrying a bit from the ISR routine that was causing me trouble.

     

    P.s. I apologize for lack of comments (not a good programmer). Some of the labels too are in my native language :(

  4. Hey everyone.

     

    I've been working for quite a while on this one. I've been trying to make a VT100 terminal emulator through serial port (RS232 standard) using Easy8051A development board. I've written down the entire code for writing from hyperterminial (yeah, I nedded XP for that) to a 2x16 LCD (8-bit mode) and also for writing from the board to hyperterminal, but I got stuck trying to bring the two together. I know I must somehow use serial interrupts to check whether a key has been pressed or not but I can't just quite figure it out.

    I'll post the code down here, just in case anyone has any bit of idea of how could I proceed.

     

    This is the code to write to the LCD (control codes including):

    ESC EQU 1BH
    
    ORG 0000H
    
    LJMP MAIN
    
    ORG 0023H
    
    MAIN:
    BUSY BIT P0.7
    E BIT P2.4
    RS BIT P2.2
    RW BIT P2.3
    
    MOV A, PCON
    SETB ACC.7
    MOV PCON, A
    MOV SCON, #52h
    MOV TMOD, #20h
    MOV TH1, #-35
    SETB EA
    SETB ES
    SETB PS
    SETB TR1
    CALL LCD_INIT;
    
    PRANO: 
    JNB RI, $  ; KONTROLLO A ESHTE SHRYPUR NDOJE KARAKTER
    CLR RI
    MOV A, SBUF
    CHECK_DEL:
    CJNE A, #7FH, CONTINUE
    LJMP CLEAR_LCD
    LJMP NEXT
    
    
    CONTINUE:
    CJNE A, #ESC, NO_ESC1
    CLR P1.7
    JNB RI, $
    CLR RI
    MOV A, SBUF
    CJNE A, #'[', NO_KLLAPA
    JNB RI, $
    CLR RI
    MOV A, SBUF
    CJNE A, #'C', CHECK_D
    LCALL MOVE_LEFT
    LJMP NEXT
    
    CHECK_D:
    CJNE A, #'D', CHECK_A
    LCALL MOVE_RIGHT
    LJMP NEXT
    
    CHECK_A:
    CJNE A, #'A', CHECK_B
    LCALL MOVE_UP
    LJMP NEXT
    
    CHECK_B:
    CJNE A, #'B', NEXT
    LCALL MOVE_DOWN
    LJMP NEXT	
    
    
    
    
    NO_ESC1:	LJMP NO_ESC
    
    MOVE_LEFT:	
    	MOV A, #14H
    	ACALL COMMAND
    	RET
    
    MOVE_RIGHT:
    	MOV A, #10H
    	ACALL COMMAND
    	RET
    
    MOVE_UP:
    	LCALL READY
    	MOV A, P0
    	ANL A,#00111111B
    	MOV R7, A
    	MOV A, #40H
    	SUBB A, R6
    	MOV R6, A
    	MOV A, R7
    	SETB ACC.7
    	ACALL COMMAND
    	RET
    
    MOVE_DOWN:
    	LCALL READY
    	MOV A, P0
    	ANL A, #00111111B
    	MOV R6, A
    	MOV A, #40H
    	ADD A, R6
    	MOV R7, A
    	MOV A, R7
    	SETB ACC.7
    	ACALL COMMAND
    	RET	
    
    CLEAR_LCD:
    	MOV A, #01H
    	CALL COMMAND		
    
    
    
    
    NO_KLLAPA:
    LJMP NEXT
    
    ;******************************************************************
    LCD_INIT:			 				 ;*
    MOV A, #38H	; 2 Linja 5x7	 			 ;*
    ACALL COMMAND		 				 ;*
    MOV A, #0DH	;Aktivizimi i Kursorit (Blinkues)	 ;*
    ACALL COMMAND		 				 ;*
    MOV A, #01H	;Fshirja e ekranit	 	       	 ;*
    ACALL COMMAND		 				 ;*
    MOV A, #06H	;Vendosja e Kursorit Ne Te Djathe	 ;*
    ACALL COMMAND						 ;*
    RET			 				 ;*
    							 ;*		   \
    			 				 ;*=================\
    COMMAND: 			 				 ;*==================\
    ACALL READY		 				 ;*==================/   Pergaditja e LCD-se        
    MOV P0, A		 				 ;*=================/
    CLR RS							 ;*		   /
    CLR RW			 				 ;*
    SETB E			 				 ;*
    CLR E			 				 ;*
    RET			 				 ;*
    			 				 ;*
    			 				 ;*
    			 				 ;*
    READY:				 				 ;*
    SETB BUSY		 				 ;*
    MOV P0, #0FFH		 				 ;*
    CLR RS			 				 ;*
    SETB RW			 				 ;*
    BACK:				 				 ;*
    CLR E			 				 ;*
    SETB E			 				 ;*
    JB BUSY, BACK		 				 ;*
    RET			 				 ;*
    			 				 ;*
    ;******************************************************************	
    
    NO_ESC:
    LCALL LCD_DISPLAY
    CPL A
    MOV P1,A
    NEXT:
    SETB P1.7
    LJMP PRANO
    
    
    LCD_DISPLAY:
    ACALL READY
    CLR E
    MOV P0, A
    SETB RS
    CLR RW
    SETB E
    CLR E
    RET
    
    
    STOP:
    
    END
    
    

     

    This is the code for hyperterminal-to-board:

    ORG 0000H
    
    MOV A, PCON	;|
    SETB ACC.7	;|------->Mundesimi i Dyfishimit te Baud-Rate (SMOD=1)
    MOV PCON, A	;|
    ;----------------|      
    
    MOV SCON, #52H	;Pori Serik, Modi 1	
    MOV TMOD, #20H	;Timeri-i 1, Modi 2
    MOV TH1, #-35	; 1200 baud-rate
    SETB TR1	; Starton timer-in 1
    
    
    WRITE_TO_TERMINAL:
    JB P0.0, CHECK_B
    
    WRITE_A:
    MOV A, #41H
    CALL OUTCHR
    
    CHECK_B:JB P0.1, CHECK_C
    
    WRITE_B:
    MOV A, #42H
    CALL OUTCHR
    
    CHECK_C:JB P0.2, CHECK_D
    
    WRITE_C:
    MOV A, #43H
    CALL OUTCHR
    
    CHECK_D:JB P0.3, CHECK_E
    
    WRITE_D:
    MOV A, #44H
    CALL OUTCHR
    
    
    CHECK_E: JB P0.4, CHECK_F
    
    WRITE_E:
    MOV A, #45H
    CALL OUTCHR
    
    CHECK_F:JB P0.5, CHECK_G
    
    WRITE_F:
    MOV A, #46H
    CALL OUTCHR
    
    CHECK_G:JB P0.6, CHECK_H
    
    WRITE_G:
    MOV A, #47H
    CALL OUTCHR	
    
    CHECK_H:JB P0.7, CHECK_I
    
    WRITE_H:
    MOV A, #48H
    CALL OUTCHR
    
    CHECK_I:JB P1.0, CHECK_J
    WRITE_I:
    MOV A, #49H
    CALL OUTCHR
    
    CHECK_J: JB P1.1, CHECK_K
    WRITE_J:
    MOV A, #04AH
    CALL OUTCHR
    
    CHECK_K: JB P1.2, CHECK_L
    WRITE_K:
    MOV A, #04BH
    CALL OUTCHR
    
    CHECK_L: JB P1.3, CHECK_M
    WRITE_L:
    MOV A, #04CH
    CALL OUTCHR
    
    CHECK_M: JB P1.4, CHECK_N
    WRITE_M:
    MOV A, #04DH
    CALL OUTCHR
    
    CHECK_N: JB P1.5, CHECK_O
    WRITE_N:
    MOV A, #04EH
    CALL OUTCHR
    
    CHECK_O: JB P1.6, CHECK_P
    WRITE_O:
    MOV A, #04FH
    CALL OUTCHR
    
    CHECK_P: JB P1.7, CHECK_Q
    WRITE_P:
    MOV A, #50H
    CALL OUTCHR
    
    CHECK_Q: JB P2.0, CHECK_R
    WRITE_Q:
    MOV A, #51H
    CALL OUTCHR
    
    CHECK_R: JB P2.1, CHECK_S
    WRITE_R:
    MOV A, #52H
    CALL OUTCHR
    
    CHECK_S: JB P2.2, CHECK_T
    WRITE_S:
    MOV A, #53H
    CALL OUTCHR
    
    CHECK_T: JB P2.3, CHECK_U
    WRITE_T:
    MOV A, #54H
    CALL OUTCHR
    
    CHECK_U: JB P2.4, CHECK_V
    WRITE_U:
    MOV A, #55H
    CALL OUTCHR
    
    CHECK_V: JB P2.5, CHECK_W
    WRITE_V:
    MOV A, #56H
    CALL OUTCHR
    
    CHECK_W: JB P2.6, CHECK_X
    WRITE_W:
    MOV A, #57H
    CALL OUTCHR
    
    CHECK_X: JB P2.7, CHECK_Y
    WRITE_X:
    MOV A, #58H
    CALL OUTCHR
    
    CHECK_Y: JB P3.2, CHECK_Z
    WRITE_Y:
    MOV A, #59H
    CALL OUTCHR
    
    CHECK_Z: JB P3.3, CHECK_SPACE
    WRITE_Z:
    MOV A, #05AH
    CALL OUTCHR
    
    CHECK_SPACE: JB P3.4, CHECK_AGAIN
    WRITE_SPACE:
    MOV A, #' '
    CALL OUTCHR
    
    CHECK_AGAIN: LCALL WRITE_TO_TERMINAL
    
    
    OUTCHR:	JNB TI, OUTCHR
    CLR TI
    CALL VONESA
    MOV SBUF, A
    
    CALL WRITE_TO_TERMINAL
    
    VONESA:	MOV R6, #0FFH
    MOV R7, #05FH
    PERS:		MOV R5, #0FFH
    	DJNZ R5, $
    	DJNZ R7, $
    	DJNZ R6, PERS
    
    	RET
    
    
    STOP:
    END
    

     

    and this is how I've tried to bring the two together (unsuccessfully):

    ESC EQU 1BH
    
    ORG 0000H
    
    LJMP MAIN
    
    ORG 0023H
    LJMP ISR
    
    ORG 0030H
    
    
    MAIN:
    BUSY BIT P0.7
    E BIT P2.4
    RS BIT P2.2
    RW BIT P2.3
    
    MOV A, PCON
    SETB ACC.7
    MOV PCON, A
    MOV SCON, #52h
    MOV TMOD, #20h
    MOV TH1, #-35
    SETB EA
    SETB ES
    SETB PS
    SETB TR1
    CALL LCD_INIT;
    
    PRANO: 
    JNB RI, $  ; KONTROLLO A ESHTE SHRYPUR NDOJE KARAKTER
    CLR RI
    JNB P1.0, GO_INT_I
    JNB P1.1, GO_INT_J
    JNB P1.2, GO_INT_K
    JNB P1.3, GO_INT_L
    JNB P1.4, GO_INT_M
    JNB P1.5, GO_INT_N
    JNB P1.6, GO_INT_O
    JNB P1.7, GO_INT_P
    MOV A, SBUF
    JMP CHECK_DEL
    GO_INT_I: 
    CLR P1.0
    MOV IE, #90H
    JMP PRANO
    
    GO_INT_J: 
    CLR P1.1
    MOV IE, #90H
    JMP PRANO
    
    GO_INT_K: 
    CLR P1.2
    MOV IE, #90H
    JMP PRANO
    
    GO_INT_L: 
    CLR P1.3
    MOV IE, #90H
    JMP PRANO
    
    GO_INT_M: 
    CLR P1.4
    MOV IE, #90H
    JMP PRANO
    
    GO_INT_N: 
    CLR P1.5
    MOV IE, #90H
    JMP PRANO
    
    GO_INT_O: 
    CLR P1.6
    MOV IE, #90H
    JMP PRANO
    
    GO_INT_P: 
    CLR P1.7
    MOV IE, #90H
    JMP PRANO
    
    CHECK_DEL:
    CJNE A, #7FH, CONTINUE
    LJMP CLEAR_LCD
    LJMP NEXT
    
    
    CONTINUE:
    CJNE A, #ESC, NO_ESC1
    CLR P1.7
    JNB RI, $
    CLR RI
    MOV A, SBUF
    CJNE A, #'[', NO_KLLAPA
    JNB RI, $
    CLR RI
    MOV A, SBUF
    CJNE A, #'C', CHECK_D
    LCALL MOVE_LEFT
    LJMP NEXT
    
    CHECK_D:
    CJNE A, #'D', CHECK_A
    LCALL MOVE_RIGHT
    LJMP NEXT
    
    CHECK_A:
    CJNE A, #'A', CHECK_B
    LCALL MOVE_UP
    LJMP NEXT
    
    CHECK_B:
    CJNE A, #'B', NEXT
    LCALL MOVE_DOWN
    LJMP NEXT	
    
    
    
    
    NO_ESC1:	LJMP NO_ESC
    
    MOVE_LEFT:	
    	MOV A, #14H
    	ACALL COMMAND
    	RET
    
    MOVE_RIGHT:
    	MOV A, #10H
    	ACALL COMMAND
    	RET
    
    MOVE_UP:
    	LCALL READY
    	MOV A, P0
    	ANL A,#00111111B
    	MOV R7, A
    	MOV A, #40H
    	SUBB A, R6
    	MOV R6, A
    	MOV A, R7
    	SETB ACC.7
    	ACALL COMMAND
    	RET
    
    MOVE_DOWN:
    	LCALL READY
    	MOV A, P0
    	ANL A, #00111111B
    	MOV R6, A
    	MOV A, #40H
    	ADD A, R6
    	MOV R7, A
    	MOV A, R7
    	SETB ACC.7
    	ACALL COMMAND
    	RET	
    
    CLEAR_LCD:
    	MOV A, #01H
    	CALL COMMAND		
    
    
    
    
    NO_KLLAPA:
    LJMP NEXT
    
    ;******************************************************************
    LCD_INIT:			 				 ;*
    MOV A, #38H	; 2 Linja 5x7	 			 ;*
    ACALL COMMAND		 				 ;*
    MOV A, #0DH	;Aktivizimi i Kursorit (Blinkues)	 ;*
    ACALL COMMAND		 				 ;*
    MOV A, #01H	;Fshirja e ekranit	 	       	 ;*
    ACALL COMMAND		 				 ;*
    MOV A, #06H	;Vendosja e Kursorit Ne Te Djathe	 ;*
    ACALL COMMAND						 ;*
    RET			 				 ;*
    							 ;*		   \
    			 				 ;*=================\
    COMMAND: 			 				 ;*==================\
    ACALL READY		 				 ;*==================/   Pergaditja e LCD-se        
    MOV P0, A		 				 ;*=================/
    CLR RS							 ;*		   /
    CLR RW			 				 ;*
    SETB E			 				 ;*
    CLR E			 				 ;*
    RET			 				 ;*
    			 				 ;*
    			 				 ;*
    			 				 ;*
    READY:				 				 ;*
    SETB BUSY		 				 ;*
    MOV P0, #0FFH		 				 ;*
    CLR RS			 				 ;*
    SETB RW			 				 ;*
    BACK:				 				 ;*
    CLR E			 				 ;*
    SETB E			 				 ;*
    JB BUSY, BACK		 				 ;*
    RET			 				 ;*
    			 				 ;*
    ;******************************************************************	
    
    NO_ESC:
    LCALL LCD_DISPLAY
    CPL A
    MOV P1,A
    NEXT:
    MOV P1, #0FFH
    LJMP PRANO
    
    
    LCD_DISPLAY:
    ACALL READY
    CLR E
    MOV P0, A
    SETB RS
    CLR RW
    SETB E
    CLR E
    RET
    
    
    ISR:
    WRITE_TO_TERMINAL:
    
    
    CHECK_I:JB P1.0, CHECK_J
    WRITE_I:
    MOV A, #49H
    CALL OUTCHR
    
    CHECK_J: JB P1.1, CHECK_K
    WRITE_J:
    MOV A, #04AH
    CALL OUTCHR
    
    CHECK_K: JB P1.2, CHECK_L
    WRITE_K:
    MOV A, #04BH
    CALL OUTCHR
    
    CHECK_L: JB P1.3, CHECK_M
    WRITE_L:
    MOV A, #04CH
    CALL OUTCHR
    
    CHECK_M: JB P1.4, CHECK_N
    WRITE_M:
    MOV A, #04DH
    CALL OUTCHR
    
    CHECK_N: JB P1.5, CHECK_O
    WRITE_N:
    MOV A, #04EH
    CALL OUTCHR
    
    CHECK_O: JB P1.6, CHECK_P
    WRITE_O:
    MOV A, #04FH
    CALL OUTCHR
    
    CHECK_P: JB P1.7, CHECK_AGAIN
    WRITE_P:
    MOV A, #50H
    CALL CHECK_AGAIN
    
    
    
    CHECK_AGAIN: RETI
    
    
    OUTCHR:	JNB TI, OUTCHR
    CLR TI
    CALL VONESA
    MOV SBUF, A
    CLR EA
    RETI
    
    VONESA:	MOV R6, #0FFH
    MOV R7, #05FH
    PERS:		MOV R5, #0FFH
    	DJNZ R5, $
    	DJNZ R7, $
    	DJNZ R6, PERS
    
    	RET
    
    END
    

     

    I know it's exceedingly boring to go through it all (neither I expext you to) but I'd really appreciate every idea on how to bring the two together.

     

    Regards,

    TDS

  5. 30 days?

    Could you explain how you got your answer (I don't know if its correct)?

     

    Here's how I got my 41.5 days :P

    The cow can finish it alone in 90 days. Since it take the goat twice as more time to finish when it is with the duck, compared to the cow, then (I assume) it would take the duck 180 days to finish to finish the entire thing alone. And similarly I got 135 days for the goat (though I'm not so sure on this one).

     

    And if you try to get the number of days that would take for the three of them together, then I tried

     

    x/90 + x/180 + x/135 = 1

    than I got that x=41.5....

     

    But there's another way to look this.

    If the cow finishes alone in 90 days, then if would finish half in 45 days. And since it takes the duck and the goat 90 days to finish it together, the three of them would finish it in 45 days:(

     

    But the problem (I think) is that none of these takes into consideration the new grass growing:-(

  6. Hey people, how are you doing?

     

    I heard this couple days ago and tried to figure it out myself but I seem not to be able to:(

     

    It goes like this:

    |=|A cow and a goat eat all the grass of a pasture in 45 days. The (same) cow and a duck eat the grass in 60 days, and the duck and the goat east the grass in 90 days. The cow eats the same amount of grass as the duck and the goat together. But you have to take into consideration that new grass grows continuously.|=|

     

    At first I got 45 days, then I got 41.5... days but I think neither of them is the answer.

     

    Any suggestion?

  7. for what i remember a star will go to a red giant dependant on it mass(.5-10 solar masses) but i suggest maybe looking the Hertzsprung - Russell diagram to help in the evolution of stars it may be helpful
    I've had the same idea too, but so far I haven't come across any H-R diagram that would show the relation mass-radius.


    Merged post follows:

    Consecutive posts merged
    i read a while back about red giants expansions based on mass, luminosity and graviation... Called " On winds of giants to binary systems by A.Frankowski..... it will should anwser your questions
    Thank you for this. I just downloaded it, and I'm going to read it right now.
  8. Hey guys,

     

    I was discussing with a friend about the evolution of stars, our sun especially. It's now absolutely well known that the radius of a star when it turns into a red giant is increased a lot, but he asked me whether there is a formula or any other way using which you can calculate this radius increase yourself. Of course there must be some way, and I couldn't answer him.

     

    So is there a formula, or other way so you can calculate yourself what the radius of our sun (for example) will increase when it turns into a Red Giant?

     

    Regards,

    shade

  9. That does neither give the proton mass (that he said he was looking for but which simply is ~1000 MeV/c²), nor something in units of voltage (what his result was), nor the kinetic energy of a proton at 99% of c (what the thread was about). What it gives is the relativistic mass of an object.
    Sorry! My Wrong! I wasn't thinking:-(
  10. Is there such a thing? How could it be figured?

    Maybe its kinda stupid but this is how I think about it.

    Force is the product of mass and acceleration ([math]F=ma[/math]), so in order for there is be a quantized unit of force, there would have to be a quanta of mass and quanta of acceleration (neither of which I am aware of), so you'd have 'smallest mass' doing 'smallest acceleration' which would mean you had 'smallest force' acting on that mass. But this implies something else, like would that quanta of force overcome the friction force of the medium where the experiment is taking place? So it's kinda stupid!

  11. Just to add another thing and create a parallel.

    In classical physics an electron (for example) is thought to create an electric field around itself, and Feynman's electrodynamic theory describes the electron as being sorrounded by things he called 'vitual photons' (because they behaved like photons) that behaved like EM waves. So when you have two electrons, one electrons absorbs this wave created by the other electrons, and this wave sort of transmits some momentum which will eventually results with a push. So in this case, the carriers of the electris field are these virtual photons. For strong nuclear force you have gluons, and similalry (why would it be different?) for gravity physicists think there are these gravitons.

     

    Hope I haven't been confusing:-)

  12. When he was talking about empty space energy, I thought of an interesting opinion I heard (IIRC it was Richard Muller). He said that maybe vacuum repells itself somehow, and as this repulsion takes place, mroe vacuum is 'created' hence the repulsion increases and it goes on.

     

    btw: accepting for a moment that cosmological constant changes, why is it then called a constant?

     

    thanks for sharing

  13. How can we speak of artificial intelligence, when modern psychologists cannot even agree on a definition of human intelligence? First, provide an operational definition of human intelligence; then, one can begin to speak of artificial intelligence.
    But we know more or less what we mean by intelligence. It's just like that 'planet' case. There is no clear definition of what a planet is (AFAIK), but but the are plenty of them that we have detected in our galaxy.
  14. My first thought is that it would heat the disk through which it passes, but I'm really not certain.
    I think so too. Occasional collisions of pthtons with the material would result in transfering the energy to that material (heating hit), which energy of course would count in total energy.
  15. If you did jump out of a spaceship in the vacuum of space with no hope of rescue.

     

    Consider how lucky you have been that life has been so good to you up until this point. If life hasn't been that good to you, which, considering your current situation seems more likely, consider how fortunate you are that it won't be bothering you for much longer.

    But this doesn't answer his question and it's kidna off-topic.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.