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.

External DAC with microcontroller

Status
Not open for further replies.

Karolina_1

Member level 3
Member level 3
Joined
Mar 10, 2017
Messages
67
Helped
0
Reputation
0
Reaction score
1
Trophy points
8
Visit site
Activity points
639
Hi

I have implemented external 22 bit ADC and external 12 bit DAC MCP4921.

Now I want to use external 24 or 22 bit DAC. I have found some 24bit DACs such as MAX5556, PCM1789, AD1852 (in worst case 16bit LTC1655 or AD5410). But i cant use them, its not working, i cant make the communication with PIC18f45k22.

I am using PIC18F45K22 with MikroC Pro. I searched on the form but I couldnt find any familiar projects. Can you possibly help me, if you know how to use 24 bit external DAC with PIC18F45K22. Capture1.PNGCapture2.PNG
 

Re: external DAC with microcontroller

Hi,

I'm confused about all your given devices:
* external DAC
* microcontroller
* external 22 bit ADC
* 12 bit DAC MCP4921
* external 24 or22 bit DAC
* MAX5556
* PCM1789
* AD1852
* 16 bit LTC1655
* AD5410
* PIC18F45k22
...we don't know which ICs you want to use.

Then there are meaningless statements like:"But i cant use them, its not working, i cant make the communication with PIC18f45k22. "
...we don't have a clue what is going wrong

*******
Therefore forget all about the devices and the problems. Just tell us what really your target is.
It doesn't start with xx bits ADC.
Step 1) It starts with an idea. Tell us about your idea.

Step 2)
* You have some analog input signal
--> describe it as good as possible, mostly with values and units

* then you want to process the signal wit a microcontroller.
--> describe what you want to do. What functions and everything you know

* and then you want to output the results of your processing.
--> describe where the (analog) signal is going to

Step 3)
With the given informations...the next step is to decide about (samplig) frequency, accuracy, resolution.

Step 4)
Then you may look for devices to use.

****
Some background.
22bits, 24 bits... are mostly marketing values. For a beginner you won't achieve more than 14 bits of useful resolution.
With a very good PCB layout maybe 18..20 bits. (As a raw assumption)

Then to your application.
There is no universal ADC or universal DAC...and a high bit value doesn't mean it is better than the other.
If you want to build a battery monitoring device, then a slow SAR ADC with 10 bits of resolution may be a good solutiin.
If you want to do audio processing, then a 16 bit sigma delta may be a good solution.
For some fast regulation loop you won't use a sigma delta ADC because of it's delay...
Some ADCs are good fir continous sampling, others are good for one shot sampling.
Some ADCs have multiple multiplexed inputs, others have multiple synchronously sampled inputs.
They have all benefits, but drawbacks, too.

Klaus
 
I need to generate ramp signal (-5V to +5V) with frequency of 100Hz with any external 22 or 24 bit DAC. I am using pic18f45k22 and mikroC pro compiler. I cant implement external DAC with microcontroller, specifically i cant make SPI communication between them. Preferably with better precision and higher resolution.
 

Hi,

I need to generate ramp signal (-5V to +5V) with frequency of 100Hz
.. makes sense so far
But a bit more information would be helpful. What is it for? On what criteras of the signal do you take special care?
Frequency? linearity? voltage levels? low noise? Fall rate? etc. --> give values with units.

with any external 22 or 24 bit DAC.
Especially the combination of "ramp signal", "SPI" and "PIC" makes no sense to me. Because of the limited set up rate you will get stairs in the output signal... stairs in the size of a 10 bit DAC..So why a 22..24bit DAC

I cant implement external DAC with microcontroller, specifically i cant make SPI communication between them.
This information is not very useful, because it doesn´t describe the problem. SPI is standard, it is no rocket science, therefore you will find many thousands of good informations on how to use SPI.
SPI is simple: first set up the SPI peripheral: mode and clock frequency.
* activate /SS
* send data (according DAC datasheet)
* deactivate /SS
that´s it.

Preferably with better precision and higher resolution.
What does this mean?

*****
If I´d want to simply generate a ramp signal... I´d just use a good OPAMP as integrator and an anlog switch to "reset" the ramp.
No dac, no SPI.
A simple PWM output to generate the reset impulse. Just a bit of PWM setup. No further processing power required.
Clean signal without stairs. Fairely linear. Precise in time.

