Anotherpower.com Forum

Renewable Energy Questions/Discussion => Automation, Controls, Inverters, MPPT, etc => Topic started by: niall on September 26, 2012, 07:02:37 pm

Title: picaxe ?
Post by: niall on September 26, 2012, 07:02:37 pm
this is very frustrating ...but ....sometimes its not too bad ...ish

i,m thinking of using a pic to control a mill into a dump water element .....no batteries just the mill , circuit and load ....

(http://i383.photobucket.com/albums/oo279/itch1niall/Picture24361262-1.jpg)

pretend big fets and cap bank actually exist in circuit ..:)

the pic seems to give the option to set  a variable power pwm point at a given voltage window .....say 48v to 56v  in increments ...a gentle curve in a way...not really sure about that bit though 

but the code i,m using is eating up the memory of the little chip very fast ....which is a pity as it could maybe do other tasks as well ......like monitoring the temp of the fets , kick in a fan maybe


crude code ..memory is almost gone...options running out now
Start:
   
   
    SYMBOL Volt = W0
   
   

    Main:
    readadc10 4,Volt 
   
    if volt>500 and volt<=510 then load0
    if volt>510 and volt<=520 then load
    if volt>520 and volt<=530 then load1
    if volt>530 and volt<=540 then load2
    if volt>540 and volt<=550 then load3
    if volt>550 and volt<=560 then load4
    if volt>560 and volt<=570 then load5 
    if volt>570 and volt<=580 then load6
    if volt>580 and volt<=590 then load7
    if volt>590  then load8
    if volt<500  then load9
   
    goto Main
     
     
    load0:
    pwmout pwmdiv16, 2, 249, 100
    goto main
       
   
    load:
    pwmout pwmdiv16, 2, 249, 200
    goto main
       
    load1:
    pwmout pwmdiv16, 2, 249, 300
    goto main
   
    load2:
    pwmout pwmdiv16, 2, 249, 400
    goto Main
     
   
    load3:
    pwmout pwmdiv16, 2, 249, 500
    goto Main
   
   
    load4:
    pwmout pwmdiv16, 2, 249, 600
    goto Main
   
    load5:
    pwmout pwmdiv16, 2, 249, 700
    goto main
   
    load6:
    pwmout pwmdiv16, 2, 249, 800
    goto main
   
    load7:
    pwmout pwmdiv16, 2, 249, 900
    goto Main
   
   
    load8:
    pwmout pwmdiv16, 2, 249, 1000
    goto main
   
    load9:
    pwmout pwmdiv16, 2, 249, 000
   
   
   
    goto main 
Title: Re: picaxe ?
Post by: Wolvenar on September 26, 2012, 07:48:18 pm
What do you plan to do with the power when water temps reach the high limits?
Title: Re: picaxe ?
Post by: rossw on September 26, 2012, 08:24:14 pm

crude code ..memory is almost gone...options running out now

Your code makes my teeth itch!!  STOP IT!

    Main:
    readadc10 4,Volt 

So basically you're detecting "windows" between 500 and 600, and two special conditions <500 and >600, and just setting a PWM value??

I'd replace all your code with this:

Start:
       SYMBOL Volt = W0
Main:
    readadc10 4,Volt 
     if volt<500 then volt=500
     if volt>600 then volt=600
    pwm=volt-500
    pwm=pwm*10
    pwmout pwmdiv16, 2, 249, pwm
    goto main
Title: Re: picaxe ?
Post by: Cornelius on September 27, 2012, 02:28:55 am
You doesn't specify which picaxe you're using, but if the code you specified eats most of the memory, i'll assume the 08M @ max. 8MHz, and with only 256 bytes of memory available.

I'm not sure that the 08M are fast enough to compensate for very fast rise in the voltage from the mill, thus risking burning out your heating elements and/or a runaway mill... ???
 
You should consider getting some of the new (pin and code compatible) 08M2; the can run @ 32MHz max, 2k memory, more variable space, and some additional useful commands, like PWMDUTY... :)

If using a 08M2 are not an option for you, i'd go with Rossw' code. :)

If you had the 08M2, i'd use something like this:

Code: [Select]
Main:
ReadADC10, 4, Volt

If Volt > 550 AND Duty < 1000 Then
   Gosub PwmUp
EndIf
If Volt < 550 AND Duty > 20 Then
   GoSub PwmDown
EndIf   
Goto Main

PwmUp:
Duty = Duty + 10 Max 1000
PwmDuty 2, duty
Return

PwmDown:
Duty = Duty - 10 Min 20
PwmDuty 2, duty
Return

