This commit is contained in:
Pascal Brisset
2009-09-11 08:41:51 +00:00
parent cc7ef84697
commit b6790d5a11
4 changed files with 71 additions and 6 deletions
+41
View File
@@ -0,0 +1,41 @@
<layout width="1024" height="768">
<rows>
<widget NAME="map2d" SIZE="500">
<papget type="message_field" display="text" x="5" y="125">
<property name="field" value="BAT:energy"/>
<property name="scale" value="1"/>
<property name="format" value="Bat: %.0fmAh"/>
<property name="size" value="20."/>
<property name="color" value="green"/>
</papget>
<papget type="message_field" display="text" x="5" y="195">
<property name="field" value="MPPT:values[8]"/>
<property name="scale" value="1e-3"/>
<property name="format" value="I tot: %.2fA"/>
<property name="size" value="20."/>
<property name="color" value="green"/>
</papget>
<papget type="message_field" display="text" x="5" y="230">
<property name="field" value="MPPT:values[5]"/>
<property name="scale" value="1e-3"/>
<property name="format" value="P sol: %.1fW"/>
<property name="size" value="20."/>
<property name="color" value="green"/>
</papget>
<papget type="message_field" display="text" x="5" y="160">
<property name="field" value="MPPT:values[1]"/>
<property name="scale" value="1e-3"/>
<property name="format" value="I bat: %.2fA"/>
<property name="size" value="20."/>
<property name="color" value="green"/>
</papget>
</widget>
<columns>
<rows SIZE="375">
<widget NAME="strips" SIZE="200"/>
</rows>
<widget NAME="aircraft" SIZE="400"/>
<widget NAME="alarms"/>
</columns>
</rows>
</layout>
+7 -6
View File
@@ -30,9 +30,8 @@
#define MPPT_SLAVE_ADDR 0x40
#define NB_DATA 8
#define NB_I2C_DATA 8
#define MPPT_MODE_ADDR 0xf
#define MPPT_IBAT_INDEX 1
/**
0: VBat (mV)
@@ -43,6 +42,8 @@
5: PSol (mW)
6: IConv (mA)
7: PConv (mW)
9: IBat + IConv
*/
@@ -67,7 +68,7 @@ static uint8_t MPPT_status;
static uint8_t data_index = 0xff;
int16_t MPPT_data[NB_DATA];
static int16_t MPPT_data[NB_DATA];
void MPPT_init( void ) {
MPPT_mode = 0;
@@ -79,11 +80,11 @@ void MPPT_init( void ) {
static void MPPT_ask( void ) {
data_index++;
if (data_index >= NB_DATA) {
if (data_index >= NB_I2C_DATA) {
/* Setting the current value */
fbw_current_milliamp = MPPT_data[MPPT_IBAT_INDEX];
MPPT_data[MPPT_ITOTAL_INDEX] = MPPT_data[MPPT_IBAT_INDEX] + MPPT_data[MPPT_ICONV_INDEX];
DOWNLINK_SEND_MPPT(DefaultChannel, NB_DATA, MPPT_data);
data_index = 0;
}
@@ -127,7 +128,7 @@ void MPPT_periodic( void ) {
case MPPT_STATUS_READING:
/* We got 2 bytes */
if (data_index < NB_DATA)
if (data_index < NB_I2C_DATA)
MPPT_data[data_index] = (i2c0_buf[0]<<8) | i2c0_buf[1];
MPPT_status = MPPT_STATUS_IDLE;
break;
+5
View File
@@ -36,6 +36,11 @@
#define MPPT_MODE_PASSIVE 2
#define MPPT_MODE_ACTIVE 3
#define NB_DATA 9
#define MPPT_IBAT_INDEX 1
#define MPPT_ICONV_INDEX 6
#define MPPT_ITOTAL_INDEX 8
extern uint8_t MPPT_mode;
+18
View File
@@ -24,9 +24,27 @@
#include "MPPT.h"
#ifndef DOWNLINK_DEVICE
#define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE
#endif
#include "messages.h"
#include "downlink.h"
uint8_t MPPT_mode;
static int16_t MPPT_data[NB_DATA];
void MPPT_init( void ) {
uint8_t i = 0;
for(i = 0; i < NB_DATA; i++)
MPPT_data[i] = 42 + i;
}
void MPPT_periodic( void ) {
MPPT_data[MPPT_ITOTAL_INDEX] = MPPT_data[MPPT_IBAT_INDEX] + MPPT_data[MPPT_ICONV_INDEX];
RunOnceEvery(8, DOWNLINK_SEND_MPPT(DefaultChannel, NB_DATA, MPPT_data));
}