wokwi / wokwi-features

Wokwi Feature requests & Bug Reports
https://wokwi.com
73 stars 17 forks source link

Add Support for Attribute Dependency in Custom Chips #706

Open hayschan opened 10 months ago

hayschan commented 10 months ago

Describe the feature request: I am currently developing a custom chip simulation for an air flow sensor in the Wokwi Simulator. The sensor's behavior involves variable flow rate values depending on another attribute, specifically the 'K' value. The Wokwi Simulator custom chips AI currently doesn't support attribute dependency, which is crucial for accurately simulating the behavior of such sensors.

Use Case: The air flow sensor has different flow rate ranges based on the 'K' value:

I need to simulate the sensor such that when the 'K' value attribute changes, the range of another attribute (the flow rate) adjusts accordingly.

Both of these attributes are set by user.

Current Limitation: The current API does not support dynamic adjustment of one attribute's range based on the value of another attribute. Here is the current JSON configuration for the custom chip:

{
    "name": "airFlowSensor",
    "author": "",
    "pins": [
        "GND",
        "SCL",
        "SDA",
        "VCC"
    ],
    "controls": [
        {
            "id": "airFlowRate",
            "label": "Gas Air Flow Rate",
            "type": "range",
            "min": 10,
            "max": 50,
            "step": 1
        },
        {
            "id": "K value",
            "label": "K value",
            "type": "range",
            "min": 100,
            "max": 1000,
            "step": 900
        }
    ]
}

Requested Feature: I propose the implementation of attribute dependency within the custom chip configuration. This feature would allow for dynamic changes in one attribute's properties (such as range) based on the value of another attribute. This enhancement would significantly increase the accuracy and utility of simulations involving sensors or components with interdependent parameters.

Thank you for considering this feature request.

djedu28 commented 1 month ago

For this specific application, you can use percentage airFlowRate. in the ranger from 0 to 100% for “airFlowRate”.

{
            "id": "airFlowRate",
            "label": "Gas Air Flow Rate",
            "type": "range",
            "min": 0,
            "max": 100,
            "step": 1
 },

In this way, the chip's programming will interpret the maximum and minimum airFlowRate as varying according to the value of K.

As a visual solution to the airFlowRate value, you could use the graphic resource on the chip itself, implemented in Framebuffer Chip - https://wokwi.com/projects/330503863007183442

"display": {
    "width": 128,
    "height": 50
}

image

Translated with DeepL.com

hayschan commented 4 weeks ago

For this specific application, you can use percentage airFlowRate. in the ranger from 0 to 100% for “airFlowRate”.

{
            "id": "airFlowRate",
            "label": "Gas Air Flow Rate",
            "type": "range",
            "min": 0,
            "max": 100,
            "step": 1
 },

In this way, the chip's programming will interpret the maximum and minimum airFlowRate as varying according to the value of K.

As a visual solution to the airFlowRate value, you could use the graphic resource on the chip itself, implemented in Framebuffer Chip - https://wokwi.com/projects/330503863007183442

"display": {
    "width": 128,
    "height": 50
}

image

Translated with DeepL.com

Thanks a lot. I'll try that out.