Page 1 of 1

Digital input always returning high

Posted: Mon Feb 15, 2016 7:18 am
by djsw
Pretty much as the topic title says. With nothing input to the pin, with the code:

Code: Select all

#!/usr/bin/python

import sys
import redpitaya_scpi as scpi

rp_s = scpi.scpi(sys.argv[1])

# Set both to be input pins
rp_s.tx_txt('DIG:PIN:DIR IN,DIO0_N')
rp_s.tx_txt('DIG:PIN:DIR IN,DIO1_N')

# Get the state of both pins
print ("Initial state:")
rp_s.tx_txt('DIG:PIN? DIO0_N')
state = rp_s.rx_txt()
print ('DIO0_N is ' + str(state))
rp_s.tx_txt('DIG:PIN? DIO1_N')
state = rp_s.rx_txt()
print ('DIO1_N is ' + str(state))
I get

Code: Select all

Initial state:
DIO0_N is 1
DIO1_N is 1
Then, with

Code: Select all

# Set both to be output pins
rp_s.tx_txt('DIG:PIN:DIR OUT,DIO0_N')
rp_s.tx_txt('DIG:PIN:DIR OUT,DIO1_N')

# Set them both high
rp_s.tx_txt('DIG:PIN DIO0_N, '+str(1))
rp_s.tx_txt('DIG:PIN DIO1_N, '+str(1))

# Set both to be input pins
rp_s.tx_txt('DIG:PIN:DIR IN,DIO0_N')
rp_s.tx_txt('DIG:PIN:DIR IN,DIO1_N')

# Get the state of both pins
print("Set high:")
rp_s.tx_txt('DIG:PIN? DIO0_N')
state = rp_s.rx_txt()
print ('DIO0_N is ' + str(state))
rp_s.tx_txt('DIG:PIN? DIO1_N')
state = rp_s.rx_txt()
print ('DIO1_N is ' + str(state))
I get

Code: Select all

Set high:
DIO0_N is 1
DIO1_N is 1
and with

Code: Select all

# Set them both to be output pins
rp_s.tx_txt('DIG:PIN:DIR OUT,DIO0_N')
rp_s.tx_txt('DIG:PIN:DIR OUT,DIO1_N')

# Set them both low
rp_s.tx_txt('DIG:PIN DIO0_N, ' + str(0))
rp_s.tx_txt('DIG:PIN DIO1_N, ' + str(0))

# Set both to be input pins
rp_s.tx_txt('DIG:PIN:DIR IN,DIO0_N')
rp_s.tx_txt('DIG:PIN:DIR IN,DIO1_N')

# Get the state of both pins
print("Set low:")
rp_s.tx_txt('DIG:PIN? DIO0_N')
state = rp_s.rx_txt()
print ('DIO0_N is ' + str(state))
rp_s.tx_txt('DIG:PIN? DIO1_N')
state = rp_s.rx_txt()
print ('DIO1_N is ' + str(state))
I get

Code: Select all

Set low:
DIO0_N is 0
DIO1_N is 1
The outputs are the same regardless of whether I set them low or high first. DIO0_N is set to whatever it's meant to be, but DIO1_N is always set high. Neither of them have anything connected. Any ideas?