Open dcl920108 opened 1 month ago
Hi Nero,
great that you're using my repository as a reference. I'm not really familiar with microchip technology, so I can just try to take some guesses what could be the problem.
Are you using a MCP4441 or MCP4442 chip? You introduced with MCP4441 but your class is named MCP4442. Maybe there are differences in the registers or addresses that need to be used for your task.
Maybe a timing issue? The write progress may take some time and when you read back the value immediately it is not yet written? Maybe try to include some waiting and then read back the value.
Maybe try to use another implementation of the smbus library? There is also smbus2 (https://pypi.org/project/smbus2/).
I hope you can figure out the problem.
Best regards, Simon
Hi Simon, I'm trying to control an MCP4441 chip using a Raspberry Pi, and I'm having some issues. I've been using your [repository/library] as a reference, but I'm not getting the expected results. Specifically, I'm trying to set the output value of Channel 2 to its maximum value, but when I read back the value, it's always 0. I've tried modifying the write and read formats, but nothing seems to work. Here's my code: import smbus
class MCP4442_DAC: def init(self, i2c_bus, hw_addr): self.i2c_bus = i2c_bus self.hw_addr = hw_addr self.i2c = smbus.SMBus(i2c_bus)
dac = MCP4442_DAC(1, 0x2C) # Initialize I2C bus and MCP4441 chip address dac.set_max() # Set Channel 2 output value to maximum
The output I get is:
Successfully wrote value 255 to register 6 Successfully read value 0 from register 6
I'm not sure what's going wrong. Can you help me troubleshoot this issue or provide some guidance on how to control the MCP4441 chip with a Raspberry Pi? Thanks in advance for your help!
Best regards, Nero