AVR & MCP4922 DAC

95 views
Skip to first unread message

jebusrice

unread,
Jun 19, 2020, 7:33:27 PM6/19/20
to mozzi...@googlegroups.com
Hi everybody!

I changed the title to make new thread but replied to the comment from TomC about his update.

Ok I have AVR Arduino (326-p).  I can make mozzi output it's pwm, that all works.

I hook up MCP4822 to the arduino using the SPI bus.  I run some test i find on the internet it works fine, I can output voltages by typing number for the 0 - 4095 range ( i can post code but dont think it will help and there are lots of examples on the internet to do this)..
I'm using pin 10 for SS, 11 for mosi, 13 for sck.  I grounded LDAC on the dac chip as I have one dac chip. As is say, this is good and i can output voltage numbers on the two channel with other software.

I download fresh mozzi from sensorium github and install library.
I copy the example from the pull request linked here, copy it into new sketch, save it.
I compile, realize this is missing the https://github.com/tomcombriat/DAC_MCP49XX from the include <DAC_MCP49xx.h> so I go get that and install it.
I update define SS_PIN to 10
DAC_MCP49xx dac(DAC_MCP49xx::MCP4921, SS_PIN) and change the chip to MCP4922 as in the library there is no MCP4822 but they are nearly the same and 12 bits is what this chip needed.
I upload to arduino, on the "old" PWM output I can hear something is different as PWM signal is on but sounded broken up.
Nothing from the dac at all.
I look again at the example.  It says #define EXTERNAL_AUDIO_OUTPUT true should be uncommented in mozzi_config.h.
I do this but dac still not working.  This fixes the bad pwm output now.

Did I miss something?  When stuff does not work it is always when I miss things!

peace to all
JR


Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Wednesday, 17 June 2020 16:54, Tom Combriat <tomco...@live.fr> wrote:

Hey!

They are completely compatible, only the voltage reference is different. This PR has been tested with both MCP49xx and MCP48xx, for both Arduino AVR and STM32!
Tom

Le mercredi 17 juin 2020 00:50:55 UTC+2, Jebus Rice a écrit :
Hi!

Has anyone got an MCP4822 to work as the external DAC for mozzi?  I have 4 of these sitting around not doing much.

Not sure how different these are to the MCP4922.

JR

Tom Combriat

unread,
Jun 20, 2020, 6:53:15 AM6/20/20
to Mozzi-users
Hey!
Could you post your complete sketch here? I might be easier to spot the problem.
A few comments:
- I tested MCP4822 so normally there should not be any problem when declaring it as 4922
- I see you are using SS as 10, so you should comment this line: dac.setPortWrite(true); //comment this line if you do not want to use PortWrite (for non-AVR platforms)
- Using portwrite will greatly improve perfs: pin 7 on Uno and similar, pin 38 for mega.
- What arduino are you using exactly?

Hope it helps,

jebusrice

unread,
Jun 20, 2020, 7:51:32 AM6/20/20
to mozzi...@googlegroups.com
You are brilliant! As I thought I just miss it!

This works fine turning off portwrite with ss on 10. Then I move to 7 and make portwrite true and again it works and sounds very good.
I'm using an old arduino with the big chip. IDE says UNO but I have to select Dueminalove or upload breaks.  Dont know why and its working so nothing to fix.
Thanks to you for this perfect help.

Peace
JR


Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
--
You received this message because you are subscribed to the Google Groups "Mozzi-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mozzi-users...@googlegroups.com.

Tom Combriat

unread,
Jun 20, 2020, 7:55:37 AM6/20/20
to 'jebusrice' via Mozzi-users

Cool! Glad to hear it! This is bit confusing at first, the fact that you can choose SS or assign it to portwrite, but I did not find a better/simpler way to do for allowing other platforms to use the lib…

I am happy to see that some people are using this port!

Hasta,

Tom

You received this message because you are subscribed to a topic in the Google Groups "Mozzi-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mozzi-users/F_iOEofFVxs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mozzi-users...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/mozzi-users/_MFg8R2ICKeepF8VSvT6Gfq_X343ExsqrMii3FAscMDJaJuZG3QDYIMLN7x7pH6q2k_R-hLq8QQKR4DaNAsOSh6Rm5uYB1Qt1HNK19npl3A%3D%40protonmail.com.
Reply all
Reply to author
Forward
0 new messages