urgent!!! help with picaxe 08M

BeanieBots

Moderator
Well there's something positive at least.
If the PWM is OK, then it has to something in your output stage.
Ignoring any possible wiring faults, there is very little to check.
Input cap, FET, inductor, diode, output cap.

You've checked, and presumably replaced the faulty FET.
Check the diode.
If that's OK, then check the caps.
If they're OK, then have a good look at the inductor. If you let it get hot, then the wire insulation may have broken down. Check it is the correct inductance. If you don't have an inductance meter, then replace it and try again.

PS.
ALWAYS, ALWAYS, ALWAYS, fit a fuse on both input and output.
If you accidently set the PWM output high or have too high duty, you can easily melt the FET. If the FET melts, it can short high voltage to the PICAXE. If the PICAXE gets high voltage, it can EXPLODE. If the PICAXE explodes, it can take your eye out.
 
Last edited:

Grogster

Senior Member
I still think you should abort this, and make an LED-based project.
VISUALLY, it is/can be far more impressive then what you are trying to do - not that I am trying to put you off, mind...

Also not sure why you are using 2x 3055's in a darlington arrangement - better surely to use the likes of a 548 and 3055 as a darington pair, or perhaps a BD139 and 3055 darlington pair, if you want a bit more push - a 139/3055 pair would drive the 3055 to full saturation no problems. Two 3055's as a darlington-pair seem like overkill to me...

...my 2c/2p...
 

parisien

Member
hi, i solve the problem, tnx. my main problem nw its the duty cycle code,can u plzz guys help me to fix that code??

tnx.
 

BeanieBots

Moderator
If you can wait another day, I'll be publishing some code for a Flyback converter lead acid battery charger. Far from MPPT but it might give you some ideas for your code.
 

BeanieBots

Moderator
Way off.

You start the pwm with an undefined value comming from b4
Then you flash an LED.
Then you define duty as 25 and take a single adc reading.
You then go off into and endless loop comparing that single reading and never do anything with the results.

No updating of the PWM anywhere in your code.
Voltage is only sampled ONCE and even then you don't do anything with it.

Sorry I've not posted my code yet. Taking longer than I thought because I had to re-write a few bits to make it fit. Hopefully today!
 

Pekari

Senior Member
parisien, you haven't fix a code.

You seems not having a Programming Editor because your code has a errors which it will tell you when you load it to IC.
You can't load that code to picaxe because those errors.

You need to put pwmout inside to main part.

Your's led isn't blinking because there is missing a pause behind a low 4 and that loop b0 can't work because there is next b1! this b1 need to be removed.

How do you that program is doing? It's only a changing a variables, but doesn't do anything else after main, so nothing will be change outside a picaxe.
It will never read adc input in main, only in the start.

You need to THINK a code: HOW IT IS WORKING AND RUNNING?
 

hippy

Ex-Staff (retired)
Apart from adding the flashing LED the code is the same as before with all the same faults as before; it does not implement the algorithm you flowcharted.

1) Only reads one ADC and only once
2) That ADC reading is ignored, and 'cv' forced to 185
3) The main loop doesn't do any ADC reading
4) The IF tests use only 'cv', not both voltages
5) The main loop doesn't update PWM duty
 

BeanieBots

Moderator
Looks a bit more hopeful.
Quite different to your original specification though.
What do you want it do? You seem be using the square of the difference now?

Might need some scaling to work without overflowing the variables.

I'm a bit concerned about your max duty.
What do you think will happen at 100% duty?
 

parisien

Member
we cant never achieve 100% ?coz we will have 1-duty=1-1=0.

can i just write "duty = difference + duty max 200 or duty = duty + 1"
and take the line "difference = difference * difference" out ??

should i leave "duty = duty - difference min 0 or duty = duty - 1 " ??

what about some scaling to work without overflowing the variables??

i told you i dt have much experienced in programming.

do i stil lhave to do more from there?? am i getting there??


plzzz let me know.
 

hippy

Ex-Staff (retired)
can i just write "duty = difference + duty max 200 or duty = duty + 1" and take the line "difference = difference * difference" out ??

should i leave "duty = duty - difference min 0 or duty = duty - 1 " ??

what about some scaling to work without overflowing the variables??
These aren't easy questions to answer because it's not clear what you are trying to achieve. Sure you can take the "difference" variable out of the equations but whether you should or not depends on what it is you need to do.

It's also complicated by the fact that the two alternatives you offer are not equivalents so there will be a difference in program behaviour. Which behaviour do you want ?