Klaus
 
I simply need to generate ramp signal (between -5V and 5V) with a frequency of 100Hz. I will use it supply a voltage to a coil. As I vary the voltage, current is also going to change and it will generate a magnetic field in the coil. This magnetic field is going to effect the voltage in the photo detector. As the current will vary in the coil, I will read the voltage in the photo detector and when the voltage in the photodetector voltage is maximum i will stop the ramp signal and apply constant DC voltage which makes the photodetector voltage maximum. I need ramp to find this maximum voltage in the photodetector.

But I dont want to mix all these things up. I just want to generate the ramp signal and thats it. I want stepsize to be small thats why I want to use 22 or 24 bit external DAC.

Capture2.PNG

I want to use the DAC output as a ramp generator because after I find the maximum voltage in the photodetector, I have to make DAC output constant DC voltage. Lets say voltage is changing from -5V to 5V and at the same time we are measureing the voltage in the photodetector. Lets say when DAC output is 1V the photodetector voltage is maxiumum. So microcontoller will sense it and DAC output will be fixed 1V.
 

Zip and post your mikroC Project and Proteus Simulation file. I will see if I can write a code for the ADC and DAC you want. I will post my code and explain the working of the code.
 
its okay, ramp signal between 0 and 5V also works fine. There is DAC1282 and DAC1220 can be also used. Any DAC with >=20 bits.
 

ramp signal between 0 and 5V with any external (resolution>=20 bits) DAC.
 

As I vary the voltage, current is also going to change and it will generate a magnetic field in the coil.

I think you should consider phenomena related to coils, current and magnetic fields as well. A voltage ramp at 100 Hz will not give you a ramp of magnetic field inside the coil.
 
Actually I am not sure about frequency. If I can only generate the ramp I can vary the frequency by simply putting the delay. So i mean that frequency is not the most important criteria
 

Hi,

In post#3 you said "generate a ramp signal with frequency of 100Hz"

In post#5 you said you want stepsize small and therefore you need 22..24 bits.
--> A 22 bit DAC has about 4 milions of steps. If you want to use this small stepsize to generate a 100 Hz ramp, this means you need to update the DAC about 400 milion times per second. Transmitting 24 bits each means you need an SPI clock of about 10GHz. Impossible.
I assume you are not aware what you are specifying.

In post#7 you showed code that runs an ADC every 10ms(plus processing time) this us more than a full wave of your signal.
--> impossible to "hold" the ramp at any desired value with this scenario.
If you want use the stepsize of the DAC, then you need to sample (ADC) with the same frequency than the DAC. (400,000,000 times per second?) Impossible.

In post#16 ... now you want to vary the frequency by using the delay.
--> Now my idia is you don't want a ramp frequency of 100Hz, but a DAC_update_frequency of 100Hz.
Ok. Let's calculate it. If you want to use the small stepsize of a 22 bit DAC to generate a ramp...
This means it takes 4milion times 10ms for the full ramp. This is 40,000 seconds. More than 11 hours.
The output signal has more "DC" character than AC character.

--> There is something wrong with your specifications.

I recommend you to re-define and re-calculate your requirements. Otherwise looking for a solution that is way beyond usefulness is just a waste of time - mostly your time.

Klaus
 

Actually I am not sure about frequency. If I can only generate the ramp I can vary the frequency by simply putting the delay. So i mean that frequency is not the most important criteria

My advise is before making any uC controlled DACs take an ordinary function generator and check if it will work with your setup. Besides DAC-related issues you should consider coil inductance, required output impedance of the coil driver, frequency and self inductance effects as well.

It seems that your are a student given an experiment/measurement to conduct but in my opinion you have started from completely wrong side of the problem.
 

okay people, I am not an expert in electronics. And I am not sure If its possible to vary the voltage in DAC from 0V to 5V using 22 or 24 bit DAC with a PIC18f45k22 microcontroller. But i was able to use 16bit DAC and vary the voltage from 0V to 5V.

I used 16bit DAC (it worked) and I think its also possible to do it with 22 or 24 bit. Lets just forget about coil and everything and focus on generating a ramp signal (DC voltage whose value changes from 0V to 5V).

Moreover, I was able to use 24bit ADC LTC2400 and its working perfectly.

I just want to use 22 or 24 bit DAC and get a changing voltage from 0V to 5V. That simple.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top