Aylmaz
Posts: 4
Joined: Wed Jan 10, 2018 11:53 am

SPI Problem for DAC 8563

Wed Jan 23, 2019 8:58 am

Hello everyone,

I am working on a project and we use dac8563, we saw voltage output in first try but we cannot see now.

Code: Select all

#!/usr/bin/python

import RPi.GPIO as GPIO
import spidev
import serial
import time

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)

GPIO.setup(21,GPIO.OUT)
GPIO.setup(2,GPIO.OUT)
ldac=19
GPIO.setup(ldac,GPIO.OUT)
clr=13
GPIO.setup(clr,GPIO.OUT)


spi=spidev.SpiDev()
spi.open(0,0)
spi.max_speed_hz=15600000

adr=0x01
lsb=0x0f
msb=0xfa

GPIO.output(21,1)
GPIO.output(ldac,1)
GPIO.output(clr,1)

while True:
    for i in range(0,0xff):
        GPIO.output(21,0)
        GPIO.output(ldac,1)
        msb=i
        GPIO.output(clr,0)
        time.sleep(0.00001)
        GPIO.output(clr,1)
        spi.xfer([adr,msb])
        
        GPIO.output(ldac,0)
        
        GPIO.output(clr,0)
        
        GPIO.output(21,1)
        
        i+=1
        time.sleep(1)
I did debug for see sent data from spi and i see this:



I guest, the device sent [0,0] from spi every time, cause adr=0x01, and msb=0xc1 when i taking screeshot

How i can fix this problem?
Attachments
Untitled-1.jpg
Untitled-1.jpg (178.46 KiB) Viewed 266 times
Last edited by Aylmaz on Wed Jan 23, 2019 5:57 pm, edited 1 time in total.

DirkS
Posts: 9881
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: SPI Problem for DAC 8563

Wed Jan 23, 2019 5:50 pm

The image is invisible and if I follow the link I get a '403 - forbidden' error

Aylmaz
Posts: 4
Joined: Wed Jan 10, 2018 11:53 am

Re: SPI Problem for DAC 8563

Wed Jan 23, 2019 5:58 pm

I attached the image

DirkS
Posts: 9881
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: SPI Problem for DAC 8563

Wed Jan 23, 2019 6:17 pm

Aylmaz wrote:
Wed Jan 23, 2019 5:58 pm
I attached the image
I can't read that, but it doesn't look like a proper error message to me...
IMHO it would be much clearer if you use print statements that output relevant state information.
Your screen dump shows 2 values and that's it. There is no info at all about other (relevant) variables, etc.

Return to “Python”