Support Forum

Share your projects and post your questions

Register   or   Sign In
The Forum

DAC not working properly

2437 Views - Created 30/11/2016

30/11/2016

Posted by:
evgueni

evgueni 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

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

HiWhich programming language are you using to run the examples?

30/11/2016

Posted by:
evgueni

evgueni 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

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

I have just tried downloading the python 2 libraries from GitHub and running 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?

30/11/2016

Posted by:
evgueni

evgueni 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

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

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

30/11/2016

Posted by:
evgueni

evgueni 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

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew 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?

30/11/2016

Posted by:
evgueni

evgueni 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

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew 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.

Sign in to post your reply

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.