Skip to content

Commit

Permalink
first version to set DC2PD preamplifier gain via MCP4725 chip on I2C bus
Browse files Browse the repository at this point in the history
  • Loading branch information
PA7T committed Sep 29, 2017
1 parent ad46c34 commit 65b96ac
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions DC2PD_preamp_set.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

if [ "$#" -lt "2" ]
then
echo "No arguments supplied"
else
CHIPADDRESS=$1
dB=$2

echo "Setting DC2PD preamplifier at address $CHIPADDRESS to $dB dB gain."

DAC=`echo "(4095 * ($dB - 7.5))/(55.5 - 7.5)" | bc`

HIGHBYTE=`echo $(($DAC >> 4))`
LOWBYTE=`echo $((($DAC << 4) & 255))`

i2cset -y 0 $CHIPADDRESS 0x60 $HIGHBYTE $LOWBYTE i # write 3000 to DAC & EEPROM
fi

0 comments on commit 65b96ac

Please sign in to comment.