Constant current source

Go To Last Post
583 posts / 0 new

Pages

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You are one hell of a guy .... But you found it, and that's the most important thing.

Dragon's lack proper protection. You also have 100 nF on the Tiny26 /Reset. And no current limiter in Dragon's Reset.

I posted a link in the OffTopic Sherlock Holmes thread for KKP's protection- and line-driver document. I am building now a derivate from his circuit (I don't need a long JTAG-line. And I don't have the AC32S ... using a HC32 instead)

A GIF is worth a thousend words   She is called Rosa, lives at Mint17.3 https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Last test:

Wired everything up like I should. 100Ohm in center tap and 1k Load instead of LED's

Nice, no blowups. Vcc 5.11V, V_led 4.76V, V_centertap 2.46V

Using 89kHz (4us on, 2us dead).

Is this good? ;)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That looks very good ! 2.5Volt at center-tap means
you have 2.5V across 100 Ohm meaning 25mA. That is
perfect ! And Vled bigger than Vcenter-tap is
also very good meaning that the converter
is up-converting !

Now you can proceed into some directions:

a) decrease 100 Ohm resistor (to 33 or 10 Ohm).
b) play with duty-cycle.
c) decrease load resistor or attach other dummy-load.

In doing the experiments always measure the voltages
as before.

Seems you are on the right track !

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Which transformer are you using now, and what number of turns ?

My test-rig is off the table again .... too messy with all those wires. So I can not confirm.
Reduce the 100 ohms to 50, and see what happens: Vct should rise, and Vled should rise.

Edit: Speedy German :)

A GIF is worth a thousend words   She is called Rosa, lives at Mint17.3 https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm using my latest.
One with PVC insulated wires (And nicely colored) on the orange toroidal core.

I'm off to experiment ;)

Thanks for confirming, that I'm on the right track. Rain be happy! Rain go jump with joy. Boom-Boom-Boom

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Speedy ?
In this morning it took me 3 hours and 45minutes to
get 35km. And now I am counting my bones again and
enjoy AVR freaks !

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That's almost 10 km per hour ! Pretty good run !

A GIF is worth a thousend words   She is called Rosa, lives at Mint17.3 https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

SUCCESS!!!!
WOOOOAAAHH!!
(Jumping with joy).

http://picasaweb.google.com/rell...