(Code to start and stop the pwm etc. omitted... ;) )
This code would try to keep the voltage at 550 by changing the duty cycle 'on the fly' with PwmDuty, which is much faster than issuing a new PwmOut command each time.
 
Each time you issue a new PwmOut command, the pwm stops and then starts again with the new values; PwmDuty doesn't stop the pwm. (But you need the M2.)
Title: Re: picaxe ?
Post by: niall on September 28, 2012, 03:55:40 pm
sorry Ross...i,ll stop scraping my fingernails down the blackboard now ..... :)

Wolv the mill is on a very mediocre site on a low mast ,  its hard to squeeze consistent power out of it .... but good for playing with 

it is an 08m chip Cornelius....took me a while to figure exactly which type it was .....the 08m2,s  seem to be the the same price so i will get one or two those definitely....and thanks for putting up the code ... :)

Ross ...i think i understand the voltage window option you lined out , but am still getting mixed up with the terminology ...need to read up

this seems to work ok ,

Start:
       SYMBOL Volt = W0
       symbol niall= w1

Main:
    readadc10 4,Volt
     if volt<700 then let volt=700
     end if
     if volt>750 then let volt=750
     end if
     
    niall=volt-700
   
   
    niall=niall*20
   
    pwmout pwmdiv16, 2, 249, niall
    goto main

Title: Re: picaxe ?
Post by: rossw on September 28, 2012, 04:59:26 pm
Ross ...i think i understand the voltage window option you lined out , but am still getting mixed up with the terminology ...need to read up

Niall, the basic principle is this: define your maximum and minimum inputs.
This gives you your "control range". Eg, if the point at which you want NO added load is lets say, 600 counts on the A/D input, and the point at which you want 100% load is 700 counts, then you want a "smooth transition" between 0% and 100% over the range of 600 to 700.
Anything less than 600 will be zero%.
Anything more than 700 will be 100%

So what I did was a simple test: if it was less than 600, USE 600.
If it was more than 700, USE 700.
We now have a solid, well-known range in which to work.
Next is to correct the "zero offset". So subtract 600. We now have a range of (600-600)=0 to (700-600)=100.
Because that range was 100, and we have 1000 steps (actually 1023) to work with, I multiplied that answer by 10.
So now anything on the raw input up and including 600 will produce 0,
and anything from 700 upwards will produce 1000.
And anything in between the two will produce an intermediate number. eg, 650 becomes (650-600)*10 = 500.
Don't look for the hard way to do things.... :)
Title: Re: picaxe ?
Post by: niall on September 30, 2012, 08:08:14 pm
:)

i did find one easy option ..ish...heatsink material ...i think ...up to a guarded point

in the local dump sometimes you can come across this stuff ...long lengths of extruded aluminum   construction tubing , often used for making safety perspex cages around production machinery ...big lego in a way , usually mangled by the time it get,s dumped ....sold by weight in the scrap yard so its pretty cheap ...

one very tentative test fet applied ...

 
Title: Re: picaxe ?
Post by: ghurd on September 30, 2012, 11:51:26 pm
"one very tentative test fet applied ..."

Those fet legs look pretty close to the AL, way to close for my test procedures.
Before I fired it up for too many tests, I'd put a layer of (go figure) hot glue under the legs.  Not kidding.  It will keep the wires from contacting the heat sink or each other.  It is easy to remove from smooth AL.

G-
Title: Re: picaxe ?
Post by: niall on October 01, 2012, 07:34:19 pm
thanks Ghurd

its the stuff than can and does go wrong is the interesting bit ....some silicone might do the same job , easy to hand as i have no hot glue ...

now that it,s ready to test i,ve got distracted a bit ....i have one 80A 12 V battery slowly loosing capacity due to what i guess is sulfation....it,s close to no good at all...pure neglect

i think ( not really sure ) that the circuit as it kind of stands could be tried as a desulfator

the fet is rated for 100v , i can set a frequency in the pic ( maybe 1k to start ) and a low duty cycle ( very unsure about that bit ) , with a 40v transformer rectified into a big cap to supply power for pulsing 

the mill is in bits at the moment for maintenance which will take a while so it might be interesting to try the battery reviving thing in the meantime ..ish

this battery is near junk level now and i can isolate it somewhere where its safe to try this

dont know .....fun though
Title: Re: picaxe ?
Post by: niall on October 11, 2012, 11:19:07 pm
one very quickly blown fet ...so quickly runs away from hv de sulphator ....back to the  re built mill then....

http://i383.photobucket.com/albums/oo279/itch1niall/Picture24361268-1.jpg

code now ....waiting for some new 0m2,s to arrive  in the post .....
 

