EuroPi
EuroPi copied to clipboard
⚡️ adding support for ain bipolar mod
This change allows the use of bipolar signals in the Analogue input (ain
)
The main change is in the read_voltage
method of the AnalogueInput
class in europi.py
. It considers the Min and Max Voltage provided in the constructor.
In order to test this, the test_AnalogueInput.py
was created and the mock_hardware.py
modified to mock analog inputs.
Now, the EuroPi ain circuit has a non-inverting input with 1.22 gain. This means that the wide range of the ain
is 0 to 12.22V. To make the pytest
doable with mock hardware, the default value of INPUT_CALIBRATION_VALUES
in the europi.py
needs to change to [0, 64354]
(roughly the range of 0 to 12V). Likewise, the test needs to specify an input of min/max of 0 to 12 and -6 to 6 V.
I did not test this on an original EuroPi, instead I used a remix that allows bipolar input. The Calibration script should work as long as the minimum voltage is used instead of Ground (or disconnected).
Not sure if the implementation of the test is ok, please make remarks if needed
Hey @luisgongod thanks for this submission. I know that there was some discussion of this change in the discord, but I'm trying to remember the full context. Specifically the details around this:
I did not test this on an original EuroPi, instead I used a remix that allows bipolar input.
I want to make sure that we have all the details recorded in this issue so that we don't have to dig through discord history.
As to the code changes themselves, they largely look ok. The changes on the tests side look good to me. I'm a little wary of the calibration changes. These will need more testing.
Finally, I ran the automated checks and the formatting check failed. We require that the core library is formatted using the black code formatter. If you don't have this set up, let me know and I can help you out, or make the formatting changes for you.
Hi @mjaskula thanks for looking at this, I agree to keep threads of code in git. My comment was to be clear that I did not test on an original EuroPi from store, but rather one that I made on protoboard. Yet, I use the same components as the official BOM. The change that I made will not make any effect in any un-modified EuroPi, is only if someone want to make the hack that Rory suggested. It will also work if someone tried to modified the resistors to take a different range... it might be more useful for the second version that he is doing I just run Black and push on it. should be fine now i hope :)
This is now very out of date with the firmware and calibration process, so I'm closing it for now. Bipolar input is planned for the EuroPi X so we can re-open this or use its findings when appropriate!