re; any help mppt

hgmjr

Joined Jan 28, 2005
9,027
I have my AVRSTUDIO up and running as well. I think one of the first things you need to do is add the idle loop I described in one of my earlier replies. You definitely don't want the sofware to execute the timer1 interrupt service routine except in the event of a legitimate interrupt.

hgmjr
 

hgmjr

Joined Jan 28, 2005
9,027
Do you have any specific question at this point on the software changes needed?

Timer1 setup?

ADC setup?

Timer1 Interrupt Service Routine?

hgmjr
 

Thread Starter

olusola

Joined May 21, 2007
74
Do you have your hardware or a hardware simulator handy?
right now no. which is the em, what can i say a bit of not that good. but i will get to it later.
can we simulate in AVR and i tell you the results later?

Do you have any specific question at this point on the software changes needed?

Timer1 setup and Timer 1 ISR?
still trying to get to understand it, as well my idea is that the times keeps the system running, but how critical are they? and also about where and were to put activities under a timer and its implications.



ADC setup?

Timer1 Interrupt Service Routine?
well maybe more of comments than questions.

i think i have set up the ADC converter well, a bit quite ok? what do you have to say about it and the conversion?

TIMER1
i am using your timer setup

thanks

Sola.


... oh so how possible is it really to simulate and expect almost the same results?
 

hgmjr

Joined Jan 28, 2005
9,027
You could take a 30W or better isolated DC power supply that has an adjustable output and put a 20 ohm power resistor in series with it to give you a crude model of a solarcell.

I am sure you are aware that a solarcell's source impedance is more complex than a fixed resistor. This model would have an advantage in that you would know all of the variables and that would allow you to calculate the mppt and then check to see if the processor correctly adjusted for it. You could vary the voltage over a range and see how the micro reacts to the change.

hgmjr
 

hgmjr

Joined Jan 28, 2005
9,027
.

i think i have set up the ADC converter well, a bit quite ok? what do you have to say about it and the conversion?
I think you have set it up fine.

One thing I was wondering about was that you use the internal 2.56 volt reference for the current measurement and then use the AVcc for the voltage.

Was that your intent?

hgmjr
 

Thread Starter

olusola

Joined May 21, 2007
74
i can actually get a pv module with a light source to check that.


i didnt know that i used AVcc at all. was meaning to use the internal 2.56V.
is this from the MUX settings , because from my code for REFS1 and REFS0 i have '1' for both?
// Measure Voltage
ldi Temp, (1<<REFS1)|(1<<REFS0)|(0<<MUX0); set voltage meausurement channel and internal referece
out ADMUX, Temp;
sbi ADCSRA, ADSC; start A-D conversion

/ Measure Current
ldi Temp, (1<<REFS1)|(1<<REFS0)|(1<<MUX0); set voltage meausurement channel and internal referece
out ADMUX, Temp;
sbi ADCSRA, ADSC; start A-D conversion
 

Thread Starter

olusola

Joined May 21, 2007
74
ldi Temp, 0b00000011;
out DDRD, Temp; Port D Output

// Enable Interupts
sei;

//***** First Conversion - Discard)
// Measure Voltage
ldi Temp, (1<<REFS1)|(1<<REFS0)|(0<<MUX0); set voltage meausurement channel and internal referece
out ADMUX, Temp;
sbi ADCSRA, ADSC; start A-D conversion

ADC_wait_K:; wait until A-D conversion finished
sbis ADCSRA, ADIF;
rjmp ADC_wait_K;

in Voltage_L, ADCL; Store Converted Low Bit value
in Voltage_H, ADCH; Store Converted High Bit value
//sbi ADCSRA, ADIF;

sei; // Enable Global Interrupts...

// Idle in this "do-nothing" loop waiting for next interrupt....

Loop_here:
rjmp Loop_here
from the above, i have 2 'sei' please doe this matter?

a note on interrupts, from this i am not sure i understand them? any brief description from your view?

also is the timer meant to execute an interrupts?
i tried simulating the system and it did not go past, the 'do nothing part'
is that the plan?


thanks
 

hgmjr

Joined Jan 28, 2005
9,027
i can actually get a pv module with a light source to check that.


i didnt know that i used AVcc at all. was meaning to use the internal 2.56V.
is this from the MUX settings , because from my code for REFS1 and REFS0 i have '1' for both?
Sorry, my mistake. You are correct. I mis-read the code. You did select the 2.56V reference on both occasions. In reality, I don't think you have to set that value with each conversion. Once should be sufficient since you plan to use 2.56 volts as your reference all the time. OF course there is no harm in setting it as a precaution. I don't think you are going to run out of program memory on this program since you have 16K bytes to play with.

