GPIO - Trying to simultaneously use ADS1256 and DAC8532 via GPIO
Posted: Sun Mar 01, 2020 5:11 am
Hi all, I am new to dealing with SPI and GPIO, and ran into an issue with the config files of the ADS1256 and DAC8532 on the Waveshare High-Precision AD/DA Board. https://www.waveshare.com/wiki/High-Pre ... /DA_Board
I would like to use both the AD and DA within the same python program, but I notice that the config files are slightly different. The config file for the ADS1256 defines its CS_PIN = 22, whereas the DAC8532 config uses CS_PIN = 23. Config for ADS:
and the code for DAC is:
I'm hoping that there is an easy solution to make one config file so I can write python programs to access both chips. Thanks for any help.
I would like to use both the AD and DA within the same python program, but I notice that the config files are slightly different. The config file for the ADS1256 defines its CS_PIN = 22, whereas the DAC8532 config uses CS_PIN = 23. Config for ADS:
Code: Select all
import spidev
import RPi.GPIO as GPIO
import time
# Pin definition
RST_PIN = 18
CS_PIN = 22
DRDY_PIN = 17
# SPI device, bus = 0, device = 0
SPI = spidev.SpiDev(0, 0)
def digital_write(pin, value):
GPIO.output(pin, value)
def digital_read(pin):
return GPIO.input(DRDY_PIN)
def delay_ms(delaytime):
time.sleep(delaytime // 1000.0)
def spi_writebyte(data):
SPI.writebytes(data)
def spi_readbytes(reg):
return SPI.readbytes(reg)
def module_init():
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(RST_PIN, GPIO.OUT)
GPIO.setup(CS_PIN, GPIO.OUT)
#GPIO.setup(DRDY_PIN, GPIO.IN)
GPIO.setup(DRDY_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)
SPI.max_speed_hz = 20000
SPI.mode = 0b01
return 0;Code: Select all
import spidev
import RPi.GPIO as GPIO
import time
# Pin definition
CS_PIN = 23
# SPI device, bus = 0, device = 0
SPI = spidev.SpiDev(0, 0)
def digital_write(pin, value):
GPIO.output(pin, value)
def digital_read(pin):
return GPIO.input(pin)
def delay_ms(delaytime):
time.sleep(delaytime // 1000.0)
def spi_writebyte(data):
SPI.writebytes(data)
def spi_readbytes(reg):
return SPI.readbytes(reg)
def module_init():
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
#GPIO.setup(RST_PIN, GPIO.OUT)
GPIO.setup(CS_PIN, GPIO.OUT)
#GPIO.setup(DRDY_PIN, GPIO.IN)
#GPIO.setup(DRDY_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)
SPI.max_speed_hz = 20000
SPI.mode = 0b01
return 0;