1
0
Fork 0

Compare commits

...

4 Commits

Author SHA1 Message Date
Florian Agbuya 232c9e3bb3 loopback read CH1 2024-08-21 14:29:08 +08:00
Florian Agbuya e1ee2f53cb add adc channel check after test mode 2024-08-21 13:44:20 +08:00
Florian Agbuya 1b673a1adb switch dac output sequence 2024-08-20 13:54:07 +08:00
Florian Agbuya 3629c9c831 test nixbld 2024-08-20 10:03:30 +08:00
4 changed files with 54 additions and 4 deletions

View File

@ -151,6 +151,8 @@ def configure_ltc2195():
main_adc_test_mode(spi, False) main_adc_test_mode(spi, False)
verify_adc_registers(spi, {0x02: 0x11}) # Verify test mode is off verify_adc_registers(spi, {0x02: 0x11}) # Verify test mode is off
print_adc_channels()
enable_adc_afe() enable_adc_afe()

View File

@ -127,13 +127,13 @@ def configure_ad9117():
configure_dac(spi) configure_dac(spi)
dac_self_calibration(spi) dac_self_calibration(spi)
# Enable DAC outputs
spi_write(spi, 0x01, spi_read(spi, 0x01) & ~((1 << 4) | (1 << 3)))
power_down(0, False) power_down(0, False)
power_down(1, False) power_down(1, False)
manual_override(True) manual_override(True)
# Enable DAC outputs
spi_write(spi, 0x01, spi_read(spi, 0x01) & ~((1 << 4) | (1 << 3)))
print("AD9117 configuration completed successfully") print("AD9117 configuration completed successfully")
return True return True

View File

@ -0,0 +1,48 @@
import time
from pyfastservo import adc, dac
from pyfastservo.common import (
ADC_CH1_HIGH_ADDR,
ADC_CH1_LOW_ADDR,
CH1_HIGH_WORD_ADDR,
CH1_LOW_WORD_ADDR,
read_from_memory,
write_to_memory
)
def read_adc():
adc_value = adc.read_adc_channel(ADC_CH1_HIGH_ADDR, ADC_CH1_LOW_ADDR)
return adc_value
def write_dac(value):
dac.set_dac_output(value)
def read_dac():
high_word = read_from_memory(CH1_HIGH_WORD_ADDR, 1)[0]
low_word = read_from_memory(CH1_LOW_WORD_ADDR, 1)[0]
return (high_word << 8) | low_word
def perform_loopback_test(test_value):
print(f"Setting DAC output to {test_value}...")
write_dac(test_value)
time.sleep(0.1) # Allow time for the signal to stabilize
print("Reading ADC value...")
adc_value = read_adc()
print(f"ADC readback: {adc_value}")
print("Reading DAC value...")
dac_value = read_dac()
print(f"DAC readback: {dac_value}")
if abs(test_value - adc_value) <= 2 and abs(test_value - dac_value) <= 2:
print("Loopback test PASSED!")
else:
print("Loopback test FAILED!")
print(f"Expected: {test_value}, ADC: {adc_value}, DAC: {dac_value}")
def main():
test_value = 0x2000 # Mid-range value (8192 in decimal)
perform_loopback_test(test_value)
if __name__ == "__main__":
main()

View File

@ -481,7 +481,7 @@
inherit migen misoc vivado; inherit migen misoc vivado;
}; };
packages.armv7l-linux = { packages.armv7l-linux = {
inherit fast-servo-gateware linien-server; inherit fast-servo-gateware linien-server pyfastservo;
} // } //
(board-package-set { board = "zc706"; }) // (board-package-set { board = "zc706"; }) //
(board-package-set { board = "fast-servo"; }); (board-package-set { board = "fast-servo"; });