hgmjr
 

Thread Starter

olusola

Joined May 21, 2007
74
Also i noticed that stepping the circuit to the timer interrupt routince, on ending it returns to the 'do nothing' loop.

am i missing something here? or something on interrupts?

thanks
 

hgmjr

Joined Jan 28, 2005
9,027
from the above, i have 2 'sei' please doe this matter?
It does matter. I would lose the first one and keep the one that occurs just prior to entry into the idle loop. The idea behind this strategy is to hold off interrupts until all of the initialzation is complete. The throw-away ADC read can be thought of as initialization.

also is the timer meant to execute an interrupts?
Yes the Timer1 interrupt service routine (ISR) executes when the counter reaches zero in the normal timer1 mode. In mode 4 the timer1_compa interrupt is triggered when timer1 equals the 16-bit value in the OCR1AL and OCR1AH registers.

i tried simulating the system and it did not go past, the 'do nothing part'
is that the plan?
Yes that is the plan. At the moment all of your heavy lifting is being done inside the Timer1 interrupt service routine.

This forever loop is to give the microcontroller a safe place to idol between timer1 interrupts. Does this make sense to you?

When you want to simulate the interrupt occurring you only need to go over to the register control panel and click your mouse on the ADIE bit in the simulated ADCSRA register.

hgmjr

P.S. I'll send you a PM on AVR interrupt schemes in general.
 

hgmjr

Joined Jan 28, 2005
9,027
Also i noticed that stepping the circuit to the timer interrupt routince, on ending it returns to the 'do nothing' loop.

am i missing something here? or something on interrupts?

thanks
That is exactly the way it should work. After executing the interrupt, the "return from interrupt" reti command should return the program execution back to the point in the regular program that was executing at the time of the interrupt's occurrence. In this case that would have been the idle loop.

hgmjr
 

Thread Starter

olusola

Joined May 21, 2007
74
we are doing very good. thanks .

well a bit like, em, how will this handle the mosfet?

oh did i tell you, my demo is expected friday afternoon.
so now working double! how nice

please how do i take the first P0 value? i am not sure where to put it as the timer 1 routine repeats itself and i just want it done only the first time?

also what values of capacitors and resistor for the DAC to the op-amp.

then i am now looking at the output values to the DAC:
which reminds me, making a 10V reference, the digital outputs are 0 and 5V right?


then also when i measure the current, do i then have to divide by 1.25 to get the current? or you think all being relative, we can handle this?

ah yes i have seen the explanation of the negative value recieved and this is from the DAC - you can see from the datasheet, the 'table 1' for the analog output ;


oh, next is my connection of the the output from the microcontroller correct to the LSB and MSB of the DAC?

thanks

thanks
 

hgmjr

Joined Jan 28, 2005
9,027
we are doing very good. thanks .

well a bit like, em, how will this handle the mosfet?

oh did i tell you, my demo is expected friday afternoon.
so now working double! how nice
Are you referring to the day after tomorrow? Can you ask to postpone the demo until next Wednesday? I think the remaining issues could be resolved by then with a day or two of testing included.

please how do i take the first P0 value? i am not sure where to put it as the timer 1 routine repeats itself and i just want it done only the first time?
How about doing it right after the throw-away ADC read and just before the "sei;" instruction.

also what values of capacitors and resistor for the DAC to the op-amp.
As a start, I would use the values in the datasheet in the figure that shows how to hook up the DAC for unipolar operation.

then i am now looking at the output values to the DAC:
which reminds me, making a 10V reference, the digital outputs are 0 and 5V right?
I'll look into this and reply tomorrow.

then also when i measure the current, do i then have to divide by 1.25 to get the current? or you think all being relative, we can handle this?
You should be able to get away with treating the value as a relative value.

ah yes i have seen the explanation of the negative value recieved and this is from the DAC - you can see from the datasheet, the 'table 1' for the analog output ;
I'll have to read up on this.

oh, next is my connection of the the output from the microcontroller correct to the LSB and MSB of the DAC?
I'll take a look in the morning an get back with an answer.

hgmjr
 

JoeJester

Joined Apr 26, 2005
4,390
Olusola,

I don't think it was wrong, I was just curious on the specs. I remember you mentioning 10W earlier and then mentioning the load being from 10 ohms to 300 ohms.

The load wasn't on your schematic. I say that because I assumed your 1.25 ohm resistor was your sample for calculating the current and the MOSFET was the control.
 
Top