TS-7500-7550 Tempsensor

From Technologic Systems Manuals

The TS-752 baseboard has a temperature sensor, which the TS-7500 and TS-7550 speak to via SPI. Information on how this is done is contained in the ts7500.subr script thus:

gettemp() {
# Determine the board model
# If 7500 or 7550, use local function
# For all other boards, use "ts7500ctl --gettemp"
local model=`ts7500ctl -i | grep "^model=" | cut -d= -f2 | cut -c3-`
if [ "$model" -ne 7500 -a $model -ne 7550 ]; then
        eval `ts7500ctl --gettemp`
        echo $temperature
        return
fi

        local n x val
        setdiopin 22 0
        setdiopin 12 Z
        n=0
        while [ $n -lt 13 ]; do
                setdiopin 14 0
                setdiopin 14 1
                x=`getdiopin 12`
                if [ "$x" -eq 0 ]; then
                        let val="val << 1"
                else
                        let val="(val << 1) | 1"
                fi
                let n="n + 1"
        done
        setdiopin 22 Z
        setdiopin 14 Z
        if [ $((val & 0x1000)) -ne 0 ]; then
                val=$(((~(val & 0xfff) & 0xfff) + 1))
                val=$((val * 62500))
                printf "-%d." $((val / 1000000))
                printf "%d\n" $(((val % 1000000) / 100000))
        else
                val=$((val * 62500))
                printf "%d." $((val / 1000000))
                printf "%d\n" $(((val % 1000000) / 100000))
        fi
        
        return $val
}