Author Topic: Waveform Generator Project  (Read 45218 times)

0 Members and 1 Guest are viewing this topic.

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: Waveform Generator Project
« Reply #50 on: October 11, 2015, 07:33:20 am »
Is there any reason as to why you are not just using a classic BJT push-pull buffer on the output versus numerous opamps? I'm not saying what your doing is the wrong way, just genuinely curious why you elected to use more opamps vs the Push-Pull buffer.

http://www.linear.com/solutions/5631

You could just bolt the BJTs to the enclosure or at least mount them on a heatsink like maybe

http://canada.newark.com/aavid-thermalloy/km50-1/heat-sink/dp/10WX1024?ost=km50&categoryId=800000006631
I thought it would be simpler to use op amps stability-wise. I found a few op amp current boosting circuits in this app note.

Quote
Anyone else who is interested in those DACs from AD I posted earlier, I've found a cheap clock source for them.

http://canada.newark.com/analog-devices/ad9516-1bcpz/clock-generator-2-65ghz-lfcsp/dp/46M5289

A little over kill but under 5 bucks. Serial control and 1-32 divider.

You should be able to put together a nice generator for under 50 bucks with those parts plus a few more bits and enclosure.
Haven't built any waveform generators before (except a few op amp triangle/sine wave oscillators and 555 based things but nothing adjustable) so this is my first go at one.
Initially I wanted to make something fairly simple but then as I began looking into DDS-based solutions I ended up adding several features which remove the requirement of tweaking trimmers with the tongue at the right angle :-/O and it got a bit complicated and at some point I was in a bit over my head.
In the end it's not going to be under $50, it's going towards $150 but the stuff I learn in the process of designing this might be worth a lot more than that.
Trust me, I'm NOT an engineer.
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 16226
  • Country: de
Re: Waveform Generator Project
« Reply #51 on: October 11, 2015, 04:35:08 pm »
The extra driver stage is easy at low frequencies, but gets difficult at higher frequencies. Tt's still possibly, though not that easy as the basic LF circuit.
If the output current is not that large, so you can get away with 2 - 4 OPs in parallel, this is likely the easier way.
Some commercial generators also chosse the way of having something like 4 OPs in parallel.

There is also the option to buy a more beefy OP, like LT1206 / LT1210.
 

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: Waveform Generator Project
« Reply #52 on: October 11, 2015, 05:24:17 pm »
There is also the  BUF634
10V into 50 ohms is 200mA which would make the BUF634 the perfect choice.

The extra driver stage is easy at low frequencies, but gets difficult at higher frequencies. Tt's still possibly, though not that easy as the basic LF circuit.
If the output current is not that large, so you can get away with 2 - 4 OPs in parallel, this is likely the easier way.
Some commercial generators also chosse the way of having something like 4 OPs in parallel.

There is also the option to buy a more beefy OP, like LT1206 / LT1210.
If 2x THS4062 can handle the heat then we have a winner.

I've also been doing some simulations with an op amp with its output current boosted by a 2N2222A/2N2907A pair and it seems to work well up to 10MHz which is the highest I want to go.
Trust me, I'm NOT an engineer.
 

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: Waveform Generator Project
« Reply #53 on: October 11, 2015, 07:16:23 pm »
There is also the  BUF634
10V into 50 ohms is 200mA which would make the BUF634 the perfect choice.
Found something cheaper: LMH6321
Trust me, I'm NOT an engineer.
 

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: Waveform Generator Project
« Reply #54 on: October 17, 2015, 12:12:16 pm »
Finally, I have an almost complete schematic for the analog part, excluding the power supplies :D
Any suggestions, pointing out of mistakes and/or questions are welcome.



EDIT: I may have accidentally left out some decoupling caps... ::)
« Last Edit: October 17, 2015, 12:40:57 pm by void_error »
Trust me, I'm NOT an engineer.
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 16226
  • Country: de
