Author Topic: Fast square wave with arduino and mosfet  (Read 1291 times)

0 Members and 1 Guest are viewing this topic.

Offline ManlishPotato

  • Contributor
  • Posts: 26
  • Country: se
Re: Fast square wave with arduino and mosfet
« Reply #25 on: September 20, 2019, 07:21:48 pm »
Wow I'll have to read through your reply a couple of times to understand it. But really, i'm not looking for efficiency and exactness, i just want to get in the ballpark of the right resonant frequency, to calculate the inductance of the coil.

In that case most of what I said is pretty useless.  But you may still want to only lightly couple the FET to the tank circuit, otherwise the drain capacitance will effect the resonant frequency.
Ok! What do you mean by "lightly couple the FET"?
 

Offline ledtester

  • Frequent Contributor
  • **
  • Posts: 535
  • Country: us
Re: Fast square wave with arduino and mosfet
« Reply #26 on: September 20, 2019, 07:28:55 pm »
Can't check what the value of the cap was right now, and I don't know the inductance of the coil, that was the start of the project, to observe the resonant frequency, to calculate the inductance.

Just excite the tank with a sharp impulse and observe the frequency of the oscillations.

Here's a circuit which will excite a tank at its resonant frequency:

840276-0

Then just measure the frequency and from knowing the cap value you can get the inductance.

Discussion of how it works:

https://electronics.stackexchange.com/questions/282451/how-is-this-oscillator-circuit-supposed-to-work
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 1389
  • Country: us
Re: Fast square wave with arduino and mosfet
« Reply #27 on: September 20, 2019, 07:56:16 pm »
I made some annotations on your last circuit and have a few thoughts:

 - I assume you are powering the circuit by +6V through R1.
 - Remove R2 as it is not needed.
 - IF YOU CONTINUE TO CONNECT YOUR SCOPE AS INDICATED, YOU WILL NOT HAVE IT LONG. 
Or you will short out your circuit.  Actually, I don't see how you managed so far unless you are powering the circuit from a battery.



 - You want to connect the scope GND clip to your circuit GND.  Then probe across the MOSFET as shown.

« Last Edit: September 20, 2019, 08:17:26 pm by MarkF »
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 1389
  • Country: us
Re: Fast square wave with arduino and mosfet
« Reply #28 on: September 20, 2019, 08:11:52 pm »
A quick refresher:

   
 

Offline ManlishPotato

  • Contributor
  • Posts: 26
  • Country: se
Re: Fast square wave with arduino and mosfet
« Reply #29 on: September 20, 2019, 08:38:02 pm »
That's a good pointer, but the power supply and arduino that i'm using are actually mains earth isolated, or floating :)
 

Offline ManlishPotato

  • Contributor
  • Posts: 26
  • Country: se
Re: Fast square wave with arduino and mosfet
« Reply #30 on: September 20, 2019, 08:41:18 pm »
Quote
I assume you are powering the circuit by +6V through R1.
Oh and this is true, forgot mark it  :)
 

Offline fourfathom

  • Regular Contributor
  • *
  • Posts: 235
  • Country: us
Re: Fast square wave with arduino and mosfet
« Reply #31 on: September 21, 2019, 12:12:01 am »
Ok! What do you mean by "lightly couple the FET"?

Rather than connect the FET directly to the LC tank, use (perhaps) a small capacitor between the drain and the tank -- much smaller than the tank capacitor.  You would need a resistor from drain to V+ since the tank inductor is no longer providing DC current to the FET.  You do this to reduce the de-tuning effect of the FET drain capacitance, and to reduce the heavy damping of the FET during the "on" state.

What are the values you intend for the tank inductor and capacitor?  The resonant frequency?  How will you be measuring the ringing tank signal frequency?  What kind of accuracy are you trying to get?  All these factors matter.
 

Offline ManlishPotato

  • Contributor
  • Posts: 26
  • Country: se
