Posted: 11:36am 27 Jan 2021 |
|
|
|
Goodmorning everyone!
thanks Poida for illustrating the logic you constantly implement. you use the powers of two as truncators to then keep the 8bit in the calculations. as a bitshift >> 8 (2 ^ 8) which the cpu interprets quickly. and the PID as a filter of a certain order via software.
i like this type of mod, something slowly I understand
I actually experienced the possibility of increasing the number of NPWM p oints to give a better shape to the output wave (not that at 20khz it is bad!) unfortunately I don't have a distortion meter or a better oscilloscope that allows me to visually check. the rise in frequency is the consequence.
I calculated a whole series of useful frequencies that gave out integers that can be used. there may be problems with the PLL but that's another story
PPWM: 200 | FREQ: 80000 | NPWM: 800 PPWM: 250 | FREQ: 64000 | NPWM: 640 PPWM: 256 | FREQ: 62500 | NPWM: 625 PPWM: 320 | FREQ: 50000 | NPWM: 500 PPWM: 400 | FREQ: 40000 | NPWM: 400 PPWM: 500 | FREQ: 32000 | NPWM: 320 PPWM: 625 | FREQ: 25600 | NPWM: 256 PPWM: 640 | FREQ: 25000 | NPWM: 250 PPWM: 800 | FREQ: 20000 | NPWM: 200 PPWM: 1000 | FREQ: 16000 | NPWM: 160 PPWM: 1203 | FREQ: 13300 | NPWM: 133 PPWM: 1250 | FREQ: 12800 | NPWM: 128 PPWM: 1280 | FREQ: 12500 | NPWM: 125 PPWM: 1600 | FREQ: 10000 | NPWM: 100 PPWM: 2000 | FREQ: 8000 | NPWM: 80
i found the limits using timer1 mode14 with values
PPWM: 200 | FREQ: 80000 | NPWM: 800
because it goes beyond the memory ability, that would be 1600 per fullwave.
I haven't tried with the PROGMEM but I think the limit is the same.
and below
PPWM: 1000 | FREQ: 16000 | NPWM: 160
it might not make sense because the frequency would become audible on an H-bridge and the number of NPWM points would be too low in my opinion.
I remember that my application is for now different from the inverter one. I say for now why the Chinese inveter taken on aliexpress must arrive: D
now i just need to have a super imposed sine wave in phase and with the same zerocross. adjusting amplitude should decrease the overall output voltage or increase it. almost like putting two secondaries of a transformer in series. Transformer AVRs work like this through relays that switch on various secondaries.
so...
I took a while to understand how I could reset the distance between the two zerocross of the waves. so automatically have superimposed wave with concident zero cross, without using the _pcorrect variable that I introduced and which refers to the analog pin.
i thought if i used another ISR interrupt (INT1_vect) on pin3 on which then to enter with our filtered rc wave (of course a square would be better but it should go anyway) in the ISR I could calculate an additional pcint.
ISR (INT1_vect) { pcint1 = pcount + (v1low == 1? NPWM: 0) - NPWM; // get position in 50Hz waveform, -200 to 200 counts // pcint is position in output waveform when this interrupt occurs }
the difference between the two pcint of the two ISRs should give the distance in pcount between the two zerocross.
_pcorrect = pcint1 - pcint;
if the logic is correct you put this value in the final calculation of the phase_error.
what do you think about it?
thank you soon, A. Edited 2021-01-27 21:43 by iannez |