Re: Waveform Generator Project
« Reply #55 on: October 17, 2015, 04:20:37 pm »
The comparator used for the square signal is rather slow. I would at least use something as fast as a LM311. Also the hystereses part is rather high impedance and thus slow.
The digital output circuit might also like a small output resistor - just as an extra level of protection and to dampen refelctions if the IC internal diodes get active.

 I don't think separate comparators for PWM and square are needed - just adjust the PWM level to 50% to get the square wave. It might help to get some feedback one the actual PWM level to the µc. For low frequency square am extra divider (e.g. by 2 or 256) might be an option - this also ensures more acurate 50% on/off ratio than the simple comparator.

The output of the LM317 / supply of digital output szage will need decoupling.

Likely one can get away without the two amps U4.1 and U4.2, by just adding the bias to the output of the filter through a resistor. It slightly depends one the comparator used, as the comparator might be a significant nonlinear load.

The output of U8.3 might want extra filtering (e.g. 100 Ohms+10 nF)  to give a low impedance signal to the following fast OP.
 

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: Waveform Generator Project
« Reply #56 on: October 17, 2015, 06:18:45 pm »
U8.3?! Damn you DipTrace, that's U8.2 and U8.2 is U8.1 :palm:

AD8611 is a fast comparator but it's a bit pricey at $5... but I will use a LM311 if fast enough.

For making sure the square wave output is square was planning at some point to add a D-type flip-flop to divide the frequency by 2, reducing the maximum frequency from 10MHz to 5MHz. No more separate comparators for square and PWM. However, I'll still have to switch between the comparator output and the flip-flop output.

U4.2 is needed there for removing the offset from the filtered DDS output and U4.1 is a leftover used as a buffer.

Noticed I screwed up the PWM comparator part... it shouldn't be receiving anything below GND. Using U4.1 as a DC amplifier to bring the DDS_OUT level into the 0...5V range should fix that.
R4, R5, R6 & R17 will be tweaked so the input voltage of the AD603 stays the same, around 50mVP-P.

Just saw I also forgot the decoupling for the LMH6321... will 10u MLCC || 10n MLCC do the job?
Trust me, I'm NOT an engineer.
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 16226
  • Country: de
Re: Waveform Generator Project
« Reply #57 on: October 17, 2015, 07:26:30 pm »
In my memory the LM311 was faster - the MCP6562 is allready faster. So it might not be fast enough, especially with such a small input level. So if there is an left over amplifier, the comperator should get somthing like a 1 V amplitude signal.
the critical part will be short PWM pulses, which are difficult anyway, because there will be no clean fast trigangle.
The MCP6562 has internal hystereses so the expernal circuit can be simpler.
So if possible I would at least keep the option to upgrade to a faster comparator.

There is no real need for an amplifier just to add the offset before the AD603. This can be done purely passive at the low level. Just the controll signal needs to deliver somthing like 1 mA.

Aus für choosing the source of the digital output, I would consider a MUX chip - this would allow for 2 more sources, like PWM from the µC or divided square for even lower frequencies. Using the comparator at less than kHz range might not give very good results, as the slope is rather slow and thus jitter may be higher than needed.
 

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: Waveform Generator Project
« Reply #58 on: October 17, 2015, 08:39:30 pm »
There is no real need for an amplifier just to add the offset before the AD603. This can be done purely passive at the low level. Just the controll signal needs to deliver somthing like 1 mA.
How? I need to remove the DC offset before the AD603 which is what U4.2 is for.
Trust me, I'm NOT an engineer.
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 16226
  • Country: de
Re: Waveform Generator Project
« Reply #59 on: October 18, 2015, 09:18:15 am »
To get rid of the offset, one can just add a negative 1 mA current to the DDS output by a resistor and negative voltage (ideally derived from Vref of the DSS chip). R3 needs to get a little larger than. So one might still need an OP to generate the suitable negative voltage, but this one is essentially DC. I would not expect much drift here, so one might not need to controll the offset via DAC/ADC.  A small residual offset could be compensated after the AD603. The down side is that the DDS chip will see a small negative voltage sometimes negative part of wave, but this is not a problem with a low impedance filter and thus low amplitide (e.g. 100 mV).

