Difference between revisions of "Sensors/Current"

From PaparazziUAV
Jump to navigation Jump to search
 
(15 intermediate revisions by 5 users not shown)
Line 2: Line 2:
__TOC__
__TOC__


It is very easy to get the Paparazzi system working with a current sensor.  
Current sensors can be easily added.


Examples are the one from Sparkfun (AttoPilot Voltage and Current Sense Breakout [http://www.sparkfun.com/commerce/product_info.php?products_id=9028 Current sensor]) or a linear hall-effect device such as the Allegro ACS755 or ACS715. The [http://www.teamnovak.com/products/data_logger/2000_sentry/index.html Novak Sentry current sensor] is based on the ACS755LCB-100 hall-effect sensor and has a range of 100A. The smaller and lighter [http://www.pololu.com/catalog/product/1186 Pololu Current Sensor Carrier] is based on the ACS715 with a current of up to 30A.
Examples are the one from Sparkfun (AttoPilot Voltage and Current Sense Breakout [http://www.sparkfun.com/commerce/product_info.php?products_id=9028 Current sensor]) or a linear hall-effect device such as the Allegro ACS755 or ACS715. The [http://www.teamnovak.com/products/data_logger/2000_sentry/index.html Novak Sentry current sensor] is based on the ACS755LCB-100 hall-effect sensor and has a range of 100A. The smaller and lighter [http://www.pololu.com/catalog/product/1186 Pololu Current Sensor Carrier] is based on the ACS715 with a current of up to 30A.
<gallery>
Image:Current_volt_sensor_01.jpg |Atto 01
Image:Current_volt_sensor_02.jpg |Atto 01
Image:Current_volt_sensor_03.jpg |Atto 01
Image:Current_volt_sensor_04.jpg |Atto 01
Image:Current_volt_sensor_05.jpg |Atto 01
Image:Current_volt_sensor_closeup_01.jpg |Atto 01 Closeup
Image:Current_volt_sensor_09028-01-L.jpg |Atto A/V
Image:Current_volt_sensor_09028-02-L.jpg |Atto A/V
Image:Current_volt_sensor_09028-03-L.jpg |Atto A/V
Image:Current_volt_sensor_alt_5360.jpg | Alternative sensor
Image:Current_volt_sensor_telemetry_data.jpg | The Current and volt sensor telemetry
Image:Current_volt_sensor_first_data_in_graph.jpg | The Current and volt sensor raw ADC first data in graph
</gallery>


== Hardware ==
== Hardware ==
Line 17: Line 32:
== Airframe integration ==
== Airframe integration ==


In the FIRMWARE section of the airframe file add these lines:
Following code needs to be added to the airframe conf:


{{Box Code|conf/airframes/myplane.xml|
<source lang="xml">
  <firmware name="fixedwing">
    ...
     <define name="USE_ADC"/>
     <define name="USE_ADC"/>
     <define name="USE_ADC_3"/>    <!-- motor current-->
     <define name="USE_ADC_3"/>    <!-- motor current-->
  </firmware>
  ...
  <section name="BAT">
    ...
    <define name="ADC_CHANNEL_CURRENT" value="ADC_3" />
    <define name="MilliAmpereOfAdc(adc)" value="Max(0,adc*88)"/>
  <section/>
</source>
}}


In the BAT section of the airframe file add these lines:


  <define name="ADC_CHANNEL_CURRENT" value="ADC_3" />
The ''Max(0,x)'' ensures that instead of getting a negative current when using a motor brake it is set to zero, thus not corrupting your energy estimate. If you have a setup where the current can become negative (e.g. charging the battery via solar cells) don't use ''Max''.
  <define name="MilliAmpereOfAdc(adc)" value="(88*adc)"/>


and remove the line:
Remove the line:
   <define name="MILLIAMP_AT_FULL_THROTTLE" value="12000" unit="mA"/>
   <define name="MILLIAMP_AT_FULL_THROTTLE" value="12000" unit="mA"/>


Line 37: Line 63:


For the ACS755LCB-100 sensor, there is a 0.6 volts offset. At 3.3v, the current is 67.5A. The formula is thus: value="(80.55*(adc-185))"
For the ACS755LCB-100 sensor, there is a 0.6 volts offset. At 3.3v, the current is 67.5A. The formula is thus: value="(80.55*(adc-185))"
For the ACS755LCB-50 sensor, there is a 0.6 volts offset. At 3.3v, the current is 45.A. The formula is thus: value="(43.94*(adc-185))"
Values By AGRESSiVA:
For the ACS755LCB-50 sensor using resistive divisor (1k8/3k3). The formula is thus: value="(68.017*(adc-120))" (not confirmed / tested)
For the ACS755LCB-100 sensor using resistive divisor (1k8/3k3). The formula is thus: value="(122.5*(adc-120))"


== Display on Ground Control Station (GCS) ==
== Display on Ground Control Station (GCS) ==
Line 47: Line 81:


You can display the energy or current on the GCS by just dragging and dropping them on the 2d map.
You can display the energy or current on the GCS by just dragging and dropping them on the 2d map.
== Current / Voltage Sensor ==
If you would like to install the autopilot on a bigger airframe, you can face the problem, that the nominal voltage of the battery-pack is higher then allowed for the autopilot. (i.e. 6 cell LiPo and TWOG ) But if you use a voltage regulator, then the autopilot has no information on the real voltage of the battery-pack. The GCS will show the autopilot input voltage, which is irrelevant regarding the remaining capacity of the battery-pack.
Fortunately the AttoPilot [http://www.sparkfun.com/commerce/product_info.php?products_id=9028 Voltage and Current Sensor (Sparkfun)] provides a voltage signal scaled down to 3.3V, too. This can be connected to a general analog input of the autopilot (for example ADC_4) similar to the current signal. If you configure the airframe file in the following way, the autopilot will provide all of the warnings (i.e. Battery Low) and calculations (i.e. power consumption) as it does in case of a direct connection between autopilot and battery-pack.
Further information can be found on [[Airframe_Configuration#Battery]].
{{Box Code|conf/airframes/myplane.xml|
<source lang="xml">
  <firmware name="fixedwing">
    ...
    <define name="USE_ADC"/>
    <define name="USE_ADC_4"/>    <!-- Battery voltage-->
    <define name="ADC_CHANNEL_VSUPPLY" value="ADC_4"/>
  </firmware>
  ...
  <section name="BAT">
    ...
    <define name="VOLTAGE_ADC_A" value="0.05"/>
    <define name="VOLTAGE_ADC_B" value="1"/>
    <define name="VoltageOfAdc(adc)" value="(VOLTAGE_ADC_A * adc + VOLTAGE_ADC_B)"/>
  <section/>
</source>
}}
'''Don't need to load the adc_generic module! You will get wrong values in the energy messages!'''
(The above method was tested with Sparkfun Attopilot Current Sensor and TWOG.)


[[Category:Sensors]] [[Category:Software]] [[Category:User_Documentation]]
[[Category:Sensors]] [[Category:Software]] [[Category:User_Documentation]]

Latest revision as of 05:57, 3 May 2015

Current sensors can be easily added.

Examples are the one from Sparkfun (AttoPilot Voltage and Current Sense Breakout Current sensor) or a linear hall-effect device such as the Allegro ACS755 or ACS715. The Novak Sentry current sensor is based on the ACS755LCB-100 hall-effect sensor and has a range of 100A. The smaller and lighter Pololu Current Sensor Carrier is based on the ACS715 with a current of up to 30A.

Hardware

Current sensor connected to the TWOG v1

Typically, the current sensor is used to measure the current flowing through the main battery (rather than the motor). Connect the + and - pole of the sensor through the battery red lead. The + and - have to be soldered directly.

On the Sparkfun breakout board, a wire is connected to the "VI" pin. It must have a voltage between 0 and 3.3V. On a TWOG v1 or Tiny v2 board, the current sense output wire ("IA" on the Sparkfun sensor) is connected to the ADC_3 (or ADC_4) pin.

On the Novak Sentry current sensor, the red wire is connected to +5 volts. The black wire is ground. The yellow wire is the output (40mV/amp. 0.6v=0amps, 5.0v=110amps) and is connected to the ADC_3 (or ADC_4) pin.

Novak 100A current sensor

Airframe integration

Following code needs to be added to the airframe conf:


File: conf/airframes/myplane.xml
  <firmware name="fixedwing">
    ...
    <define name="USE_ADC"/>
    <define name="USE_ADC_3"/>    <!-- motor current-->
  </firmware>
  ...
  <section name="BAT">
    ...
    <define name="ADC_CHANNEL_CURRENT" value="ADC_3" />
    <define name="MilliAmpereOfAdc(adc)" value="Max(0,adc*88)"/>
  <section/>


The Max(0,x) ensures that instead of getting a negative current when using a motor brake it is set to zero, thus not corrupting your energy estimate. If you have a setup where the current can become negative (e.g. charging the battery via solar cells) don't use Max.

Remove the line:

 <define name="MILLIAMP_AT_FULL_THROTTLE" value="12000" unit="mA"/>

The correct multiplier for the raw measurement conversion depends on the current sensor. The Sparkfun sensor returns a linear voltage of 0 V - 3.3 V and at 90.15 A it reaches the maximum of 3.3 V. The TWOG v1 or Tiny v2 have a A/D converter with 10-bit precision (1024 different values) to represent the voltage. So you can calculate the multiplier with the following formula:

1000 / precision * A_at_max_voltage

For the Sparkfun sensor, the precision is 1024 and A_at_max_voltage is 90.15 => 1000/1024*90.15 = 88.037

For the ACS755LCB-100 sensor, there is a 0.6 volts offset. At 3.3v, the current is 67.5A. The formula is thus: value="(80.55*(adc-185))"

For the ACS755LCB-50 sensor, there is a 0.6 volts offset. At 3.3v, the current is 45.A. The formula is thus: value="(43.94*(adc-185))"

Values By AGRESSiVA:

For the ACS755LCB-50 sensor using resistive divisor (1k8/3k3). The formula is thus: value="(68.017*(adc-120))" (not confirmed / tested)

For the ACS755LCB-100 sensor using resistive divisor (1k8/3k3). The formula is thus: value="(122.5*(adc-120))"

Display on Ground Control Station (GCS)

Use the Messages application to show it.

The total energy consumed during the flight (in mAh) is sent in the "BAT" message.

The actual current flowing through the sensor (in mA) is sent in the "fbw_status" message.

You can display the energy or current on the GCS by just dragging and dropping them on the 2d map.

Current / Voltage Sensor

If you would like to install the autopilot on a bigger airframe, you can face the problem, that the nominal voltage of the battery-pack is higher then allowed for the autopilot. (i.e. 6 cell LiPo and TWOG ) But if you use a voltage regulator, then the autopilot has no information on the real voltage of the battery-pack. The GCS will show the autopilot input voltage, which is irrelevant regarding the remaining capacity of the battery-pack.

Fortunately the AttoPilot Voltage and Current Sensor (Sparkfun) provides a voltage signal scaled down to 3.3V, too. This can be connected to a general analog input of the autopilot (for example ADC_4) similar to the current signal. If you configure the airframe file in the following way, the autopilot will provide all of the warnings (i.e. Battery Low) and calculations (i.e. power consumption) as it does in case of a direct connection between autopilot and battery-pack.

Further information can be found on Airframe_Configuration#Battery.


File: conf/airframes/myplane.xml
  <firmware name="fixedwing">
    ...
    <define name="USE_ADC"/>
    <define name="USE_ADC_4"/>    <!-- Battery voltage-->
    <define name="ADC_CHANNEL_VSUPPLY" 	value="ADC_4"/>
  </firmware>
  ...
  <section name="BAT">
    ...
    <define name="VOLTAGE_ADC_A" value="0.05"/>
    <define name="VOLTAGE_ADC_B" value="1"/>
    <define name="VoltageOfAdc(adc)" value="(VOLTAGE_ADC_A * adc + VOLTAGE_ADC_B)"/>
  <section/>


Don't need to load the adc_generic module! You will get wrong values in the energy messages!

(The above method was tested with Sparkfun Attopilot Current Sensor and TWOG.)