Where to go from here: interfacing to Leadshine servo drive


Page 1 of 2 12 LastLast
Results 1 to 12 of 16

Thread: Where to go from here: interfacing to Leadshine servo drive

  1. #1
    Registered
    Join Date
    May 2016
    Posts
    16
    Downloads
    0
    Uploads
    0

    Default Where to go from here: interfacing to Leadshine servo drive

    Hi everyone,

    I bought a Leadshine EL5-D1000 driver and matching 1000W motor (just 1 to try out, and I am glad I didn't buy in bulk). It has a number of inputs and features, but I was just looking for a low-cost 240V torque controller and was planning on using a Kanalog +/-10V single ended output to control it.

    I was having a heck of a time tuning the motor without a load attached to learn how the driver behaved under torque control. After hooking the motor up to the ballscrew I discovered the problem with using the single ended output onto the driver's differential input: when reversing the Kanalog DAC polarity the motor will spin in the wrong direction for a while before eventually proceeding in the correct direction. Without the drag of the ballscrew and linear bearings it was just taking off into unstable cycling as soon as the Kanalog reversed polarity and I couldn't figure out what was happening exactly, with the ballscrew attached it looks to turn in the wrong direction for about a quarter turn before coming around, under a constant (minimal so as to keep it slow) DAC output with a DAC(0,60) type command. I can attach a graph if that is helpful.

    The servo driver manual shows pins 39/41 were for single ended inputs and 43/44 were for differential inputs (see attachment), but there is no way to choose which one is used for the controlling input (based on context I suspected that parameter pr317 might control this, but it is omitted from the description table in the manual) as per their support:

    Hi , I just discuss with RD teammate , torque control is only available with analog input from P43&44 ,and the input range is -10 ~ +10v ,positive means CW and negative means CCW .
    About pr317 , 0 is for your application , no need to change to 1 or 2 , sorry i have no details about this parameter now .

    BTW, which country are you from ? from US ?

    Best regards
    clark
    product&technical engineer
    Leadshine Technology Co., Ltd.

    Address: 11/F, Block A3, iPark, No.1001 Xueyuan Blvd.
    Nanshan District, Shenzhen, China www.leadshine.com


    (this response is unsatisfying, as is the claim that they have US support when I bought it on americanmotiontech.com, it arrived direct from China after claiming it was out of stock once the order was placed as well.)

    So my conundrum now is how to move forward. Options I see are:

    1) Switch the servo driver over to velocity mode on the single ended analog in pins and only set the P parameter in the driver (which is sort of equivalent to torque mode with extra time lag as it goes through the PID loop in the servo drive?)
    2) Try and get the step/dir function of the KFLOP working to control it (which I hadn't been planning on using for any of my setup)
    3) Get a single ended to differential IC chip and wire that up externally
    4) (some handwaving involved by a ME trying to do EE stuff here) Use two DAC channels to create a differential signal as I only need 5 out of the 8 channels.

    Which is the best option from a controls perspective for 1-4? 1 seems the simplest if it would work well enough; I am going to try a different vendor for the rest of the axes, maybe DMM.

    Thanks,
    Andy

    Where to go from here: interfacing to Leadshine servo drive-unnamed-png



    Similar Threads:
    Attached Thumbnails Attached Thumbnails Where to go from here: interfacing to Leadshine servo drive-unnamed-png  


  2. #2
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2289
    Downloads
    0
    Uploads
    0

    Default Re: Where to go from here: interfacing to Leadshine servo drive

    Hi Andy,

    Kanalog should work with single ended analog inputs or differential analog inputs. I doubt it that is your issue. Kanalog DAC outputs are single ended (the DAC output is relative to its GND). The best approach would be to used the Drive's Differential input and connect the Drive's Vin- signal to Kanalog GND. Connect the Drive's Vin+ to the Kanalog DAC.

    You might just have unstable PID settings. Torque mode with only P Gain is theoretically unstable. It is similar to a pendulum. Torque is the same as acceleration. As the target is approached the acceleration is reduced, but reaches maximum speed right at the target so naturally overshoots. Some friction or damping (D Gain) is required to cause the motor to slow down as it approaches the target.

    What settings were you using? Post a plot.

    Regards

    TK
    http://dynomotion.com


  3. #3
    Registered
    Join Date
    May 2016
    Posts
    16
    Downloads
    0
    Uploads
    0

    Default Re: Where to go from here: interfacing to Leadshine servo drive

    Hi Tom,

    Knowing that the Vin- to Kanalaog ground should work is helpful, that's how I'd been connecting it and that lets me strike that off the list of suspects. I am pretty sure it's in the servo side now, the KFLOP is not running any of its servo loops for this, the axis is disabled in Kmotion and I am just directly setting the DAC output to a small value enough to overcome friction. The c code to do a little back and forth and write the position to disk is at the bottom, along with the plot.

    I experimented a little more tonight and the vendor's setup tool shows the current traces (unclear what specific current this is measuring physically, and their graph is funky in that the present is at the left side and the past moves to the right) but it seems to show the wrong-direction dip at the change of polarity (which is sensed properly) that then recovers. The tool also turns out to show the input which looks correct. Only one of the 3 phases has any current shown in their tool, but I don't know if that is an expected quirk or not. I continuity checked the motor from the plug that goes into the servo driver and all 3 phases are there and at the right resistance though I haven't measured the current going into each phase directly yet.

    Thanks,
    Andy

    Where to go from here: interfacing to Leadshine servo drive-current-traces2-jpg
    Where to go from here: interfacing to Leadshine servo drive-going-wrong-direction-plot-pdf

    Code:
    #include "KMotionDef.h"
    #include "init_definitions.h" // this loads up the mapping of input/output channels and bits to names
    #include "function_definitions.h" // load up all the definitions
    
    // save file to disk for plotting
    
    main()
    {
    
    //float current_time = Time_sec();
    //printf("c:\\Temp\\P%f_I%f_D%fTime%f.txt\n", ch0->P, ch0->I, ch0->D, current_time);
    
    	
    	float current_time = Time_sec();
    	float target_time;
    	float target_time2;
    	double current_position;
    	short int DACoutput;
    	
    	float D_term = 1;
    	float P_term = 0.06;	
    		
    	FILE *f;
    	char s[256];
    	
    	ch0->Enable=FALSE; 
    
    	ch0->LimitSwitchOptions=0x103;
    	ch0->LimitSwitchNegBit=138;
    	ch0->LimitSwitchPosBit=139;
    
    	f=fopen("c:\\Temp\\logdata.txt","wt");
    
    	if (!f)
    	{
    		printf("Unable to open file\n");
    		return;
    	}
    	
    
    //// Run back and forth
    
    	printf("\n\nstart - move\n");
    	chan[0].Position=0.0;  // set current position to Zero
    
    	while(current_position < 10000.0 && current_position > -10000.0) {
    		current_position = ch0->Position;
    		current_time = Time_sec();
    		DACoutput = DAC_Buffer[2]-2048;
    		fprintf(f, "%f,%f,%d\n", current_time, current_position, 100*DACoutput);
    		DAC(2,-65);
    		//if (current_position > 10000.0 || current_position < -10000.0) {
    		//	ch0->Enable=FALSE;
    		//	DAC(1,0);
    		//	printf("too far\n");
    		//	break;
    		//}
    	}
    	DAC(2,0);
    	printf("end - move\n");
    	
    	current_time = Time_sec();
    	target_time = current_time + 1;
    	while(current_time < target_time) {
    		current_time = Time_sec();
    		DACoutput = DAC_Buffer[2]-2048;
    		fprintf(f, "%f,%f,%d\n", current_time, current_position, 100*DACoutput);	// make a line to show when stopped		
    
    	}	
    	
    	
    	printf("start + move\n");
    
    	while(current_position > 0.0) {
    		current_position = ch0->Position;
    		current_time = Time_sec();
    		DACoutput = DAC_Buffer[2]-2048;
    		fprintf(f, "%f,%f,%d\n", current_time, current_position, 100*DACoutput);
    		DAC(2,75);
    		//if (current_position > 10000.0 || current_position < -10000.0) {
    		//	ch0->Enable=FALSE;
    		//	DAC(1,0);
    		//	printf("too far\n");
    		//	break;
    		//}
    	}
    	printf("end + move\n");
    	DAC(2,0);
    //// End back and forth	
    	
    	/*
    	current_time = Time_sec();
    	target_time = current_time + 10;
    	printf("Start axis motion\n");
    	ch0->Enable=TRUE; 
    	chan[0].Position=1500.0;  // set current position to Zero
    	ch0->Dest=0.0;
    // this only moves in one direction (-1500 to 0 seems to work. Is CW on end).
    //DAC control moves in both. integer sign issue?
    // what's the difference between this syntax and chan[0].Position?	
    // It was briefly working with this new syntax??
    	
    
    	while(current_time < target_time) {
    		current_position = ch0->Position;
    		current_time = Time_sec();
    		DACoutput = DAC_Buffer[1]-2048;
    		fprintf(f, "%f,%f,%d\n", current_time, current_position, DACoutput);
    		//printf("%f,%f\n", current_time, current_position);
    		
    		if (current_position > 7500.0 || current_position < -7500.0) {
    			ch0->Enable=FALSE;
    			DAC(1,0);
    		}
    		
    	}*/
    	fclose(f);
    	printf("completed write\n");
    	ch0->Enable=FALSE; 
    	DAC(1,0);
    }
    
    // Then in Octave: A = importdata('c:\Temp\logdata.txt', ',')
    // plot(A)




  4. #4
    Registered
    Join Date
    May 2016
    Posts
    16
    Downloads
    0
    Uploads
    0

    Default Re: Where to go from here: interfacing to Leadshine servo drive

    The graph looks pretty bad uploaded, the red trace (CurrentGiven(%)) basically follows along with the blue one (CurrentFeedback(%)) except for some single bit noise, including during the aberrant spike.



  5. #5
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2289
    Downloads
    0
    Uploads
    0

    Default Re: Where to go from here: interfacing to Leadshine servo drive

    Hi Andy,

    It isn't clear why you are doing all this yourself when the Step Response Screen was designed for this type of thing, but it should work.

    Here are some possible issues:

    #1 - please use EnableAxisDest and DisableAxis to enable and disable an Axis. Forcing the Enable Flag on and off may give unpredictable results

    #2 - note that if an axis is enabled and using/writing to a DAC then anything you attempt to write to the DAC will soon be overwritten. Make sure any and all axes that use a DAC are disabled before writing to the DAC manually.

    #3 - you shouldn't change the Axis Position Value while the Axis is Enabled

    #4 - normally you would call a Move Function to move an axis. Not just change the Destination

    #5 - avoid tight printf/fprintf loops (with out any delays) that may flood the communication buffers between KFLOP and the PC

    #6 - times in the plots don't seem to match your program delays. Does the program exactly what was used to make the plots?

    But assuming those items aren't causing any problem, it does seem like simply setting the DAC to -65 moves positive, DAC to 0 stops, DAC to +75 causes a jerk in the wrong direction for some reason. If you have an oscilloscope you might verify the Kanalog DAC is doing as we expect to prove the Drive is definitely the issue..

    Regards

    TK
    http://dynomotion.com


  6. #6
    Registered
    Join Date
    Jun 2004
    Location
    Scotland
    Posts
    250
    Downloads
    0
    Uploads
    0

    Default Re: Where to go from here: interfacing to Leadshine servo drive

    From what I understand, Andy is trying to run the Servo open loop as a constant torque source?
    Which for some reason when the DAC voltage is reversed, the servo continues to move in the wrong direction, before finally reversing direction.

    Some kind of oscillation due to lack of load on the servo?



  7. #7
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2289
    Downloads
    0
    Uploads
    0

    Default Re: Where to go from here: interfacing to Leadshine servo drive

    Hi m_c,

    Something like that. But not "continues to move" rather it is fully stopped, first moves in the wrong direction for a bit, then reverses and moves in the correct direction.

    Regards

    TK
    http://dynomotion.com


  8. #8
    Registered
    Join Date
    Jun 2004
    Location
    Scotland
    Posts
    250
    Downloads
    0
    Uploads
    0

    Default Re: Where to go from here: interfacing to Leadshine servo drive

    I never noticed it was after being stationary.

    If there's no oscilloscope, could the DAC be linked over to one of the ADC's?



  9. #9
    Registered
    Join Date
    May 2016
    Posts
    16
    Downloads
    0
    Uploads
    0

    Default Re: Where to go from here: interfacing to Leadshine servo drive

    Hi m_c,

    As Tom has noticed, this whole thing is a big, inefficient debugging process. I started using the Kmotion step/response tools after first spinning the servo enough to get a hello, world motion with a straight DAC output, but couldn't figure out what was going on in tuning it because sometimes it would behave as expected and settle, but re-running the very same parameters would go rapidly very unstable after the initial motion. I believe what was happening was the Kflop servo loop was seeing the 180 degree opposed motion from the servo polarity reversal transient. Without any load on the servo it was going nuts basically instantly (I was able to get some control really cranking the D term but it was clearly not right), adding the ballscrew gave enough drag to get a handle on the observables, which is where I started this thread.

    For the code and charts here I am doing like you say, trying to just run it open loop, constant torque to figure out why it continues in the wrong direction on polarity reversal (stopping and starting without reversing DAC polarity doesn't exhibit the same effect). The plots are all with the ballscrew and two linear bearings attached, so some load is present. I am going to reconfigure the servo drive to velocity mode and see if the same situation occurs when polarity is reversed, another guy on another forum had issues and ended up switching to velocity mode, which had success for him.

    Andy



  10. #10
    Registered
    Join Date
    May 2016
    Posts
    16
    Downloads
    0
    Uploads
    0

    Default Re: Where to go from here: interfacing to Leadshine servo drive

    (for clarity, what I'm trying to do is spin it 10,000 counts in one direction open loop, stop motion and wait briefly, reverse direction until back where it started. The code is a hodgepodge of commented out stuff and unnecessary commands from prior debugging attempts when I thought it might have been a plain tuning issue)



  11. #11
    Registered
    Join Date
    May 2016
    Posts
    16
    Downloads
    0
    Uploads
    0

    Default Re: Where to go from here: interfacing to Leadshine servo drive

    Update: after trying a last few shot-in-the-dark the torque mode parameters with no joy, I switched the servo to velocity control and all of a sudden everything works. No more wrong direction on polarity flipping, and tuning the PID parameters works a treat in Kmotion. I will keep one axis in velocity mode with this motor/servo pairing and switch vendors for the remaining axes, I'm assuming that works well enough for coordinated motion since the Kflop will be getting the encoder feedback without needing to know the particulars of how the driver is controlling the motors?

    If Leadshine ever gets back to me with a solution for torque mode control I will post it.



  12. #12
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2289
    Downloads
    0
    Uploads
    0

    Default Re: Where to go from here: interfacing to Leadshine servo drive

    I'm assuming that works well enough for coordinated motion since the Kflop will be getting the encoder feedback without needing to know the particulars of how the driver is controlling the motors?
    Not exactly sure what you mean by this, but yes if all the axes are working correctly and following their trajectory then coordinated motion should be correct.

    Regards

    TK
    http://dynomotion.com


Page 1 of 2 12 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
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

Where to go from here: interfacing to Leadshine servo drive
Where to go from here: interfacing to Leadshine servo drive