Hi guys, I am having trouble implementing my 8 bit R-2R DAC using 10k and 20k resistors. I connected it to PORTD of my PIC18F452, I de-activated PSP by setting TRISE to 0 and I set TRISD to 0 to put the pins into output mode. If I send 255 (0xFF) to PORTD I get 5v to each and everyone of the 8 pins D0-D7. Now comes the part I really don't understand : measuring the voltages on the output pin of the DAC by sending different values on PORTD I get the following results : Sending decimal 50 = 0.89v Sending decimal 100 = 1.70v Sending decimal 150 = 2.24v Sending decimal 200 = 2.30v Sending decimal 250 = 2.35v I think the PIC is not able to supply enough current and this is the reason I get all the values from above. If i try to analyse the value after sending "50" over to the DAC and I multiply it by 5 I virtually get ~4.5v, close to 5v, my supply voltage. This is almost the value I should get by sending "250" to the DAC but instead I get 2.35, almost half of what it should be. Am i right here ? On Dec 13, 2007 12:17 AM, Robert Rolf wrote: > > > > Dumitru Stama wrote: > > > On Dec 12, 2007 8:37 PM, Hector Martin wrote: > > > >>Note that PIC16s and PIC18s internally divide the clock by 4, so the > >>delay would be 625 cycles. Also, the I2C read will take some time. Your > >>best bet for timing is to use one of the PIC's built in timers. In fact, > >>if you're running your EEPROM at 100Khz, it will be too slow since you > >>have to read/write 4 bytes = 40 bits approximately (after adding in > >>start conditions and whatnot), so your maximum sampling rate would be > >>100/40 = 2.5Khz. You should read chunks of data of a longer length (to > >>reduce the overhead of three bytes for each I2C transaction), buffer > >>them in memory, and have an interrupt running off a timer put them into > >>PORTB. > > > > > > In the end i will use two buffers and a timer for feeding my DAC with values > > but this is my first work in this field and i wanted to hear some sound out > > of my design :) Thank you for your correction, i will fix my delays now to see > > what i get. > > So break the problem into parts. > First make the D/A make sound. A running binary counter will > get you a nice ramp (sawtooth) that sounds like an Oboe. > That way you know your playback rate is OK and that your amplifier > is not clipping or otherwise wonky. > > Then make sure you are reading/writing the EEPROM correctly. > For example, write the compliment of the address > (plus some offset),to each location > and then make sure you are reliably getting it back. > > And as noted by others, you only need to write the start address > to most serial EEPROM devices. Subsequent reads will get you > the next byte in the sequence so your overhead is greatly reduced. > > Robert > > > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist