Author Topic: picaxe ?  (Read 18767 times)

0 Members and 1 Guest are viewing this topic.

Offline niall

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +16/-0
  • No Personal Text Set by User
picaxe ?
« 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 ....



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 

Offline Wolvenar

  • Senior Moderator
  • Hero Member
  • *******
  • Posts: 1474
  • Karma: +40/-0
  • Mr. Murphys pawn
Re: picaxe ?
« Reply #1 on: September 26, 2012, 07:48:18 pm »
What do you plan to do with the power when water temps reach the high limits?
Trying to make power from alternative energy any which way I can.
Just to abuse what I make. (and run this site)

Offline rossw

  • Senior Moderator
  • Hero Member
  • *******
  • Posts: 879
  • Karma: +35/-0
  • Grumpy-old-Unix-Admin
Re: picaxe ?
« Reply #2 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

Offline Cornelius

  • Full Member
  • ***
  • Posts: 57
  • Karma: +7/-0
  • Grimstad, Norway
Re: picaxe ?
« Reply #3 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.)

Offline niall

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +16/-0
  • No Personal Text Set by User
Re: picaxe ?
« Reply #4 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


Offline rossw

  • Senior Moderator
  • Hero Member
  • *******
  • Posts: 879
  • Karma: +35/-0
  • Grumpy-old-Unix-Admin
Re: picaxe ?
« Reply #5 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.... :)

Offline niall

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +16/-0
  • No Personal Text Set by User
Re: picaxe ?
« Reply #6 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 ...

 

Offline ghurd

  • Global Moderator
  • Sr. Member
  • ******
  • Posts: 442
  • Karma: +22/-0
    • GHurd Solar
Re: picaxe ?
« Reply #7 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-

Offline niall

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +16/-0
  • No Personal Text Set by User
Re: picaxe ?
« Reply #8 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

Offline niall

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +16/-0
  • No Personal Text Set by User
Re: picaxe ?
« Reply #9 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 .....
 


Offline Cornelius

  • Full Member
  • ***
  • Posts: 57
  • Karma: +7/-0
  • Grimstad, Norway
Re: picaxe ?
« Reply #10 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... ;)

Offline niall

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +16/-0
  • No Personal Text Set by User
Re: picaxe ?
« Reply #11 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




Offline Cornelius

  • Full Member
  • ***
  • Posts: 57
  • Karma: +7/-0
  • Grimstad, Norway
Re: picaxe ?
« Reply #12 on: October 13, 2012, 03:48:24 am »
Not unlike the way i did it... ;)
1607-0
 
Edit:
Not shown are a ferrite bead around the leg of the 10ohm gate resistors, close to the gate leg.

Offline niall

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +16/-0
  • No Personal Text Set by User
Re: picaxe ?
« Reply #13 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 .......






 

Offline Cornelius

  • Full Member
  • ***
  • Posts: 57
  • Karma: +7/-0
  • Grimstad, Norway
Re: picaxe ?
« Reply #14 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.