Page 2 of 2
Re: Arduino interrupt Frequency
Posted: Tue Dec 17, 2024 2:46 am
by viktor_au
Understood Bijumon.
I prefer to use Arduino Nano to test the code.
The reason I have sent you the links to the IDE Ard code is that the author uses only 100 lut values, not 200, as you do.
As well the work of Timer1 in mode8 is very interesting and I thought you will have a look at it.
All the best.
Re: Arduino interrupt Frequency
Posted: Tue Dec 17, 2024 3:14 pm
by Bijumon
hi viktor,
code from above said link i had converted to Flowcode as same, 100 lut values and 10Khz interrupt.
Re: Arduino interrupt Frequency
Posted: Tue Dec 17, 2024 9:53 pm
by viktor_au
Hi Bijumon.
Good job.
The converted by you IDE code works (to a degree).
The problem exists with the LUT table.
I added to the main loop the output to flash the onboard LED (B5).
It does not flash.
For some reason the main loop is frozen.
However the converted by you code works and Timer1 works OK in mode8.
I can be wrong, but I think, the next can be done:
- lut and main loop problem should be solved.
- improve the dead time code.
- create the mechanism of changing the value of Timer1 ISR1.
I think, when ICR1 = 800 the sinewave value is close to zero or zero.
The code line: OCR1A = FCV_LOOKUP * 0.7 + FCV_DTA should be changed as well.
PS
Have you considered the Egs002 module to be used?
Re: Arduino interrupt Frequency
Posted: Wed Dec 18, 2024 11:05 am
by Bijumon
Hi Viktor,
i haven't seen any issue in main loop, i had added LED on D13 and its blinking, may your hardware issue.
LUT just copied from the article as same, didn't change.
That fixed voltage correction value (0.7) and dead time you can change as you whish. i follow the article.
there are inverted signal as well with dead time that's what the filtered signal showing inverted sine as well.
Re: Arduino interrupt Frequency
Posted: Wed Dec 18, 2024 9:48 pm
by viktor_au
Hi Bijumon
About the fixed voltage correction value = 0.7.
The author of the article used this value (I think) as an example.
It is not a feedback value for AC voltage.
-----
Correct me if I am wrong.
Example: If OCR1A = 0, Vout = max.
Set as norm: If Vout = 240v, set OCR1A=5,
Do something if Vout = 260v (OCR1A=0?),
Do something if Vout = 220v (OCR1A=10?),
I think there are a different ways to control the AC voltage.
Any ideas?
Re: Arduino interrupt Frequency
Posted: Fri Dec 20, 2024 7:17 pm
by Bijumon
Hi Viktor,
About the fixed voltage correction value = 0.7 is an Example it can be change as you wish, 0.7 will give 70% of each LUT value.
Eg: 0.5 will give 50% of each LUT value , 0.9 will give 90% of each LUT value.
it can be use to vary the output voltage or stabilize the output voltage use feed back from output.
you have to use a variable instead of fixed value.
Correct me if I am wrong?
in this case Lut value 0 will give always 0% duty cycle and 800 will give 100% duty cycle without voltage correction value.
adding different voltage correction vale will allow to control output amplitude.
i had draw the the circuit in proteus as same as in article ( i don't have full hardware to test it in real world) if you have hardware you can test it.
proteus simulation is working well as attached.
Re: Arduino interrupt Frequency
Posted: Fri Dec 20, 2024 9:54 pm
by viktor_au
Hi Bijumon
Timer1 OCR1A register changes the state of pin B1.
From datasheet:
The 16-bit comparator continuously compares TCNT1 with the output compare register (OCR1x).
When ICR1 value = 0, the OCRIA register value is set to LUT value.
The question.
What is the default state of pin B1?
Is it zero?
I attached the diagram from the datasheet.
Looks like:
If ICR1 counts up, if OCRIA register value = ICR1 value, the pin B1 state changes from 1 to 0.
If ICR1 counts down, if OCRIA register value = ICR1 value, the pin B1 state changes from 0 to 1.
In this case you right, the sinewave graph values follow the OCR1A values.