Re: Fast square wave with arduino and mosfet
« Reply #32 on: September 21, 2019, 12:46:38 pm »
Quote
Rather than connect the FET directly to the LC tank, use (perhaps) a small capacitor between the drain and the tank -- much smaller than the tank capacitor.  You would need a resistor from drain to V+ since the tank inductor is no longer providing DC current to the FET.  You do this to reduce the de-tuning effect of the FET drain capacitance, and to reduce the heavy damping of the FET during the "on" state.

What are the values you intend for the tank inductor and capacitor?  The resonant frequency?  How will you be measuring the ringing tank signal frequency?  What kind of accuracy are you trying to get?  All these factors matter.

Can't check the values right now since i'm not in the office. I'll post an update on Monday once i get a chance to check it out. But i can say that the resonant frequency is or more or less unknown and that's the purpose of the experiment, to use the resonant frequency to calculate the inductance. I'm not really looking for accuracy, only to get in the ballpark of the right value.
Oh and i'm using a digital oscilloscope to view the experiment.
 

Offline ledtester

  • Frequent Contributor
  • **
  • Posts: 535
  • Country: us
Re: Fast square wave with arduino and mosfet
« Reply #33 on: September 21, 2019, 01:05:00 pm »
The default circuit for the Falstad simulator shows how to excite a tank with just a switch:

https://www.falstad.com/circuit/

The 10R - 1H - 15 uF side is your tank, the 10R representing the internal resistance of the tank.

The 100R is there to limit the current through the inductor when you hold down the switch.


 
The following users thanked this post: ManlishPotato

Offline ManlishPotato

  • Contributor
  • Posts: 26
  • Country: se
Re: Fast square wave with arduino and mosfet
« Reply #34 on: September 21, 2019, 02:23:42 pm »
Quote
The default circuit for the Falstad simulator shows how to excite a tank with just a switch:

https://www.falstad.com/circuit/

The 10R - 1H - 15 uF side is your tank, the 10R representing the internal resistance of the tank.

The 100R is there to limit the current through the inductor when you hold down the switch.

That's pretty cool!
I guess what basically i'm suggesting is to replace the button operated switch with a mosfet, and turn it off and on at just the right time to achieve stable oscillation.
 

Offline fourfathom

  • Regular Contributor
  • *
  • Posts: 235
  • Country: us
Re: Fast square wave with arduino and mosfet
« Reply #35 on: September 21, 2019, 04:11:02 pm »
I guess what basically i'm suggesting is to replace the button operated switch with a mosfet, and turn it off and on at just the right time to achieve stable oscillation.

That "stable oscillation" part is going to be quite tricky.  Driving the LC tank with a mosfet, 50% duty-cycle, at anywhere the natural resonant frequency of the tank will just show you the frequency of the driving squarewave.  Even lightly-coupled to the tank as I have mentioned, the frequency will be forced by the driving signal.

Your best bet may be to set the driving frequency to be much lower than the tank resonant frequency (say 10x or 100x lower), and with your scope observe the ringing that follows the "off" portion of the driving waveform.  You should initially see a high voltage transient ringing at the tank resonant frequency that decays over time.  The amplitude and duration depends on mainly the "Q" of the inductor and the speed of the mosfet cutoff.  You will still want to compensate for the mosfet drain capacitance and scope probe capacitance.  You will want a current-limiting resistor in the drain circuit, and do be careful that the transient voltage doesn't exceed the mosfet specs.
 
The following users thanked this post: ManlishPotato

Offline ledtester

  • Frequent Contributor
  • **
  • Posts: 535
  • Country: us
Re: Fast square wave with arduino and mosfet
« Reply #36 on: September 21, 2019, 05:58:58 pm »
I guess what basically i'm suggesting is to replace the button operated switch with a mosfet, and turn it off and on at just the right time to achieve stable oscillation.

If your goal is just to get a stable trace on your DSO so that you can measure the period, as fourfathom said, you only need to pulse the tank once in a while -- like once a second or perhaps once every 1/10th of a second.

If your goal is to produce a continuous signal at the resonant frequency of the tank then I would recommend the LM311 circuit I referred to above. It naturally finds the right time to inject a new impulse. This is important as to not affect the frequency of the oscillation.