Title: Re: picaxe ?
Post by: Cornelius on October 12, 2012, 01:42:25 am
Do you have a drawing of your ciruit?

It's always interesting to see how people do pwm with mosfets... ;)
Title: Re: picaxe ?
Post by: niall on October 12, 2012, 05:44:50 pm
so far this is what it looks like Cornelius , frequency is about 800hz with 2 irfp150n mosfets in parallel

(http://i383.photobucket.com/albums/oo279/itch1niall/fetdriver.jpg)

Title: Re: picaxe ?
Post by: Cornelius on October 13, 2012, 03:48:24 am
Not unlike the way i did it... ;)
[attach=1]
 
Edit:
Not shown are a ferrite bead around the leg of the 10ohm gate resistors, close to the gate leg.
Title: Re: picaxe ?
Post by: niall on October 14, 2012, 07:17:06 pm
thanks Cornelius ... :)

its interesting looking at your diagram...

you have the serial out pin used , i should have done that ...a de bugging option ?

i physically take out the picaxe  to upload any program ( ish ...very ish ) changes using the original 3.5v  battery proto board ....

i,ve put the fet driver chip in the same proto board socket a few times by mistake .....dont think it,s to amused by that .....

its like a " why am i here ? " moment .....

i think the windmill wants to play ball , hopefully good winds this week .......






 
Title: Re: picaxe ?
Post by: Cornelius on October 15, 2012, 01:43:26 am
I got the standard 3.5mm stereo jack socket connected to the serial out; used for logging to pc (and easy programming on the fly)... :)

The picaxe part of the circuit are on a proto board, but the driver and fets are on a separate hand-etched board.
I toasted 6 drivers before i got that right... ;D

Also, i have separate wires to power the fet-board and the picaxe, due to the voltage drop when the driver are active, which would make voltage measurement with the picaxe inaccurate if powered from the same cable as the driver.
Title: Re: picaxe ?
Post by: ghurd on October 16, 2012, 08:07:38 pm
Also, i have separate wires to power the fet-board and the picaxe, due to the voltage drop when the driver are active, which would make voltage measurement with the picaxe inaccurate if powered from the same cable as the driver.

I don't know about the ICs you guys are using, but sometimes it takes separate wires AND a larger cap than expected or quoted to keep things smooth in DIY.

Some ICs use regular type transistor technology, and switching can make for big draws.  555 can take over a half amp during switching.
Long ago, I heard some styles of fet drivers can act roughly the same way, which could cause unexpected issues (like smoking fet syndrome).

G-
Title: Re: picaxe ?
Post by: niall on October 17, 2012, 07:29:59 pm
" like smoking fet syndrome "...mmm..

the ceiling is full now  ..it just wont take any more impaled  fets.... or it will fall down

the cap ( battery ?) is 10,000 uf...  seems best to sample the positive and negative directly of it , but its the ground,s  that may have the devil in the detail....that seems to be the very fuzzy frustrating bit

i think i have the pwm switching down a bit lower now in the new 0m2  pic chip ...more like 500 hz .....the mill is running on the circuit now and doesn't seem to be to bothered either way ...(yet)

i think it could dump at a hz of 200  .....if a relay can have a fair go at 3 times a sec , 200 hz sounds fairly smooth.... ish...

i,m trying to tidy things up this evening ....and maybe etch a pcb ...probably better than vero board ...less wire links 

(http://i383.photobucket.com/albums/oo279/itch1niall/cct.jpg)

Title: Re: picaxe ?
Post by: Cornelius on October 18, 2012, 01:13:56 am
Take a look at Frackers controller:

http://www.anotherpower.com/board/index.php/topic,237.0.html (http://www.anotherpower.com/board/index.php/topic,237.0.html)

I have to admit that i used his pcb layout as a template when i designed my fet-board... ::)
Title: Re: picaxe ?
Post by: niall on October 18, 2012, 06:30:50 pm
indeed , looking at the fet driver pcb is a stop and think moment...

i want to make pcb,s now ...totally convinced ....but getting distracted again i have 3 inkjet hp printers just sitting looking at me and saying that  "we dont work anymore ..sorry "  ..i,ve seen vids on utube of adapted inkjets making nice basic pcb boards ....i know laser is the way .......but
Title: Re: picaxe ?
Post by: ghurd on October 18, 2012, 07:39:26 pm
but its the ground,s  that may have the devil in the detail....that seems to be the very fuzzy frustrating bit

i think i have the pwm switching down a bit lower now in the new 0m2  pic chip ...more like 500 hz .....the mill is running on the circuit now and doesn't seem to be to bothered either way ...(yet)

i think it could dump at a hz of 200  .....if a relay can have a fair go at 3 times a sec , 200 hz sounds fairly smooth.... ish...


Devil's advocate:
Sure.  The ground is always the bad part, because the ground is ALWAYS the bad part, so make it huge and thick.
BUT what goes through the ground also goes through the Pos.
Might try laying some solid #22 (tinned before laying), soldered heavily it on the Pos traces.  In the US, I use solid heavy duty phone wire.  If the Pos traces are large, I use a 2~3 of them, twisted.

I expect the issue may be measured with a simple volt meter from a solid ground at the battery to the PCB.
OR
A solid connection at the input to the farthest Pos terminal on the PCB.
It would be like testing a faulty battery cable.  Any voltage reading is a bad sign. (you knew that.  it is for ref material)


200Hz is plenty smooth enough.  8)
Last I knew, Trace/Xantrex used 166Hz, MorningStar publishes 300Hz (all MS CCs I tested, which is a LOT of various units, read 359~360Hz).

That is for PWM controllers when the battery is at regulation voltage:
Even a cheap meter with HZ can read 360Hz... on the terminals of a 12V 110AH battery being charged by a 50W 12V PV.
If the reading is strange, try it at the controller terminals.
I know they say it can't be done because the battery is like a giant cap, but I do it all the time.
G-
Title: Re: picaxe ?
Post by: Cornelius on October 19, 2012, 12:55:35 am
Ghurd;
I route the positive 'track' outside the board in the form of an AWG#9 wire in my dumpload circuit; there's no reason to have the positive wire (to the dumpload) on the pcb, since it has no active role in the switching circuit itself... Except maybe in a snubber circuit. :)
Title: Re: picaxe ?
Post by: niall on October 23, 2012, 05:24:18 pm
hopefully ....i,ll get some king of grip with the ground plane thing if i eventually etch a pcb ...thats going to take a while ...a long while

mean time the pic is running on a cross of Ross,s suggested code and using the pwmduty command option available in the m2 ...thats as close as i can get for now Cornelius.....its all very confusing still

the pic still has free available i/p,s and outputs ...so hooking up a 12v psu fan seemed interesting for extra cooling for the fets ...

i added a thermistor  from and old pc psu ....this is a lot of fun ...the thermistor is floating in air at the minute and is picking up the heat from the desk lamp , the pic senses this heat and trips the fan in a crude pwm  (blinking led option ) ...the fan has a small time delay added so it kindof over cools the thermistor....the fan keeps cycling trying to compensate ...move the desk lamp a little further away and the cycle slows down ....too much fun .. :)     

 (http://i383.photobucket.com/albums/oo279/itch1niall/PA231111-1.jpg)

the big heatsink on the fan fet is a bit butch but it keeps it nice and cool ...a trickle of air from the fan works nicely with it ...ish...the fan looks like its running fast but its actually fairly slow ...

code for cooling ...ish ..very ish

symbol volt=w0


main:

readadc10 1,Volt
if volt> 382 then ok
if volt< 382 then cool
 
cool:
high 0
pause 80
low 0
pause 10
goto main

ok:
low 0

goto main
Title: Re: picaxe ?
Post by: Cornelius on October 25, 2012, 03:08:31 am
I also have an 80mm fan cooling the heatsink, but i took the lazy route; the fan are connected to the fet output, so it varies according to the load. ;)
 
Here's my complete current code.:
 
Code: [Select]

Start:
setfreq m4
SYMBOL Volt = w0
SYMBOL Mode = b15
Symbol Temp = w1
Symbol TempLow = b16
Symbol TempComp = b17
Symbol PrevTemp = b18
Symbol Counter = b19
Symbol CompTempBoost = w2
Symbol CompTempMaint = w3
Symbol Duty = w4
Symbol BulkDone = b20
Symbol Elapsed = w5
Symbol ManualOverride = b21
 
Duty = 0    'Set initial Maintenance duty cycle to 0%.
Mode = 0    'Set initial Mode to off/Battery Ok.
BulkDone = 0
Elapsed = 0
ManualOverride = 0
ReadTemp 4, TempLow
PrevTemp = 120   'Set PrevTemp to very high to force a tempcomp
 
