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

Different AI resolution in python and node-red #407

Closed
bergmanu opened this issue Jan 12, 2023 · 4 comments
Closed

Different AI resolution in python and node-red #407

bergmanu opened this issue Jan 12, 2023 · 4 comments

Comments

@bergmanu
Copy link
Collaborator

Using the GPIO node-red node to read in an analog value from the I/O Module - either 0..10V or 0..20mA - results in a value from 0..4095 (12-bit resolution)

Using the same analog input with mraa in python the resolution is only 0..1023 (9-bit)

Where does this difference come from?

@AsuraZeng
Copy link
Contributor

After my investigation, node red set the ADC bit to 12bit, but
the default setting in mraa is 10bit. The current workaround is to set the bit of adc to 12 after initializing the ADC.

I have a PR to resolve this one.
eclipse/mraa#1103.
it's under review currently.

@jan-kiszka
Copy link
Collaborator

As you correctly noted: That PR is a workaround, not the solution yet.

@jan-kiszka
Copy link
Collaborator

And: there is no issue. node-red-node simply raises the number of bits to what the hardware can do. That is done at https://github.com/node-red/node-red-nodes/blob/9bae313b722147b00480ce2e26ed0aab357b836b/hardware/intel/mraa-gpio-ain.js#L15. That is logically one level above what the Python (or also NodeJS) bindings does which only exposes the AIO abstraction. And that abstraction chose to start with 10 bits, hardware-independently.

IOW: Nothing to fix here or elsewhere, just to understand logic-wise.

@jan-kiszka
Copy link
Collaborator

In that light, setting the number of bits unconditionally in node-red-node could even be questioned from a hardware abstraction POV. It should rather become a tunable of that node.

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

No branches or pull requests

3 participants