CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Reconstruction Filter
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
temtronic



Joined: 01 Jul 2010
Posts: 9108
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Apr 04, 2017 5:35 am     Reply with quote

When you read RF D's post every reason he points out can be an 'argument' for the MCP's 'high' noise spec.
Some engineer designed it, another tested it then some 'bean counter' in marketing put a price tag on it. From an earlier post it's 7* cheaper than the MAX part ,though the max has far less noise. When you design a product you have to look at the whole picture, but when 'they' say build it for 50 cents less, YOU have to compromise something,somewhere to save the money. Component selction is usually the first area that happens.
In todays economy money is the KEY factor. Just look at all the posts here trying to use an 8 pin PIC when a 28 should be used, or a nonHW UART one when you really need the HW UART.
There is obviously a viable( profitablbe) market for the MCP ,otherwise uC would have discontinued it. I know Microchip sells PICs that were designed for 'application specific' uses for companies, since from a manufacturing aspect it makes no sense to have so many variations of internals in a product.
I'm still amazed you can buy a 12bit DAC for less than a buck,when 40 years ago I was paying thousands....
Jay
viki2000



Joined: 08 May 2013
Posts: 233

View user's profile Send private message

PostPosted: Tue Apr 04, 2017 6:46 am     Reply with quote

I agree with everything what you said as I went through these kind of costs arguments in some previous projects, but again, I must repeat myself, I do not care about that because now I have no real project, the whole point here for me was not the money or overall picture, but to show that MCP4725 is noisy and that noise is not coming so much from my PCB, power supply or oscilloscope. I realize it can be reduced with a better PCB layout, but still so will be high, more than everyone expected, that’s why most of you said that is my PCB the cause of the noise that we see on the scope. It is, but not so much. MCP4725 is noisy itself. Who cares? You did when you told me that my PCB is “guilty” and the noise that we see on the scope must come from my PCB interferences.

Regarding the prices,

MCP4725 on Mouser:
1: 1,00 €
10: 0,905 €
25: 0,754 €
100: 0,688 €

MAX5812 on Mouser:
1: 6,60 €
10: 6,22 €
25: 4,98 €
50: 4,73 €
100: 4,36 €
250: 4,14 €
500: 3,99 €
2.500: 3,17 €

DAC121C081 on Mouser:

1: 2,24 €
10: 2,02 €
25: 1,92 €
100: 1,62 €
250: 1,53 €
500: 1,33 €
1.000: 0,993 €

The right way is to compare the prices at the same volume.
Are you sure RF-Developer that you compared MCP4725 and MAX5812 at the same volume? because it seems MAX5812 6.6€ for 1pc and MCP4725 0.688 € for 100 pcs.
If we look at 100 pcs then MAX 5812 is 4.36 €.
I know is still a big difference and I do not care about prices now, I am focus on the product quality/specs.
And it also depends how big is the project, because if the volume is high then we come down to 3.17€ for 2500pcs. It is true that also MCP4725 will be lower too, but let’s look at another product TI DAC121C081. At 100pcs is only 1.62 €.
The datasheet:
http://www.ti.com/lit/ds/symlink/dac121c081.pdf

Here is the test done with DAC121C081:
https://goo.gl/Etnjax
We look at Digital Feedthrough for DAC121C081 and is 0.5 nV-s, double than MAX5812 and still lots lower than MCP4725, but the result is very good and the price is good. I can declare it winner up to now.

The code used:
Code:
#include <16F1825.h>
#fuses NOFCMEN ,NOIESO, NOCLKOUT, BROWNOUT, NOCPD, NOPROTECT, NOMCLR, NOPUT, NOWDT, INTRC_IO
#fuses NOLVP, NODEBUG, BORV19, NOSTVREN, PLL, NOWRT
#use delay(clock=32M)
#use I2C(MASTER, scl=PIN_C4, sda=PIN_C3, FORCE_SW, FAST=400000)

CONST unsigned long SINE_WAVE[38] = {0, 34, 68, 101, 135, 168, 201, 234, 266, 298, 329, 360, 390, 419, 448, 476, 503, 529, 555, 579, 603, 625, 646, 667, 686, 704, 720, 736, 750, 763, 775, 785, 794, 802, 808, 813, 816, 818};

void dac_i2c(unsigned int16 sample){
   i2c_start();
   i2c_write(0b00011010);                // Device address
   i2c_write((sample >> 8) & 0xF);       // Upper 4 data bits
   i2c_write(sample & 0xFF);             // Lower bits 8 bits
   i2c_stop();                           // Stop
   
   }

void main() {
setup_adc(ADC_OFF);
output_A(0x00);
output_bit(PIN_C0, 0);
output_bit(PIN_C1, 0);
output_bit(PIN_C2, 0);
output_bit(PIN_C5, 0);
unsigned long int i=0;
   disable_interrupts(GLOBAL);
   //i2c_start();
   //i2c_write(0b00011010);
   while(TRUE){
      while (i< 37){
         i++;
         dac_i2c(SINE_WAVE[i]);
      }
      while (i>0){
         i--;
         dac_i2c(SINE_WAVE[i]);
      }     
   }
}

We can increase the speed of execution by sending only once the start, then the address and then only the data in cycles without stop. Before “while(TRUE)” remove the comments “//” from
   //i2c_start();
   //i2c_write(0b00011010);
and add “//” in subroutine “void dac_i2c(unsigned int16 sample){” for:
   i2c_start();
   i2c_write(0b00011010);               
   i2c_stop();

I had a question before. When you start a project and you have to choose for example such DAC I2C, there is a big variety from different manufacturers. How do you know to choose it? Let’s say the price is the second qualifier. Of course you look at the specs in the datasheet and at the packages and then the price. Still is hard to decide when are many to choose. How do you do it? Order some devices and test each one? I guess this is what I have done now.
temtronic