'pin1 = Volt
'pin2 = Output (MosFet)
'pin3 = Manual On/Dumpload off
'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 Time = 5 Then
 SerTXD("V:", #volt, " D:", #duty, " M:", #Mode, " TL:", #TempLow, 13, 10)
 Time = 6
EndIf

If Time = 10 Then
 ReadTemp 4, TempLow
 SerTXD("V:", #volt, " D:", #duty, " M:", #Mode, " TL:", #TempLow, 13, 10)
 If BulkDone = 0 AND Mode = 1 Then
  Let Elapsed = Elapsed + Time
 EndIf
 Let Time = 0
EndIf

If Pin3 = 1 AND ManualOverride = 0 Then
 BulkDone = 1
 ManualOverride = 1
 Pause 500 'Pause here to avoid on/off in one go.
 Goto Main
ElseIf Pin3 = 1 AND ManualOverride = 1 Then
 BulkDone = 0
 ManualOverride = 0
 GoSub DumpOff
EndIf

If Mode = 1 AND BulkDone = 0 Then
 If Elapsed >= 3600 Then '1 Hour
  BulkDone = 1
  Let Elapsed = 0
 EndIf
EndIf

If Volt <= 540 AND BulkDone = 1 Then
 BulkDone = 0
 ManualOverride = 0
EndIf
 
If BulkDone = 0 Then
 If Volt >= CompTempBoost AND Mode = 0 Then
  GoSub BoostDump
 EndIf
ElseIf BulkDone = 1 AND Mode <> 2 Then
 If Volt >= CompTempMaint AND Mode = 0 Then
  GoSub MaintDump
 ElseIf Mode = 1 Then
  GoSub MaintDump
 EndIf
EndIf
 
If Volt <= 563 AND Mode > 0 AND Duty <= 202 Then ' 13,20V
 GoSub DumpOff
EndIf

If Volt > CompTempMaint AND Mode = 2 AND Duty < 1015 Then
 Gosub PwmUp
EndIf

If Volt < CompTempMaint AND Mode = 2 AND Duty > 202 Then
 GoSub PwmDown
EndIf

If Volt > CompTempBoost AND Mode = 1 AND Duty < 1015 Then
 Gosub PwmUp
EndIf

If Volt < CompTempBoost AND Mode = 1 AND Duty > 202 Then
 GoSub PwmDown
EndIf
Goto Main
 
SetTempComp: 'Find TempComp 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 = 616 + TempComp '14,4V baseline.
CompTempMaint = 581 + TempComp '13,6V baseline.
Return
 
PwmUp:
Duty = Duty + 1 Max 1015
PwmDuty 2, duty
Return
 
PwmDown:
Duty = Duty - 1 Min 202
PwmDuty 2, duty
Return
 
MaintDump:
If Mode <> 1 Then
 pwmout 2, 255, 202
 Duty = 202
EndIf
Mode = 2
Return
 
BoostDump:
pwmout 2, 255, 202
Mode = 1
Duty = 202
Let Elapsed = 0
Return
 
DumpOff:
pwmout 2, Off
Mode = 0
Duty = 0
Return

The code - as is, are not suitable for a windgen because it's not fast enough; i use it with solar.
The reason it's not fast now, are that i run it at 4MHz, and the ReadTemp command uses up to 750mS to execute (to communicate to the Dallas 18b20 temp sensor). In addition, the SerTxd command also uses some time, even when limited to every 5 sec. (ReadTemp are executed every 10sec.)
 
The function of the code are as follows:
If Voltage are below 12.7V the output are off, and a flag for bulk charge are set.
As long as the voltage are under 14.4V +/- temperature compensation, the code keeps the voltage at 14.4V for an hour before switching to maintenance mode at 13.6V.
 
If the voltage drops below 13.2V, it turns off the dumpload, and turns it on again at 13.6V.
 
It sends a log line every 5 sec., and reads the temp every 10 sec.
 
It checks pin 3 for manual override, forcing bulk charge on or forcing it into maintenance charge.
 
I'm sure the code can be optimalized, so everyone; feel free to comment... ;)
 
Edit:
The voltages are temperature compensated in 5 deg. celsius step. (0.15V/5deg. for 12V battery.)
Title: Re: picaxe ?
Post by: niall on October 25, 2012, 04:44:09 pm
i think i like the lazy route better  :)....less bits to go wrong

drools over  code .... :P

the wind picked up a bit the last two days , with peaks of about 600w from the mill.....getting a bit better for testing with then ...some interesting problems showed up at that level ...not the best of instrumentation gear available  (sound card scope , multimeter and a small led tapped on the pic output ( that bit seems very useful )... oddly ...listening to the fet frequency is useful as well

pic pwm running at about 250hz  ( i think ) ..pic clock speed 8m ...mill at 48v...dump 1k 

at low power things seemed fine , nice even  , but at higher power levels the pic pwm was going out of sync with the mill , kind of chasing the mill a little , the pic pwm led was picking up a bit of flicker...i thought this might have been a problem with pic sensing the voltage and tried a few things with the v divider but to no avail

next was to up the pic clock to 16m as you mentioned Cornelius...doubling the pwm by default , so now at 500 hz pwm ( i think )...much much better , now the pic pwm stayed in sync with the mill ,even in partial furling ...nice smoother led brightness transition ...

i had another 10,000uf cap , so i added that too.....it did effect  things as well  ...instead of a slightly " buzzy " noise from the fets now i had more of quieter "whine " ...sounds a lot better

setting pwm frequency in the pic is a bit of a pain ...i,d rather look at the scope and actually see something....

at a 10m time setting i have 5 wave forms...5 * 100 should mean 500hz  ... is this right ?   

(also managed to touch the fets live and got a little nip of 50v pwm ..... this was not a good idea at all  >:()     

 



     
Title: Re: picaxe ?
Post by: ghurd on October 25, 2012, 09:21:39 pm
Here's my complete current code.:
Start:
(lots of stuff, then more stuff, and after that more stuff)
Return
 
If the voltage drops below 13.2V, it turns off the dumpload, and turns it on again at 13.6V.

... everyone; feel free to comment... ;)

Newton's 5th Law:  Code = Ghurd Headache
(Newton's 4th law:  No wind for 3 days when you need wind)
I am impressed you guys are doing this.
To me, it is something akin to leaning to speak Icelandic.  I probably could, if I wanted to bad enough!

Why 13.2V?  Seems quite low, even with 750mS delay.


but at higher power levels the pic pwm was going out of sync with the mill , kind of chasing the mill a little , the pic pwm led was picking up a bit of flicker

(also managed to touch the fets live and got a little nip of 50v pwm ..... this was not a good idea at all  >:() 

"but at higher power levels the pic pwm was going out of sync with the mill , kind of chasing the mill a little"?
I do not understand what that means.  Care to rephrase it for the rest of us (or just for me)?

"the pic pwm led was picking up a bit of flicker"?
"i,d rather look at the scope and actually see something"?
At 250HZ?  Might want to put a $3 HF HZ meter on that to see what it says.
Personally I can (formerly could?) sometimes see >120HZ LED flicker, IF my eyes, the conditions, and duty cycle, are just right.  I didn't think most people could see that high HZ.

20Voc solar bites me bad.
50V battery gives me nightmares.
G-
Title: Re: picaxe ?
Post by: rossw on October 26, 2012, 04:47:25 am
At 250HZ?  Might want to put a $3 HF HZ meter on that to see what it says.

Probably because it's PWM, and as such the frequency should remain the same.

Quote
Personally I can (formerly could?) sometimes see >120HZ LED flicker, IF my eyes, the conditions, and duty cycle, are just right.  I didn't think most people could see that high HZ.
I certainly could see 100Hz easily. But only from the edges of my eye. There is a pretty standard trick to seeing much higher frequencies, and thats to put your fingers out and move your hand side to side between the source and your eye. Move faster or slower until you can "see" your fingers stationary rather than as a blur. Stroboscopes are SUCH cool things :)
Title: Re: picaxe ?
Post by: niall on October 26, 2012, 08:25:09 am
sorry heres another go ... ???...i dont really understand it myself either

when the mill hits 48v the pic trys to vary the duty cycle to clamp the voltage and hold the rpm
if the voltage goes to 48.5 , it increases the duty even more , so the led slowly increases in brightness ...100% duty cycle = full on led ( the mill furls out at about 80%)

i think the flicker was something like this...

when the pic was running at a low duty everything seemed fine ..the led would light up to a low level and reflect any changes ...but once it got to about 30% duty it started to give spikes in brightness , it seemed to be missing its que ...then waking up a fraction to late and overcompensating ( pulling the mill down more that it needed to ) ....over compensating is a better description than out of sync ...i think ...ish   

the pic has 100 linear duty steps to choose from ...somewhere it was missing a section of 10 or 20 and then getting a bit flustered and adding the missing 20 in the wrong place ....the threshold is 48v but sometimes it would drag down mill to 46v ...the code should,nt really allow that to happen ...

today is a good wind day (the first) ....so i,m keeping a close eye on the mill 

the clock speed can go to 32m but this again would double the pwm frequency ....   


Start: setfreq m16
       SYMBOL Volt = w0
       symbol niall= w1
       

init:   
       pwmout pwmdiv64,C.2,150,000       ;start pwm
Main:
    readadc10 4,Volt                     ;sample input volt

i think its the "150" bit that would need a tweak .....not sure about that either       
Title: Re: picaxe ?
Post by: Cornelius on October 26, 2012, 03:31:00 pm
Quote
Why 13.2V?  Seems quite low, even with 750mS delay.

Ghurd;
I assume you're referring to where i turn off the dumpload?
Because my dumpload consists of some ceramic heat elements with a fan behind, and the fan stops turning below a duty of 20 in my code, so the result are that my dumpload draws a minimum of 6A.
My battery bank are 1060Ah of Rolls S-4000 batteries, so they can handle 6A without the dump. :)
 
And the 750mS are just the time the ds18b20 takes to respond to the 'ReadTemp' command.

Niall;
Use the 'pwmout...' wizard under the PicAxe, Wizards menu to get the right pwm numbers for the frequency you want...

That 'chasing' you're describing are normal, and the delay will be greater at slower cpu speeds. The delay will also be greater with more code the picaxe has to perform each cycle...
I think it would be hard to get a 100% steel control over the voltage with a 08m2, because the voltage from a mill could rise very fast in a gust. If your voltage doesn't vary more than a couple of volts around 48V, your dumpload should be pretty safe.
And since you have furling, the windmill should be protected as well... ;)
 
Edit:
Actually, the picaxe have 1024 steps on the duty command, but it's frequency dependent... I think 61Hz are the lowest frequency one can choose to get 1024 steps; next are 244 etc... (multiply with 4 each time.)
Title: Re: picaxe ?
Post by: ghurd on October 26, 2012, 08:36:11 pm

I assume you're referring to where i turn off the dumpload?

Because my dumpload consists of some ceramic heat elements with a fan behind, and the fan stops turning below a duty of 20 in my code, so the result are that my dumpload draws a minimum of 6A.
My battery bank are 1060Ah of Rolls S-4000 batteries, so they can handle 6A without the dump. :)
 
