About Us Knowledge Base Community Forum Electronics Toolbox FAQ Shipping & Delivery

Community Forum

Share your projects and post your questions

Search
Register or Sign In
Forum

DAC not working properly

1428 Views - Created 30/11/2016

30/11/2016

Posted by:
evgueni

Last edited: 30/11/2016

Users Avatar

Location:
Wellingborough, UK

Hi,

I have the following problem. ADC is working properly - the "Reading from the ADC" example works and I read back voltage values. Although I had to modify read_adc_voltage function call to have the correct number of arguments before the example would run.

The "Writing to DAC" example does not work. I do not see a square wave on the DAC output. Very occasionally the output does switch to 1.5V but then remains there. Are correct parameters being passed to spidev for the MCP4822E chip?

I have checked SPI clock, data and SC lines with an oscilloscope and everything seems in order. Perhaps the wrong SPI mode is selected?

30/11/2016

Posted by:
andrew

Users Avatar

Location:
United Kingdom

Users Twitter  Users Website  

Hi

Which programming language are you using to run the examples?

AB Electronics UK Tech Support

30/11/2016

Posted by:
evgueni

Users Avatar

Location:
Wellingborough, UK

It's Python 2.7.9. The examples are from your knowledge base article. Actually I have found these also in the ABElectronics_Python_Libraries/ADCDACPi folder - same result though when I run them.

 

30/11/2016

Posted by:
andrew

Users Avatar

Location:
United Kingdom

Users Twitter  Users Website  

I have just tried downloading the python 2 library from github and ran the demo-dacwrite.py script and it does appear to be working correctly on the ADC DAC Pi I have here.  Can you try running the demo-dacsinewave.py script and see if that generates a sine wave?

If the ADC is reading then it shouldn't be a problem with the SPI configuration in linux.

Can you try our Python 3 or C library to see if it is a problem with python 2 or the ADC DAC Pi

AB Electronics UK Tech Support

30/11/2016

Posted by:
evgueni

Users Avatar

Location:
Wellingborough, UK

I have already tried demo-dacsinewave.py - same result, DAC output does not respond. I am thinking of ordering another board to rule out a board fault.

Will try Python 3 also and report back.

30/11/2016

Posted by:
andrew

Users Avatar

Location:
United Kingdom

Users Twitter  Users Website  

If you can send me your order number using our contact form I will send you a replacement board.

AB Electronics UK Tech Support

30/11/2016

Posted by:
evgueni

Users Avatar

Location:
Wellingborough, UK

OK tried with Python 3 libraries and the result is the same. A bit more detail - when I run demo-dacwrite.py I can provoke an occasional change in DAC output voltage by probing pin 5 (LDACn) with oscilloscope probe. The new voltage is always one of the two levels set in demo-dacwrite.py, either 0V or 1.5V (I also tried changing 1.5V to 2.0V to check there is no coincidence).

30/11/2016

Posted by:
andrew

Users Avatar

Location:
United Kingdom

Users Twitter  Users Website  

It does sound like there is a fault with the DAC output.  Can you let me know your order number and I will send you a new board.

AB Electronics UK Tech Support

30/11/2016

Posted by:
evgueni

Users Avatar

Location:
Wellingborough, UK

According to the MCP4822 datasheet LDACn signal "transfers the input latch registers to the DAC registers (output latches) when low. Can also be tied low if transfer on the rising edge of CS is desired". This is connected to GPIO25 of RPI2 which remains HIGH at all times. When I modify the demo-dacwrite.py to hold GPIO25 LOW, I finally see the square wave on the o/p of the DAC.

Why is demo-dacwrite.py leaving GPIO25 unattended?

30/11/2016

Posted by:
andrew

Users Avatar

Location:
United Kingdom

Users Twitter  Users Website  

Normally the GPIO pins are kept low on a fresh install of Raspian Linux so I didn't add the GPIO code in to set GPIO25 low.  I will update our tutorials and library to make sure GPIO25 is set low.

AB Electronics UK Tech Support

Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view, download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.