Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Reading Digital + Analog Data from Sensors / Bus

OkAd9498

New Member
Hello!

I have a PCB that uses STM32U575 MCU and it has 3 sensors shown in the image connected to it through I2C bus. Using internal ADC of the MCU I want to also read the analog data that is coming from the bus. Is there a way to do it? Maybe there is a example or a reference project which I can follow and do it.

Also Question: Do I actually need ADC or DAC?

1711443106896.png
 
The data on the I2C bus is digital so I don't understand why you want to read the analogue values of the SDA and SCL lines. Can you explain what you are trying to do ? The analogue to digital conversion is done in the sensors. After looking at the data on the sensors they do not do any digital to analogue conversion.
Les.
 
Last edited:
The data on the I2C bus is digital so I don't understand why you want to read the analogue values of the DSA and SCL lines. Can you explain what you are trying to do ?
Les.
I would like to acquire some of the physical characteristics of the signal, so want to also see what is exactly happening behind these 0s and 1s
 
I still don't understand what information you can gain by reading the analogue values of the digital signals. Looking at the I2C signals using a digital storage oscilloscope will show you the digital signals in analogue form so you could see the rise and fall parts of the waveform. It will also probably display the data being transmitted. I have only used the BMP280 myself. I found it to be usefull when writting the I2C code (For a PIC12F1840) You can see the start bits, the bus address, register address and the data a fields. It also show the ACK and NAK responces from the receiving end of the transaction.

Les.
 
I still don't understand what information you can gain by reading the analogue values of the digital signals. Looking at the I2C signals using a digital storage oscilloscope will show you the digital signals in analogue form so you could see the rise and fall parts of the waveform. It will also probably display the data being transmitted. I have only used the BMP280 myself. I found it to be usefull when writting the I2C code (For a PIC12F1840) You can see the start bits, the bus address, register address and the data a fields. It also show the ACK and NAK responces from the receiving end of the transaction.

Les.
Yes, the osciloscope will work, but I want to get this data and process it internally, within MCU, so because of that I want to know if I should use ADC or DAC and which one of these will work
 
You would use and ADC (This reads the value of an analog signal.) You would only use a DAC if you wanted to create the digital signal and create the rise and fall slopes of the signal. I have not read the data sheet on the STM32U575 MCU so I don't know if if it could read many samples of the two I2C lines between the clock pulses of the I2C signal.
Have you read up in I2C protocol and understand it ?
Les.
 
it has 2 internal ADCs and assumption is that its sampling rate (around 2MSPS) should be enough to capture the needed data. My main question is in the scope of designing - So in this case if I use ADC, can I just connect SDA line of the bus to the ADC input? No any other components and extra details are needed?
 
Your devices are converting the analogue signal to a digital signal (I²C). If you want to read the analogue voltage then use something like an LM35 and connect it to an ADC input. Reading the I²C lines into an ADC will not give you anything that is useful.

Mike.
 
Your devices are converting the analogue signal to a digital signal (I²C). If you want to read the analogue voltage then use something like an LM35 and connect it to an ADC input. Reading the I²C lines into an ADC will not give you anything that is useful.

Mike.
I want to reconstruct something like this what is shown on the image from the I2C bus. Using analog sensors will not be useful

1711446615800.png
 
Your micro has 2 SARs in it, both, based on datasheet, can convert from Vssa to Vdd.
And they are multi channel, so one SAR can manage both I2C lines. That being said
you should look at latency it will take between samples as "normally" you would
want to do simultaneous sampling of the 2 I2C lines to get correct time relationship
between the lines. eg. use both SARs to minimize skew between sample of the two
lines, SDA, SCL. Both SARs can convert at a rate in the low Mhz area. Because of the
conversion references you should be able to attach the SAR inputs directly to the I2C
pins.

You have to oversample the I2C lines by some amount, at their max data rate. So
examine the timing of the I2C interface, and then decide what resolution of that
time period of the data you want for accuracy/analysis.

You will want to capture frames of data (I think) depending on what your are trying
to analyze, so must move the SAR samples into some form of storage, internal RAM
or external store that data into SIM card.... Examining the data rate one would think
some form of DMA process would be needed to do that. Depends on I2C data rate
the link is running at. Once you capture a frame, then you do your analysis., again
what you decide to analyze is key to doing this on a bit by bit basis or a frame basis
or some combination of both. Note processor has ability to synch multiple DMA
processes, so thats good.


Regards, Dana.
 
Last edited:
Your micro has 2 SARs in it, both, based on datasheet, can convert from Vssa to Vdd.
And they are multi channel, so one SAR can manage both I2C lines. That being said
you should look at latency it will take between samples as "normally" you would
want to do simultaneous sampling of the 2 I2C lines to get correct time relationship
between the lines. eg. use both SARs to minimize skew between sample of the two
lines, SDA, SCL. Both SARs can convert at a rate in the low Mhz area.

You have to oversample the I2C lines by some amount, at their max data rate. So
examine the timing of the I2C interface, and then decide what resolution of that
time period of the data you want for accuracy/analysis.

You will want to capture frames of data (I think) depending on what your are trying
to analyze, so must move the SAR samples into some form of storage, internal RAM
or external store that data into SIM card.... Examining the data rate one would think
some form of DMA process would be needed to do that. Depends on I2C data rate
the link is running at. Once you capture a frame, then you do your analysis., again
what you decide to analyze is key to doing this on a bit by bit basis or a frame basis
or some combination of both. Note processor has ability to sysnch multiple DMA
processes, so thats good.


Regards, Dana.
Dear Dana,

First of all, thank you very much for such a detailed information, suggestions and instructions. This helps a lot!

Just one more question: Is there any special detail to consider while connecting ADC to I2C bus lines? OR di I just take the lines and connect them to ADC inputs?


I know, for many people in the community questions like this sound stupid and they always point to the beginner's books, etc. But unfortunately, even after watching videos, reading books and papers, to fully understand something I have to implement it on my own and learn from practice. I can understand them, but I am happy someone understood my question and gave me such a detailed answer!


Best Regards,
George
 

Latest threads

New Articles From Microcontroller Tips

Back
Top