
modifications to run via legfile.txt and then exit, manage logfile versions, diagnostics file
Dependencies: mbed MODSERIAL FATFileSystem
Diff: LinearActuator/LinearActuator.cpp
- Revision:
- 74:d281aaef9766
- Parent:
- 73:f6f378311c8d
- Child:
- 75:92e79d23d29a
--- a/LinearActuator/LinearActuator.cpp Mon Jul 30 16:48:48 2018 +0000 +++ b/LinearActuator/LinearActuator.cpp Tue Aug 14 21:06:48 2018 +0000 @@ -26,7 +26,7 @@ _init = true; _paused = false; _limit = false; - _slope = 498.729/4096; //this value should be correct for our current string pots using .625" diameter and 12 bit ADC + _slope = 498.729/4096; //this value should be correct for our current string pots using .625" diameter and 12 bit ADC (hardcoded in config as 0.12176) _deadband = 0.5; _pid_high_limit = 0.0; @@ -123,17 +123,6 @@ _init = true; } -void LinearActuator::start() { - _init = true; - _pulse.attach(callback(this,&LinearActuator::update), _dt); //fixed deprecated warning -} - -void LinearActuator::stop() { - _motor.stop(); - _pulse.detach(); - _init = true; -} - void LinearActuator::pause() { //this allows the controller to keep running while turning off the motor output _motor.stop(); @@ -269,31 +258,53 @@ } void LinearActuator::homePiston() { - //start calling the update for the Linear Actuator - //start the controller update and immediatley pause the motor output - start(); - pause(); + //system is already active, input readings should be valid - //Now that the readings are stabilized // This sends the motor on a kamakaze mission toward the limit switch // The interrupt should catch and stop it, and the piston is now at home // position - _motor.run(-0.5); + + //unpause the motor (activate it) + unpause(); + + _motor.run(-0.1); //slowed down from -0.5 for testing 08/09/2018 + + xbee().printf("HOMING SEQUENCE ENGAGED. Press \"X\" to exit!\n\r"); while (1) { //trap the program here while we wait for the limit switch to be triggered //when it does, the limit interrupt will stop the motors if (_limit) { - pc().printf("\r\nHit limit switch\r\n"); + xbee().printf("\r\nHit limit switch\r\n"); //the switch has been pressed if (abs(_filter.getVelocity()) < 0.1) { //this is here to make sure the adc filter is not jittering around //we are probably stable enough to take a zero here - _zeroCounts = _filter.getPosition(); + + _zeroCounts = _filter.getPosition() + 50; //get position of motors + + //Added 50 counts for some margin of error // This can be used for troubleshooting - pc().printf("\n\rzero_counts: %4i \n\r" , _zeroCounts); - return; + xbee().printf("\n\rzero_counts: %4i \n\r" , _zeroCounts); + + //pause the motor (deactivate it) + pause(); + + break; //end while loop + } + } //end of limit switch if statement + + if (xbee().readable()) { + char user_input = xbee().getc(); + + if (user_input == 'x' or user_input == 'X') { + xbee().printf("EXIT! HOMING NOT COMPLETE!\n\r"); + break; //end while loop + } + + else if (user_input == 'c' or user_input == 'C') { + xbee().printf("Current counts: %d\n\r", _filter.getPosition()); } } }