You have the same situation when pushing someone on a swing set... if you push them at the bottom of the swing trajectory you will make them go higher without affecting the period and frequency of their motion. If you push them at any other point you will change the amount of time it takes to complete the next swing.





 
The following users thanked this post: ManlishPotato

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 1919
  • Country: us
Re: Fast square wave with arduino and mosfet
« Reply #37 on: September 22, 2019, 02:43:01 am »
Screenshots below show a tank circuit ringing in response to a square pulse from a mosfet, and a tank circuit excited by "scratching" the terminals of a 9v battery to produce a spiky pulse. The frequency of the inductive ringdown is easily measured in each case, and it's a good exercise in scoposcopy, especially using the single shot mode to capture the "scratch" ringdown. This frequency, along with the known capacitance or inductance, can then be used in your favourite tank circuit calculator to determine the unknown value.
http://www.1728.org/resfreq.htm

This video may also be of interest to the OP:


The easiest person to fool is yourself. -- Richard Feynman
 
The following users thanked this post: ManlishPotato

Offline JustMeHere

  • Regular Contributor
  • *
  • Posts: 185
  • Country: us
Re: Fast square wave with arduino and mosfet
« Reply #38 on: September 22, 2019, 05:35:05 pm »
BTW, why do you use i resistor in series to the gate of the mosfet, isn't mosfets voltage driven unlike bjt's?

This is to stop the mosfet pin from drawing/sinking too much current when it changes state.  It looks like a small cap when it does this.  So it behaves as a straight short for a (very) brief time.

There should also be a high value pull down between this resistor (100k to 1M) and the pin.  This will stop the pin from floating during programming and chip start up.
 

Offline ManlishPotato

  • Contributor
  • Posts: 26
  • Country: se
Re: Fast square wave with arduino and mosfet
« Reply #39 on: September 25, 2019, 01:45:53 pm »
Update! 25-09-2019
Hey! I have finally had som time to work on the project!
I was able to excite the tank by using a push button like in the schematic suggested by ledtester :) That gave me a stable ish frequency that when converted comes reasonably close to the actual value. The values were 0.15 mH and 10mH and the cap was a 2.2nF ceramic capacitor. I have tried to use a mosfet in place of the P Button, but that gave me an inaccurate frequency. I tried to "lightly" couple the fet like fourfathom suggested, but i had no luck with this, could you suggest which values of coupling capacitor and resistor from drain to V+ should be used?
I included a schematic with the mosfet and the produced waveform after the push button is released.

Would it be possible to get close to the actual resonant frequency, or should i use something like a bjt or igbt instead?
Lots of thanks!
//Benji
« Last Edit: September 25, 2019, 01:49:20 pm by ManlishPotato »
 

Offline fourfathom

  • Regular Contributor
  • *
  • Posts: 235
  • Country: us
Re: Fast square wave with arduino and mosfet
« Reply #40 on: September 25, 2019, 07:40:40 pm »
Here's a very simple circuit and simulation waveform.  I'm using a 2n3904 bipolar transistor and a 10K resistor for the LC tank stimulus coupling.  Actually, with the inductor and capacitor values in your LC tank, the output capacitance of the transistor (either bipolar or mosfet) is fairly inconsequential, but the 10K resistor does serve to limit the transistor current and reduce the voltage peaks on the ringing tank circuit.  If I drop this resistor to 100 Ohms (for example), when the transistor switches off the collector voltage spikes up to 140V -- well past the collector breakdown voltage -- and then swings down negative and forward-biases the base-collector junction.  Neither of these is a good thing, and show how you need to watch the voltage spikes when dealing with an inductive load.

I have a 1KHz square wave driving the transistor, but you could go with a much narrower "on" pulse if you like.  You could replace the bipolar transistor with a mosfet if you like.

You can also insert a small diode (1n4148 or similar, cathode towards the collector) between the transistor collector and the series resistor.  This will block the reverse voltage and avoid collector-base-diode clamping.  Doing this lets you substitute a 1K resistor for the 10K to increase the stimulus current and give you a bigger tank waveform voltage to measure.

