iannez Newbie
 Joined: 05/07/2019 Location: ItalyPosts: 23 |
Posted: 03:31pm 24 Jan 2021 |
|
|
|
Hello Podia, thanks for the edited sketch! I almost understood how everything works ...
I am over 40 and I don't go to university, even if that's one thing in the lineup that I would like to do sooner or later. I consider myself an experimental physicist in heart and mind, first because I love physics and then because I adopt this type of philosophy also in life, but in my daily work I am a humble linux system administrator.
I have always had a passion for electronics. but unfortunately I discovered microcontrollers only this last year due to Covid as I am working from home and I have some time to devote myself to these studies.
I tested your sketch and obviously it works perfectly: D
as a generator I used the sketch present at the link on the previous page which uses the dds technique and produces a very stable sinusoid in frequency, also modifiable via pot if desired.
some photos:
phase KO, no pin D2 linked


phase OK, pin D2 linked via optocoupler and green LED light


in the last photo there are the two superimposed waves
I apologize for the awful setup. I will buy a rigol 1054 as soon as possible :)
I only had to "modify" a couple of things to get the two waves in perfect phase with the same zerocross. I read about this practice in one of your previous posts. I inserted the _pcorrect variable which is managed through pin A0 mapped in the boundary values -200, 200 because I did not know regardless the correct value. I did some tests :) then I made the variable fixed so it doesn't flicker in real use.
volatile int _pcorrect;
void loop() _pcorrect = map(analogRead(A0), 0, 1023, -200, 200); //_pcorrect = -169;
ISR (INT0_vect) phase_error = (pcint - _pcorrect); //default value sketch orig. 4
I guess there is an automatic way to make the phase shift tend to about 0.
in practice now it is like the nano variac but with PLL and fullwave, great for experimenting with a couple of things without using the H bridge and using low voltage for now :)
I hope I can ask you a few more questions about the operation of the sketch without abusing your patience.
I have already read all the threads concerning the nanoverter, but I can't find the correlations in the use of some variables.
#define NPWM 200 here it is clear, number of sinusoid points created in array l, even if you then create one with 201 points.
#define PPWM 800 here I imagine that 800 derives from dividing the arduino clock (16mhz) by 20khz of the PWM carrier 16 000 000/20 000 = 800 correct? but when you use it here OCR1A = PPWM / 2 + c; what does it mean?
uint16_t l [NPWM + 1]; why do you use 200 + 1 values? to something to do with the v1low toggle? to get 50hz we use 20khz / 400 = 50hz if I use 201 I get 20khz / 402 = 49,7512hz what logic should i follow?
I probably lost something on the way :)
thanks for your time, A. Edited 2021-01-25 01:33 by iannez |