mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-10 06:59:54 +08:00
*** empty log message ***
This commit is contained in:
@@ -32,7 +32,7 @@ main.srcs += $(SRC_ARCH)/mb_servo.c
|
||||
main.CFLAGS += -DMB_TACHO
|
||||
main.srcs += $(SRC_ARCH)/mb_tacho.c
|
||||
|
||||
main.CFLAGS += -DADC -DUSE_ADC_0
|
||||
main.CFLAGS += -DADC -DUSE_ADC_0 -DUSE_ADC_1
|
||||
main.srcs += $(SRC_ARCH)/adc_hw.c
|
||||
main.srcs += $(SRC_ARCH)/mb_current.c
|
||||
|
||||
|
||||
@@ -30,4 +30,15 @@
|
||||
//#define USE_AD0_0
|
||||
#endif
|
||||
|
||||
#define ADC_1 AdcBank0(1)
|
||||
#ifdef USE_ADC_1
|
||||
#ifndef USE_AD0
|
||||
#define USE_AD0
|
||||
#endif
|
||||
#define USE_AD0_1
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* CONFIG_MOTOR_BENCH_H */
|
||||
|
||||
@@ -181,6 +181,7 @@ void adc_init( void ) {
|
||||
}
|
||||
|
||||
#include "led.h"
|
||||
|
||||
#include "uart.h"
|
||||
#include "messages.h"
|
||||
#include "downlink.h"
|
||||
@@ -192,7 +193,6 @@ void adcISR0 ( void ) {
|
||||
uint8_t channel = (uint8_t)(tmp >> 24) & 0x07;
|
||||
uint16_t value = (uint16_t)(tmp >> 6) & 0x03FF;
|
||||
adc0_val[channel] = value;
|
||||
DOWNLINK_SEND_BOOT(&value);
|
||||
|
||||
struct adc_buf* buf = buffers[channel];
|
||||
if (buf) {
|
||||
|
||||
@@ -14,6 +14,8 @@ void mb_current_init(void) {
|
||||
|
||||
void mb_current_periodic(void) {
|
||||
uint16_t cur_int = mb_current_buf.sum / mb_current_buf.av_nb_sample;
|
||||
// uint16_t cur_int = adc0_val[0];
|
||||
mb_current_amp = cur_int * 1.;
|
||||
// mb_current_amp = (float)mb_current_buf.sum;
|
||||
// mb_current_amp = (((float)cur_int / 1024 * 5) - 0.77)/ 0.185;
|
||||
mb_current_amp = (float)mb_current_buf.sum * 0.00113607 - 2.8202;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,21 +1,38 @@
|
||||
#include "mb_modes.h"
|
||||
|
||||
#include "adc.h"
|
||||
|
||||
|
||||
uint8_t mb_modes_mode;
|
||||
float mb_modes_throttle;
|
||||
|
||||
|
||||
static struct adc_buf mb_modes_adc_buf; /* manual mode */
|
||||
|
||||
void mb_mode_init(void) {
|
||||
mb_modes_mode = MB_MODES_IDLE;
|
||||
adc_buf_channel(1, &mb_modes_adc_buf, 16);
|
||||
mb_modes_mode = MB_MODES_MANUAL;
|
||||
mb_modes_throttle = 0.;
|
||||
}
|
||||
|
||||
|
||||
void mb_mode_event(void) {}
|
||||
|
||||
|
||||
void mb_mode_periodic(void) {
|
||||
mb_modes_throttle += 0.0001;
|
||||
if (mb_modes_throttle > 1.)
|
||||
|
||||
uint16_t poti = mb_modes_adc_buf.sum;
|
||||
|
||||
switch (mb_modes_mode) {
|
||||
case MB_MODES_MANUAL :
|
||||
mb_modes_throttle = (float)poti/(16.*1024.);
|
||||
break;
|
||||
case MB_MODES_RAMP :
|
||||
mb_modes_throttle += 0.0001;
|
||||
if (mb_modes_throttle > 1.)
|
||||
mb_modes_throttle = 0.;
|
||||
break;
|
||||
default:
|
||||
mb_modes_throttle = 0.;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
#include "std.h"
|
||||
|
||||
|
||||
#define MB_MODES_IDLE 0
|
||||
#define MB_MODES_RAMP 1
|
||||
#define MB_MODES_STEP 2
|
||||
#define MB_MODES_PRBS 3
|
||||
#define MB_MODES_IDLE 0
|
||||
#define MB_MODES_MANUAL 1
|
||||
#define MB_MODES_RAMP 2
|
||||
#define MB_MODES_STEP 3
|
||||
#define MB_MODES_PRBS 4
|
||||
|
||||
extern uint8_t mb_modes_mode;
|
||||
extern float mb_modes_throttle;
|
||||
|
||||
@@ -53,6 +53,7 @@ static inline void main_periodic_task( void ) {
|
||||
float throttle = mb_modes_throttle;
|
||||
mb_servo_set(throttle);
|
||||
float rpm = mb_tacho_get_averaged();
|
||||
mb_current_periodic();
|
||||
float amps = mb_current_amp;
|
||||
static uint8_t my_cnt = 0;
|
||||
my_cnt++;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
CC = gcc
|
||||
CFLAGS=-g -O2 -Wall `pkg-config gtk+-2.0 --cflags`
|
||||
LDFLAGS=`pkg-config gtk+-2.0 --libs` -s `pcre-config --libs` -lglibivy
|
||||
|
||||
|
||||
motor_bench : main.c
|
||||
$(CC) $(CFLAGS) -g -o $@ $^ $(LDFLAGS)
|
||||
|
||||
# -lgtkdatabox
|
||||
@@ -0,0 +1,57 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <Ivy/ivy.h>
|
||||
#include <Ivy/ivyglibloop.h>
|
||||
|
||||
//#include "sliding_plot.h"
|
||||
|
||||
|
||||
GtkWidget* build_gui ( void ) {
|
||||
|
||||
GtkWidget *window1;
|
||||
GtkWidget *vbox1;
|
||||
|
||||
|
||||
window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (window1), "motor_bench");
|
||||
|
||||
vbox1 = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (window1), vbox1);
|
||||
|
||||
return window1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void on_scale_value_changed (GtkScale *scale, gpointer user_data) {
|
||||
gfloat cf = gtk_range_get_value(GTK_RANGE(scale));
|
||||
gint c = round(cf);
|
||||
g_message("foo %d %f", user_data, c);
|
||||
IvySendMsg("ME RAW_DATALINK 16 SETTING;%d;0;%d", (gint)user_data, c);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void on_MOTOR_BENCH_STATUS(IvyClientPtr app, void *user_data, int argc, char *argv[]){
|
||||
int time_ticks = atoi(argv[0]);
|
||||
g_message("foo %d", time_ticks);
|
||||
|
||||
}
|
||||
|
||||
int main (int argc, char** argv) {
|
||||
|
||||
gtk_init(&argc, &argv);
|
||||
|
||||
GtkWidget* window = build_gui();
|
||||
gtk_widget_show_all(window);
|
||||
|
||||
IvyInit ("MotorBench", "MotorBench READY", NULL, NULL, NULL, NULL);
|
||||
IvyBindMsg(on_MOTOR_BENCH_STATUS, NULL, "^\\S* MOTOR_BENCH_STATUS (\\S*) (\\S*) (\\S*) (\\S*),(\\S*),(\\S*)");
|
||||
IvyStart("127.255.255.255");
|
||||
|
||||
gtk_main();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user