Looking at the amplitude, I am not shure the resistor values are correct: at 2 mA peak and effectively 50 Ohm impedance (at least DC / LF), I would not expect 100 mV peak/peak on both sides of the filter.

Alternatively the offset could also be compensate directly at the AD603 input with a divider, R17 and an additional resistor to a negative voltage.
 

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: Waveform Generator Project
« Reply #60 on: October 18, 2015, 09:54:43 am »
To get rid of the offset, one can just add a negative 1 mA current to the DDS output by a resistor and negative voltage (ideally derived from Vref of the DSS chip). R3 needs to get a little larger than. So one might still need an OP to generate the suitable negative voltage, but this one is essentially DC. I would not expect much drift here, so one might not need to controll the offset via DAC/ADC.  A small residual offset could be compensated after the AD603. The down side is that the DDS chip will see a small negative voltage sometimes negative part of wave, but this is not a problem with a low impedance filter and thus low amplitide (e.g. 100 mV).
I'd rather not have the DDS IOUT swing below GND, that's why I used an op amp. Removing U4.1 is not a good idea either because the low input impedance of the next stage (U4.2) will influence the voltage at DDS_OUT.

Quote
Looking at the amplitude, I am not shure the resistor values are correct: at 2 mA peak and effectively 50 Ohm impedance (at least DC / LF), I would not expect 100 mV peak/peak on both sides of the filter.
I goofed that one up too, used 100ohm instead of 50ohm in one place. That means DDS_OUT will swing from almost 0 to about 193.910mV.

Quote
Alternatively the offset could also be compensate directly at the AD603 input with a divider, R17 and an additional resistor to a negative voltage.
The AD603 has a 100R resistor at the input, between VINP & COMM, not sure how that will affect the operation of the divider.
Trust me, I'm NOT an engineer.
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 16226
  • Country: de
Re: Waveform Generator Project
« Reply #61 on: October 18, 2015, 11:01:31 am »
At low frequency the DDS output will see the resistors at both sides of the filter in parallel. So with 100 Ohms at both sides there will be a 50 Ohm impedance. A proper dsigned filter schould keep the same amplitude also in the rest of the pass band.

The low input impedance of the amplifier around U4.2 is not a problem. One can just see this as a part of the terminating impedance of the filter. So one has to reduce R4 acordingly that R4 in parallel with the input impedance of the following stage would give the 100 Ohms. This could go so far as having the differential amplifier with 100 Ohms at the input and no resistor where R4 is. Because of the limited bandwith of the amplifier it's likely still a good idea to have R4 and a higher input resistor for the amplifier.

The input resistance of the AD603 will not chance anything on a divider used to compensate the offset. At zero offset there will be not DC current to ground. The input impedance just reduces the amplitude and the size of any uncompensated offset.
 

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: Waveform Generator Project
« Reply #62 on: October 20, 2015, 08:15:15 pm »
Just to make sure I don't screw up the gain calculations I made a spreadsheet in OpenOffice.
It calculates the output voltage of the DDS, AD603 and the LM6172 + LMH6321 output stage gain.
I'll be tweaking the offset part towards the end of this week.
Trust me, I'm NOT an engineer.
 

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: Waveform Generator Project
« Reply #63 on: November 03, 2015, 06:53:13 pm »
The signal generation and power supply parts are almost done. The Cauer filter has been redesigned yet again. What's left would be to start working on the microcontroller part and writing some firmware for it.
I still have no idea what to do about U22's output in case of short circuit. Add more gates in parallel each with its own current limiting resistor?
Anyway, here's what it looks like now:

« Last Edit: November 03, 2015, 06:59:25 pm by void_error »
Trust me, I'm NOT an engineer.
 

Offline vinicius.jlantunes

  • Regular Contributor
  • *
  • Posts: 225
  • Country: br
Re: Waveform Generator Project
« Reply #64 on: December 15, 2015, 04:41:38 pm »
Subscribed.

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 2149
  • Country: fi
  • Embedded SW/HW.
