Hello, I have an Arduino Mega 2560
So, I need to get a signal out of it, It needs to have a frequency in the range of 200 Khz but can go down to 50 Khz or less, I need the signal to be extremely accurate and reliable, So it seems to me that running Timer 1 at those frequencies is not so reliable as there are random delays and some general dirt in the signal, And since i have the Mega i though of this..
We have Timer 1, 3, 4 and 5, All are 16 bit, Why not run two or three of them at the same frequency, Then check them against each other for mistakes? If a timer makes 5 mistakes in places, The other timers make 5 mistakes in other places, We check them against each other the result is a cleaner signal, Is this possible to do this with an arduino board?
Not reliable ? mistakes ? I don't understand.
When you program an internal hardware timer for a certain frequency and have the output go to one of the pins, the output is as accurate as the 16MHz crystal. There will be absolutely no mistakes.
You can not create every output frequency, since the 16MHz is divided with a whole number.
Well, I am using the arduino to directly drive a half bridge of Mosfets, The signal i get out of a half bridge is not uniform and it seems like there are some pulses skipped.
Timers are hardware; once set up they run perfectly consistently. Nothing going on in the MCU should affect them (except of course reconfiguring the timers). External influences are something else again, any circuit can be affected by external fields to a greater or lesser extent depending on its design and the strength of the field.
Well, The half bridge is used to drive a high voltage transformer at resonance, Which happens to be a high frequency, The result is about 80 Kv at high frequencies, Enough to light fluorescent lights at a good distance (About 2 meters), So it is a pretty strong RF field, It was kind of stupid not to use proper shielding anyway.
That's very cool, and dangerous and it brings back memories.
I get about 10 or 30 times more voltage out of a transformer at resonance frequency. Perhaps with your transformer it is even more.
That is also inductive, can you show us the schematics or a drawing of the H-bridge ?
At resonance frequency, the H-bridge generates a square wave, however the current through the transformer is completely different. But as far as I know, the square wave does not have a negative influence on the efficiency.
Are there wires between the Arduino and the H-bridge ? longer than 10cm ?
Keep in mind that using optocouplers is a good option. To isolate the Arduino from the high power / high voltage circuit.
You could use the Arduino to find the optimum frequency
There is a GDT for good isolation, The arduino goes straight into the gdt, The wires are rather short and shielded, Also
Resonance really is black magic
I calculated the resonant frequency of the transformer, However as usual, Calculations aren't quite 100% accurate as they expect optimum conditions and that is not usually provided by hobbyist gear, But at least they give you a place to start
Peter_n:
Do you have an Arduino output connected to one of the GDT (Gate Drive Transformer) coils ? I have not seen an Arduino connected like that.
Of course, There are three coils on the GDT, The arduino's output is on one of the three, The schematic was found online and modified ever so slightly then run with an arduino, But again, The unstable signals are again, Most probably nasty electromagnetic fields interfering with the arduino, A random wire or the bridge itself, I might have to find a metal box, Perhaps an old computer PSU could work, Those also have massive fans and nice ventilation
Also it indeed is very exciting.. And shocking! ]
Edit: Yes i have a horrible enough editing skill to point an arrow in that horrible way
I shielded my entire arduino, The problem persists, Perhaps there are delays during executing code? Arduino flawed? I set it to 280 Khz, Only 250 came out, I tried setting it to 1 Mhz, It was rather accurate, 999300, Help?
When you use a hardware timer it is as accurate as the 16MHz crystal. The output of a hardware timer is completely independant of the sketch, the interrupts, the delays, or whatever.
Do you use a hardware timer ? I don't think so, and if you do, the sketch is wrong.
We can't help if we don't know what you are doing.
So far we have a part of a schematic. The Arduino output to the GDT could be wrong, resulting in missed gate triggers.
Maybe you use TIMER1, but we don't know which library or sketch you are using, so we don't know if you are using the hardware timer output, or a software interrupt generated pulse. I don't even know at what point you measure the frequency.