As to scaling; scaling what and why ?

Imagine if someone asked you if their circuit should use a 56R or 120K resistor ? How could you even start to answer that question without a lot more information about how the resistor was being used and the purpose it served ? It's unfortunately the same with your code.
 

hippy

Ex-Staff (retired)
Okay, based on your circuit in post #38, your flowchart in post #64, and code in post #91, this implements what you specified according to your flowchart operation.

The code is untested and you will have to adjust the lines with "?" in them to match what you actually have and need and I take absolutely no responsibility for incorrect operation of the code or any consequences for its use whatsoever.

Code:
Symbol vInAdc         = b0
Symbol vIn            = b1
Symbol vOutAdc        = b2
Symbol vOut           = b3
Symbol duty           = b4

Symbol PIN_VIN_ADC    = ?
Symbol PIN_VOUT_ADC   = ?
Symbol PIN_PWMOUT     = ?

Symbol VIN_MIN_VOLTS  = ?      '  8.8V
Symbol VOUT_MAX_VOLTS = ?      ' 12.0V

Symbol PWM_FREQ       = 99
Symbol MIN_DUTY       = 100
Symbol MAX_DUTY       = 200

duty = 0
PwmOut PIN_PWMOUT, PWM_FREQ, duty
Do
  ReadAdc PIN_VIN_ADC, vInAdc
  vIn = vInAdc ?
  If vIn < VIN_MIN_VOLTS Then
    If duty > MIN_DUTY Then
      duty = duty-1
      PwmOut PIN_PWMOUT, PWM_FREQ, duty
    End If
  Else
    ReadAdc PIN_VOUT_ADC, vOutAdc
    vOut = vOutAdc ?
    If vOut < VOUT_MAX_VOLTS Then
      If duty < MAX_DUTY Then
        duty = duty+1
        PwmOut PIN_PWMOUT, PWM_FREQ, duty
      End If
    End If
  End If
Loop
 

parisien

Member
The mppt should adjust the input current, in a way there is always impedance matching and maximum power transfered.

lets say for example i have 100W output. to make sure that im drawing max power from the input, when the input decreases, i can adjust (increase)the input current to raised to the max power.

i think dats wat the mppt doing

put he new code, but done some few changes.

iwant a code which behaves the way an mppt should do.
 

Attachments

BeanieBots

Moderator
Parisien, you getting closer. Keep at it.
I'll not comment on the code. I have every faith that Hippy's code will do what you asked for, but I might question what you asked for.

Controlling for maximum input current won't work.
Maximum input current will occur when the panel is shorted out. under these conditions, the panel voltage will be zero and hence so will the power.
Also, what is going on with the input side does not take into account any inefficiencies in your converter. Besides, who cares what the input power is, other than for accademic reasons. It's the output power which is important.

As I've mentioned several times, you need to control for maximum OUTPUT current. That assumes that your load is purely resistive. (which includes charging into a battery).

I've been doing a lot of work in this area myself recently and have found that the limited resolution of the PICAXE pwm makes the input voltage hunt badly when controlling output current. Just changing the PWM by +/- 1 can make the input voltage go above and below the optimum value by several volts. This makes it very unstable.
REAL results (when using PICAXE PWM) indicate that controlling input voltage against a lookup table yields better results. However, I am prepared to accept that some of the instability may be down to my poor programming. The delay between PWM updates is also important to prevent hunting. This is something I've not played with using PICAXE. Normally this would be taken care of with the compensation amplifier in an analogue controlled MPPT.
Making the input cap much larger than is actually required electrically and inserting a few strategic pauses should get around the problem. You will need to experiment once you have the circuit up and running.

Unfortunately, my developments have come to a halt due to other reasons outlined in my other thread:mad:
 

parisien

Member
hey

tanx 4ur code. i posted the other one before seeing this one. wan to ask some question, the following symbols:

Symbol PIN_VIN_ADC = ?
Symbol PIN_VOUT_ADC = ?
Symbol PIN_PWMOUT = ?

hw are we going to initialise them?? we know already the pin of the picaxe like Vin_ADC is at pin 4, Vout_ADC at pin 6, and the pwmout at pin 5.

what value should i write there?? W4, W5, etc....


Symbol VIN_MIN_VOLTS = ? ' 8.8V
Symbol VOUT_MAX_VOLTS = ? ' 12V
 

hippy

Ex-Staff (retired)
Symbol PIN_VIN_ADC = ?
Symbol PIN_VOUT_ADC = ?
Symbol PIN_PWMOUT = ?

