Hi there.
I am currently in the progress of of making myself a stand with a fan for my laptop.
I am using a PIC16F88, Thernistor 4k7 and a 5V Fan, with a home made plastic base.
I am using a Pickit 3.
My board is finished and the layout is as follows:
* Terminator --> RA2 / AN2 Port
* Fan ----> RB0 / CCP1 Port
MPLAB programming and I am struggling heavily.
Here is my code so far, I cannot go any further as I don't know the rest:
Can someone please help me to finish my code
I would love to see my fan in action
Thanks so much!
Refugees
I am currently in the progress of of making myself a stand with a fan for my laptop.
I am using a PIC16F88, Thernistor 4k7 and a 5V Fan, with a home made plastic base.
I am using a Pickit 3.
My board is finished and the layout is as follows:
* Terminator --> RA2 / AN2 Port
* Fan ----> RB0 / CCP1 Port
MPLAB programming and I am struggling heavily.
Here is my code so far, I cannot go any further as I don't know the rest:
Rich (BB code):
;List all PIC16F88 Files that are needed to run the program
List p=PIC16F88
#INCLUDE <P16F88.INC>
__CONFIG _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_ON & _PWRTE_OFF & _WDT_OFF & _INTRC_IO
__CONFIG _CONFIG2, _IESO_OFF & _FCMEN_OFF
ORG 0x0000 ;Force program to start at address 0
goto start ;Go to the start loop
;-----------------------------------------------------------------------------
;Interrupt - Motor Speed Control
ISR: ;Interrupt
bcf PIR1,ADIF ;Clear AD interrupt flag
bsf STATUS,RP0 ;Go to bank 1
movlw b'00000000' ;Making all TRISB pins outputs
movwf TRISB ;Get to TRISB
moVLW ADRESH ;ADC result byte
movwf PR2 ;Period register
bcf STATUS,RP0 ;Go to back 0
movlw b'00001100' ;Set control register pins
movwf CCP1CON ;PWM control register
bsf T2CON, TMR2ON ;Swtches on timer
movlw .100 ;Set the speed of the motor
movwf CCPR1L ;PWM low byte
retfie
;-----------------------------------------------------------------------------
;Start of the inital program
start: ;Begin the start loop
bsf INTCON,PEIE ;Set interrupt enable
bsf PIE1,ADIE ;Set AD interrupt enable
nop ;No operation
bsf STATUS,RP0 ;Go to bank 1
movlw b'00000001' ;Set TRISA pins
movwf TRISA ;Set pins in TRISA
movlw b'10111111' ;Set TRISB pins
movwf TRISB ;Set pins in TRISB
bsf INTCON,GIE ;Global interrupt enable
;-----------------------------------------------------------------------------
;Analog to Digital Converter
clrf ANSEL ;Clear analog select
movlw b'00000100' ;Set pin to analog
movlw ANSEL ;Analog pin select register
movlw b'10000000' ;Reference voltage to external pins
movwf ADCON1 ;ADC control register
movlw b'10000101' ;Reference voltage to external pins
movwf ADCON0 ;ADC control register
;-----------------------------------------------------------------------------
;Motor Speed Control
; btfss ADCON0,GO_DONE ;This bit will change to zero when the conversion is complete
; goto $-1 ;So loop till it does.
;-----------------------------------------------------------------------------
;End of Program
goto $ ;Endless loop
end ;End the program
I would love to see my fan in action
Thanks so much!
Refugees