I’d love some help interfacing a 16-bit ADC (AD7706) with a 28x2 (3v) picaxe using SPI comms protocol if possible?
My ultimate goal is to use this ADC to read the S+ and S- output from a set of electronic bathroom scales. I realise there are more elegant ADC's for weigh scales, e.g. the TI1231 which are dedicated and have no registers to program. However, I happen to have some AD7706 ADC's on hand and figure I could learn a lot about precision analogue to digital interfacing if I master this one.
Since this is my first foray into external ADC and SPI, I thought I’d go simple and breadboard the ADC to a 28x2 3v MCU and try and read the output of an analogue LM35 temperature sensor. Power to my breadboard is via a 3.6v SAFT Lithium battery reduced to 3.0V via an in-line regulator to the MCU, suitably decoupled. Reference voltage to the ADC and LM35 temp sensor is 2.5V via a REF192 precision voltage reference IC, also decoupled as per the datasheet.
I’m currently getting nothing at all in my debug screen, so am guessing I’m not even connecting with the ADC. I’ve triple checked my wiring against the data sheets and have tried all 8 possible SPI modes and a few speeds. All to no avail. Any ideas?
Here’s my code so far:
My ultimate goal is to use this ADC to read the S+ and S- output from a set of electronic bathroom scales. I realise there are more elegant ADC's for weigh scales, e.g. the TI1231 which are dedicated and have no registers to program. However, I happen to have some AD7706 ADC's on hand and figure I could learn a lot about precision analogue to digital interfacing if I master this one.
Since this is my first foray into external ADC and SPI, I thought I’d go simple and breadboard the ADC to a 28x2 3v MCU and try and read the output of an analogue LM35 temperature sensor. Power to my breadboard is via a 3.6v SAFT Lithium battery reduced to 3.0V via an in-line regulator to the MCU, suitably decoupled. Reference voltage to the ADC and LM35 temp sensor is 2.5V via a REF192 precision voltage reference IC, also decoupled as per the datasheet.
I’m currently getting nothing at all in my debug screen, so am guessing I’m not even connecting with the ADC. I’ve triple checked my wiring against the data sheets and have tried all 8 possible SPI modes and a few speeds. All to no avail. Any ideas?
Here’s my code so far:
Code:
; #####################################
;RB implementation of the AD7706 16-bit ADC and Picaxe 28X2 (3v) with an LM35 analog temperature sensor
; ADC setup includes an external 4.9152mHz crystal on the MCLKIN and MCLKOUT pins, buffered on both sides with a 0.1uF ceramic capacitor.
; Also includes a REF192 precision 2.5V voltage reference for the ADC, decoupled with a 10uF electrolytic and 0.1uF ceramic capacitor on the Vdd input side and with a 1uF tantalum and 0.1uF ceramic capacitor at the output side.
; Vdd is via a SAFT 3.6v Lithium SOCL2 battery reduced to 3.0V by a LE30AB in-line voltage regulator decoupled with a 10uF electrolytic and 0.1uF ceramic capacitor.
' 28X2 (3v) Picaxe MCU
;#########################################
Symbol CS = C.2 'AD7706 Chip select on C.2 MCU pin
init:
hspisetup spimode00, spimedium ' not sure on mode but have tried all combinations. Have also tried Slow and Medium speeds to no avail.
High CS
' Params for Setup registry :
Low CS
Hspiout (%00010000) 'zero 'write' bit to Communications Register, instruct to enter Setup Register and that next operation is a 'write'
Hspiout (%01000110) 'Perform calibration at full scale on channel 1; set gain to 1; unipolar input; buffered; and FSYNC disabled.
High CS
' Params for Clock registry :
Low CS
Hspiout (%00100000) 'instruct to enter Clock Register (from Communications registry) and next operation is a 'write'
Hspiout (%00010100) 'MCKOUT disabled since using ext crystal; CLKDIV turn off to use 4.9152 crystal internally as well; CLK set to 1 for crystal; 50Hz update frequency
High CS
Main:
Low CS
Hspiout (%00111000) 'instruct to enter Data Register (from Communications registry) and next operation is a 'read'
Pause 50
Hspiin (b1,b0) 'Shift in the 16-bit data in two bytes
debug
High CS
Pause 1000
Goto Main