Powered by Invision Power Board

Forum Rules Forum Rules (Please read before posting)
  Reply to this topicStart new topicStart Poll

> Computer Controlled Square Wave Generator, Driving MOSFET gates with digital signal
  Posted: January 08, 2012 07:06 pm
Reply to this postQuote Post


Group: Members+
Posts: 1
Member No.: 36,341
Joined: January 08, 2012

I am trying for some time to control/drive a simple N-channel MOSFET gate with a computer. Therefore I need a TTL 5 to 12 V output signal from my computer. From what I know, the only output capable of such thing is Parallel Port/Centronics. However I'm not satisfied with that, because I can't get it to switch faster than 1ms. sad.gif I've heard speculating that some people have managed to get the maximum switching time out of it, were one bit of info sent acts like a signal picked up by the switching transistors. I wish I could do that, but these are dreams. What I'm only after is kind of a simple square wave generator(emphasize> ONLY SQUARE WAVE) frequency controlled by the computer. What I'm having in mind is a low gate threshold MOSFET acting as a driver for a bigger MOSFET's intended for heavy inductive loads. How can it be more simpler than two transistors? Sadly I wish it were that simple. This low-threshold MOSFET should be controlled by ANY 1V DIGITAL OUTPUT FROM MY COMPUTER. There are MANY "Pick-up points" were I can extract such a digital signal that I can then control with the computer. One is the Parallel port (if someone would actually tell how to make it switch in the KHz range), second is the serial port (here I will need another simple circuit, I say simple because I'm only interested in fast square wave switching, therefore no amplification, no current, no analog signal. Only digital levels. Using pull-ups resistors and additional FET stages to raise the digital level require to open high power N MOSFETs- so what I have in mind is something ridiculous simple. Here using the serial port, I will also need a software). There are many ways I know in theory that a digital output can be extracted from the computer. Another I've heard can be done using the Joystick/MIDI output from a sound card. Another way is through the USB data out pin. But I've also seen another more accessible way to control power FET switching is through the audio output 3.5mm jack stereo output speakers from the sound card. Although in theory I can only achieve a maximum of 20KHz switching frequency, I have to be satisfied with that considering other inaccessible alternatives. The problem with the audio output, is the fact that is weak analog signal. So it must be converted in a high TTL digital output (Analog to Digital conversion ADC) like we see here, or here. I've tried with no success to build such circuits. I like this alternative, because I can easily generate for example exactly 13.4567 Hz in a coil using only a computer and few components which is difficult to do with expensive high precision/accuracy signal/function generators! What can it be more cool than that? cool.gif
Another way through which I'm thinking of controlling the gate switching a MOSFET is through the use of a Soundcard that has a digital output. What can I do about that? wacko.gif Another possibility I'm considering is using the PWM yellow wire fan speed control going into any of the cooling fan in the computer.Is it possible to extract that PWM and use it to drive a low-threshold n channel MOSFET acting as a driver for a bigger more powerful heavy switching nMOSFET? If yes, then I'm going to also need the software that controls the speed of the fan). What schematic should I use? The only thing I am finding on the web regarding all these things, are people that are controlling leds, servos, motors, relays and all kinds of garbage, mad.gif except a simple common ordinary MOSFET !!! Then you have a Square wave (only) generator controlled by the computer. Isn't that cool or what? thumbsup.gif Another problem I have to consider with all these possibilities presented, is which of these can most easily provide an almost DC output for longer periods of time, say when I'm trying to output a 50% duty cycle 0.5 Hz frequency switching. This means that I'm not only interested in peaks, or one-shots or low duty cycle. So a S/R latch IC might be required. Therefore I seek a way to generate computer controlled high power/high frequency/adjustable duty-cycle/PWM fast switching using one of the methods described above. Can anybody please help me with advices, suggestions, links or a diagram or something?
PMEmail Poster
Posted: January 08, 2012 09:26 pm
Reply to this postQuote Post

Forum Addict ++
Group Icon

Group: Moderators
Posts: 19,505
Member No.: 73
Joined: July 24, 2002

Computers are great signal generating machines. You're looking at a ridiculously high bandwidth signal right now.

Unfortunately, most sources aren't very general: the video output specifically produces signals intended to drive a raster scanned display, so although you can control the signal levels during a scan line (simply by drawing graphics on the screen), you can't stop it from taking over at the edges. You can control when the screen edges occur (if you have access to the hardware), but you can't eliminate them.

Serial output has a fair bit of control, but it's limited in timing and bit patterns, and is usually fairly slow (although >100kbaud isn't too bad for switching purposes). Its control signals are asynchronous, and could be used in much the same way as the parallel port.

The parallel port is the only truely general digital output available (if you have one equipped). Since it was introduced, it's been little more than a couple gates driven off the data bus. Back in the day, timing was guaranteed -- with nothing to interrupt operation, the processor has direct control over everything.

However, even back in the day, interruptions were common -- system timer, keyboard, hard drive access, system function calls, etc. If you need a perfectly coherent signal source, a computer will NEVER give you what you want.

These days, things are even worse. Not only does the user have only minimal control over the processor, but the processor doesn't even have direct control over I/O operations -- these are carried out by the system chips on the motherboard. It's also more difficult to even use the parallel port -- this requires operating system control, which means installing a driver for Windows users, or sudo for Linux users.

And the whole situation is even worse if your computer doesn't even have a parallel port. USB dongles are available, but it's my understanding that these are only good for communication with legacy devices. If nothing else, latency is controlled by, not only operating system and computer resources, but the USB controller as well, which does not guarantee timing constraints. More and more, achieving reliable timing is less and less likely to succeed.

The best solution today is to use an embedded system (microcontroller, CPLD or FPGA) with USB interface to deliver commands to the signal generator, while the generator performs its task independently, guaranteeing internal timing. One could also purchase an existing signal generator (with far more options than a simple digital system would have) and a USB to GPIB (IEEE-488) interface to do the same thing. Most digital function generators have this type of interface, which allows remote control and networking of test equipment for just this purpose. HP/Agilent signal generators are very good.


Answering questions is a tricky subject to practice. Not due to the difficulty of formulating or locating answers, but due to the human inability of asking the right questions; a skill that, were one to possess, would put them in the "answering" category.
PMEmail PosterUsers Website
Posted: January 08, 2012 09:41 pm
Reply to this postQuote Post

Forum Addict ++

Group: Spamminator Taskforce
Posts: 10,629
Member No.: 2,735
Joined: June 21, 2005

There are plenty of soundcard signal generator software programs out in the interweb (such as http://www.techmind.org/audio/#siggen ).

Taking the audio output throuogh and external buffer/driver should be simple enough.

There will be programs out there that allow settings for m/s ratio as well as frequency.

May contain nuts
PMEmail PosterYahoo
Posted: January 09, 2012 12:33 pm
Reply to this postQuote Post

Forum Addict ++

Group: Cleanup Taskforce
Posts: 6,053
Member No.: 1,770
Joined: December 31, 2004

Hi There,
Welcome to the forums, I'd recommend that with the font/colours we use here your messages will be a lot more readable if broken up using line breaks and paragraphs liberally.

Thanks and have fun!
PMEmail PosterUsers Website
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll


:: support us ::

ElectronicsSkin by DutchDork & The-Force