************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
I try to put another 'tips' in the code of this button.
At start ( plus by auto's contact) the PIC read from eeprom the value of overrload (variable "calibra"). If this is zero or less than minimum value (setting by me at 270 mV) start subroutine "calibration:". The value of maximum tension reading here are memorized as new value for "calibra".
One new start : the value of calibra is NOT zero or less than minimum value, so the module works as usual.
It's correct the code ? I think it's something wrong with reading/writing "calibra" from eeprom ?!? How write correct value of "calibra" in eeprom ?
I made some experiments ; the window roll-up (or roll-down) in about 6 seconds. I'm thinking to something like this :
...............
eeprom 0, [0, 0]
..............
read 0, calibra.byte0
read 1, calibra.byte1
if calibra =0 then
high rel1
....read U for maximum 7-8 seconds
....identify the highest value of U
....write this value in eeprom for further using as max.value in check:
low rel1
endif
..............
main:
....etc,etc.
Help, please, with the red lines; starting with what ? I use "search" but perhaps not so good ; I can't find one "clue" ! Thanks for supporting me !
I read about MAX. It's this correct :
'------------------------
read 0, calibra.byte0
read 1, calibra.byte1
if calibra =0 then
high rel1
gosub calibration
endif
'------------------------
calibration:
for cnt=0 to 80
adcin 3, v_cal
v_cal=v_cal * 5000
v_cal=div32 1023
vmax=vmax max v_cal
pause 100
next cnt ' reading v_cal for about 8 seconds ?
endfor
low rel1
calibra=vmax
calibra.highbyte = ADRESH
calibra.lowbyte = ADRESL
write 0, calibra.byte0
write 1, calibra.byte1
Return
'---------------------------
Thanks for any advice !
L.E.: The problem is : writing vmax ( example: 275) to eeprom, and then reading.
Last edited by fratello; - 10th August 2009 at 20:59.
This is my working code :
calibration:
rel1=1 ' rel1 = 1 -->> window roll-up !
for cnt=1 to 80 ' assuming window roll-up complete in 8 seconds !
adcin 3, v_cal
v_cal=v_cal * 5000
v_cal=div32 1023
vmax=0 max v_cal
pause 100
next cnt
low rel1
calibra = vmax
if calibra > 20 then ' "20" is value knowing by user !
write 0, calibra.byte1
pause 10
write 1, calibra.byte0
pause 10
else
calibra = 19
write 0, calibra.byte1
pause 10
write 1, calibra.byte0
pause 10
endif
RETURN
The value for long press button it's a little to big. I want to reduce him. So,
Please, help :
Timer1 = 3037 ' 1 second
Timer1 = ? ' for 0.5 sec
' for 0.6 sec
' for 0.7 sec
' for 0,8 sec
Thanks !
3037 with a prescaler of 1:8, sets Timer1 to 500mS periods.
2 of those periods are counted to reach 1 second.
To calculate the number for any other time period, download mister-e's calculator ...
PicMultiCalc v1.3.1
http://www.picbasic.co.uk/forum/atta...achmentid=2957
In the "Timer Helper" app, set the time to 300ms and it shows the reload value as 28037. Two 300ms periods would give you a total time of 600ms.
Set it to 500mS and you'll see where I got the original number.
Any other period can be calculated easily.
<br>
DT
Bookmarks