(1 LED is broken. V_led 8.64. Vin 5.03V, Vcentertap = Vin

Everything is running cool (except the LED's)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Nice :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

JOOOO :!:

Great. Magnificent. Fabulous. And more.

A GIF is worth a thousend words   She is called Rosa, lives at Mint17.3 https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Congratulations !
:D :D :D :D

(But I cant see the photo on ...picasa...)

Some hours ago I thought: Will you get
it before this thread enters page 30 ?

And you did it !

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks you all! But I haven't finished it yet ;) (so Ossi... I can still get it past 30)
Right now all I have is the lazy mans PWM. Now I have to get that PWM smarter (interrupt driven) and get my check routines working (V and C sense etc). Oeh...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And for those, who can't see that image on picasa:

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Looking Good.
Way to go Rain!!!!

Yippee,
John

Resistance is futile…… You will be compiled!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Now I have to get that PWM smarter (interrupt driven)
Indeed. The problem with interrupt-driven is: the latency. It depends on the current instruction "in process" when the interrupt is recognized. Can take 3 cycles f.i.
Since the Tiny26 lacks Phase&Freq Correct PWM, I think you'll have to use bitbang. Use NOP's for the dead-time, and stop the converter for a short while to do what you need to do: ADC etc.

But you're far more familiar with 26's than I am, so you'll probably find a way :)

Cheers!

Nard

A GIF is worth a thousend words   She is called Rosa, lives at Mint17.3 https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

May be the following could work:

A timer generates the two PWM outputs and triggers
the ISR (Interupt-Service-Routine).

Within the ISR you re-program the PWM-outputs
so that alternate pulses are generated.
Since the re-setting of the PWM-functionality
comes into effect a little bit later, the
jitter of the ISR-trigger may be of no effect.

Warning:
Even if this should be possible, it is not easy !
This must be very carefully implemented and tested.

And if we come even to page 50 or more:

You never walk alone !

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There's one advantage, the control loop doesn't have to be that fast, with batteries and constant load there's no need to be able to handle transients.

What about bit banging 1000 PWM cycles, then execute the control loop? Maybe the PWM from with an timer ISR, so that the control loop can be executed in small parts.

Short dropouts (<1ms) probably are not noticable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What do you think ;)

#include 
#include 
#include 

#define PWM_TOP 100

int main (void)
{
	TCCR1A = (1<<COM1A1)|(1<<PWM1A);
	TCCR1B = (1<<CS10)|(1<<CTC1);
	
	uint8_t dutyA = 40;
	
	OCR1A = dutyA;
	//OCR1B = 32;
	OCR1C  = 100;

	DDRB = 0xFF;
	PORTB = 02;
	PINB = 02;

	for(;;)
	{
		while (((TCCR1B & (1<<CS10))) != 0)
		{
			do
			{
				while ((PINB & (1<<PB1))==0)
				{
					uint8_t x,y;
					for (x = 0; x<(((PWM_TOP/2)-dutyA)/5); x++)  //(PWM_TOP/2-dutyA)/2
						asm("nop");
					PORTB = (1<<PB3);
					for (y = 0; y<(dutyA/5);y++)
						asm("nop");
					PORTB = 0;
					for (x = 0; x<(((PWM_TOP/2)-dutyA)/5); x++)  //(PWM_TOP/2-dutyA)/2
						asm("nop");
					break;
				}
			}
			while ((PINB & (1<<PB1)));
		}
	}
}

Works at ~80kHz, dead time 1us on both sides (thanks to ~40% duty).

Only problem is, that when I turn on the Center TAP voltage everything hangs and blows (stops working). Is this because of the 1us delay? should I aim for 2us?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello. It's me again...

Does anyone know, what resolution do I need? I'm thinking of hard coding 10 PWM levels into the chip so that I could use nop's to make an accurate (enough) PWM. I assume, you have dome a bit more testing with it and know better, how this circuit works so I turn to you to ask, what duty cycles should I use for this. I can't generate clean enough PWM with this code above. It only worked perfectly with duty cycle of 40. everything else gave me everything BUT PWM. ;)

What PWM's do you suggest?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Only problem is, that when I turn on the Center TAP voltage everything hangs and blows (stops working). Is this because of the 1us delay? should I aim for 2us?
Let me first answer this one. When power is applied, the AVR starts up with all ports as input. And that's why I recommended the pull-downs.
When you initialize the ports, make sure the fets are kept in off-state.
Then, when you start the PWM, you have to make sure that the pulses to the 2 fet's are equal in length AND that there is sufficient dead-time (I needed 0.6 us with the fets I used) A soft start would be great. It means that you'll have to ramp-up the pulsewidth until the Led-current reaches the Soll-wert :)

So the effect that you see is either caused by one fet being in ON-state too long, or two fets open at the same time.

For your latest post: I'll try to think of a smart way to do this with a tiny26. It's such a pitty that you don't have Phase&Freq Correct PWM in the 26.
I don't think that hard-coding 10 pwm-levels is necessary, if THE idea :idea: pops up.

Edited

A GIF is worth a thousend words   She is called Rosa, lives at Mint17.3 https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think jayjay's method is worth a try !

Write a short routine in assembly using 3
parameters called ON (8Bit) and OFF (8Bit)
and REPETITIONS (16 Bit). Call the assembly
loop from C.
(A nice exercise to combine C and ASM, perhaps
Jörg enters the thread.)

The assembly does the following

