Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[P166] Add plugin GP8403 DAC Dual channel 0-10V #4952

Merged

Conversation

tonhuisman
Copy link
Contributor

@tonhuisman tonhuisman commented Jan 24, 2024

From a Forum request

Features:

  • Support for GP8403 DAC Dual channel 0-10V
  • Using partial and customized code from DFRobot_GP8403 library
    • Unsupported: Sine wave, Triangle wave and Square wave output, these use blocking code, and are too timing critical to reliably implement in ESPEasy
    • Unsupported: Storing current value in chip, reason: Disconnects I2C and 'wiggles' the GPIO pins to put the values in the chip, then re-initializes I2C. This will most likely cause any other I2C device on the bus to fail, and possibly break 😨
  • Settings:
    • Range setting 5V/10V
    • Restore output on warm boot (default enabled)
    • Initial value per output channel
    • Up to 25 named presets
  • Command handling for: set output voltage, select range and apply a preset value by name
    • <ch> = output (channel) 0, 1 or 2 (both)
    • gp8403,volt,<ch>,<value> : Set the voltage in V (0..5.0/0..10.0) value to channel
    • gp8403,mvolt,<ch>,<value> : Set the voltage in mV (0..5000/0..10000) value to channel (resolution limited to 12 bit = 4096 steps)
    • gp8403,range,<5|10> : Set the range to 5V or 10V (both channels, hardware limitation/feature)
    • gp8403,preset,<ch>,<name> : Set the voltage from preset <name> to channel
    • gp8403,init,<ch> : Set the initial voltage to channel
  • GET_CONFIG support to read the initial values, configured presets and range setting
    • [<taskname>#preset<X>] : The configured preset <X> value (range checked)
    • [<taskname>#initial0] : The configured initial output 0 value
    • [<taskname>#initial1] : The configured initial output 1 value
    • [<taskname>#range] : The configured range setting 5 or 10
  • This plugin is available in the MAX and Collection G builds.

Additional features:

  • [UI] The I2C Address selector now allows for an explicit default value, instead of the first value in the list, so the list can be in numeric/natural order
    • Adjusted this for plugins: [P015] TSL2561, [P032] MS5611, [P060] MCP3221, [P106] BME-68x, [P120] ADXL345, [P127] CDM7160 and [P154] BMP-3xx.

TODO:

  • Testing:
    • Wait for hardware to arrive 🐌
    • Test on hardware
      • Range 0-10V
      • Range 0-5V
    • Testing by requester (confirmed)
  • Handle general feedback (if any)
  • Documentation

@saint-hh
Copy link

saint-hh commented Jan 25, 2024

Build: ESP_Easy_mega_20240124_collection_G_ESP32_4M316k_ETH Jan 24 2024

After flashing, I've immediately added the Output - GP8403 Dual-channel DAC 0-10V device.
The WT32-ETH01 board crashed then. After a reboot everything was fine.
I guess it may have something to do with the fact, that I haven't configured the I2C Interface yet. Maybe this could be handled without crashing.

Next: connecting one DAC

@tonhuisman
Copy link
Contributor Author

The WT32-ETH01 board crashed then. After a reboot everything was fine.
I guess it may have something to do with the fact, that I haven't configured the I2C Interface yet. Maybe this could be handled without crashing.

Not having the GPIOs for I2C set shouldn't crash the ESP, I'd assume that the crash is just an unhappy coincidence of some events.
And the device being disabled when the hardware is not found is on purpose, as by default the Tools/Advanced setting Check I2C devices when enabled: is enabled. This feature was introduced to defeat hanging or slow performance because of some poorly written sensor libraries that keep polling the I2C bus indefinitely when an expected response isn't read.
With this setting turned off I was able to test the commands and values for this plugin without the hardware being connected 😸

@saint-hh
Copy link

Yes, since I fixed the messed up I2C address, everything works as intended.
Only: sending to controller doesn't update the values in ioBroker, if interval is set to 0 sec. I have to set 1 sec, then it's updated.
Is it intended to be this way?

@TD-er
Copy link
Member

TD-er commented Jan 25, 2024

Interval set to 0 means no interval.
If you really need to have it run more frequent, you can set it to 0 interval and create a looptimer_ms and call taskrun when the timer creates an event.

But I doubt it makes sense to do it this fast.
It makes more sense to call taskrun on that task when setting the output value.
I guess it would make even more sense if the plugin would do this automatically when setting a new output value :) (thus work for Ton)

@saint-hh
Copy link

I guess it would make even more sense if the plugin would do this automatically when setting a new output value :)

Exactly what I think would be best. I need a feedback, only once it's changed.

@TD-er TD-er merged commit 0e0145e into letscontrolit:mega Jan 31, 2024
168 checks passed
@tonhuisman tonhuisman deleted the feature/P166-Add-plugin-gp8403-dac-0-10V branch January 31, 2024 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants