# micro timer help plz ASAP :( im having it after 2 few days :(

Status
Not open for further replies.

#### goldfish300

##### New Member
well first of all im working on a pic 16f84a

we need to connect the circuit to an oscilloscope and to fit these conditions :

if signal on portA,0 < 10 hz ------> motor stop

else
if 10 hz < signal < 100 hz -----> motor left
else
if signal > 100 ------>motor right

plz if anyone knows how to write such a program help

i wrote something about interupt at RB0
in which its as follow:
at startup led PORTA, 0 is on for one second then im having two leds instead of motor which turn on after the delay of the first leds and just keep blinking like left >right and right > left until i press on the button and it just turn the right led for one second and then stop for one sec then cont to the left >right and right > left until i press on the button. im askin how to fix that for the timer0 with the conditions i need above

i don't know how to link this with an oscilloscope and writing the timer function.

well i the code is as follows
Code:
#INCLUDE <P16F84.INC>
#DEFINE		LED				PORTA, 0
#DEFINE		RELAY1			PORTB, 1
#DEFINE		RELAY2			PORTB, 2
#DEFINE		PB				PORTB, 0

__CONFIG _WDT_OFF  &  _PWRTE_OFF  &  _CP_OFF  &  _XT_OSC

CBLOCK  0X0C
W_TEMP, STATUS_TEMP, A1, A2, A3, B1, B2, B3

ENDC

ORG     0X000
GOTO    MAIN
ORG     0X004
MOVWF   W_TEMP
SWAPF   STATUS,W
MOVWF   STATUS_TEMP

BTFSC   INTCON,INTE
BTFSS   INTCON,INTF
GOTO    $+4 CALL INTRB0 BCF INTCON,INTF GOTO RESTOREREG RESTOREREG SWAPF STATUS_TEMP,W MOVWF STATUS SWAPF W_TEMP,F SWAPF W_TEMP,W RETFIE INTRB0 CALL MOTOR_RIGHT CALL DELAY_1S_B CALL MOTOR_STOP CALL DELAY_1S_B RETURN MAIN CALL SETUP BSF LED CALL DELAY_1S_A BCF LED CALL MOTOR_RIGHT CALL DELAY_1S_A CALL MOTOR_LEFT CALL DELAY_1S_A GOTO$-4

MOTOR_RIGHT
BCF		RELAY1
BSF		RELAY2
RETURN

MOTOR_LEFT
BSF		RELAY1
BCF		RELAY2
RETURN

MOTOR_STOP
BSF		RELAY1
BSF		RELAY2
RETURN

DELAY_1S_A
MOVLW    D'46'
MOVWF    A3
MOVLW    D'189'
MOVWF    A2
MOVLW    D'37'
MOVWF    A1
DECFSZ   A1, F
GOTO     $-1 DECFSZ A2, F GOTO$-5
DECFSZ   A3, F
GOTO     $-9 RETURN DELAY_1S_B MOVLW D'46' MOVWF B3 MOVLW D'189' MOVWF B2 MOVLW D'37' MOVWF B1 DECFSZ B1, F GOTO$-1
DECFSZ   B2, F
GOTO     $-5 DECFSZ B3, F GOTO$-9
RETURN

SETUP
CLRF    PORTA
CLRF    PORTB
BSF     STATUS, RP0
MOVLW   B'00000000'
MOVWF   TRISA
MOVLW   B'00000001'
MOVWF   TRISB
MOVLW   B'11000000'
MOVWF   OPTION_REG
MOVLW   B'10010000'
MOVWF   INTCON
BCF     STATUS, RP0
RETURN

END

Last edited:

#### blueroomelectronics

##### Well-Known Member
At least you used code tags, you should comment your code else it's hard to follow.

What happens in two days?

#### goldfish300

##### New Member
u mean comment for the code i wrote whats about ???

#### goldfish300

##### New Member
At least you used code tags, you should comment your code else it's hard to follow.

What happens in two days?
do u need me to put the text file or all the files i have ??

##### Banned
goldfish, all you posted was the ASM code, you didn't post any comments on what it does. It's not apparent and abhorrent to try to read someone elses ASM code without commentary.

#### blueroomelectronics

##### Well-Known Member
Assembly code should be liberally commented (as should any code) it's a good habbit and makes it possible for anyone reading your code to see what it's supposed to do.

#### goldfish300

##### New Member
here is a Schematic Design to use with the asm code

#### Attachments

• 21.3 KB Views: 53
Last edited:

#### blueroomelectronics

##### Well-Known Member
Is the code commented?

#### goldfish300

##### New Member
im using a program called ASM code generator v1.2 i just put what i have on input and out and it just generate the code for me

Last edited:

#### blueroomelectronics

##### Well-Known Member
Where is the source code? Never heard of asm generator.

#### goldfish300

##### New Member
Where is the source code? Never heard of asm generator.
yes there is it was created by my DR
just if we can over msn ?
to talk better

#### blueroomelectronics

##### Well-Known Member
I don't chat on MSN. And I'm running Ubuntu at the moment. What does ASM generator do?

#### goldfish300

##### New Member
i don't chat on msn. And i'm running ubuntu at the moment. What does asm generator do?
this program is a code source generator for the pic 16f84 of microchip.
Based on its user interfsce, user can configure porta, portb, intcon and option_reg registers

#### goldfish300

##### New Member
plzzz anyone help me with that

#### amitak

##### New Member
can u post the schematic in JPG form .. i cant open the file u uploaded
i donot know if u still have time for the project, so i shall simply write my way of implementing it
the input should be given to interrupt, and the interrupt routine should should count the time between the two consecutive interrupts using timer
think of doing this to measure frequency
the rest of the program should be easy - a compare routine to ccompare the frequency and take the required action
hope this explanation makes it clear .. u can ask further doubts
i shall prefer that u understand the program flow and write the program yourself
it is easier to debug your own program than that written by somebody else

#### goldfish300

##### New Member
still not working im having it for tom.

Who's Tom?

#### goldfish300

##### New Member
Status
Not open for further replies.