Re: Waveform Generator Project
« Reply #65 on: December 15, 2015, 04:45:49 pm »
I still have no idea what to do about U22's output in case of short circuit. Add more gates in parallel each with its own current limiting resistor?
You may want to add a 50 ohm series resistor to the U22's output so that the output impedance will match 50 ohms. Thus, you will also get at least some current limiting functionality.
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5491
  • Country: gb
Re: Waveform Generator Project
« Reply #66 on: December 15, 2015, 05:04:24 pm »
Edit, sorry I appear to have necroposted, apologies/

Quote
1. Is the 8-bit DAC like the one in a PIC16F1707 good enough for DC offset adjustment?

I'm currently building a function generator too with the AD9834, PIC16F876, small OLED display and a rotary encoder.

The D/A functionality in the PIC can supply almost NO current.  You will need to buffer it with an op-amp.  I intend to use it to control the signal amplitude instead of the DC offset.  It uses the FS_Adjust pin on the AD9834 which is totally internal on the AD9833. 

You only get 4 bits (16 levels) of amplitude control.  That doesn't seem like a very fine adjustment. 
A Microchip MCP4802 8-bit DAC with a SPI interface would be a better choice.  They are only $1.62 at Mouser.  The MCP4822 is a 12-bit version for $3.16

The PIC in question has opamps on board. The NINV can be connected internally to the DAC you can also select Op Amp Unity Gain Select bit and save another pin, so you have a buffer. The on board OPamps are not spectacular by any means, comparable to many low cost PWM controllers EAs in performance but maybe good enough for the application at hand.

You can also use an external reference with the DAC thereby setting whatever resolution you want. Use the other opamp to buffer a resistive divider off your Vcc rail to the Vref pin, make it whatever you want for ultra cheapo solution. :D

EDIT

The 1707 has no DAC pick the 08 or 09

Edit2

You might try the PIC16F1716 only about a buck in small quantity its been out a couple years, 3 I think minimal errata and nothing major so far.

http://canada.newark.com/microchip/pic16f1716-i-so/microcontroller-mcu-8-bit-pic16/dp/96W5477

I've been there with PIC DACs, _and_ using the onboard opamps. In short, neither the DACs themselves nor the slew rates of the opamps are enough to do a sampling rate of anything much over few hundred kHz.

The best I achieved was with a PIC24FV16KM202 which has dual 8 bit DACs, and as has been stated, loading on the DACs must be minimised or the waveforms is severely distorted.

I did get a reasonably good scope clock and asteroids running on it though, ISTR I had to limit the sampling rate to about 100kSa/s or the probe capacitive loading led to smearing.

 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5491
  • Country: gb
Re: Waveform Generator Project
« Reply #67 on: December 16, 2015, 07:21:41 am »
Apologies, as mentioned in the edit at the head of the post, I realised soon after the post that the conversation I was referring to was old and had moved on.
 

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: Waveform Generator Project
« Reply #68 on: December 18, 2015, 08:05:10 pm »
Edit, sorry I appear to have necroposted, apologies/

I've been there with PIC DACs, _and_ using the onboard opamps. In short, neither the DACs themselves nor the slew rates of the opamps are enough to do a sampling rate of anything much over few hundred kHz.

The best I achieved was with a PIC24FV16KM202 which has dual 8 bit DACs, and as has been stated, loading on the DACs must be minimised or the waveforms is severely distorted.

I did get a reasonably good scope clock and asteroids running on it though, ISTR I had to limit the sampling rate to about 100kSa/s or the probe capacitive loading led to smearing.



Necroposting? My apologies for not keeping this thread alive as I was busy with work... and also the last schematic I posted is a bit outdated...

Anyway, nice vid!

I still haven't decided what MCU I'll use but it's definitely going to be one with USB. Haven't abandoned the project but I'm a bit busy with other things at the moment. If it has a DAC it'll be used to set the current limit for the LMH6321.
Trust me, I'm NOT an engineer.
 

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: Waveform Generator Project
« Reply #69 on: April 25, 2016, 04:50:55 pm »
Back to this project again...

