Author Topic: ATmega 32u4 and AD9833 based function generator  (Read 11605 times)

0 Members and 2 Guests are viewing this topic.

Offline GabrielTopic starter

  • Regular Contributor
  • *
  • Posts: 66
  • Country: au
Re: ATmega 32u4 and AD9833 based function generator
« Reply #50 on: June 26, 2020, 12:22:12 am »
Ok, thanks for your explanation. The gain is not software controlled as getting a digital pot with the correct ratings (1k and 50k and something more than like 64 stops between them) turned out to be very hard and expensive... The solution that I settled for is using dual potentiometers and using the Arduino's ADC to read back the values to display. So one side of the pot goes from -12V to +12V for the bias or just works as a variable resistor for the gain and the other side is hooked up to GND and 5V for the Arduino to read. I also implemented a 3 position switch for the gain to switch between the pot, GND and 2.5V. This way I can have a semi-accurate way of setting a 0-5V waveform or one that is perfectly centred on 0.

robca: Fair enough about the 32-bit uC. I ended up going with the Atmegas as it is what I am familiar with and it had all the things I needed. I initially just wanted to go with a 328P but then I chose to go with the 32U4 for its USB functionality. I should just get a small dev board and have a play around with the 32-bit ones... Might just grab one off eBay and give it a shot and use it in my next project, whatever it may be!
 

Offline robca

  • Frequent Contributor
  • **
  • Posts: 257
Re: ATmega 32u4 and AD9833 based function generator
« Reply #51 on: June 26, 2020, 03:05:41 pm »
robca: Fair enough about the 32-bit uC. I ended up going with the Atmegas as it is what I am familiar with and it had all the things I needed. I initially just wanted to go with a 328P but then I chose to go with the 32U4 for its USB functionality. I should just get a small dev board and have a play around with the 32-bit ones... Might just grab one off eBay and give it a shot and use it in my next project, whatever it may be!
I highly recommend getting an ESP32 board (pretty much all have the same functionality, as long as you get one with the USB  integrated. There are even ones with integrated LCD screen, if you want: https://www.banggood.com/LILYGO-TTGO-T-Display-ESP32-CP2104-WiFi-bluetooth-Module-1_14-Inch-LCD-Development-Board-p-1522925.html. If you want hardware debugging for those, you need a F2232L board, which can be used as SWD for the ESP32 line

Up to a year ago, I would have also recommended a Blue Pill, but these days a lot of the Blue Pill boards on eBay have a face STM32, some with a lot of problems. So still good if you are an expert and can make them work, but not for a beginner who would waste a lot of time chasing board issues https://www.eevblog.com/forum/microcontrollers/cheap-bluepill-very-likely-it-has-fake-stm32-right/.

Probably one of the ST Nucleo boards with an STM32F4 would be a good choice. Slightly more expensive, but also immensely more powerful than an STM32F1. The Nucleo boards also have the ST Link on board, so you can hardware debug as well. Or you can build something like this https://github.com/profdc9/STM32surface plus a ~$3 ST Link clone on eBay. https://robotdyn.com/catalogsearch/result/?q=stm32 also has a lot of very good, well designed boards.

The STM32 support USB natively (even USB OTG), while the ESP32 does not and requires USB Serial chip. But on the other hand, if you use the WiFi functionality of the ESP32, you can program only once an OTA bootloader, and from then on the device can be updated over the air via WiFi. There are also a lot of libraries to help preconfigure WiFi on any network, so it's very easy to design a device that can self provision over WiFi and update over the air
 

Offline GabrielTopic starter

  • Regular Contributor
  • *
  • Posts: 66
  • Country: au
Re: ATmega 32u4 and AD9833 based function generator
« Reply #52 on: December 15, 2020, 05:52:25 am »
Hi Guys,

I'm back. Life has been crazy and I didn't get a chance to do much in regards to this project. I now have it finally assembled and it's working mostly. I am facing a couple issues, mostly relating to the amplitude and offset adjustments. I am writing this more as a sanity check then anything but as I have it set up right now, the first op-amp (amplitude) has a maximum gain of ~40 (1+50k/1.3k) and the second one has a gain of 2 (1+10k/10k). The output of the AD9833 is ~600mV p2p so to get that to the maximum +-12V range I need a gain of 40. So I would need really the first one to have a gain of only 20 so that the pot covers the entire range and doesn't "clip", right?

Apart from these issues, everything seems to be working just fine the AD9833 seems to be happy and generates all the waveforms and frequencies as requested, once again thanks for all the help in the earlier stages!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf