Mycodo icon indicating copy to clipboard operation
Mycodo copied to clipboard

Request to add DFRobot i2c DAC output module (0-10v)

Open Nithalik opened this issue 1 year ago • 43 comments

Found a awesome DAC from DFrobot, it is the first i2C device that i have found that outputs a 0-10v signal. also has 8 possible i2c addresses. i am a failure at programming so hoping this is universal enough for other people to find useful too.

https://www.dfrobot.com/product-2613.html

tons of lighting systems use 0-10v dimming, and this is the easiest way to add it to mycodo without making your own circuit, which is how i am currently doing it, this is just more user friendly

https://www.prolighting.com/blog/2020/03/25/understanding-0-10v-dimming-with-todays-led-commercial-fixtures/

wiki: https://wiki.dfrobot.com/SKU_DFR0971_2_Channel_I2C_0_10V_DAC_Module

probably somewhat similar to https://kizniche.github.io/Mycodo/Supported-Outputs/#digital-to-analog-converter-mcp4728

i envision the output to just have the option to select i2c address and set output voltage, bit simpler then the mcp4728

they also have 6 version of this board with various different outputs

Nithalik avatar Dec 10 '23 04:12 Nithalik

Do you own one that you can test with?

kizniche avatar Dec 10 '23 19:12 kizniche

i am ordering one today to test with, just recently found these.

Nithalik avatar Dec 10 '23 20:12 Nithalik

don't think it would matter from your side, but i can always order one of their different versions for testing if you are interested in it.

i just dont really understand the use of the (4-20mA) ones, i think there are really just commercial applications, but there are also the PWM ones

Nithalik avatar Dec 10 '23 20:12 Nithalik

No need to buy others, unless you have a use for it.

kizniche avatar Dec 10 '23 20:12 kizniche

ok, ordered, should be here within 2 weeks

Nithalik avatar Dec 10 '23 20:12 Nithalik

asking here to see if this is even something feasible if this output module gets added to the system

if this output module is added, would it be hard to also add Trigger Configuration: Trigger: Output based on

image

if this output gets added, would it be hard to add a similar trigger output based on this output device? does not seem like you can trigger things by i2c devices at this point

Nithalik avatar Dec 12 '23 01:12 Nithalik

It's feasible and wouldn't be too hard to develop. It would act like any other Value Output that allows you to set a value (between 0 and 10) and would work with the current Output Value Action.

kizniche avatar Dec 19 '23 19:12 kizniche

the parts have arrived. have 2 of 2-Channel I2C DAC Module (0-10V) and 1 1-Channel 15-bit I2C to 0-5V/10V DAC Module

Nithalik avatar Dec 22 '23 23:12 Nithalik

that could open some options for both Lights, Fan Control, Valves, VFD and some more hope we can test some soon with those chips

silverhawk1983 avatar Feb 14 '24 15:02 silverhawk1983

It's feasible and wouldn't be too hard to develop. It would act like any other Value Output that allows you to set a value (between 0 and 10) and would work with the current Output Value Action.

0-1000 would be more suited for that kind of output in relation to 0.00v to 10.00v so we could send for 6.34v - 634 as value internally would be higher due to 12/15bit conversion internally

realworld 0.00-10.00v Mycodo 0-1000(equal to 0 to 1000mV) module 12bit - 0-4.095 (0x000-0xFFF) / 15bit 0-32767 (0x0000-0x7FFF)

silverhawk1983 avatar Feb 27 '24 00:02 silverhawk1983

i got 2 2ch 15bit 0-10v modules today in the mail did we have by any chance some code to test with them

silverhawk1983 avatar Mar 06 '24 17:03 silverhawk1983

no code from me, am in the middle of a move

Nithalik avatar Mar 06 '24 18:03 Nithalik

Yes, I have a module that you can test. I'll push the code later when I have access to my development system.

kizniche avatar Mar 06 '24 18:03 kizniche

I just committed an untested module. Give it a test and let me know if there are any issues.

kizniche avatar Mar 06 '24 20:03 kizniche

will try it hope it will work with the 15bit to

silverhawk1983 avatar Mar 07 '24 15:03 silverhawk1983

So i try use the new module with the 15bit thats not working but throws no error

so then i did a modifiy of the module code for the GP8413 the 15bit one value_p8413_dac_0_10_vdc.txt could not find a lib for the 8413 gone for the 8403 but it trows mycodo.outputs.output_gp8413_dac_0_10_vdc_a3f3677f - Cannot manipulate Output a3f3677f-482a-4ada-9f5d-934557eb22d1: output channel doesn't exist: 0

missing the 5V/10V selection

missing Name field for each Channel

silverhawk1983 avatar Mar 07 '24 16:03 silverhawk1983

Have you tested the hardware the module was designed for? Let's stick to the original issue before bringing in other hardware into the discussion. I also don't see any links to the product you're referring to, so I wouldn't be able to even reference a datasheet.

kizniche avatar Mar 07 '24 17:03 kizniche

sure your right i have only the 15bit Version but the Control is the same for all of those

only dif is the internal command for the value in Case of 12 or 15 bit etc showed that last week in a post the pip-pi lib is only to hard coded only for the 8403 the DFrobot lib instead has them all in it.

Produkt Overview shop https://www.dfrobot.com/product-2756.html