And the 750mS are just the time the ds18b20 takes to respond to the 'ReadTemp' command.


"I assume you're referring to where i turn off the dumpload?"
Correct.  Now I understand that part of the concept.

If temp comp is 750mS, and code hz is relaterd to pic effort,
couldn't that step be skipped 999 of 1000 times?
Not like a 50, 500, or 5000 lb bank (suitable to the system) is going to change temp much in 1 minute.
I don't know. Maybe it is better to go 750ms for some reason related to the chip or program stuff.
Just throwing it out there.
G-
Title: Re: picaxe ?
Post by: ghurd on October 26, 2012, 09:00:20 pm
Probably because it's PWM, and as such the frequency should remain the same.

I certainly could see 100Hz easily. But only from the edges of my eye.

For me, there was a Hi and Lo point where duty cycle simply made it look dimmer/brighter.  May have been C issues.
Anyway, it was duty cycle related.

I 'could' see 120Hz easy, maybe I still can but haven't done anything like that with 60Hz grid and simple circuits since my eyes got old.

For a few years, some FL and HID at some BigBox stores (mall, Lowe's, Home DePot, burrito joint that McDs used to own, that cheap low-quality china jeans store usually in the mall, etc) made me dizzy and ill.
Maybe they still do, but I don't spend so much time in those places lately.
G-
Title: Re: picaxe ?
Post by: Cornelius on October 27, 2012, 01:37:13 am
Quote
If temp comp is 750mS, and code hz is relaterd to pic effort,
couldn't that step be skipped 999 of 1000 times?

You're absolutely right. ;)

I have my bank in a cellar with 1 meter thick granite walls, so the temperature varies only 10°C during the whole year, so i could skip the variable temp. comp. alltogether... But i like the temp comp... ;)
And since i use the controller for solar only, the speed are not critical. As the code are now, it uses around 1.5 sec. from low idle to full dump.
 
Niall;
Using 1024 step-resolution in the pwmduty will more or less get rid of the hunting, but it will also slow down the response; you'll have to find a middle way. (steps of 5 or 10? )
Title: Re: picaxe ?
Post by: niall on November 02, 2012, 02:27:48 pm
the way the pic is set now Cornelius ( i keep changing things ) is , when it reads 430 , it treats this as zero , if it goes to 431 this becomes 1 and is multiplied by 13 ...so i have 78 steps of pwm up to  a sense reading of 508 ...a total of 1014 ..i hope  thats fairly close  ::)

roughly a window of 50 to 57v...easy on at 50 , full on at 57 ...( furling affected )  ....kind of ..ish ..:'(

standing with my ear to the mast is concerning the neighbors a bit , so a good excuse to get the logger working again ...

reasonably good winds but its a terrible site , lots of tail hunting going on ...



(http://i383.photobucket.com/albums/oo279/itch1niall/scope3.jpg)

even though the site is bad it,s good for testing the picaxe  in a way ...the picture is,nt very clear but the green line is the voltage readings over 1 hour ...orange rpm ..white amps

with a swing of 7v at the top end there's a fair amount of spikes ...( furling is kicking in at the top level )

some stormy weather is needed to see when the elements conspire to do their damage ...all fun  :)

