Close



Page 5 of 7 FirstFirst ... 34567 LastLast
Results 41 to 50 of 68

Hybrid View

  1. #1
    Thanks for the help.

    I am pretty sure that I am not using the code you are referring to that uses probe_pt(), so I went to try and get it by clicking on the "M48.c" link that is on the first post in this thread, but all I get is a black screen with

    http://3dprintboard.com/attachment.p...5&d=1398698586

    Then, I saw in the previous few posts that you specify a link to the main Marlin code, which I pulled and it looks identical to the code I have - the M48 code never calls probe_pt() but run_z_probe().

    Looking at run_z_probe(), it does (in summary) calls to:

    prepare_move_raw();
    st_synchronize();
    endstops_hit_on_purpose();

    enable_endstops(false);

    calculate_delta(current_position);
    plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS]);

    float zPosition = -10;
    plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
    st_synchronize();

    // we have to let the planner know where we are right now as it is not where we said to go.
    zPosition = st_get_position_mm(Z_AXIS);
    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS]);

    // move up the retract distance
    zPosition += home_retract_mm(Z_AXIS);
    plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
    st_synchronize();

    // move back down slowly to find bed
    feedrate = homing_feedrate[Z_AXIS]/4;
    zPosition -= home_retract_mm(Z_AXIS) * 2;
    plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
    st_synchronize();

    and then returns the Z position found.

    So, it never makes a call to probe_pt(). However, this does not appear to be working in my config. It looks like it ought to work for a delta, but it always just returns without having moved the probe and returns the same Z position it started with. Kinda stuck.

    Is odd that the probe_pt() routine is still in marlin_main.cpp, and it's called by the auto leveling command g29, but not g30, so I guess when M48 was "folded in" someone rewrote some of it? I kinda wanted to tackle g29 and g30 next, so I guess I need to figure out what's wrong with run_z_probe().
    Last edited by revwarguy; 05-13-2015 at 09:04 PM.

  2. #2
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,182
    Quote Originally Posted by revwarguy View Post
    Thanks for the help.
    You are most welcome.
    Quote Originally Posted by revwarguy View Post
    Is there anywhere else I can find the code that uses probe_pt() in the M48 implementtion?
    Try this:
    Code:
       case 48: // M48 Z-Probe repeatability
            {
                #if Z_MIN_PIN == -1
                #error "You must have a Z_MIN endstop in order to enable calculation of Z-Probe repeatability."
                #endif
    
    
    	double sum=0.0; 
    	double mean=0.0; 
    	double sigma=0.0;
    	double sample_set[50];
    	int verbose_level=1, n=0, j, n_samples = 10, n_legs=0, engage_probe_for_each_reading=0 ;
    	double X_current, Y_current, Z_current;
    	double X_probe_location, Y_probe_location, Z_start_location, ext_position;
    	
    	if (code_seen('V') || code_seen('v')) {
            	verbose_level = code_value();
    		if (verbose_level<0 || verbose_level>4 ) {
    			SERIAL_PROTOCOLPGM("?Verbose Level not plausable.\n");
    			goto Sigma_Exit;
    		}
    	}
    
    
    	if (verbose_level > 0)   
    		SERIAL_PROTOCOLPGM("M48 Z-Probe Repeatability test.   Version 1.85\n");
    
    
    	if (code_seen('n')) {
            	n_samples = code_value();
    		if (n_samples<4 || n_samples>50 ) {
    			SERIAL_PROTOCOLPGM("?Specified sample size not plausable.\n");
    			goto Sigma_Exit;
    		}
    	}
    
    
    	X_current = X_probe_location = st_get_position_mm(X_AXIS);
    	Y_current = Y_probe_location = st_get_position_mm(Y_AXIS);
    	Z_current = st_get_position_mm(Z_AXIS);
    	Z_start_location = st_get_position_mm(Z_AXIS) + Z_RAISE_BEFORE_PROBING;
    	ext_position	 = st_get_position_mm(E_AXIS);
    
    
    	if (code_seen('E') || code_seen('e') ) 
    		engage_probe_for_each_reading++;
    
    
    	if (code_seen('X') || code_seen('x') ) {
            	X_probe_location = code_value() -  X_PROBE_OFFSET_FROM_EXTRUDER;
    		if (X_probe_location<X_MIN_POS || X_probe_location>X_MAX_POS ) {
    			SERIAL_PROTOCOLPGM("?Specified X position out of range.\n");
    			goto Sigma_Exit;
    		}
    	}
    
    
    	if (code_seen('Y') || code_seen('y') ) {
            	Y_probe_location = code_value() -  Y_PROBE_OFFSET_FROM_EXTRUDER;
    		if (Y_probe_location<Y_MIN_POS || Y_probe_location>Y_MAX_POS ) {
    			SERIAL_PROTOCOLPGM("?Specified Y position out of range.\n");
    			goto Sigma_Exit;
    		}
    	}
    
    
    	if (code_seen('L') || code_seen('l') ) {
            	n_legs = code_value();
    		if ( n_legs==1 ) 
    			n_legs = 2;
    		if ( n_legs<0 || n_legs>15 ) {
    			SERIAL_PROTOCOLPGM("?Specified number of legs in movement not plausable.\n");
    			goto Sigma_Exit;
    		}
    	}
    
    
    //
    // Do all the preliminary setup work.   First raise the probe.
    //
    
    
            st_synchronize();
            plan_bed_level_matrix.set_to_identity();
    	plan_buffer_line( X_current, Y_current, Z_start_location,
    			ext_position,
        			homing_feedrate[Z_AXIS]/60,
    			active_extruder);
            st_synchronize();
    
    
    //
    // Now get everything to the specified probe point So we can safely do a probe to
    // get us close to the bed.  If the Z-Axis is far from the bed, we don't want to 
    // use that as a starting point for each probe.
    //
    	if (verbose_level > 2) 
    		SERIAL_PROTOCOL("Positioning probe for the test.\n");
    
    
    	plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location,
    			ext_position,
        			homing_feedrate[X_AXIS]/60,
    			active_extruder);
            st_synchronize();
    
    
    	current_position[X_AXIS] = X_current = st_get_position_mm(X_AXIS);
    	current_position[Y_AXIS] = Y_current = st_get_position_mm(Y_AXIS);
    	current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS);
    	current_position[E_AXIS] = ext_position = st_get_position_mm(E_AXIS);
    
    
    // 
    // OK, do the inital probe to get us close to the bed.
    // Then retrace the right amount and use that in subsequent probes
    //
    
    
            engage_z_probe();	
    
    
    	setup_for_endstop_move();
    	run_z_probe();
    
    
    	current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS);
    	Z_start_location = st_get_position_mm(Z_AXIS) + Z_RAISE_BEFORE_PROBING;
    
    
    	plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location,
    			ext_position,
        			homing_feedrate[X_AXIS]/60,
    			active_extruder);
            st_synchronize();
    	current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS);
    
    
    	if (engage_probe_for_each_reading)
            	retract_z_probe();
    
    
            for( n=0; n<n_samples; n++) {
    
    
    		do_blocking_move_to( X_probe_location, Y_probe_location, Z_start_location); // Make sure we are at the probe location
    
    
    		if ( n_legs)  {
    		double radius=0.0, theta=0.0, x_sweep, y_sweep;
    		int rotational_direction, l;
    
    
    			rotational_direction = (unsigned long) millis() & 0x0001;			// clockwise or counter clockwise
    			radius = (unsigned long) millis() % (long) (X_MAX_LENGTH/4); 			// limit how far out to go 
    			theta = (float) ((unsigned long) millis() % (long) 360) / (360./(2*3.1415926));	// turn into radians
    
    
    //SERIAL_ECHOPAIR("starting radius: ",radius);
    //SERIAL_ECHOPAIR("   theta: ",theta);
    //SERIAL_ECHOPAIR("   direction: ",rotational_direction);
    //SERIAL_PROTOCOLLNPGM("");
    
    
    			for( l=0; l<n_legs-1; l++) {
    				if (rotational_direction==1)
    					theta += (float) ((unsigned long) millis() % (long) 20) / (360.0/(2*3.1415926)); // turn into radians
    				else
    					theta -= (float) ((unsigned long) millis() % (long) 20) / (360.0/(2*3.1415926)); // turn into radians
    
    
    				radius += (float) ( ((long) ((unsigned long) millis() % (long) 10)) - 5);
    				if ( radius<0.0 )
    					radius = -radius;
    
    
    				X_current = X_probe_location + cos(theta) * radius;
    				Y_current = Y_probe_location + sin(theta) * radius;
    
    
    				if ( X_current<X_MIN_POS)		// Make sure our X & Y are sane
    					 X_current = X_MIN_POS;
    				if ( X_current>X_MAX_POS)
    					 X_current = X_MAX_POS;
    
    
    				if ( Y_current<Y_MIN_POS)		// Make sure our X & Y are sane
    					 Y_current = Y_MIN_POS;
    				if ( Y_current>Y_MAX_POS)
    					 Y_current = Y_MAX_POS;
    
    
    				if (verbose_level>3 ) {
    					SERIAL_ECHOPAIR("x: ", X_current);
    					SERIAL_ECHOPAIR("y: ", Y_current);
    					SERIAL_PROTOCOLLNPGM("");
    				}
    
    
    				do_blocking_move_to( X_current, Y_current, Z_current );
    			}
    			do_blocking_move_to( X_probe_location, Y_probe_location, Z_start_location); // Go back to the probe location
    		}
    
    
    		if (engage_probe_for_each_reading)  {
            		engage_z_probe();	
              		delay(1000);
    		}
    
    
    		setup_for_endstop_move();
                    run_z_probe();
    
    
    		sample_set[n] = current_position[Z_AXIS];
    
    
    //
    // Get the current mean for the data points we have so far
    //
    		sum=0.0; 
    		for( j=0; j<=n; j++) {
    			sum = sum + sample_set[j];
    		}
    		mean = sum / (double (n+1));
    //
    // Now, use that mean to calculate the standard deviation for the
    // data points we have so far
    //
    
    
    		sum=0.0; 
    		for( j=0; j<=n; j++) {
    			sum = sum + (sample_set[j]-mean) * (sample_set[j]-mean);
    		}
    		sigma = sqrt( sum / (double (n+1)) );
    
    
    		if (verbose_level > 1) {
    			SERIAL_PROTOCOL(n+1);
    			SERIAL_PROTOCOL(" of ");
    			SERIAL_PROTOCOL(n_samples);
    			SERIAL_PROTOCOLPGM("   z: ");
    			SERIAL_PROTOCOL_F(current_position[Z_AXIS], 6);
    		}
    
    
    		if (verbose_level > 2) {
    			SERIAL_PROTOCOL(" mean: ");
    			SERIAL_PROTOCOL_F(mean,6);
    
    
    			SERIAL_PROTOCOL("   sigma: ");
    			SERIAL_PROTOCOL_F(sigma,6);
    		}
    
    
    		if (verbose_level > 0) 
    			SERIAL_PROTOCOLPGM("\n");
    
    
    		plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, 
    				  current_position[E_AXIS], homing_feedrate[Z_AXIS]/60, active_extruder);
            	st_synchronize();
    
    
    		if (engage_probe_for_each_reading)  {
            		retract_z_probe();	
              		delay(1000);
    		}
    	}
    
    
            retract_z_probe();
    	delay(1000);
    
    
            clean_up_after_endstop_move();
    
    
    //      enable_endstops(true);
    
    
    	if (verbose_level > 0) {
    		SERIAL_PROTOCOLPGM("Mean: ");
    		SERIAL_PROTOCOL_F(mean, 6);
    		SERIAL_PROTOCOLPGM("\n");
    	}
    
    
    SERIAL_PROTOCOLPGM("Standard Deviation: ");
    SERIAL_PROTOCOL_F(sigma, 6);
    SERIAL_PROTOCOLPGM("\n\n");
    
    
    Sigma_Exit:
            break;
    	}
    #endif		// ENABLE_AUTO_BED_LEVELING

  3. #3
    Hello Roxy,
    Ive been lurker here and just wanted to say thanks for the huge amount of help you've offered here.

    I am just trying to use my z probe for the first time, so I thought I would start out easy by trying the M48, but it doesn't work.

    First, I have a delta with a probe that is placed by hand (which means it doesn't need to be engaged or retracted, so just for now, I've inserted a return at the top of those routines) and the switch trigggers when at 18.21mm above the zero location (as determined by the paper test - it prints fairly well at this point.)

    When I execute a M48 v3 the probe is lowered to Z_RAISE_BEFORE_HOMING, but then it just stays there, printing out a report with all the same values. Debug statements Ive inserted show the run_z_probe() getting repeatedly called, but nothing moves.

    The m119 appears to work fine - the probe (hooked into zmin) is OPEN normally, and TRIGGERED when the switch is closed.

    Any ideas?

  4. #4
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,182
    The

    static float probe_pt(float x, float y, float z_before, ProbeAction retract_action=ProbeEngageRetract, int verbose_level=1) {

    function raises and lowers the probe. And it controls the engaging of the probe. Did you make modifications to it? Or are you just not calling it? Either way, why don't you post the code you changed so we can talk about it.

  5. #5
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,182
    What code base are you using? Can you pull down the Beckdac code and move your settings to that? I know what is in that fork and how things are setup in there. If you move your setting over to that code base it will be much easier to help you get things going.

    Beckdac's code is at: https://github.com/beckdac/Marlin

  6. #6
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,182
    Oh? I didn't expect that. OK... How about we use this repository:

    https://github.com/ErikZalm/Marlin

    What I'm trying to do is not use the recent code at: https://github.com/MarlinFirmware/Marlin They have made change after change without testing anything and right now the Auto Bed Leveling is sick. So let's try that ErikZalm link and get your stuff going using that.

  7. #7
    Ok, give me a bit to get the Zalm configuration.h updated to my machine. Other than that, the M48, G29, G30 and relavant section of the configuration.h file appears to be the same as what I am running on my verison, with the exception I mentioned before - I've cut off the engage_z_probe() and retract_z_probe() routines to just return right away as I don't need to do that. Could there be something in there that is needed later that is the problem?

    You know who PJR is?
    Last edited by revwarguy; 05-14-2015 at 02:28 PM.

  8. #8
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,182
    Quote Originally Posted by revwarguy View Post
    Ok, give me a bit to get the Zalm configuration.h updated to my machine. Other than that, the M48, G29, G30 and relavant section of the configuration.h file appears to be the same as what I am running on my verison, with the exception I mentioned before - I've cut off the engage_z_probe() and retract_z_probe() routines to just return right away as I don't need to do that. Could there be something in there that is needed later that is the problem?
    I think what you ought to do is leave the engage_z_probe() and retract_z_probe() alone and just assign them to use unused pins. That way everything is behaving the same other than those two functions don't do anything. But with that said, making them null routines really ought to be OK.

    Part of the reason to leave the engage_z_probe() and retract_z_probe() alone is there may be other code that assumes a servo is available because you have Auto Bed Leveling. That would be the easiest path to getting everything going. And then when everything is working we can prune the servo out of the picture.


    Quote Originally Posted by revwarguy View Post
    You know who PJR is?
    No...
    Last edited by Roxy; 05-14-2015 at 05:26 PM.

  9. #9
    The code base I am using has specific enhanemments other than M48/G29/G30 I need to use. My understanding is that it's g30 is better in that it takes only a few passes to converge, so I was also hoping to use it.

    Thanks for the help, Roxy. I guess I'll just have to work it out what is going on with what I have.

    I sure would like to know why they rewrote your m48 code for the latest Marlin pull, though. As it is, there is a lot of code in marlin_main.cpp for this stuff when it seems it could be unified into something much simpler.

  10. #10
    Student
    Join Date
    Jul 2014
    Location
    Van Nuys, CA
    Posts
    22
    Roxy, I've got a question about how the z position numbers are calculated in your M48 code compared to other commands. I've been battling a problem all day that started with a wire falling off my z-probe. After fixing that, I noticed that the microswitch was slightly tilted and when coming down to the bed, the lever would hit first, but before tripping, the opposite side of the switch would hit the glass and move the arm slightly. I adjusted that and since I haven't been able to get a good print. I've gone around and around adjusting the z probe offset value and storing it in EEPROM, but every time I try to start a print, it's just smashing the filament down on the glass making blobs and wide streaks.

    Anyway, what I've noticed is that if my current offset is set to say -10.65, when I run the G29 command, the 4 points it probes list z values close to and around that offset. However, when I run the M48 code, the numbers it reports for each sample are around the 10.24 range. The test comes out very acceptable. I can't see that there's any great fluctuation or problems with the probe, but I'm curious why the numbers are different as that amount of difference looks to be in the ballpark of what might actually get it printing properly again. I'd guess it's about .4mm off.

    Bruce

Page 5 of 7 FirstFirst ... 34567 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •