partially working Extruder module, fixed but in Robot.cpp
authorArthur Wolf <wolf.arthur@gmail.com>
Tue, 22 Nov 2011 10:59:50 +0000 (11:59 +0100)
committerArthur Wolf <wolf.arthur@gmail.com>
Tue, 22 Nov 2011 10:59:50 +0000 (11:59 +0100)
src/modules/robot/Block.cpp
src/modules/robot/Robot.cpp
src/modules/tools/extruder/Extruder.cpp

index d105dc3..82f98f8 100644 (file)
@@ -184,13 +184,12 @@ void Block::release(){
     this->times_taken--;
     if( this->times_taken < 1 ){
         this->player->kernel->call_event(ON_BLOCK_END, this);
+        //player->kernel->serial->printf("gcodes: %d, dist: %f \r\n", this->commands.size(), this->millimeters );
         this->pop_and_execute_gcode(this->player->kernel);
         Player* player = this->player;
         if( player->queue.size() > 0 ){ 
-            //player->kernel->serial->printf("before: %d\r\n", player->queue.size() );
             player->queue.delete_first();
         } 
-        //player->kernel->serial->printf("after: %d\r\n", player->queue.size() );
         player->current_block = NULL; 
         player->pop_and_process_new_block();
     }
index eb2c7bd..97a0a4d 100644 (file)
@@ -63,8 +63,8 @@ void Robot::on_gcode_received(void * argument){
         }
     }else{
         Block* block = this->kernel->player->queue.get_ref( this->kernel->player->queue.size() - 1 );
-        block->append_gcode(gcode);
         this->execute_gcode(gcode);
+        block->append_gcode(gcode);
     }
     
 
index 2fef76b..80ae698 100644 (file)
@@ -73,7 +73,7 @@ void Extruder::on_gcode_execute(void* argument){
         if( gcode->get_value('G') == 92 ){
 
             if( gcode->has_letter('E') ){
-                this->current_position = gcode->get_value('E') * 100;
+                this->current_position = gcode->get_value('E') * 1000;
                 this->target_position  = this->current_position;
                 this->start_position   = this->current_position; 
             }            
@@ -84,14 +84,14 @@ void Extruder::on_gcode_execute(void* argument){
             if( gcode->has_letter('E' )){
                 double extrusion_distance = gcode->get_value('E');
                 //this->kernel->serial->printf("extrusion_distance: %f, millimeters_of_travel: %f\r\n", extrusion_distance, gcode->millimeters_of_travel);
-                if( gcode->millimeters_of_travel == 0.0 ){
+                if( fabs(gcode->millimeters_of_travel) < 0.0001 ){
                     this->solo_mode = true;
                     this->travel_distance = extrusion_distance;
-                    //this->kernel->serial->printf("solo mode distance: %f\r\n", this->travel_distance );
+                    //this->kernel->serial->printf("solo mode distance: %f, mm: %f \r\n", this->travel_distance, gcode->millimeters_of_travel );
                 }else{
                     this->solo_mode = false;
                     this->travel_ratio = extrusion_distance / gcode->millimeters_of_travel; 
-                    //this->kernel->serial->printf("follow mode ratio: %f\r\n", this->travel_ratio);
+                    //this->kernel->serial->printf("follow mode ratio: %f, mm: %f \r\n", this->travel_ratio, gcode->millimeters_of_travel );
                 } 
             // Else do not extrude
             }else{
@@ -115,7 +115,7 @@ void Extruder::on_block_begin(void* argument){
         block->take(); // In solo mode we take the block so we can move even if the stepper has nothing to do
         this->current_block = block; 
         this->start_position = this->current_position;
-        this->target_position = ( !this->absolute_mode ? this->start_position : 0 ) + ( this->travel_distance * 100 ); //TODO : Get from config ( extruder_steps_per_mm )
+        this->target_position = ( !this->absolute_mode ? this->start_position : 0 ) + ( this->travel_distance * 1000 ); //TODO : Get from config ( extruder_steps_per_mm )
         this->acceleration_tick();
         //this->kernel->serial->printf("distance %f %f\r\n", this->travel_distance, this->travel_ratio);
     }   
@@ -124,12 +124,12 @@ void Extruder::on_block_begin(void* argument){
         // In non-solo mode, we just follow the stepper module
         this->current_block = block; 
         this->start_position = this->current_position;
-        this->target_position =  ( !this->absolute_mode ? this->start_position : 0 ) + ( this->current_block->millimeters * this->travel_ratio * 100 ); //TODO : Get from config ( extruder_steps_per_mm )
+        this->target_position =  ( !this->absolute_mode ? this->start_position : 0 ) + ( this->current_block->millimeters * this->travel_ratio * 1000 ); //TODO : Get from config ( extruder_steps_per_mm )
         this->acceleration_tick();
         //this->kernel->serial->printf("ratio %f %f %d\r\n", this->travel_distance, this->travel_ratio, block->times_taken );
 
     } 
-    
+    //this->kernel->serial->printf("%d %d %d %f %f\r\n", this->start_position, this->current_position, this->target_position, this->travel_distance, this->travel_ratio); 
 }
 
 void Extruder::on_block_end(void* argument){