Joined: 01 Jul 2010
Posts: 9108
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Apr 04, 2017 7:19 am     Reply with quote

re:...
How do you do it? Order some devices and test each one?

You've partially answered your own question,buy/test/compare...
Welcome to my nightmare....

Product availablity is a concern, IE can you GET the parts? Is there a 'second source' for the same part? Not a problem if it's say, less than 1000 pieces as you'd buy the lot and you're done. 30 years ago I got shafted buy Motorola on the 68HC11. I designed the product, tested,PCB ready to go and MOTO said 'none avaliable as I wasn't 'on the list'. At the time I didn't know that Toshiba made the same chip(actually same plant!). As there wasn't a second source I 'jumped ship' and started with PICs even though there is NO second source, the Microchip guys said no problem, we got millions in stock,always.

Sooner or later ,you'll have to consider R&D time as a real expense. At $100/hr ,it's cheaper to buy a more expensive device than waste 2-3 hrs(or days) on trying to make the cheaper device almost work. Consider a small run of say 50. Spend $1 more per device saves you $50 in R&D time and gets the product out the door faster. I see that a lot here, guys trying to 'tweak' the most ot of a PIC when for 25c more you could use a 'bigger' PIC. My goto PIC is the 18F46K22,2HW UARTs,lots of RAM,code space, 40 pins and have never run out. Yes, when the bean counters say cut costs THEn you can see if a smaller PIC might do the job...It's all about compromise.

The great thing about you doing the bench work is you've eliminated a lot of the issues BEFORE the final product was manufactured!
viki2000



Joined: 08 May 2013
Posts: 233

View user's profile Send private message

PostPosted: Tue Apr 04, 2017 7:50 am     Reply with quote

I really have a problem where maybe your advice would help. The problem is in my head, the way how I see the things. Before I decide for a solution, I “need” to have the overview of all possibilities and to see which one is better, more suitable for a given application. This is time consuming, especially if I do not know a lot of things behind and because of that I think I cannot be a good R&D guy if I would like to become one. I see the R&D more like: you found a solution as fast as possible that satisfies you, and then you go for it and forget about the rest. For some reasons I cannot do that. What if there is a better solution? Improve later? I feel trapped.
For example, in many previous posts was suggested that producing a rectified sine directly with DAC makes a lot troubles due to the harmonics and better would be to produce a pure sine, filter it and then then to rectify it. I got that.

Here is my question, which solution would be then better for fixed frequency and fixed amplitude of rectified sine wave 100Hz 1Vpp?
- Use a microcontroller, say PIC, + a DAC, say SPI (+ optional Filter), because SPI is faster and I can increase the lookup table, more points, or maybe a math function if the PIC is fast enough.
- Use a microcontroller, say PIC, + a PWM output + Filter + precision rectifier (OpAmp). The PWM resolution is lower than DAC, but there are tricks using CLC and NCO to increase PWM resolution.
www.microchip.com/ApplicationNoteAN14769426
- Use a microcontroller, say PIC, + NCO (make square wave) + Filter precision rectifier (OpAmp).
http://ww1.microchip.com/downloads/en/AppNotes/00001523A.pdf
- Forget about microcontrollers, use pure analog solution, sine wave oscillator + precision rectifier (OpAmp).
- Eventually I must use a bipolar power supply to compensate the offset of final wave, but I must generate that from my unipolar +5Vdc power supply/battery.
newguy



Joined: 24 Jun 2004
Posts: 1902

View user's profile Send private message

PostPosted: Tue Apr 04, 2017 8:29 am     Reply with quote

The requirements of the waveform you want to generate will, in part, dictate how you generate it. Another consideration is total cost which factors in the actual cost of the hardware and the R&D time to make it work. A "dirty" generator (like a PWM based solution) will require a lot more filtration than some of the other solutions, and the requirements of the filter will be more stringent than say a DAC where the filter will be "easier" because the noise spectrum will be much higher than the signal you want. Finally, is the solution set in stone or can it be adapted in case you discover that something needs to be changed in future?

Regarding your final point,
Code:
- Eventually I must use a bipolar power supply to compensate the offset of final wave, but I must generate that from my unipolar +5Vdc power supply/battery.


Unless your offset needs to be adjustable to be below 0V, you don't need a bipolar supply. ....Or at least I really doubt that you do. I personally haven't needed bipolar power supplies in almost 20 years and almost every project I've created in those 20 years has had an analog component, some including audio and NTSC video - all done with single supply circuitry.
viki2000



Joined: 08 May 2013
Posts: 233

View user's profile Send private message

PostPosted: Tue Apr 04, 2017 8:38 am     Reply with quote

Thank you for the tips.
The solution is not set in stone, I just investigate possibilities for the moment.
Then according with your proposal, the PWM solution is out.
I do not need negative values, that means I will stay with only +5Vdc and no bipolar power supply.
It remains then 3 more solutions to decide:
- PIC+DAC (+ optional Filter)
- PIC (square wave, eventually NCO) + Filter + Rectifier
- Pure analog
temtronic



Joined: 01 Jul 2010
Posts: 9108
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Apr 04, 2017 9:31 am     Reply with quote

Since it's only 100Hz, you might want to spend an afternoon with an opamp and a few Rs + Cs. Easy to generate a sine wave and is very stable. I used one, 30+ years ago as the 24Hz clock for the remote energy controllers. Only had to go pure digital when the last rcvr 'lost' communications. Mind you that was at the end of 17 miles of copper....kinda expected it to happen.
I'm assuming opamps are a tad better than 3 decades ago....
Really, sometimes the 'best' solution is the tried and true, simple ones....
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8
Page 8 of 8

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group