}
// Add a stepper motor object to our list of steppers we must take care of
-Actuator* StepTicker::add_stepper_motor(Actuator* stepper_motor){
+StepperMotor* StepTicker::add_stepper_motor(StepperMotor* stepper_motor){
this->stepper_motors.push_back(stepper_motor);
stepper_motor->step_ticker = this;
this->has_axes = true;
// We make a list of steppers that want to be called so that we don't call them for nothing
-void StepTicker::add_motor_to_active_list(Actuator* motor)
+void StepTicker::add_motor_to_active_list(StepperMotor* motor)
{
uint32_t bm;
int i;
}
// Remove a stepper from the list of active motors
-void StepTicker::remove_motor_from_active_list(Actuator* motor)
+void StepTicker::remove_motor_from_active_list(StepperMotor* motor)
{
uint32_t bm; int i;
for (i = 0, bm = 1; i < 12; i++, bm <<= 1)
#include "libs/nuts_bolts.h"
#include "libs/Module.h"
#include "libs/Kernel.h"
-#include "libs/actuators/Actuator.h"
+#include "libs/StepperMotor.h"
class StepTicker{
public:
void set_frequency( double frequency );
void tick();
void signal_moves_finished();
- Actuator* add_stepper_motor(Actuator* stepper_motor);
+ StepperMotor* add_stepper_motor(StepperMotor* stepper_motor);
void set_reset_delay( double seconds );
void reset_tick();
- void add_motor_to_active_list(Actuator* motor);
- void remove_motor_from_active_list(Actuator* motor);
+ void add_motor_to_active_list(StepperMotor* motor);
+ void remove_motor_from_active_list(StepperMotor* motor);
double frequency;
- vector<Actuator*> stepper_motors;
+ vector<StepperMotor*> stepper_motors;
uint32_t delay;
uint32_t period;
uint32_t debug;
bool moves_finished;
bool reset_step_pins;
- Actuator* active_motors[12];
+ StepperMotor* active_motors[12];
uint32_t active_motor_bm;
};
*/
#include "mri.h"
#include "libs/Kernel.h"
-#include "libs/actuators/StepperMotor.h"
-#include "libs/actuators/Actuator.h"
+#include "StepperMotor.h"
#include "MRI_Hooks.h"
// A StepperMotor represents an actual stepper motor. It is used to generate steps that move the actual motor at a given speed
// TODO : Abstract this into Actuator
+StepperMotor::StepperMotor(){
+ this->moving = false;
+ this->paused = false;
+ this->fx_counter = 0;
+ this->stepped = 0;
+ this->fx_ticks_per_step = 0;
+ this->steps_to_move = 0;
+ this->remove_from_active_list_next_reset = false;
+ this->is_move_finished = false;
+ this->signal_step = false;
+ this->step_signal_hook = new Hook();
+}
+
StepperMotor::StepperMotor(Pin* step, Pin* dir, Pin* en) : step_pin(step), dir_pin(dir), en_pin(en) {
this->moving = false;
this->paused = false;
#include "libs/Kernel.h"
#include "libs/Hook.h"
-#include "libs/actuators/Actuator.h"
class StepTicker;
-class StepperMotor : public Actuator {
+class StepperMotor {
public:
- //StepperMotor();
+ StepperMotor();
StepperMotor(Pin* step, Pin* dir, Pin* en);
-
void tick();
void step();
+ void move_finished();
void move( bool direction, unsigned int steps );
void signal_move_finished();
void set_speed( double speed );
void update_exit_tick();
void pause();
void unpause();
-
+
+
+
+ template<typename T> void attach( T *optr, uint32_t ( T::*fptr )( uint32_t ) ){
+ Hook* hook = new Hook();
+ hook->attach(optr, fptr);
+ this->end_hook = hook;
+ }
+
+ template<typename T> void attach_signal_step(uint32_t step, T *optr, uint32_t ( T::*fptr )( uint32_t ) ){
+ this->step_signal_hook->attach(optr, fptr);
+ this->signal_step_number = step;
+ this->signal_step = true;
+ }
+
+ Hook* end_hook;
+ Hook* step_signal_hook;
+
+ bool signal_step;
+ uint32_t signal_step_number;
+
StepTicker* step_ticker;
Pin* step_pin;
Pin* dir_pin;
Pin* en_pin;
+ double steps_per_second;
+
+ volatile bool moving;
+ bool paused;
+
+ //bool direction_bit;
+ //bool step_bit;
+
+ uint32_t steps_to_move;
+ uint32_t stepped;
+ uint32_t fx_counter;
+ uint32_t fx_ticks_per_step;
+
+ //bool exit_tick;
+ bool remove_from_active_list_next_reset;
+
bool is_move_finished; // Whether the move just finished
};
+++ /dev/null
-/*
- This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl).
- Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
- Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef ACTUATOR_H
-#define ACTUATOR_H
-
-#include "libs/Hook.h"
-#include "libs/StepTicker.h"
-
-/* Actuator is the base class for all actuator-type things ( StepperMotors, ServoMotors etc ). */
-
-class StepTicker;
-
-class Actuator {
- public:
- Actuator(){};
- virtual ~Actuator(){};
-
- /* Functions all actuators must have are still to be defined, but here are a few bellow for a start */
- virtual void tick()=0;
- virtual void step()=0;
- virtual void move( bool direction, unsigned int steps )=0;
- virtual void signal_move_finished()=0;
- virtual void set_speed( double speed )=0;
- virtual void update_exit_tick()=0;
- virtual void pause()=0;
- virtual void unpause()=0;
-
- template<typename t> void attach( t *optr, uint32_t ( t::*fptr )( uint32_t ) ){
- Hook* hook = new Hook();
- hook->attach(optr, fptr);
- this->end_hook = hook;
- }
-
- template<typename t> void attach_signal_step(uint32_t step, t *optr, uint32_t ( t::*fptr )( uint32_t ) ){
- this->step_signal_hook->attach(optr, fptr);
- this->signal_step_number = step;
- this->signal_step = true;
- }
-
- Hook* end_hook;
- Hook* step_signal_hook;
-
- bool signal_step;
- uint32_t signal_step_number;
-
- double steps_per_second;
-
- volatile bool moving;
- bool paused;
-
- uint32_t steps_to_move;
-
- StepTicker* step_ticker;
- Pin* step_pin;
- Pin* dir_pin;
- Pin* en_pin;
-
-
- uint32_t stepped;
- uint32_t fx_counter;
- uint32_t fx_ticks_per_step;
-
- bool remove_from_active_list_next_reset;
-
- bool is_move_finished; // Whether the move just finished
-
-
-};
-
-
-
-#endif
#include "Robot.h"
#include "libs/nuts_bolts.h"
#include "libs/Pin.h"
-#include "libs/actuators/StepperMotor.h"
+#include "libs/StepperMotor.h"
#include "../communication/utils/Gcode.h"
#include "PublicDataRequest.h"
#include "arm_solutions/BaseSolution.h"
#include "arm_solutions/BaseSolution.h"
#include "Planner.h"
#include "libs/Pin.h"
-#include "libs/actuators/Actuator.h"
+#include "libs/StepperMotor.h"
#include "RobotPublicAccess.h"
#define default_seek_rate_checksum CHECKSUM("default_seek_rate")
Pin gamma_dir_pin;
Pin gamma_en_pin;
- Actuator* alpha_stepper_motor;
- Actuator* beta_stepper_motor;
- Actuator* gamma_stepper_motor;
+ StepperMotor* alpha_stepper_motor;
+ StepperMotor* beta_stepper_motor;
+ StepperMotor* gamma_stepper_motor;
double seconds_per_minute; // for realtime speed change
};
#define STEPPER_H
#include "libs/Module.h"
#include "libs/Kernel.h"
-#include "libs/actuators/Actuator.h"
#include "Planner.h"
#include "Block.h"
bool enable_pins_status;
Hook* acceleration_tick_hook;
- Actuator* main_stepper;
+ StepperMotor* main_stepper;
};
#include "Endstops.h"
#include "libs/nuts_bolts.h"
#include "libs/Pin.h"
-#include "libs/actuators/Actuator.h"
+#include "libs/StepperMotor.h"
#include "wait_api.h" // mbed.h lib
Endstops::Endstops(){
#include "libs/Module.h"
#include "libs/Kernel.h"
#include "modules/communication/utils/Gcode.h"
-#include "libs/actuators/Actuator.h"
+#include "libs/StepperMotor.h"
#include "libs/Pin.h"
#define ALPHA_AXIS 0
void on_gcode_received(void* argument);
void on_config_reload(void* argument);
- Actuator* steppers[3];
+ StepperMotor* steppers[3];
Pin pins[6];
double slow_rates[3];
double fast_rates[3];
#include "modules/robot/Conveyor.h"
#include "modules/robot/Block.h"
#include "modules/tools/extruder/Extruder.h"
-#include "libs/actuators/StepperMotor.h"
#include <mri.h>
/* The extruder module controls a filament extruder for 3D printing: http://en.wikipedia.org/wiki/Fused_deposition_modeling
#include "libs/Module.h"
#include "libs/Kernel.h"
-#include "libs/actuators/Actuator.h"
#include "modules/robot/Block.h"
#define microseconds_per_step_pulse_checksum CHECKSUM("microseconds_per_step_pulse")
bool paused;
- Actuator* stepper_motor;
+ StepperMotor* stepper_motor;
};
#include "modules/robot/Conveyor.h"
#include "libs/Kernel.h"
#include "modules/communication/utils/Gcode.h"
-#include "libs/actuators/Actuator.h"
-
+#include "libs/StepperMotor.h"
#include "libs/Pin.h"
#define touchprobe_enable_checksum CHECKSUM("touchprobe_enable")
FILE* logfile;
string filename;
- Actuator* steppers[3];
+ StepperMotor* steppers[3];
Pin pin;
unsigned int debounce_count;