Arduino MCUs and MCP48XX/MCP49XX Family DACs - The Basics

Поделиться
HTML-код
  • Опубликовано: 16 сен 2024

Комментарии • 76

  • @thomass.9473
    @thomass.9473 4 года назад +1

    Stumbled upon this while trying to figure out what sort of DAC to use for a school project- super useful! Thank you!

    • @robertssmorgasbord
      @robertssmorgasbord  3 года назад

      You're welcome! And yes, the 8-pin DIP MCP48XX are for sure suitable for small (school) projects on a breadboard.

  • @phuongnamnguyen572
    @phuongnamnguyen572 3 года назад +1

    Thank you Robert. Your guide is amazing. It's raise some fire and passion on me.

    • @robertssmorgasbord
      @robertssmorgasbord  3 года назад

      You're welcome! And thank you for the praise! I hope that fire and passion will lead you to building some amazing circuits.

  • @XumiTran
    @XumiTran 2 года назад +1

    Excellent video. Very easy to follow and understand. Thank you very much for all your time and effort putting into explanation.

    • @robertssmorgasbord
      @robertssmorgasbord  2 года назад +1

      I thank you for the praise! And of course you're very welcome!

  • @philipgiacalone5605
    @philipgiacalone5605 Год назад

    Really excellent work on this series of videos. Thank you for contributing such valuable, deep and clear technical explanations.

  • @rene-jeanmercier6517
    @rene-jeanmercier6517 4 года назад

    Hi Robert. Excellent as usual. It will be very helpfull for my future projects. Your videos are for sure becoming a teaching compement in technical college. Have a safe trip and an excellent holiday . Regards, RJM

    • @robertssmorgasbord
      @robertssmorgasbord  4 года назад +1

      Hello René-Jean, thanks for the praise! I'm happy this video is helpful to you (and maybe others too). And yes, I had a safe trip an a wonderful vacation - a crude video coming up soon :-) Best Regards, Robert

  • @mastermeenie
    @mastermeenie 3 года назад

    Loads of info about MCP4822 online, but nothing as clear as this, very good work

    • @robertssmorgasbord
      @robertssmorgasbord  3 года назад +1

      Thank you very much! To be fair, I started out with the information and libraries available online. "I stand on the shoulders of giants." ;-)

    • @mastermeenie
      @mastermeenie 3 года назад

      @@robertssmorgasbord Of course, as with all high level programming 😁 but the information from datasheets and the library examples, all condensed and explained very well

    • @robertssmorgasbord
      @robertssmorgasbord  3 года назад +1

      @@mastermeenie Thanks again! And yes, the datasheets! That's THE quintessential (and primary) source of information. You could say I love my datasheets :-)

    • @mastermeenie
      @mastermeenie 3 года назад

      @@robertssmorgasbord By the way, in the schematic show at 7:09, is there no need for resistors between the Arduino and the MCP4822's pins ? Also, is the MISO pin definitely free for other purposes ?

    • @robertssmorgasbord
      @robertssmorgasbord  3 года назад

      @@mastermeenie No, you don't need any resistors for a SPI bus, neither pull-up nor series. The MISO pin is controlled by the Arduino SPI library, so it's not free for other purposes, e.g. general I/O. You can of course have other additional slaves on the SPI bus that do use the MISO pin.

  • @andymouse
    @andymouse 4 года назад

    Fantastic stuff, very useful, I look forward to part 2...cheers.

    • @robertssmorgasbord
      @robertssmorgasbord  4 года назад +1

      I'm glad you liked it :-) Part II ("The Details") will be coming this Sunday (27th of September).

  • @buildlover9959
    @buildlover9959 2 года назад

    Very excellent explanation, big thanks and great work.

  • @electronic7979
    @electronic7979 4 года назад +1

    Helpful video

  • @veasy
    @veasy Год назад

    Thank you! I missed the extra 10 uF decouling capacitor! ;-)

    • @robertssmorgasbord
      @robertssmorgasbord  Год назад

      You're welcome! Those decoupling capacitors are easy to miss ;-)

  • @muhammednihalmm261
    @muhammednihalmm261 2 года назад +1

    saved my day

  • @rahaz7073
    @rahaz7073 2 года назад

    Very useful video---Thanks

  • @prettypointlessvideo
    @prettypointlessvideo Год назад

    Excellent video. Thank you so much for helping people who (like me) don't have years of knowledge regarding these things. Using a library is very useful for me. I'm building a synthesizer and this is exactly what I'm looking for (generating control voltages). One question, is there any way to get the output of the DAC up to +5V without using an op-amp? The output of my DAC is maxed out around +4.5V. Thank you!

    • @robertssmorgasbord
      @robertssmorgasbord  Год назад

      With the MCP48XX (internal reference) you are limited to 2.048V (gain setting 1x) and 4.096V (gain setting 2x) output voltage.
      The MCP49XX (external reference) can get up to VDD-0.04V, so 4.96V at 5.00V VDD (close enough?) . Please note that you can run that thing at up to 5.5V VDD. Anyway get 5V out you'll just need an 2.5V external reference (gain setting 2x) or an 5.0V external reference (gain setting 1x). If precision is not a requirement, just connect your reference input to the 5V VDD rail and your done.
      Note: The output amplifier can only supply up to 15mA. If you draw more current, you'll clip the output voltage.

  • @programmingtips404
    @programmingtips404 3 года назад

    Thanks!

  • @redwoodword
    @redwoodword Год назад

    I am trying to figure out if it is possible to connect two MCP4822s to using the library that you are working with here. Is it as simple as defining two dac instances at the top of the code and assigning different pins on the Arduino like this?
    MCP4822 dac(10);
    MCP4822 dac2(9);
    I would then call dac and dac2 in the setup and loop. Am I missing anything?

    • @robertssmorgasbord
      @robertssmorgasbord  Год назад +1

      Yes, it should be as simple as that. Note that you also have to run separate CS (chip select) lines to each of the MCP4822 from your Arduino (you're using pin 10 and 9 as CS pins on the Arduino in your example).

  • @ThevonMusic
    @ThevonMusic 11 месяцев назад

    Thanks for the video! Why the decoupling capacitors at VDD? is this just to get rid of spikes/noise? and also why two of them?

    • @robertssmorgasbord
      @robertssmorgasbord  11 месяцев назад +2

      One of the reason for the decoupling capacitors is indeed to get rid of spikes and noise on the power supply, which otherwise could get through to the analog output(s). Another reason is to buffer changing current requirements by the chip. The power supply trace/wire/cable has some resistance/inductance, so every change in current will cause some change in voltage. The reason for using two capacitor is to cover a wider range of frequencies: The smaller capacitor is good for filtering out higher frequencies and the larger one is good at filtering lower frequencies.

    • @ThevonMusic
      @ThevonMusic 11 месяцев назад

      Thanks!@@robertssmorgasbord

    • @robertssmorgasbord
      @robertssmorgasbord  11 месяцев назад

      @@ThevonMusic You're welcome! If you want to know more details, have a look at that video: ruclips.net/video/BcJ6UdDx1vg/видео.html (not mine).

  • @mumbaiverve2307
    @mumbaiverve2307 8 месяцев назад

    Hi Robert, Is it possible to vary the amplitude of the sinus wave, just with the PWM ? Just curious because I was wondering how closed loop inverters generate a varying amplitude with mosfets directly driving a 50Hz transfomer. TIA.

    • @robertssmorgasbord
      @robertssmorgasbord  8 месяцев назад

      Hi, yes it's possible. If your PWM lookup table models a sine wave with values between 0% and 100%, you get the maximum possible sine amplitude. If, for example, your PWM lookup table models a sine wave with values between 25% and 75%, you get a sine amplitude that's only half of the possible maximum.

    • @mumbaiverve2307
      @mumbaiverve2307 8 месяцев назад

      @@robertssmorgasbord Thanks for the reply. Consider doing a video on this topic :-) , Cheers and a happy new year !

    • @robertssmorgasbord
      @robertssmorgasbord  8 месяцев назад

      @@mumbaiverve2307 You're welcome! And happy new year to you too!

  • @yurkshirelad
    @yurkshirelad 2 года назад

    Excellent video! Is it possible to set the output amplitude to 200mV peak to peak?

    • @robertssmorgasbord
      @robertssmorgasbord  2 года назад +1

      Yes, just use a MC49XX model with an external 200mV reference.

  • @vengug7303
    @vengug7303 3 года назад

    Hello very excellent teaching sir more useful for me . How to increase the frequency of the sine wave please

    • @robertssmorgasbord
      @robertssmorgasbord  3 года назад +1

      Thanks for the praise and you're welcome! To answer your question: In the second part "Arduino MCUs and MCP48XX/MCP49XX Family DACs - The Details" ruclips.net/video/BrZYVWQ-p3U/видео.html I talk quite a bit about performance (frequency).

    • @vengug7303
      @vengug7303 3 года назад

      @@robertssmorgasbord Thank you very much, your explanation is very excellent again thank you ... If interested please share your email address....

    • @robertssmorgasbord
      @robertssmorgasbord  3 года назад +1

      @@vengug7303 You are very welcome! Anyway, for privacy reasons I can't/won't share my email address here on RUclips. As of now I'm not a professional RUclipsr, this is just a hobby for me. Thank you for your understanding!

    • @vengug7303
      @vengug7303 3 года назад

      @@robertssmorgasbord Thank you sir

    • @robertssmorgasbord
      @robertssmorgasbord  3 года назад +1

      @@vengug7303 You're welcome :-)

  • @jenniferw8963
    @jenniferw8963 Год назад

    Thank you for this wonderful video. I have a 4922 layring around and I've been wanting to get into DAC :) How many devices can you run off a single SPI connection? Do you have both the 4822 and 4922 running at the same time off same SPI? I know with I2C you can have a lot of devices on that bus.. dont' know about SPI.

    • @robertssmorgasbord
      @robertssmorgasbord  Год назад

      You're welcome! With SPI you'll need a dedicated slave select (SS) line for each slave device on the bus. Don't let yourself be fooled by only one explicit SS pin being available on the Arduino. You can use any I/O pin for a slave select line. And if you run out of I/O pins you can use a demultiplexer to turn your N I/O pins into 2^N SS lines.

    • @jenniferw8963
      @jenniferw8963 Год назад

      @@robertssmorgasbord Wow, sweet! Thank you, I just journaled this! So I could use like 4 of these dacs on an Arduino nano :) For 8 synth Eurorack CV lines :)

    • @robertssmorgasbord
      @robertssmorgasbord  Год назад

      @@jenniferw8963 Yes, four of these for 8 DAC channels should be no problem on an Arduino Nano. But pumping out 8 channels at audio sample rates (40kHz/44kHz) is not possible with that little MCU. Or do you need just 8 analog voltages to control CV processors?

    • @jenniferw8963
      @jenniferw8963 Год назад

      @@robertssmorgasbord I want to use my Arduino to generate CV signals for eurorack. They are low frequency, typically.

    • @jenniferw8963
      @jenniferw8963 Год назад

      @@robertssmorgasbord Btw, what do you think about the 5V output from a 7805 both powering the arduino, dac chips and most imporantly AREF voltage? Would it be as good as the 4822 internal referenence voltage? Or perhaps better?

  • @user-ms6yj7mk6s
    @user-ms6yj7mk6s 2 года назад

    Can it be used even if the capacity of the capacitor is different? And, is there any reason to have 0.1uF connected in parallel?

    • @robertssmorgasbord
      @robertssmorgasbord  2 года назад

      Well, the two decoupling capacitors are what's suggested in the datasheet. I'm sure it will run with just a 4.7uF or 2.2uF capacitor too, but it might impede the quality of the output signal. The 0.1uF capacitor parallel to the 10uF capacitor is there to decouple higher frequency stuff. The larger 10uF capacitor has a larger equivalent series resistance (ESR) for higher frequencies than the 0.1uF.

    • @user-ms6yj7mk6s
      @user-ms6yj7mk6s 2 года назад

      @@robertssmorgasbord
      Are you saying that it is possible, but there could be a difference in performance? Thank you for kindly letting us know.

    • @robertssmorgasbord
      @robertssmorgasbord  2 года назад

      @@user-ms6yj7mk6s Exactly. With a lesser decoupling (not using the recommended 10uF + 0.1uF) on the VCC rail you might experience more noise on the output signal. Also, the precision of the output signal of the variants with a build in voltage reference (MCP48xx) might suffer.

  • @artyomzingfeld360
    @artyomzingfeld360 Год назад

    Amazing series! Could you explain me one thing, please? I have also built the schematics as you did (arduino nano and mcp4802). Supply voltage to mcp4802 is 4.87 volts, however on the Arduino's Serial Plotter I can see that my output signal is cut off at 3.6 volts on the upper part of the sine wave and the lower part of the signal is not at 0 volts. I set gain to 2, so I should have maximum output of 4.08 volts on upper part of the wave and 0 volts on the lower part of the wave. My signal is supposed to be oscillated from 4.08 to 0 V. Thanks in advance!

    • @artyomzingfeld360
      @artyomzingfeld360 Год назад

      P.S I send to mcp4802 8bit values from an array of total 256 values

    • @robertssmorgasbord
      @robertssmorgasbord  Год назад +1

      First, thanks for the praise! Regarding your question: The output swing of the MCP4802 is between 0.01V and VCC - 0.04V. So in theory you should easily get an output swing between 0.01V and 4.096V (gain 2, your VCC being at 4.87V far above the required 4.096V + 0.04V). So my question is how are you measuring the output of the MCP4802? Since you're using the Arduino's serial plotter I'm assuming your using one of its analog input pins. Here's the caveat: The ATmega's ADCs are crap. I think in the Arduino environment the VCC rail used as reference by default. Could you measure the output of your MCP4802 with a multimeter?

    • @robertssmorgasbord
      @robertssmorgasbord  Год назад +1

      @@artyomzingfeld360 That shouldn't change anything.

    • @artyomzingfeld360
      @artyomzingfeld360 Год назад

      @@robertssmorgasbord you are right, this is the problem of analogRead whereas oscilloscope give it correctly out. Btw, what is the highest frequency have you gotten using SPI.h library, on my side it was something around 50-60Hz with almost no other Arduino logic added (pure reading from array and sending via SPI)? Thank you in advance!

    • @artyomzingfeld360
      @artyomzingfeld360 Год назад

      @@robertssmorgasbord I means why so slow , taking into account that cpu is running 8 MHz (16/2 for default prescaling)