2023-08-04, 01:05 PM
Hello,
I started building up a pypilot controller with a MD13S I had in possession. The setup seems to be working fine, but since this controller is missing a current sensor, I added a VMA323/ACS712 sensor.
This sensor measures currents from -20A (~0V) to +20A (~5V) with a 0A corresponding to an offset of 2.4V approximately. It has a sensitivity of 100mV/A.
I connected its output to the A1 pin of the Arduino nano.
This is what I've done to motor.ino so far:
- #define VNH2SP30, DISABLE_TEMP_SENSE, DISABLE_VOLTAGE_SENSE, DISABLE_RUDDER_SENSE (I do not have sensors for this yet)
- in TakeAmps(), replace:
with:
- Since I need an analog measurement range from 2.4V to 3.4V (approximately), and as far as I understand, the current definition of adcref=_BV(REFS0)| _BV(REFS1) provides a range from 0 to 1.1V, I replaced it with adcref=BV(REFS0) everywhere in the code (two lines changed) to get a 0 to 5V range.
Now when I plot the current on openplotter's pypilot scope, I can see that the voltage offset is properly handled (0 when no current is flowing into the sensor; if I replace 2400 with a lower value in the code, I get a positive value for 0 amps).
But the value increase when current starts flowing in the motor is invalid:
- 100mA --> 1.3
- 1.7 A --> 3
Direct voltage measurement on the ACS712 sensor shows that the sensor works fine.
It seems this increase is not linear, which is what I would have expected. Is there something else I could have missed or misunderstood in the file?
Thanks for the help!
I started building up a pypilot controller with a MD13S I had in possession. The setup seems to be working fine, but since this controller is missing a current sensor, I added a VMA323/ACS712 sensor.
This sensor measures currents from -20A (~0V) to +20A (~5V) with a 0A corresponding to an offset of 2.4V approximately. It has a sensitivity of 100mV/A.
I connected its output to the A1 pin of the Arduino nano.
This is what I've done to motor.ino so far:
- #define VNH2SP30, DISABLE_TEMP_SENSE, DISABLE_VOLTAGE_SENSE, DISABLE_RUDDER_SENSE (I do not have sensors for this yet)
- in TakeAmps(), replace:
Code:
if(pwm_style == 2)
return v * 9 / 34 / 16;
with:
Code:
if(pwm_style == 2)
v = v * 5000 / 1024 / 16;
if (v > 2400)
return v - 2400;
return 0;
- Since I need an analog measurement range from 2.4V to 3.4V (approximately), and as far as I understand, the current definition of adcref=_BV(REFS0)| _BV(REFS1) provides a range from 0 to 1.1V, I replaced it with adcref=BV(REFS0) everywhere in the code (two lines changed) to get a 0 to 5V range.
Now when I plot the current on openplotter's pypilot scope, I can see that the voltage offset is properly handled (0 when no current is flowing into the sensor; if I replace 2400 with a lower value in the code, I get a positive value for 0 amps).
But the value increase when current starts flowing in the motor is invalid:
- 100mA --> 1.3
- 1.7 A --> 3
Direct voltage measurement on the ACS712 sensor shows that the sensor works fine.
It seems this increase is not linear, which is what I would have expected. Is there something else I could have missed or misunderstood in the file?
Thanks for the help!