BLCtrl 2.0 testing - currently only 8 Bit resolution - motor detection and px4 mode as default - with safety shutdown - fix

This commit is contained in:
marco
2013-04-29 20:42:06 +02:00
parent 130c7a3530
commit ee4a93d668
+14 -7
View File
@@ -121,7 +121,7 @@ public:
int set_motor_test(bool motortest); int set_motor_test(bool motortest);
int set_px4mode(int px4mode); int set_px4mode(int px4mode);
int set_frametype(int frametype); int set_frametype(int frametype);
unsigned int mk_check_for_blctrl(unsigned int count, unsigned int showOutput); unsigned int mk_check_for_blctrl(unsigned int count, bool showOutput);
private: private:
static const unsigned _max_actuators = MAX_MOTORS; static const unsigned _max_actuators = MAX_MOTORS;
@@ -412,6 +412,8 @@ MK::set_frametype(int frametype)
int int
MK::set_motor_count(unsigned count) MK::set_motor_count(unsigned count)
{ {
if(count > 0) {
_num_outputs = count; _num_outputs = count;
if(_px4mode == MAPPING_MK) { if(_px4mode == MAPPING_MK) {
@@ -453,6 +455,11 @@ MK::set_motor_count(unsigned count)
} }
return OK; return OK;
} else {
return -1;
}
} }
int int
@@ -668,7 +675,7 @@ MK::mk_servo_arm(bool status)
unsigned int unsigned int
MK::mk_check_for_blctrl(unsigned int count, unsigned int showOutput) MK::mk_check_for_blctrl(unsigned int count, bool showOutput)
{ {
_retries = 50; _retries = 50;
uint8_t foundMotorCount = 0; uint8_t foundMotorCount = 0;
@@ -709,13 +716,13 @@ MK::mk_check_for_blctrl(unsigned int count, unsigned int showOutput)
} }
} }
if(showOutput == 1) { if(showOutput) {
fprintf(stderr, "[mkblctrl] MotorsFound: %i\n",foundMotorCount); fprintf(stderr, "[mkblctrl] MotorsFound: %i\n",foundMotorCount);
for(unsigned i=0; i< count; i++) { for(unsigned i=0; i< foundMotorCount; i++) {
fprintf(stderr, "[mkblctrl] blctrl[%i] : found=%i\tversion=%i\tcurrent=%i\tmaxpwm=%i\ttemperature=%i\n", i,Motor[i].State, Motor[i].Version, Motor[i].Current, Motor[i].MaxPWM, Motor[i].Temperature); fprintf(stderr, "[mkblctrl] blctrl[%i] : found=%i\tversion=%i\tcurrent=%i\tmaxpwm=%i\ttemperature=%i\n", i,Motor[i].State, Motor[i].Version, Motor[i].Current, Motor[i].MaxPWM, Motor[i].Temperature);
} }
if(foundMotorCount == 0) { if(foundMotorCount != 4 && foundMotorCount != 6 && foundMotorCount != 8) {
_task_should_exit = true; _task_should_exit = true;
} }
} }
@@ -1295,7 +1302,7 @@ mk_new_mode(PortMode new_mode, int update_rate, int motorcount, bool motortest,
/* count used motors */ /* count used motors */
do { do {
if(g_mk->mk_check_for_blctrl(8, 0) != 0) { if(g_mk->mk_check_for_blctrl(8, false) != 0) {
shouldStop = 4; shouldStop = 4;
} else { } else {
shouldStop++; shouldStop++;
@@ -1303,7 +1310,7 @@ mk_new_mode(PortMode new_mode, int update_rate, int motorcount, bool motortest,
sleep(1); sleep(1);
} while ( shouldStop < 3); } while ( shouldStop < 3);
g_mk->set_motor_count(g_mk->mk_check_for_blctrl(8, 1)); g_mk->set_motor_count(g_mk->mk_check_for_blctrl(8, true));
/* (re)set the PWM output mode */ /* (re)set the PWM output mode */
g_mk->set_mode(servo_mode); g_mk->set_mode(servo_mode);