mcp4728: Update to better match printrbot revf requirements
Reported by @Grumps49. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
73709984b0
commit
a878831d5e
|
@ -890,27 +890,28 @@
|
|||
#i2c_mcu: mcu
|
||||
# The name of the micro-controller that the MCP4451 chip is
|
||||
# connected to. The default is "mcu".
|
||||
#i2c_address:
|
||||
#i2c_address: 96
|
||||
# The i2c address that the chip is using on the i2c bus. The default
|
||||
# is zero.
|
||||
# is 96.
|
||||
#channel_a:
|
||||
#channel_b:
|
||||
#channel_c:
|
||||
#channel_d:
|
||||
# The value to statically set the given MCP4728 channel to. This is
|
||||
# typically set to a number between 0.0 and 1.0 with 1.0 being the
|
||||
# highest voltage and 0.0 being the lowest voltage. However, the
|
||||
# range may be changed with the 'scale' parameter (see below). If a
|
||||
# channel is not specified then it is left unconfigured.
|
||||
# highest voltage (2.048V) and 0.0 being the lowest voltage. However,
|
||||
# the range may be changed with the 'scale' parameter (see
|
||||
# below). If a channel is not specified then it is left
|
||||
# unconfigured.
|
||||
#scale:
|
||||
# This parameter can be used to alter how the 'channel_x' parameters
|
||||
# are interpreted. If provided, then the 'channel_x' parameters
|
||||
# should be between 0.0 and 'scale'. This may be useful when the
|
||||
# MCP4728 is used to set stepper voltage references. The 'scale' can
|
||||
# be set to the equivalent stepper amperage if the MCP4728 were at
|
||||
# its highest voltage, and then the 'channel_x' parameters can be
|
||||
# specified using the desired amperage value for the stepper. The
|
||||
# default is to not scale the 'channel_x' parameters.
|
||||
# its highest voltage (2.048V), and then the 'channel_x' parameters
|
||||
# can be specified using the desired amperage value for the
|
||||
# stepper. The default is to not scale the 'channel_x' parameters.
|
||||
|
||||
|
||||
# Statically configured MCP4018 digipot connected via two gpio "bit
|
||||
|
|
|
@ -6,6 +6,10 @@ All dates in this document are approximate.
|
|||
|
||||
# Changes
|
||||
|
||||
20190726: The mcp4728 digital-to-analog code has changed. The default
|
||||
i2c_address is now 0x60 and the voltage reference is now relative to
|
||||
the mcp4728's internal 2.048 volt reference.
|
||||
|
||||
20190710: The z_hop option was removed from the [firmware_retract]
|
||||
config section. The z_hop support was incomplete and could cause
|
||||
incorrect behavior with several common slicers.
|
||||
|
|
|
@ -7,7 +7,7 @@ import bus
|
|||
|
||||
class mcp4728:
|
||||
def __init__(self, config):
|
||||
self.i2c = bus.MCU_I2C_from_config(config, default_addr=0)
|
||||
self.i2c = bus.MCU_I2C_from_config(config, default_addr=0x60)
|
||||
scale = config.getfloat('scale', 1., above=0.)
|
||||
# Configure registers
|
||||
for i, name in enumerate('abcd'):
|
||||
|
@ -17,7 +17,7 @@ class mcp4728:
|
|||
self.set_dac(i, int(val * 4095. / scale + .5))
|
||||
def set_dac(self, dac, value):
|
||||
self.i2c.i2c_write([0x40 | (dac << 1),
|
||||
(value >> 8) & 0x0f, value & 0xff])
|
||||
((value >> 8) & 0x0f) | 0x80, value & 0xff])
|
||||
|
||||
def load_config_prefix(config):
|
||||
return mcp4728(config)
|
||||
|
|
Loading…
Reference in New Issue