The tank voltages and duration of ringing will somewhat depend on the inductor series resistance.  I assumed a resistance of 10 Ohms in my simulations.  Lower resistance will give you a slightly bigger ringing voltage and a much longer ringing duration.  Looking at the damping on your waveform, I would guess that the inductor resistance is closer to 100 Ohm.
« Last Edit: September 25, 2019, 08:59:53 pm by fourfathom »
 

Offline ManlishPotato

  • Contributor
  • Posts: 26
  • Country: se
Re: Fast square wave with arduino and mosfet
« Reply #41 on: September 26, 2019, 01:27:42 pm »
Ok i've tried the schematic you sent me, it gave a nice oscillation, but the frequency was wrong! It had a frequency of about 4.90kHz, whereas it should be closer to 33.93 kHz. Any ideas what the reason of this could be?
I was using a BC337 npn bjt transistor and a 1n5255b zener diode (which i hope is a good stand-in to the diode you were using since i didn't hava any on hand).
The voltage was still +7v and the cap and coil values are the same. The base resistor was the same you were using, 1k.

The images are respectively using the following resistors:
10k
1k
560
220
 

Offline fourfathom

  • Regular Contributor
  • *
  • Posts: 235
  • Country: us
Re: Fast square wave with arduino and mosfet
« Reply #42 on: September 26, 2019, 04:25:09 pm »
Ok i've tried the schematic you sent me, it gave a nice oscillation, but the frequency was wrong! It had a frequency of about 4.90kHz, whereas it should be closer to 33.93 kHz. Any ideas what the reason of this could be?
I was using a BC337 npn bjt transistor and a 1n5255b zener diode (which i hope is a good stand-in to the diode you were using since i didn't hava any on hand).
The voltage was still +7v and the cap and coil values are the same. The base resistor was the same you were using, 1k.

The images are respectively using the following resistors:
10k
1k
560
220

Are you sure about the component values?  I agree, your 10mH / 2.2nF tank should resonate around 33.9 KHz.

The frequency of the ringing tank circuit will only be affected by the values of L and C, and any stray reactance in the circuit.  The zener you used has a reasonable low capacitance when reverse-biased, and even if you removed it from the circuit the tank ringing frequency will be virtually unchanged.  Your transistor is a fine choice for this circuit (as long as the ringing voltage doesn't exceed the Vce breakdown voltage, which it doesn't).  The transistor output capacitance is about 15pF, which is trivial here given the 2.2nF tank capacitor.

I notice in your previous post you also show a 4.9 KHz tank oscillation frequency.  I suspect that your inductor is not really 10mH, or possibly the capacitor is not 2.2nF (or both).

Another interesting thing is that your ringing tank voltage is much smaller than I get in my simulation (with a 1K series resistor I get 20V P-P but you get about 3.7V P-P).  Can you measure the DC resistance of your inductor?  In my simulation I have the inductor resistance at 100 Ohms, which is pretty high for a 10mH part.

Finally, in your previous schematics you show "DSO", which I assume is your digital storage oscilloscope connected directly across the tank circuit.  Is this a differential measurement?  The top of the tank is at +7V so I hope your scope ground isn't connected there.  The fact that the tank voltage goes negative when the transistor switches off tells me that the +7V rail is your ground reference.  I don't see how this will affect the resonant frequency, but it might be simpler to measure the tank signal relative to DC ground.  There will of course be a +7V offset.

 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 1919
  • Country: us
Re: Fast square wave with arduino and mosfet
« Reply #43 on: September 26, 2019, 10:58:43 pm »
Here's where we would like to see photos of the components.

Sure enough the scope trace, measured by the horizontal graticule markers, agrees with the "numbers in boxes" 4.9 kHz displayed by the scope (although there is some error there due to the way the Rigol measures frequency when the screen isn't completely filled with the waveform). And sure enough your favorite tank calculator says, given the stated tank component values, that the ring frequency should be about 33.9 kHz. And as we have seen the simulation also agrees. And we believe that the schematic of the probing connection, while "unorthodox" should still yield the correct resonant frequency.

So please let's have a nice look at the components in question so we can verify their values, as that seems to be the only explanation for the discrepancy.
« Last Edit: September 26, 2019, 11:02:12 pm by alsetalokin4017 »
The easiest person to fool is yourself. -- Richard Feynman
 

Offline fourfathom

  • Regular Contributor
  • *
  • Posts: 235
  • Country: us
Re: Fast square wave with arduino and mosfet
« Reply #44 on: September 26, 2019, 11:10:15 pm »
The fact that the tank voltage goes negative when the transistor switches off tells me that the +7V rail is your ground reference.  I don't see how this will affect the resonant frequency, but it might be simpler to measure the tank signal relative to DC ground.  There will of course be a +7V offset.

When I wrote the above comment I got my reference points turned upside down.  It looks like your 'scope "ground" reference is on the driven side of the tank circuit, and the probe point is on the +7V rail.  If this is a true high-impedance differential measurement this shouldn't matter.  If somehow your actual scope ground is connected to the driven side of the tank, then this could dramatically affect the oscillation amplitude and frequency.

And yes, some photos of the components might give us a better idea of what's going on.
 

Offline ManlishPotato

  • Contributor
  • Posts: 26
  • Country: se
Re: Fast square wave with arduino and mosfet
« Reply #45 on: September 27, 2019, 03:33:36 pm »
Aaaaand apparently i'm an idiot!
Yes i had the oscilloscope hooked up in parallel to the tank circuit, exactly like in the schematic with normal 10x probe. I'm pretty new to oscilloscope's, so i'm still kinda learning where to place the probes for accurate readings. I know how to do it safely, i'm just not familiar to all the intricacies of the practice just yet. The circuit is virtually the same, this time i was using a 560ohm resistor. I included some pictures of the waveform down below, one with 10mH inductor, and one with 0.15mH. Using a resonant freq calculator gives us reasonable values of 11.105mH and 0.1332mH.
In these i had the probe ground connected to the lowest ground in the circuit and the other end connected to negative side of tank circuit.
I also included some pictures of the circuit of anyone is still curious :)

The conversation might go on, but i would like to thank fourfathom and anyone who helped me find a solution!
//Benji
 

Offline fourfathom

  • Regular Contributor
  • *
  • Posts: 235
  • Country: us
Re: Fast square wave with arduino and mosfet
« Reply #46 on: September 27, 2019, 03:57:39 pm »
Yes i had the oscilloscope hooked up in parallel to the tank circuit, exactly like in the schematic with normal 10x probe.

It's working!!!  Great news!

To be honest, your probing "technique" is a problem that that most of us old-timers would't have been considering when troubleshooting this circuit.  You must be using a floating (non-grounded) power supply, or (shudder) not have your 'scope grounded, because otherwise you would have short-circuited the power supply through the inductor.  Usually we clip the scope probe ground to "circuit ground".  If we want to measure a signal relative to some other voltage (directly across the tank circuit in your case) we will use two probes and subtract the signals.

Could you measure the inductor resistance for me? (might as well measure both of them.)  I'm still curious about the amplitude and "damping" differences between your circuit and my simulation.  It's probably due to resistance.

And thank you for sticking with this and reporting back.  I'm here to a large extent for the "puzzles".  My wife likes crosswords, and I like circuits!
 

Offline ManlishPotato

  • Contributor
  • Posts: 26
  • Country: se
Re: Fast square wave with arduino and mosfet
« Reply #47 on: October 07, 2019, 01:44:20 pm »
For anyone still interested, here is the final schematic i used to achieve my goal!
I also included a picture of the final soldered project :)
 

Offline ledtester

  • Frequent Contributor
  • **
  • Posts: 535
  • Country: us
Re: Fast square wave with arduino and mosfet
« Reply #48 on: October 07, 2019, 07:04:50 pm »
Using the ring-down method:

http://www.giangrandi.ch/electronics/ringdownq/ringdownq.shtml

the Q of your tank is around 19.

 
The following users thanked this post: ManlishPotato


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf