Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

DAC 10 I2C communication

biedronka

Newbie level 5
Joined
Aug 20, 2022
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
161
Hi there,
I'd need some advice in this task, mentioned in the title above.
In class, we worked on I2C communication achieving combined I2C transaction using ioctl() function (with repeated start sequence). Not sure if I will use it this way, as soon as I manage to implement the code that will work. I'm also using Raspberry Pi in my Linux Environment (VM Machine).
Also, I should test my DAC, at the output I should ensure that several standard waveforms can be generated at the output of the D/A converter. I was thinking about making lookup tables of those waveforms (their digital equivalents) and just loop through.
The reason I'm writing is because I'm a bit lost in information. Not sure about how to configure my DAC, what to include, what to keep in mind ...
I'd really appreciate any kind of directions in this task.
 
first you need to narrow the DAC that you are going to use.. sadly there's a ton of i2c devices, and even with a common bus, each device is configured differently.

let's take in example that you'll use a https://wiki.dfrobot.com/Gravity__12-Bit_I2C_DAC_Module_SKU__DFR0552 it uses a MCP4725 so you should start checking the datasheet of that chip.

any way, that wiki should address most common questions regarding initialization and some examples for raspberry (even the arduino ones, can be used as foundation for a C implementation)

to only one consideration I would have in mind, is that i2c is slow... the base 100kHz frequency (or 10 us per bit) will require at least 270 us to transmit 3 bytes (1 i2c address, 2 data bytes) so you can achieve a max sampling frequency of 3.7 kHz
 
Hi,

if you are referring to Analog Devices DAC10, then it has no I2C interface at all. How do you like to control it?

Klaus
 
first you need to narrow the DAC that you are going to use.. sadly there's a ton of i2c devices, and even with a common bus, each device is configured differently.

let's take in example that you'll use a https://wiki.dfrobot.com/Gravity__12-Bit_I2C_DAC_Module_SKU__DFR0552 it uses a MCP4725 so you should start checking the datasheet of that chip.

any way, that wiki should address most common questions regarding initialization and some examples for raspberry (even the arduino ones, can be used as foundation for a C implementation)

to only one consideration I would have in mind, is that i2c is slow... the base 100kHz frequency (or 10 us per bit) will require at least 270 us to transmit 3 bytes (1 i2c address, 2 data bytes) so you can achieve a max sampling frequency of 3.7 kHz.
Hi,

if you are referring to Analog Devices DAC10, then it has no I2C interface at all. How do you like to control it?

Klaus
Actually, I'm about to use DAC53401 which has I2C interface. This https://www.kernel.org/doc/Documentation/i2c/dev-interface is site I'm using to achieve R/W transactions.
I've already made it to write one R/W transaction to obtain my DeviceID from Status register for example. Now, I'm not sure about configuring bits from General config register, where I'd use to possibility to configure a triangular and square wave.
 
Hi,

You need to decide how your application is supposed to work. (I guess we can't help you with this)
Then you need to read the datasheet - at least as much that you understand it's features and how to use them.
(Professionals need to do this, too)
Then I recommend to write down your own DAC cheat sheet ... where you easily can find each (setup) bit important for your application.

The I2C interface is standard. So you may use any available standard I2C library.
(For each byte you want to read back from the slave you need to "write 0xFF" as dummy byte, to generate the according SCK signals.

It's a good idea to write your own DAC53401 functions (if not using available library).
Your DAC_COMMAND --> [DAC function] --> standard I2C

Waveform generation:
Is not as simple as it sounds. It means you need to folow rules.
* Define your output signal bandwidth (f_u)
* according f_u define your sampling frequency
* according f_u define/design an analog reconstruction filter (connected at the output of the DAC to transfirm the DAC stairs into smooth analog signals)

* Draw (sketch) your own timing diagrams and flow charts before writing code.
* SW: use interrupt to guarantee the DAC access is according your desired sampling frequency
* SW: define buffers (ring buffer, FIFO) to transfer data to the ISR

Don't ask too general questions. Ask elaborated questions by giving all your detail informations, schematics, part values, sketches, referring to datasheet sections/pages .... show what you have done so far.

Klaus
 
Hi,

You need to decide how your application is supposed to work. (I guess we can't help you with this)
Then you need to read the datasheet - at least as much that you understand it's features and how to use them.
(Professionals need to do this, too)
Then I recommend to write down your own DAC cheat sheet ... where you easily can find each (setup) bit important for your application.

The I2C interface is standard. So you may use any available standard I2C library.
(For each byte you want to read back from the slave you need to "write 0xFF" as dummy byte, to generate the according SCK signals.

It's a good idea to write your own DAC53401 functions (if not using available library).
Your DAC_COMMAND --> [DAC function] --> standard I2C

Waveform generation:
Is not as simple as it sounds. It means you need to folow rules.
* Define your output signal bandwidth (f_u)
* according f_u define your sampling frequency
* according f_u define/design an analog reconstruction filter (connected at the output of the DAC to transfirm the DAC stairs into smooth analog signals)

* Draw (sketch) your own timing diagrams and flow charts before writing code.
* SW: use interrupt to guarantee the DAC access is according your desired sampling frequency
* SW: define buffers (ring buffer, FIFO) to transfer data to the ISR

Don't ask too general questions. Ask elaborated questions by giving all your detail informations, schematics, part values, sketches, referring to datasheet sections/pages .... show what you have done so far.

Klaus
I must explore a bit more, thank you Klaus. I'd only ask you one more thing and that is about one DAC_DATA register where I should write my sine samples to. I'm not sure I understand good enough, should data fit only from 11th to 2nd bit here to be read correctly? This confuses me, I also have to write to registers MARGIN_HIGH and MARGIN_LOW that are in same way like this register. Can you please clarify? Thanks in advance!
 

Attachments

  • Screenshot 2023-09-16 144716.png
    Screenshot 2023-09-16 144716.png
    13.2 KB · Views: 57
One issue you will encounter is jitter.

You have a routine which samples a waveform array and sends that out
to DAC, over a non synchronous interface, I2C. That will cause harmonic distortion.

Help, but not total solution, is DMA out to the I2C, to decouple the sampling
R/W loop needed from other code running. There are parts out there that have
onboard dacs and separate busses so that concurrent operations can occur in isolation.,
like a HW driven DMA operation. Sample rate timing supplied from a timer/clock.

If you are constrained to just ISR driven sampling then make sure the ISR is highest
priority, and that ISR itself is simple, no f() calls within it, and use pointers to get/move
data to I2C. And live with some jitter due to I2C.

You can see the jitter if you have a DSO, put it on infinite persistence, and look at
the jitter collected over time.


Regards, Dana.
 
Hi,
I'd only ask you one more thing and that is about one DAC_DATA register where I should write my sine samples to.
From my perspective it´s very clear where to write the data.
It´s a 10 bit DAC.
Bits 11..2 are 10 bits.

Could you please explain what is unclear?

What does "to be read correctly" mean?

I also have to write to registers MARGIN_HIGH and MARGIN_LOW that are in same way like this register. Can you please clarify?
Please, next time if you refer to a datasheet, please provide a link to it so we can talk about the same document.

Your picture shows just the DAC_internal DAC_DATA register, but not the I2C protocol:


You need to read datasheet about the I2C protocol, especially:
* Section 8.5.2
* Table 10,
* Table 13,
* Table 15,
* Table 16,

Klaus
 

LaTeX Commands Quick-Menu:

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top