Difference between revisions of "Current sensor"
Line 11: | Line 11: | ||
== Airframe integration == | == Airframe integration == | ||
In the BAT section of the airframe file add this lines: | |||
<define name="ADC_CHANNEL_CURRENT" value="ADC_3" /> | <define name="ADC_CHANNEL_CURRENT" value="ADC_3" /> | ||
<define name="MilliAmpereOfAdc(adc)" value="(88*adc)"/> | <define name="MilliAmpereOfAdc(adc)" value="(88*adc)"/> | ||
and remove the line: | |||
<define name="MILLIAMP_AT_FULL_THROTTLE" value="4000" unit="mA"/> | |||
The right multiplicator for the raw measurement conversion depends on the current sensor. The sparkfun sensor returns a voltage of 0 V - 3.3 V it is linear and at 90.15 A it reaches the maximum of 3.3 V. The Twog have a A/D with 10-bit precision wich leads to 1024 different values for the voltage. So you can calculate the multiplicator with the following formula: | The right multiplicator for the raw measurement conversion depends on the current sensor. The sparkfun sensor returns a voltage of 0 V - 3.3 V it is linear and at 90.15 A it reaches the maximum of 3.3 V. The Twog have a A/D with 10-bit precision wich leads to 1024 different values for the voltage. So you can calculate the multiplicator with the following formula: | ||
Line 34: | Line 24: | ||
In case of the sparkfun sensor precision is 1024 and A_at_max_voltage is 90.15 => 1000/1024*90.15 = 88.037 | In case of the sparkfun sensor precision is 1024 and A_at_max_voltage is 90.15 => 1000/1024*90.15 = 88.037 | ||
In the makefile section following lines must set to you needs (ADC_0 - ADC_2 are in use for IR sensors): | |||
ap.CFLAGS += -DADC -DUSE_ADC_0 -DUSE_ADC_1 -DUSE_ADC_2 -DUSE_ADC_3 | |||
ap.srcs += $(SRC_ARCH)/adc_hw.c | |||
== Display on ground station == | == Display on ground station == |
Revision as of 18:44, 1 September 2009
If you have a current sensor like the one from sparkfun (AttoPilot Voltage and Current Sense Breakout Current sensor it is very easy to get the paparazzi working with that.
I have only a TWOG 1.0 so i am only able to descibe the way for this device. The Tiny v2 should be the same.
Hardware
I use the current sensor also for power supply so i have 3 wires to the current sensor. The + and - pole and the wire for the current measurement. The + and - have to be soldered directly to the cabels which came from the power supply. The 3rd wire is connected to the VI pin on the sparkfun breakout board. It must have a voltage between 0 and 3.3V. On the Twog or Tiny side you connect the 3rd wire to the ADC_3 or ADC_4 pin.
Airframe integration
In the BAT section of the airframe file add this lines:
<define name="ADC_CHANNEL_CURRENT" value="ADC_3" /> <define name="MilliAmpereOfAdc(adc)" value="(88*adc)"/>
and remove the line:
<define name="MILLIAMP_AT_FULL_THROTTLE" value="4000" unit="mA"/>
The right multiplicator for the raw measurement conversion depends on the current sensor. The sparkfun sensor returns a voltage of 0 V - 3.3 V it is linear and at 90.15 A it reaches the maximum of 3.3 V. The Twog have a A/D with 10-bit precision wich leads to 1024 different values for the voltage. So you can calculate the multiplicator with the following formula:
1000 / precision * A_at_max_voltage
In case of the sparkfun sensor precision is 1024 and A_at_max_voltage is 90.15 => 1000/1024*90.15 = 88.037
In the makefile section following lines must set to you needs (ADC_0 - ADC_2 are in use for IR sensors):
ap.CFLAGS += -DADC -DUSE_ADC_0 -DUSE_ADC_1 -DUSE_ADC_2 -DUSE_ADC_3 ap.srcs += $(SRC_ARCH)/adc_hw.c
Display on ground station
After following the instruction the energy consumed during the flight is send in the BAT message. Use the Messages application to show it. In the fbw_status message the current value show the actual current flow through the current sensor.
You can display the energy or current on the GCS by just drag and drop them on the 2d map.