Produkt Overview wiki (https://wiki.dfrobot.com/SKU_DFR1073_2_Channel_15bit_I2C_to_0-10V_DAC)

Link to Datasheets 8403 https://dfimg.dfrobot.com/nobody/wiki/0e324f3dbbd888ea78b2c0d23340998c.pdf

8413 https://dfimg.dfrobot.com/60c1e008bddfc41c3293de80/wiki/56397a22232d7e06df627ec8a688539a.pdf

Joe2824 the lib you used linked to Pypi https://github.com/Joe2824/DFRobot_GP8403/tree/main

DFRobot Github Lib https://github.com/DFRobot/DFRobot_GP8XXX/tree/master/python/raspberryPi

my Old reply to one of your replys

It's feasible and wouldn't be too hard to develop. It would act like any other Value Output that allows you to set a value (between 0 and 10) and would work with the current Output Value Action.

0-1000 would be more suited for that kind of output in relation to 0.00v to 10.00v so we could send for 6.34v - 634 as value internally would be higher due to 12/15bit conversion internally

realworld 0.00-10.00v Mycodo 0-1000(equal to 0 to 1000mV) module 12bit - 0-4.095 (0x000-0xFFF) / 15bit 0-32767 (0x0000-0x7FFF)

silverhawk1983 avatar Mar 07 '24 20:03 silverhawk1983

And does the code you linked to work?

kizniche avatar Mar 07 '24 22:03 kizniche

I don't think your library is a good solution. For one, it uses RPi.GPIO, which A) is not supported in Pi 5s, and B) is a terrible way to conduct I2C communication due to it changing the I2C pins to inputs and other issues that conflict with other libraries, such as smbus2.

kizniche avatar Mar 07 '24 22:03 kizniche

I don't think your library is a good solution. For one, it uses RPi.GPIO, which A) is not supported in Pi 5s, and B) is a terrible way to conduct I2C communication due to it changing the I2C pins to inputs and other issues that conflict with other libraries, such as smbus2.

that´s true i linked that only for comparison

silverhawk1983 avatar Mar 08 '24 12:03 silverhawk1983

And does the code you linked to work?

no!

So i try use the new module with the 15bit thats not working but throws no error

so then i did a modifiy of the module code for the GP8413 the 15bit one value_p8413_dac_0_10_vdc.txt could not find a lib for the 8413 gone for the 8403 but it trows mycodo.outputs.output_gp8413_dac_0_10_vdc_a3f3677f - Cannot manipulate Output a3f3677f-482a-4ada-9f5d-934557eb22d1: output channel doesn't exist: 0

missing the 5V/10V selection

missing Name field for each Channel

but i think the problem lies in the pypi Lib witch is only written for the 8403

silverhawk1983 avatar Mar 08 '24 12:03 silverhawk1983

Did you set the right sda & scl pins when you tested the code?

kizniche avatar Mar 09 '24 14:03 kizniche

Tested Your Code in my dev system on Raspi 5 but like i sad no error and no output but like i said the 8413 not the 8403 8413_1 8413_2

Nithalik has the 8403

did you look in the lib you used

could it be the reason for that no output that the range setting is missing all modules of that kind have hat 5/10V to set the range

silverhawk1983 avatar Mar 09 '24 17:03 silverhawk1983

Did you set the right sda & scl pins when you tested the code? i dont tested the DFRobot Lib

I2C ist working fine with all other modules i have is set to gpio 2/3

61 is SCD30 5F is GP8413 5A is MLX not shoing in overview some how both the scd30 and the Mlx workling fine

silverhawk1983 avatar Mar 09 '24 18:03 silverhawk1983

Rasp 5

SInce the library uses Rpi.GPIO, it is not compatible with Pi >= 5, as indicated in the Output module:

https://github.com/kizniche/Mycodo/blob/fd837e55fac4c604fa3c3ffa06caf566a801792e/mycodo/outputs/value_dac_p8403.py#L40

I2C ist working fine with all other modules i have is set to gpio 2/3

This doesn't directly answer the question of whether you set the same pins with the example code you posted. Also, see the note above about any library using RPi.GPIO, you need to use a Pi <= 4.

To work with a Pi 5, the library needs to be refactored to use smbus2 or similar, with all use of RPi.GPIO removed.

kizniche avatar Mar 09 '24 18:03 kizniche

that statement was not in the first try 2 days ago i re downloaded today the module for the test and the pictures the only other pi i have is an old zero thats on full throttle with mycodo not realy usefull

so it would be wise to get the original DFRobot Lib ubgraded for the pypi and without RPi.GPIO https://github.com/DFRobot/DFRobot_GP8XXX/tree/master/python/raspberryPi

but my python skills are not at a point to take that on im happy that i can read and half way understand whats written there

silverhawk1983 avatar Mar 09 '24 20:03 silverhawk1983

@silverhawk1983 I will try to update the pypi repository. The problem is that the chip is using a non i2c standard to save values to the chip. Or I have to delve further into the smbus2 library. I will try to adopt the DFRobot_GP8XXX. But right now I'm a limited with my time.

Joe2824 avatar Mar 30 '24 16:03 Joe2824

@Joe2824 yeah happy to hear i will test the GP8413 as soon as posible Thanks for the invest! @kizniche here is Joes new Lib https://pypi.org/project/GP8XXX-IIC/ hope that helps with a more universal implemention so we can test the three modules that @Nithalik and i have on hand!

silverhawk1983 avatar Apr 02 '24 01:04 silverhawk1983