The Square Wave / PWM output will no longer use the signal from the DDS, going to use the a PWM output from the micro that's going to control the User Interface (LCD/Buttons/Encoders, which will be shared by a few projects like a Modular DC Electronic Load , a Lab Power Supply and maybe others), which will be a separate board. An ADC will be used to provide the UI micro with the voltage offset feedback (OFFSET_FB) as well as the actual DC offset at the input of the VCA (NULL_FB) via SPI.

To reduce the number of Chip Select lines on the connector going to the UI board I'll be using a MCP23S08 which will also handle the EF signal from the LMH6321 and set the Square Wave / PWM output level via Q1 & Q2.

USB will be added some time later in the form of a PIC16F1454 running some code based on the CDC example from the Microchip Libraries for Applications.

Am I biting off more than I can chew? :scared:
« Last Edit: April 25, 2016, 04:58:56 pm by void_error »
Trust me, I'm NOT an engineer.
 

Offline grants225

  • Newbie
  • Posts: 4
  • Country: lt
Re: Waveform Generator Project
« Reply #70 on: April 29, 2016, 12:11:14 pm »

The Square Wave / PWM output will no longer use the signal from the DDS, going to use the a PWM output from the micro that's going to control the User Interface (LCD/Buttons/Encoders, ...

I am not familiar with PICs, but run into problems with Atmega doing that. It will be quite hard to run programm code to check buttons, encoders, update lcd and avoid conflicts with PWM rutines. I would sugest to go for separate small micro (kind of attiny 20MHz or PIC equivalent) for PWM. I also whould suggest to add fast pulse out on that micro (changes OC1A pin), which can provide fout up to Clock / 2 MHz.
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 16226
  • Country: de
Re: Waveform Generator Project
« Reply #71 on: April 29, 2016, 01:09:50 pm »
The PWM output from the µC can run in the background as long as you stay within the 16 bit range of the hardware timers. If you need extended resolution it can get tricky.

However the output from the DDS and comparator is still different and sometimes superior, as it can give fine frequency adjustment, just as for the sine wave. The PWM output from the CPU has only coarse resolution at high frequencies - so it is not a full replacement.
 

Offline void_errorTopic starter

  • Frequent Contributor
  • **
  • Posts: 673
  • Country: ro
  • I can transistor...
Re: Waveform Generator Project
« Reply #72 on: April 30, 2016, 03:02:45 pm »
I am not familiar with PICs, but run into problems with Atmega doing that. It will be quite hard to run programm code to check buttons, encoders, update lcd and avoid conflicts with PWM rutines. I would sugest to go for separate small micro (kind of attiny 20MHz or PIC equivalent) for PWM. I also whould suggest to add fast pulse out on that micro (changes OC1A pin), which can provide fout up to Clock / 2 MHz.
Most of the code will be interrupt driven. The PIC16F18855 (or its bigger brothers) which I'll most likely be using has a ton of core-independent peripherals so there won't be too much coding. It also has a NCO (Numerically Controlled Oscillator) module which I will probably use for the square wave once I fully understand how it works (not that difficult).

Another nice feature of this micro is the PPS module which allows assigning different peripheral inputs or outputs to I/O pins which will allow me to switch between NCO output and PWM output on the same I/O pin.

Going to start a topic on the User Interface Project at some point in the near future, after I get most things figured out.

The PWM output from the µC can run in the background as long as you stay within the 16 bit range of the hardware timers. If you need extended resolution it can get tricky.

However the output from the DDS and comparator is still different and sometimes superior, as it can give fine frequency adjustment, just as for the sine wave. The PWM output from the CPU has only coarse resolution at high frequencies - so it is not a full replacement.
I'm aware of that but decided I don't need very high resolution for frequency or duty cycle and I don't need continuous frequency adjustment either, preset values will do.

PWM modules start at 10bit resolution which goes down as you increase the frequency.

For Fosc = 32MHz the PWM module's minimum output frequency would be slightly below 2kHz for the older PICs because of the limited Timer2 clock prescaler values (1, 4, or 16). However the one I'll be using has prescaler options ranging from 1 to 128 which means I can have the PWM output down to 250Hz. That'll do. I'm also ok with 1% steps for duty cycle.
Trust me, I'm NOT an engineer.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf