Sensors/Current

Sensors
__TOC__
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.
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
== Hardware ==
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. 
== Airframe integration ==
Following code needs to be added to the airframe conf:
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.
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