hw are we going to initialise them?? we know already the pin of the picaxe like Vin_ADC is at pin 4, Vout_ADC at pin 6, and the pwmout at pin 5.
In which case ...

Symbol PIN_VIN_ADC = 4
Symbol PIN_VOUT_ADC = 6
Symbol PIN_PWMOUT = 5

However as there's no I/O pin 5 or 6 on an 08M I presume you mean "chip leg", so mapping leg to pin ...

Symbol PIN_VIN_ADC = 3
Symbol PIN_VOUT_ADC = 1
Symbol PIN_PWMOUT = 2

But Pin 3 / Leg 4 cannot be an analogue input, so I'm not sure what you actually want there, or anywhere, so that's why I left it for you to make the changes.

what value should i write there?? W4, W5, etc....

Symbol VIN_MIN_VOLTS = ? ' 8.8V
Symbol VOUT_MAX_VOLTS = ? ' 12V
You'll need to put in whatever numeric constants represent the values 8.8V and 12V after you've read the input and output voltages and have performed any necessary processing on them.

Code:
                      .--------.
          ___         |        |
Vraw >---|___|---.--->| ADC    |
          Rt    .|.   |        |
                | |   `--------'
             Rb |_|
                _|_

The voltage at the ADC pin (Vadc) will be ...

           Rb
Vadc =  ------- * Vraw
        Rt + Rb

The number returned by a READADC (Nadc) will be ...

        Vadc
Nadc =  ---- * 255
        Vpsu

So the number returned for a READADC for a particular Vraw is ...

          Rb * Vraw * 255
Nadc =  ------------------
        ( Rt + Rb ) * Vpsu

Thus, for 8.8V ...

                   Rb * 8.8 * 255
VIN_MIN_VOLTS =  ------------------
                 ( Rt + Rb ) * Vpsu

Thus, for 12.0V ...

                     Rb * 12 * 255
VOUT_MAX_VOLTS =  ------------------
                  ( Rt + Rb ) * Vpsu
 

parisien

Member
tanx. so far its fine

i would like to use the ADC4 on the picaxe, but on the picaxe protoboard, there no option given to use that pin.

can i just solder a wire on it and use it, or is there another way of doing it !!!!

tanx.
 

parisien

Member
Very interesting result !!!!

but a few things to change.

my min duty cycle seems to be 20% and max cycle 50%.
how can i go further than 50%???

however my duty cycle starts increasing Vin at 9.5V. even though i go further 9.5V, the duty cycle doesnt change anymore but my output voltage still increasing.

i wanted to fix a reference voltage to compare to that value. for example if its clouds, the input voltage will drop severally, lets say to a voltage Voc=0.22/cell which can give us 3.5V input in total. at that moment the duty cycle should increase to increase the output current to maintain the power at its maximum !!! am i wrong by saying that??

how can i set the reference voltage??

it seems like the second loop doenst work at all. it always jumps !!!

ReadAdc PIN_VOUT_ADC, vOutAdc
vOut = vOutAdc 'reset?
If vOut < VOUT_MAX_VOLTS Then
If duty < MAX_DUTY Then
duty = duty+1
PwmOut PIN_PWMOUT, PWM_FREQ, duty
End If
End If
End If


the way the circuit works, i dont think we gonna have a case where vOut=vOutAdc or vIn=vInAdc ???
 

Attachments

hippy

Ex-Staff (retired)
A few helpers for your questions ...

To connect ADC4 ( Leg 3 ) - If there's no connection to that then you will have to just solder a wire to the board.

Increasing the maximum PWM duty - This will require changing the PWM_MAX_DUTY constant. The Programming Editor PWM Wizard will show what values should be used.

As to the reference voltage and other operation of the code - I have no idea I am afraid. This is where it comes down to algorithm design rather than algorithm coding. I do not know anything about this type of power supply, know almost nothing about MPPT, do not understand how your circuit works or is meant to work and an explanation has not been forthcoming.

As has been said from the very beginning; this is a complex project which will require understanding of the principles of operation, hardware and software and will take some time to get right even for an expert in this field. I am not such an expert so cannot really help in that respect.
 

parisien

Member
wat i want the circuit doing is to always regulate the power at its maximum, when even the input is decreasing at a certain value.

i think we can regulate the output power by increasing or decreasing the duty cycle.

i would like to fix my reference input voltage at 3.4-5V. meaning for 3.5<Vin<8.8V, it increases the duty cycle and in the mean time, increases the output voltage. but dont exceed 13V.

at 8.8V, ithe duty cycle should 50% and will have the expected output.

thats how i see it.
 

hippy

Ex-Staff (retired)
There is a gap between what you want and how to get it if you want others to help write your code. This application goes right over my head so I cannot help in 'how to' only in translating flowcharts or formal specification into code.
 

parisien

Member
in the flowchart, i mentionned if voltage is less than 8.8V, its increase the duty cycle, instead of decrease .but now want the output voltage to change between 3.5-8.8V.

i choose increase coz of Vo = Vi/(1-D) ,
 

moxhamj

New Member
Re "i would like to fix my reference input voltage at 3.4-5V. meaning for 3.5<Vin<8.8V, it increases the duty cycle and in the mean time, increases the output voltage. but dont exceed 13V."

That isn't using MPPT. It might be something else but not MPPT. MPPT seeks to get the maximum output power, so what is going on at the input is not important. You can measure it for interest but it doesn't affect the outcome.

You need to get the theory right before writing the code.

It also is not as simple as changing the duty cycle. Consider short pulses spaced a long way apart - that might be very efficient. But long 'on' pulses and short 'off' pulses will most likely just send the inductor into saturation and you won't get much power out at all. Then you might be changing the pulse width and getting different amounts of power out, and you think you are tracking the maximum power point of the solar cells, but in actual fact you are tracking the maximum power point of the inductor and associated switching circuit. And that is just wasting power.

I've found the best way to optimise these things is to put a load on the output, feed in fixed volts and measure the maxiumum volts you can get on the output. And that usually is around a 50:50 duty cycle. That gives you the maximum efficiency - and then rather than change the duty cycle, it usually works out more efficient to turn the entire oscillator on and off to regulate the output.
 

BeanieBots

Moderator
Some good points there Doc.
An idea I've pinched from the desulphator forum is to detect inductor saturation by measuring FET temperature rise. Basically, rapid dT/dt means you've hit saturation and need to back off. Current sense on the FET is the traditional way but that's another I^2.R loss and another op-amp to make it PICAXEable.
 

parisien

Member
hi Dr Acula,

seems ur method is interesting and simple , but i really dont understand how to implement it, how to make it work.

i will really appreciate if u tell me more about it.

tnax.
 

manuka

Senior Member
Parisien: I've had a long career (largely NZ based) teaching degree level electronics,with a particular slant towards achievable WORKING final projects & their presentation.

With approaching deadline calls for help such as yours, electronic woes are often secondary to more localised factors. IMHO initial issues to clarify relate to WHICH QUALIFICATION, YOUR LOCATION, WHY THIS TOPIC, AVAILABLE PROJECT RESOURCES, HOW THE PROJECT IS ASSESSED, YOUR SKILL LEVEL, BUDGET, LOCAL ASSISTANCE, TIME FRAMES, INTELLECTUAL PROPERTY, COPYRIGHT and (of course) the DEGREE OF EXTERNAL HELP ALLOWED. Does your supervisor approve of our assistance?

In spite of frequent requests,you have yet to mention these essentials. Any one of these factors could greatly influence assistance - for all we know you may be aiming to publish a Ph.D thesis based largely on the Forum's brainpower. Worse still (for you) we could be leading you astray on MPPT (Maximum Power Point Tracking), and you may fail to meet your course criteria.

This latter point is often of crucial significance - I've run up against it myself here in NZ,most memorably with WiFi security & mains energy monitoring, & now will NOT give any more than casual assistance unless the specified course supervisor approves it in writing/email. Supervisors/markers usually have their own slant (often dated) on an electronic topic & may totally reject work cobbled together from the inspiration of others. Hence you may have specifically been told to use low level PIC coding, & our hi level PICAXE approach may be considered "kid's stuff". Stan

EXTRA: I've had decades of downunder solar PV experiences &, like fellow colonial Dr_A, increasingly subscribe to the "add an extra panel" approach, as this tends to be more reliable & cost effective than tracking/concentrating/MPPT systems that try to squeeze every last Joule out of the sunbeams. It depends on your local solar resource of course- Aust/NZ usually have such clear air, high sunshine levels and suitable rooftops that this approach appeals.

As part of a solar lighting system (Jaycar MP-4552) review, I've just been doing some work with CIS/CIGS (Copper Indium Gallium (di) Selenide) PVs, & pondered a more serious tertiary workout is justified. Compared with classic poly/mono-X Si, the off angle, overcast & shaded performance of these CIS/CIGS PVs was astounding. Stan.
 
Last edited:

parisien

Member
hi

there is something very strange that i noticed, u see the voltage divider that i connected at the output. actually it is supposed to be 3.5V at my ADC when i got 12V output. i did the calculation and everything, and i put the resistor (2.2K, 1K). now, connecting and supply, i got 0.55V (across 1k, which is supposed to be 3.75V)at my ADC when i got 12V output. which is not the value that im supposed to get. do u guys have any idea of what the rpoblem can be??

tnx

im playing with a code. actually i would like when the voltage changes in the interal [3.5, 8.7], the duty cycle increases for each value of v in that specific interval. i wrote the code:

Do
Readadc 4, VinAdc
Vi= VinAdc
If Vi<=247 and Vi>=99 Then

difference =Vi*100/Vo ' Vout=13
duty = 397* difference/100
duty = duty+1
PwmOut 2, 99 , duty
end if

loop

but it is not working as i want, because it just increasing (oscillating) everytime, even tho Vin hasnt changed. how can i correct it??

would like to know also, how many code lines picaxe 08M can support?? wats the memory size??

tnx
 

BeanieBots

Moderator
Hello, thought you'd left us!

You can get about 80 lines of code in a 08M PICAXE.

If you are seeing 0.55v on your divider, it sounds like a short to an output pin or trying to measure the voltage when the PICAXE is not powered. If it's not that, then it will be some other simple error.
A divider of 2k2 and 1k should give 3.75v for 12v input.
 

parisien

Member
hi ,

im not getting wat i want with my flowchart, is it possible to use the P & O MPPT method for this case with my circuit and using picaxe 08M?? to measure and read the current, can i use a Hall effect current sendor ?? if yes how am i going to connect it and read the corresponding value???

do u think i can apply this P & O method with my circuit??

dr acula said easy way to get MPP saying " best way to optimise this is to put a load on the output, feed in fixed volts and measure the maxiumum volts you can get on the output. And that usually is around a 50:50 duty cycle. That gives you the maximum efficiency - and then rather than change the duty cycle, it usually works out more efficient to turn the entire oscillator on and off to regulate the output."

in your thread, u were saying "MPPT control is possible with a PICAXE but NOT if the PWMout from the PICAXE is used to control the gate of a FET" so in my case it wont work !!!

PS : between the pwm and the FET, i put a FEt driver

How do we turn the entire oscillator on and off to regulate the output??
do we have to change the program code ???
 

Attachments

BeanieBots

Moderator
Sorry, don't know what you mean by "the P & O MPPT method ".

I should probably change my statement of "not possible" to "not worthwhile".
Whilst I won't dissagree with Dr_Acula that turning the entire oscillator on/off is a valid option for MPPT, if my findings that PWMout resolution is too coarse, then I would think oscillator on/off would be even more so. However, I've not tried that approach so cannot comment with any validity.

It should be easy enough to try. Just set duty to zero to turn off PWMout.

My comments relating to direct drive of the FET are two fold.
First is the lack of gate drive. This proved to be of far less consequence than anticipated. The energy lost as a result of FET switching times was very small and almost insignificant at the PWM frequencies involved. I was using a flyback topology and was getting >85% in the switching part of the converter. (quiescent power not included). The problem with "direct drive of the FET" relates to the control you have over PWMout.
My conclusion is that you need to drive the FET from a seperate oscillator and use PWMout (or whatever method) to control that oscillator. Such a method also permits the use of much higher frequency and hence much smaller magnetics. Higher frequency would of course also require the use of a proper FET drive circuit.
 

parisien

Member
hi boriz, u mentionned in onthe of the thread that :
"My idea is to use two duties. Both equally spaced on either side of a virtual centre duty (D0). Let’s say D- is 5% less than D0 and D+ is 5% greater than D0. The feedback routine follows this sort of logic:

Set duty to D- and measure output (O-)
Set duty to D+ and measure output (O+)
If O- < O+ then you are on the left hand side of the slope, increase D0
If O- > O+ then you are on the right hand side of the slope, decrease D0
Repeat

Most of the time, the duty should be set to D0, and the above process is called (say) every few seconds. If the difference between O- and O+ is below a certain ‘tolerance threshold’ then no change is made."


this is code that itry to write.can u plzz check if its ok.

tnx
 

Attachments

parisien

Member
there is some algorithm method develop on internet for MPPt. the most used is the P&O method. i showed you the algorithm in the thread.
 
Top