Title: Re: picaxe ?
Post by: Cornelius on November 02, 2012, 04:51:08 pm
Seems to me that you have the voltage and the gen under good control. :)

And yes; fast and varying output from the gen are good to test the controller... But it would also be interesting to see how it performs under a good steady wind, too; preferrably close to furling. ;)
Title: Re: picaxe ?
Post by: niall on November 03, 2012, 05:07:42 pm
yes ...that would be the interesting bit ...but the mill may not play ball to soon on this one ...the only bit of clean (ish) wind comes from the north west across a small field at the back of the house ....

very dubious at best .....

i set the pic pwm  back down to 250 tonight ,(very windy today , mill maxing out at 956w ) running at 16m clock frequency ....

it seems ok with that ....all very confusing ...

edit..i had a small cheap pot on the v divider for the pic .....just taking this out has changed things a lot ...dont know,  but i read on threads where these pots can have one reading ...and the next day its something slightly different..... 
Title: Re: picaxe ?
Post by: niall on January 25, 2013, 03:17:18 pm
the circuits been running on the mill for a while now ......no other tweeking since...

the fan code plan did,nt quite work out .....using the pause command to pwm the heatsink fan was interfering with the rest of the code ....the pause in the code was  interupting realtime voltage sensing.....not a good idea

so now the temp code is just a simple on/off aux signal .....

final full code.....

Start: setfreq m16
       SYMBOL Volt = w0
       symbol niall= w1
       symbol temp = w2

init:   
       pwmout pwmdiv64,C.2,249,000       ;start pwm
Main:
    readadc10 4,Volt                     ;sample input volt
    readadc10 1,temp                   ;sample thermistor v on heatsink
   
     
   
   
   
   
    if volt<430 then let volt=430        ;set up volt window
    end if
    if volt>508 then let volt=508
    end if
   
     
    niall=volt-430                       
           
   
                                         ;compensate volt to act as 0-1000 duty ish
       
     
    niall=niall*13
   
       
    pwmduty C.2,niall
   
   
    if temp< 382 then high 0     ; have a feel of the heatsink   
    end if
    if temp> 382 then low 0 
    end if
    goto main




the pic has no " doomsday  " option ....so playing with a simple transistor 60v peak voltage trip might be an option ....fun if nothing else  :)...and will run at hi dc without any v regulation ...cheap too   

(http://i383.photobucket.com/albums/oo279/itch1niall/P1251128.jpg)

this is kind of a copy of one of  " fc solar circuits " voltage switchs....a small pnp is fired when zener diodes in series on its base sense enough v to turn on .... very experiential this bit

all the mill power goes directly into a dc immersion element added in to the oil heater .

(http://i383.photobucket.com/albums/oo279/itch1niall/P1251129.jpg)
Title: Re: picaxe ?
Post by: Burnit0017 on January 25, 2013, 04:58:36 pm
Hi, very nice load. Did you post the circuit that reads the voltage into the pic?
Title: Re: picaxe ?
Post by: niall on January 25, 2013, 05:49:10 pm
...i was just copying the basic backshed piclogger layout...Burnit

i though for 48v a 47k and 2k2 divider might be ok , with a 100n decoupler and no zener protection ...this should give a safe portion of the 5v window to the pic ....ish

thats pretty much the sense input v at the moment on pin 4 of the pic ...not much else......

a multi turn pot with the 47k is usefull i think ......it works well in tandem with code .......trim the Resistance and the code readings can compensate at the same time ...kind of ....

i,m  sure theres other ways to do the same thing .....the pic seem,s  very adaptable .... :) 
Title: Re: picaxe ?
Post by: niall on March 02, 2015, 04:35:23 pm
the thread is a bit old now , but i thought i,d update it as its an ongoing control system for the mill .....

capacitors are the 1k mills "battery".....and these are failing periodically ....you get that unique smell and somethings wrong , the picaxe,s  pwm led indicator goes a little rough ...you can feel it in the mill too ( a different rumble )

i have about 15000uf at 80v ....30,000uf  would be required , i thought i would get away with less ....thats what thinking did

Hugh recommends a min of 25000uf 100v on his ldr,s .....should have stuck to that

[attachimg=1]

this cap did,nt swell but started shorting inside near the - terminal.....

the picaxe/ fets settled down with the replacement cap .....the chip and fets are cheap , the caps ...not some much

 i guess thats the trade off....

the older the mill gets the more maintenance it needs ...some of last summers repairs

[attachimg=2]


.[attachimg=3]