LOOP: wait OFF cycles*2
      switch on MOSFET1
      wait on cycles*2  
      switch off MOSFET1

      wait OFF cycles*2
      switch on MOSFET2
      wait on cycles*2  
      switch off MOSFET2

      REPETITIONS--
      if REPETITIONS>0 goto LOOP

Careful instruction-cycle timing is necessary to
balance the parts so that perfect symmetry is
given.

(You told us you have a fast logic-analyser
to check signals!)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

oh god! ASM... I know nothing about asm... :$

Have to learn then! ;) How hard can it be...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok,
I withdraw my proposal and invoke the
C-freaks to show what the can do.

Perhaps we could even start another C versus ASM war.
This would bring another 50 pages to this thread !

Or:
You say "Good Bye" to the push-pull :wink: .
You could simply use the boost-converter.
No compilcated PWM necessary.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Perhaps we could even start another C versus ASM war

There are already too many wars in the world .... so let's keep it peacefull in this community (of course I understand the wink in your sentence, but I think it's a good thing to say this now and then)

Quote:
You say "Good Bye" to the push-pull

Possible :) But what a waste of effort .... after all we have gone through.

I found a more manageble way to deal with the problem:

Assuming 8 MHz int. osc., setup timer 1 for CTC, top = OCR1C = 50, clock = Ck (max resolution, don't use PLL). Ovf1 will occur on timer 1 reaching 50. On that Ovf1-int, toggle a flag and, depending on that flag-status enable either OC1A or OC1B with the Com1a and Com1b bits in TCCR1A. Update the (equal, same) values in OCR1A and OCR1B at the beginning of this Ovf-int.

In the main loop, calculate the required PWM-width using the ADC, and make sure the highest value is (50 - 5). That ensures a dead-time of 0.6 us minimum.

Advantage of this approach is that the timer takes care of the pulsewidth, and the interrupt-mechanism allows for other tasks to be done meanwhile ....

Should work ...

Nard

A GIF is worth a thousend words   She is called Rosa, lives at Mint17.3 https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks.

AS soon As I get my hands on new FETs I'll try that approach.

Yes I DID blow up one of my FETs! I isolated one, but forgot, that the other one needed an isolation also! damn temperature! made my FET go bigged 0.1um and enough to cause the magical smoke to come out of it :'(.

Oh well!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Happens. Bad, but happens.

For the software-concept to write (and test), you don't need the fets .... just your logic analyzer. So good luck ! Btw, setup TCCR1A to clear on match .... that will ensure the symmetry between the two fets.

A GIF is worth a thousend words   She is called Rosa, lives at Mint17.3 https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The term is LOSS, because if LOOSSES are too high
you have a LOSS of a FET.

Some years ago I started working at a company
designing switched mode supplies.
When we started a project I wanted to order 1 MOSFET.

The colleagues said:
Order at least 50 ! (they were not expensive)
I said: Why ?
They answered: You will learn !

....... And I learned ........

You have now a pause to rethink pulse-generation
and really dig into that sub-problem.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It's very quiet lately in this thread. How is your project coming, Rain ? Did you find a way to make the timer do what you want them to do ?

Nard

A GIF is worth a thousend words   She is called Rosa, lives at Mint17.3 https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Nard,

Now that I am back from the "wet" holiday, I must return to my "thermal fuse". While away I wondered if I have got the phasing of the coil windings wrong. I used Ossi's "three wire at once" trick, ie

A-------------B
C-------------D
E------F------G

...and then connected F to the Vin, C to G and one Fet drain, E to B and the other Fet drain, and finally D and A to the anodes of the two diodes.

Is that correct?

Cheers.

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That winding-connection scheme looks perfect.
Nard psted a photo of a nice multi-color
setup a page earlier in this thread, it's
worth a look.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks Ossi....and Nard.

I think that I should go back to the start date of my holiday and read all of the postings in this thread. Obviously I have missed some good discussions and photos.

Cheers.

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Locking this as awoken by spam

Pages

Topic locked