Hi folks, long time no see!
Maybe someone is in the mood to help.
Thanks in Advance.
try to make an engine water pump driver and Iīm frustrated about my inability to get the HPWM working.
the °C reading works and the speed change works too but I canīt
get the RB0 to make it right....I know its in the config thingy..
Heres my code:
'************************************************* ***************
'* Name : Thermometer-LCD1 + HPWM (only for range 70-90°C) *
'* Test with 20-23 °C RB0 = HPWM out *
'* Author : M.David *
'* Notice : Copyright (c) 2011 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 31.03.2011 *
'* Version : 1.0 for NTC Probe AB 94 098 000.D1 M12 x 1.5 *
'* Notes : 16F88 LCD 1X16 connected as usual *
'* : Portb.7 analog IN 0-2V *
'************************************************* ***************
Include "modedefs.bas"
Define OSC 4
Define ADC_BITS 10 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 100 ' Set sampling time in uSec
define CCP1_REG PORTB
DEFINE CCP1_bit 0
CMCON = 7 ' Disable analog comparator
ANSEL = %01000000 ' set AN6 (RB7) as analog, others to digital
ADCON1.7 = 1 ' Right justified results... duh... really needed in 8 bits???
Uhilf var word
Uin VAR Word
Fac var Word
Multi Var Word
Uresult var Word
Temp Var word
speed var word
Speed = 0
pause 100
LCDOUT $FE,1
PAUSE 1
LCDOUT $FE,1,"Pumpensteuerung"
pause 2000
LCDOUT $FE,$C0,"Wassertemperatur"
pause 3000
main:
HPWM 1,speed,1000
ADCIN 6, Uin ' Read channel 6 (RB7)
pause 10
Uhilf = Uin * 7
Uresult = Uhilf / 48
Temp = Uresult / 100
pause 10
if Uresult = 21 then
speed = 0
endif
if Uresult = 22 then
speed = 127
endif
if Uresult = 23 then
speed = 255
endif
LCDOUT $FE,1,"Temp=",DEC2 Uresult
pause 2000
LCDOUT $FE,1,"Speed",DEC3 speed
pause 2000
goto main
END ' End of program
Bookmarks