*** empty log message ***

This commit is contained in:
Andreas Kleinert
2007-09-27 14:49:06 +00:00
parent ab42c75031
commit ef31d52c50
9 changed files with 110 additions and 12 deletions
+1 -1
View File
@@ -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
+11
View File
@@ -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 */
+1 -1
View File
@@ -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) {
+4 -2
View File
@@ -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;
}
+21 -4
View File
@@ -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.;
}
}
+5 -4
View File
@@ -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;
+1
View File
@@ -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++;
+9
View File
@@ -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
+57
View File
@@ -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;
}