Closed frittna closed 2 years ago
Hi, when i try to use "Curr" with an analog signal on ADC pin20 (on my TeensyLC) i get really bad quantization setps, like only a few steps for 0-100%.. BUT when i simply swap the pins in the MSRC code at constants.h (pin20 and 26 in my case) to use the current sensor on the Airspeed-input instead of the Current-input it is quantisizing fine like it should.
Thanks. There was a mistake on the pin numbers for current and pressure for the Teensy. It is fixed now. Pins 18 and 19 are used for the I2C port and can't be used for analog readings. Pin 20 should be fine for Current now.
btw: my ACS711EX hall current sensor was not usable because of far to heavy noise on the signal line on my try
You can reduce the noise in two ways:
Thanks ! I made a picture for you. It is a LOG where i try to explain what i mean with the wrong calculated values of current, no matter what is connected. The wrong definings which was in conflict with the I2C (18+19) was not the cause. Here i have only one sensor on PIN20, PIN26 is free. After the break i swapped the pins only in the SW at constants.h and tried again.
It looks like it is enabled the pressure pin instead of the current pin
Please could you attach or post your config.h and the debug when enabling DEBUG_EEPROM_READ (if using lua script)
i will enable and post a debug log soon.
but i explain it again in a short version:
1: i have an analog sensor connected to Pin20, which is "Curr" at default , my PIN26 is free Result --> received "Curr" values are choppy.
2: Then, i do not change anything on the connections/sensors/etc I ONLY change PIN numbers for Curr and Pressure in Arduino (constants.h) where Port connections are set. Result --> Pressure is showing the correct value from pin20 and it is smooth and nice.
no unit, no calculation, and same precision for both SPort sensors are set in OpenTX 2.3.14 (Q7)
so here must be a difference in handling analog values at current in comparison to pressure. if i would connect 2 identical sensors to pressure and curr at the same time it would be interesting, have not done that because i can't try at the moment..
regards
here is a part of my config.h / Sensors / ...
/ Refresh rate in 0.1s (1 = 100ms) /
/ Averaging elements (1 = no averaging) /
...
here is the part in my constants.h ... // Teensy LC/3.x
...
Indeed there was an issue with the analog current resolution. Also with analog voltage. Fixed with ded3b53af5ad7094489262927ec9beee0258729d
I've added multipliers for analog current and analog voltage sensors. This allows to transform to the correct values from code, rather than from opentx, which was causing a poor value resolution.
This also allows other rx protocols to adjust the current and voltage values to the real ones.
So rather using opentx to adjust the current value, use CURRENT_MULTIPLIER in config.h to transform Volts to Amps
One comment is that you may be getting low Vout in your circuit for current measurement. Based on log data I suspect you are getiing a max Vout of 0.4V or so, while maximum is 3.3v. You may need to change the diffamp for a bigger gain. If I'm correct you resolution will be about 400 points using CURRENT_MULTIPLIER (with opentx you were getting a resolution about 4 levels, on the log above)
The reason for the poor resolution was that, if the transformation is done in opentx, it is sent the voltage value on the pin with 1 decimal (1 decimal is the precision for the current sensor in opentx). This produces a resolution of 33 levels for 3.3v boards. For analog voltage, the precision in opentx is 2 decimals, so is less critical, giving 330 levels for 3.3v. Other analog sensors (ntc, airspeed) are already calculated in MSRC, that's why it was producing more resolution when using the airspeed pin. BTW maximum resolution is 4096 (12bits ADC)
Hi, when i try to use "Curr" with an analog signal on ADC pin20 (on my TeensyLC) i get really bad quantization setps, like only a few steps for 0-100%.. BUT when i simply swap the pins in the MSRC code at constants.h (pin20 and 26 in my case) to use the current sensor on the Airspeed-input instead of the Current-input it is quantisizing fine like it should.
I mean without any hardware change.
any idea if that could be a bug beside the hardware which is working good with TeensyLC@3.3V Smartport, HobbyWing ESCv4, BMP280, 2xTemp analog. For the current - since the Hobbywing 40A ESC has no built in shunt - I now use 1mOhm shunt resisor with a LM358N as diff-amp placed in the GND Cable, 0-40A equals 0-1.6V and it is working good, no bad noise with 1u and 220n caps, nice level shifing on a scope. Shunt is ok i guess. btw: my ACS711EX hall current sensor was not usable because of far to heavy noise on the signal line on my try
AND: Great project!! everything is working superb after dealing with many many issues but that was perhaps all my fault and mainly Pololu 5V related
regards