Remember, it does timeslicing, not true parallel tasking.
Default speed are still 4MHz, but if you run 2 tasks, it defaults to 8MHz, so each task get 4MHz, etc...
Nevertheless, you should manage to speed up the code with it. Like i do; i let the code sense voltage and adjust the pwm duty in one task, and reads the temp (which takes 750mS) each 10 sec. and output log data each 5 sec. in another task.
Except the readtemp command, the pauses in the second task does not affect the first, so the pwmduty adjusting response are pretty fast; maybe 500mS from 10% to 100% duty. (I've never timed it...)
In your case, both rpm and wind speed uses count, and count have to count for a certain time to get a count...
But i think you could put them in separate parallel tasks and that way, speed things up. Maybe also clock the 08M2 up to 32MHz too?
And yes, i wrote a simple logging program in Clarion (?!); here's a snapshot of the graph output for one day:
(For some reason, the numbers for the y-axis does not display for Duty, but it's scaled 0%-100%)
This is from a sunny day with only occasional clouds, which are reflected in the dips in the duty cycle. The voltage are a bit variable, because i have 25A of solar in, and only 22A worth of dumpload right now...
Right now, I'm struggling a bit with a Mosfet driver which won't behave...
the picaxe struggles to drive the irfz48 fets directly, so they get very hot with these loads, due to insufficient gate voltage.
Edit:
A new 'current' code; with multitasking...
Start0:
'setfreq m16
SYMBOL Volt = w0
SYMBOL Mode = b10
Symbol Temp = w1
Symbol TempLow = b11
Symbol TempComp = b12
Symbol PrevTemp = b13
Symbol Counter = b14
Symbol CompTempBoost = w2
Symbol CompTempMaint = w3
Symbol Duty = w4
Duty = 0 'Set initial Maintenance duty cycle to 10%.
Mode = 0 'Set initial Mode to off/Battery Ok.
setint %00001000,%00001000 'Arm interrupt for pin3.
ReadTemp 4, TempLow
PrevTemp = 120 'Set PrevTemp to very high to force a tempcomp
'pin1 = Volt
'pin2 = Output (MosFet)
'pin3 = Manual Boost on/Dumpload off (if within dumpload voltages)
'pin4 = Temperature
Main:
ReadADC10 1,Volt
If TempLow <> PrevTemp Then 'A weakness here; if Templow are 0C at startup,
GoSub SetTempComp 'variables will not be set...
EndIf
If Volt > CompTempBoost AND Mode = 0 Then
GoSub MaintDump
EndIf
If Volt <= CompTempMaint AND Mode = 1 Then
GoSub MaintDump
EndIf
If Volt <= 546 AND Mode > 0 Then ' 12,80V
GoSub DumpOff
EndIf
If Volt > CompTempMaint AND Mode = 2 AND Duty < 1015 Then
Gosub PwmUp
EndIf
If Volt < CompTempMaint AND Mode = 2 AND Duty > 105 Then
GoSub PwmDown
EndIf
Goto main
SetTempComp: 'Find TempComp Voltage
'SerTxd("Setting Temperature Compensation voltage.")
If TempLow >= 25 And TempLow <= 29 Then '0,0V comp @ 25-29c
TempComp = 0 '14,4V, 13,2V
EndIf
If TempLow >= 20 And TempLow <= 24 Then '0,15V comp @ 19-24c
TempComp = 6 '14,55V, 13,35V
EndIf
If TempLow >= 15 And TempLow <= 19 Then '0,30V comp @ 15-19c
TempComp = 12 '14,7V, 13,5V
EndIf
If TempLow >= 10 And TempLow <= 14 Then '0,45V comp @ 10-14c
TempComp = 19 '14,85V, 13,65V
EndIf
If TempLow >= 5 And TempLow <= 9 Then '0,60V comp @ 5-9c
TempComp = 25 '15,0V, 13,8V
EndIf
If TempLow >= 0 And TempLow <= 4 Then '0,75V comp @ 0-4c
TempComp = 31 '15,15V, 13,95V
EndIf
If TempLow >= 129 And TempLow <= 134 Then '0,90V comp @ -5--1c
TempComp = 38 '15,3V, 14,1V
EndIf
If TempLow >= 135 And TempLow <= 140 Then '1,05V comp @ -10--5c
TempComp = 44 '15,45V, 14,25V
EndIf
PrevTemp = TempLow
CompTempBoost = 615 + TempComp '14,4V baseline.
CompTempMaint = 562 + TempComp '13,2V baseline.
Return
Interrupt:
If Pin3 = 1 then
Goto Interrupt
EndIf
If Mode <= 1 Then
pwmout 2, 255, 1015
Mode=1
' SerTxd("Boosting ")
Pause 1000
EndIf
If Mode = 2 Then
pwmout 2, Off
Mode=0
Duty = 0
' SerTxd("Off ")
Pause 1000
EndIf
'SerTxd(#Mode)
setint %00001000,%00001000 'Arm interrupt for pin3.
Return
PwmUp:
Duty = Duty + 1 Max 1015
PwmDuty 2, duty
'SerTxd("Up! ")
'Pause 20
Return
PwmDown:
Duty = Duty - 1 Min 101
PwmDuty 2, duty
'SerTxd("Down! ")
'Pause 20
Return
BoostDump:
pwmout 2, 255, 1015
Mode=1
'Pause 1000
Return
MaintDump:
pwmout 2, 255, 101
Mode=2
Return
'Goto Main
DumpOff:
pwmout 2, Off
Mode=0
Duty = 0
'Pause 1000
Return
Start1:
For Counter = 0 to 10
If Counter = 5 OR Counter = 10 Then
SerTXD("V:", #volt, " D:", #duty, " M:", #Mode, " TL:", #TempLow, 13, 10)
EndIf
If Counter = 10 Then
'ReadTemp12 4,Temp
ReadTemp 4, TempLow
let Counter = 0
EndIf
Pause 1000
Next
The code needs a bit cleaning up, but it works ok as is...