pyfastservo: fix adc, dac init script and cleanup #63

Merged
sb10q merged 4 commits from fsagbuya/nix-servo:adc_dac into master 2024-07-10 16:11:17 +08:00
Collaborator

Description

  • Fix ADC and DAC initialization scripts according to datasheet; adjust settings based on hardware schematic
  • Clean up code: remove unused functions, add convenience functions for repeating tasks, apply consistent structure

TODO: Calibrate DAC due to attenuation factor

ADC log:

python -m pyfastservo.adc       
Spi readback register 0x01: 0x20
Spi readback register 0x02: 0x15
Spi readback register 0x03: 0x81
Spi readback register 0x04: 0x1f
Performing bitslip (iteration: 0). Current frame: 0x09
No bitslip required; Current frame: 0x0c
Tap delay: 0, Current frame: 0x0c
Tap delay: 1, Current frame: 0x0c
Tap delay: 2, Current frame: 0x0c
Tap delay: 3, Current frame: 0x0c
Tap delay: 4, Current frame: 0x0c
Tap delay: 5, Current frame: 0x0c
Tap delay: 6, Current frame: 0x0c
Tap delay: 7, Current frame: 0x0c
Tap delay: 8, Current frame: 0x0c
Tap delay: 9, Current frame: 0x0c
Tap delay: 10, Current frame: 0x0c
Tap delay: 11, Current frame: 0x06
Tap delay: 12, Current frame: 0x06
Tap delay: 13, Current frame: 0x06
Tap delay: 14, Current frame: 0x06
Tap delay: 15, Current frame: 0x06
Tap delay: 16, Current frame: 0x06
Tap delay: 17, Current frame: 0x06
Tap delay: 18, Current frame: 0x06
Tap delay: 19, Current frame: 0x06
Tap delay: 20, Current frame: 0x06
Tap delay: 21, Current frame: 0x06
Tap delay: 22, Current frame: 0x06
Tap delay: 23, Current frame: 0x06
Tap delay: 24, Current frame: 0x06
Tap delay: 25, Current frame: 0x06
Tap delay: 26, Current frame: 0x06
Tap delay: 27, Current frame: 0x03
Edge detected; setting iDelay to: 15
Final ADC_CH0: 0x60c7
Final ADC_CH1: 0x60c7
Spi readback register 0x02: 0x11
ADC_AFE_CTRL: 0x00

DAC Log:

DAC version: 0x0A
DAC self-calibration completed
REG contents: 0b001
REG contents: 0b001
REG contents: 0b001
AD9117 configuration completed successfully

### Description - Fix ADC and DAC initialization scripts according to datasheet; adjust settings based on hardware schematic - Clean up code: remove unused functions, add convenience functions for repeating tasks, apply consistent structure TODO: Calibrate DAC due to attenuation factor ADC log: ``` python -m pyfastservo.adc Spi readback register 0x01: 0x20 Spi readback register 0x02: 0x15 Spi readback register 0x03: 0x81 Spi readback register 0x04: 0x1f Performing bitslip (iteration: 0). Current frame: 0x09 No bitslip required; Current frame: 0x0c Tap delay: 0, Current frame: 0x0c Tap delay: 1, Current frame: 0x0c Tap delay: 2, Current frame: 0x0c Tap delay: 3, Current frame: 0x0c Tap delay: 4, Current frame: 0x0c Tap delay: 5, Current frame: 0x0c Tap delay: 6, Current frame: 0x0c Tap delay: 7, Current frame: 0x0c Tap delay: 8, Current frame: 0x0c Tap delay: 9, Current frame: 0x0c Tap delay: 10, Current frame: 0x0c Tap delay: 11, Current frame: 0x06 Tap delay: 12, Current frame: 0x06 Tap delay: 13, Current frame: 0x06 Tap delay: 14, Current frame: 0x06 Tap delay: 15, Current frame: 0x06 Tap delay: 16, Current frame: 0x06 Tap delay: 17, Current frame: 0x06 Tap delay: 18, Current frame: 0x06 Tap delay: 19, Current frame: 0x06 Tap delay: 20, Current frame: 0x06 Tap delay: 21, Current frame: 0x06 Tap delay: 22, Current frame: 0x06 Tap delay: 23, Current frame: 0x06 Tap delay: 24, Current frame: 0x06 Tap delay: 25, Current frame: 0x06 Tap delay: 26, Current frame: 0x06 Tap delay: 27, Current frame: 0x03 Edge detected; setting iDelay to: 15 Final ADC_CH0: 0x60c7 Final ADC_CH1: 0x60c7 Spi readback register 0x02: 0x11 ADC_AFE_CTRL: 0x00 ``` DAC Log: ``` DAC version: 0x0A DAC self-calibration completed REG contents: 0b001 REG contents: 0b001 REG contents: 0b001 AD9117 configuration completed successfully ```
fsagbuya added 1 commit 2024-07-10 14:45:24 +08:00
fsagbuya force-pushed adc_dac from ab9d8f6966 to 43aada8ec3 2024-07-10 15:45:56 +08:00 Compare
Owner

What attenuation factor?

What attenuation factor?
sb10q merged commit f5729d3bdb into master 2024-07-10 16:11:17 +08:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/nix-servo#63
No description provided.