Need Help! Problem jig grinding machine.


Page 1 of 3 123 LastLast
Results 1 to 12 of 35

Thread: Problem jig grinding machine.

  1. #1
    Registered
    Join Date
    Nov 2016
    Posts
    18
    Downloads
    0
    Uploads
    0

    Default Problem jig grinding machine.

    Hello everybody.
    Help is needed!

    We remake control system jig grinding machine 32K84SF4 USSR production. This machine has 5 main axes.

    3 axis is the coordinate ( "X, Y, Z" DC motors) are controlled through the driver, voltage +/- 10V. The measurement takes place via the optical linear encoder.
    Another axis ( "A" DC motor) is a planetary spindle (rotary axis) that rotates around the axis "Z"), which is also controlled via the driver, voltage +/- 10V. The measurement takes place via rotary encoder.
    Another axis ( "B" hydraulic cylinder (linear axis) moves parallel to the Z axis), the axis moves the tool reciprocating motion (down <-> up - cycles) by a predetermined distance, the hydraulic cylinder is controlled by an electromagnetic directional hydraulic control valve through a relay. The measurement takes place through an optical linear encoder.
    The axes X, Y, Z, we have set up, checked the A axis, but have not yet set, the axis checked in and proceeded to set up, but faced with a problem. We need to hydraulic cylinder axis is moved by a predetermined distance (down <-> up - cycles).

    The algorithm is as follows:
    In KmotionCNC are editing the value field and two buttons (start and stop).

    When a worker enters a value in the edit box and presses the start button, this value is passed to the file "name.c" which recorded the cycle of movement of the hydraulic cylinder, further:
    Checks for a condition
    If the value (which introduced the work)> 0;
    then
    Enable relay 0; (Axis moves in the up position)
    If the axis position (the value of the optical linear encoder) = 0;
    then
    Turn OFF the relay 0 and turn ON the relay 1;
    If the axis position (the value of the optical linear encoder) = value (which introduced the worker);
    then
    Turn OFF the relay 1 and turn ON the relay 0;
    end.

    Stop button
    If the axis position (the value of the optical linear encoder)> 0;
    then
    Turn OFF the relay 0 and turn ON the relay 1;
    end.


    My problem is that I do not know how to implement it, because there is no knowledge in programming.
    I would be grateful for any help.

    Similar Threads:
    Last edited by vadim_cnc; 11-10-2016 at 12:25 AM.


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

    Default Re: Problem jig grinding machine.

    Hi vadim_cnc,

    It seems like you have basic knowledge of how a program works. Why don't you try as a first step something simple like setting the I/O for your relays, waiting 1 second, the resetting your relays. Especially since you have not explained how you have wired your relays and what IO bit numbers control them. You don't need to be an expert programmer to do what you are asking.

    To have the operator enter a value have you looked at the example MessageInputBox.c. Are you able to run it? Would that work for you?

    Regards
    TK

    TK
    http://dynomotion.com


  3. #3
    Registered
    Join Date
    Nov 2016
    Posts
    18
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    Thank you for fast answer.
    I will try to do what you said. On the results I will write later.

    Best Regards.



  4. #4
    Registered
    Join Date
    Nov 2016
    Posts
    18
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    Hi Tom!

    We have displacement hydraulic cylinder.

    PHP Code:
        SetBitDirection(144,1); 
        
            for (;;)  
    //loop forever
       
    {
          
    WaitNextTimeSlice();
                       
            
    SetBit(144) && ClearBit(145);            
            
    Delay_sec(5);
           
        
    ClearBit(144) && SetBit(145);
            
    Delay_sec(5);
        } 
    relay control, we got through opto out, pins 144 and 145.

    optical linear encoder we connected on channel 4.

    Our Problem is that we do not know how to make that pins 144 and 145 switched ON or OFF when the optical linear encoder of the desired value.

    Best Regards.



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

    Default Re: Problem jig grinding machine.

    Hi vadim_cnc,

    Very good! But you didn't explain whether that code compiles, runs, and what happens. Please put more effort into your responses to make things go faster.

    Here are a few comments:

    #1 - Outputs 144 and 145 are Kanalog Outputs only. So there is no need to SetBitDirection(). It doesn't hurt anything to do so. But if you do it to one then you should do it to both.

    #2 - the C language '&&' is the logical '"AND" operator. So your code calls both functions and 'AND's the results together and doesn't do anything with the result. This makes no sense in your case. Its better to just call both functions as:

    SetBit(144);
    ClearBit(145);

    #3 - The indentation of your code is sloppy making it hard to read. Please read this note.

    #4 - You forgot to mention what KFLOP Axis Channel is using Encoder Input #4. The Axis Channel is what is needed to check the Position of the Encoder. Any Encoder Channel can be configured to any KFLOP Axis Channel. You might read this article.

    Assuming KFLOP Axis Channel #4 is using Encoder channel #4 you might use this code instead of your fixed 5 second delay:
    Code:
    #define DESIRED_ENCODER_VALUE 1000.0
    
    
        while (ch4->Position < DESIRED_ENCODER_VALUE) ;  // loop waiting for the encoder to pass some desired value
    HTH
    Regards

    TK
    http://dynomotion.com


  6. #6
    Registered
    Join Date
    Nov 2016
    Posts
    18
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    Thanks for the answer.
    We used a tip with your code, and that was it:
    Code:
      for (;;)  //loop forever
       {
          WaitNextTimeSlice();
    	     
    	#define DESIRED_ENCODER_VALUE_1 100000.0
    	#define DESIRED_ENCODER_VALUE_2  -50000.0
    	
                   while (ch4->Position < DESIRED_ENCODER_VALUE_1)
    		    SetBit(144) & ClearBit(145);
    		
    			
    	         while (ch4->Position > DESIRED_ENCODER_VALUE_2)
    		      SetBit(145) & ClearBit(144);
    		
      }
    This code works well and properly switches the relay in the band in which he was set. But there is one small remark, perhaps due to feature of the mechanics of movement of the hydraulic cylinder is observed tool going beyond the operating range.
    Is it possible to increase the speed of reading data from an optical linear encoder? For faster switching relays.

    And one more important question of how to implement the transmission of values from KmotionCNC in the control code hydraulic cylinder ?


    P.S.
    I tried experimenting with KmotionCNC and Screen Editor, but nothing is working did not work.



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

    Default Re: Problem jig grinding machine.

    Hi vadim_cnc,

    Very good!

    That obviously works but you are still using the & operator unnecessarily. Its ok to set the bit only once before the wait loop rather than continuously in the wait loop. And the indentation is incorrect. Here is how I would code and format it:
    Code:
    #include "KMotionDef.h"
    
    main()
    {
        for (;;)  //loop forever
        {
            WaitNextTimeSlice();
    
    #define DESIRED_ENCODER_VALUE_1 100000.0
    #define DESIRED_ENCODER_VALUE_2  -50000.0
    
            SetBit(144);  //Drive Forward
            ClearBit(145);
            while (ch4->Position < DESIRED_ENCODER_VALUE_1);  // wait doing nothing until at Position
    
    
            SetBit(145);  //Drive Reverse
            ClearBit(144);
            while (ch4->Position > DESIRED_ENCODER_VALUE_2);  // wait doing nothing until at Position
    
        }
    }


    This code works well and properly switches the relay in the band in which he was set. But there is one small remark, perhaps due to feature of the mechanics of movement of the hydraulic cylinder is observed tool going beyond the operating range.
    Is it possible to increase the speed of reading data from an optical linear encoder? For faster switching relays.
    I don't think the overshoot problem has to do with the time it takes to read the encoder (that is much less than a millisecond). The problem is the time it takes to stop. It is like driving your car and waiting until you are exactly at a Stop sign to begin stopping. There is no way to avoid overshooting the stop sign. You could start stopping some distance before the position you need to stop. You can monitor the speed and make the stopping point variable depending on the current speed. Maybe you could add another Relay+Valve to slow down when you get close? A proportional valve would be best.



    And one more important question of how to implement the transmission of values from KmotionCNC in the control code hydraulic cylinder ?
    Well you haven't explained how you expect the machine to operate and what other functions you need. But the Add example in the KMotionCNC Screen Editor should be very similar to what you need. When you push a button it runs a C Program to read two numbers from the Screen and add them. In your case you might just use the two values as your set points. Such as:
    Code:
    #include "KMotionDef.h"
    
    #define TMP 10 // which spare persist to use to transfer data
    #include "KflopToKMotionCNCFunctions.c"
    
    
    main()
    {
        double d1, d2;
        char s[80];
        // Read double from a KMotionCNC Edit Control
        // Persist Var identifies the Control and contents specifies 
        // where the string data should be placed in the 
        // Gather Buffer as an offset in words
        if (GetEditControlDouble(&d1, 160, 1000))
        {
            printf("Error Reading Edit Control Var=160\n");
            DROLabel(1000, 162, "???");
            return;
        }
        // Read double from a KMotionCNC Edit Control
        // Persist Var identifies the Control and contents specifies 
        // where the string data should be placed in the 
        // Gather Buffer as an offset in words
        if (GetEditControlDouble(&d2, 161, 1100))
        {
            printf("Error Reading Edit Control Var=161\n");
            DROLabel(1000, 162, "???");
            return;
        }
    
        for (;;)  //loop forever
        {
            WaitNextTimeSlice();
    
            SetBit(144);  //Drive Forward
            ClearBit(145);
            while (ch4->Position < d1);  // wait doing nothing until at Position
    
    
            SetBit(145);  //Drive Reverse
            ClearBit(144);
            while (ch4->Position > d2);  // wait doing nothing until at Position
    
        }
    }


    P.S.
    I tried experimenting with KmotionCNC and Screen Editor, but nothing is working did not work.
    What exactly did you try? What didn't work? What happened?

    Regards

    TK
    http://dynomotion.com


  8. #8
    Registered
    Join Date
    Nov 2016
    Posts
    18
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    Hi Tom!

    I don't think the overshoot problem has to do with the time it takes to read the encoder (that is much less than a millisecond). The problem is the time it takes to stop. It is like driving your car and waiting until you are exactly at a Stop sign to begin stopping. There is no way to avoid overshooting the stop sign. You could start stopping some distance before the position you need to stop. You can monitor the speed and make the stopping point variable depending on the current speed. Maybe you could add another Relay+Valve to slow down when you get close? A proportional valve would be best.
    Yes it's a good idea!

    Well you haven't explained how you expect the machine to operate and what other functions you need.
    Hydro cylinder will operate independently of the other machine movements, the value will be set at the beginning of the processing on and off in the end.

    My idea is to enter a value in KmotionCNC and clicking on the button "enter value" and give it to another file in which values are entered in the variables and set range of motion hydraulic cylinder from KmotionCNC . And when press the stop button turns bit.
    Problem jig grinding machine.-1-jpg

    What exactly did you try? What didn't work? What happened?
    I moved the entry form and the buttons and wanted to set the action on button. But I do not know what to do next. Where and how to record ID for "entry forms" and to read from his values.
    Problem jig grinding machine.-2-jpg



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

    Default Re: Problem jig grinding machine.

    Hi vadim_cnc,

    Here is an example screen that sets two Persist Variables (double #10 and #11) in KFLOP

    Problem jig grinding machine.-settwovalues-png

    Here are the Programs for each button to read and save the value

    Code:
    #include "KMotionDef.h"
    
    #define TMP 10 // which spare persist to use to transfer data
    #include "KflopToKMotionCNCFunctions.c"
    
    
    #define VALUE1_DVAR 10
    main()
    {
    	double d;
    	// Read double from a KMotionCNC Edit Control
    	// Persist Var identifies the Control and contents specifies 
    	// where the string data should be placed in the 
    	// Gather Buffer as an offset in words
    	if (GetEditControlDouble(&d, 160, 1000))
    	{
    		printf("Error Reading Edit Control Var=160\n");
    		return;
    	}
    	
    	SetUserDataDouble(VALUE1_DVAR,d);  //Save it in a global persist double variable
    	
    	printf("Variable set to %f\n",GetUserDataDouble(VALUE1_DVAR));  // print it as a test
    }
    Code:
    #include "KMotionDef.h"
    
    #define TMP 10 // which spare persist to use to transfer data
    #include "KflopToKMotionCNCFunctions.c"
    
    
    #define VALUE2_DVAR 11
    main()
    {
    	double d;
    	// Read double from a KMotionCNC Edit Control
    	// Persist Var identifies the Control and contents specifies 
    	// where the string data should be placed in the 
    	// Gather Buffer as an offset in words
    	if (GetEditControlDouble(&d, 161, 1000))
    	{
    		printf("Error Reading Edit Control Var=161\n");
    		return;
    	}
    	
    	SetUserDataDouble(VALUE2_DVAR,d);  //Save it in a global persist double variable
    	
    	printf("Variable set to %f\n",GetUserDataDouble(VALUE2_DVAR));  // print it as a test
    }

    Here is an example of how to read and print the values in KFLOP

    Code:
    #include "KMotionDef.h"
    
    #define TMP 10 // which spare persist to use to transfer data
    #include "KflopToKMotionCNCFunctions.c"
    
    
    #define VALUE1_DVAR 10
    #define VALUE2_DVAR 11
    main()
    {
    	printf("2 Variable set to %f %f\n",
            GetUserDataDouble(VALUE1_DVAR),
            GetUserDataDouble(VALUE2_DVAR));  // print it as a test
    }
    I've also attached the screen script. Note extensions are changed for upload to cnczone

    HTH
    Regards

    Attached Files Attached Files
    TK
    http://dynomotion.com


  10. #10
    Registered
    Join Date
    Nov 2016
    Posts
    18
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    Hi Tom!
    Thank you so much!

    I will try to use your code.
    Thanks again

    Best Regards



  11. #11
    Registered
    Join Date
    Nov 2016
    Posts
    18
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    Hi Tom.
    Sorry for the stupid question, but I can not configure the files to the correct operation.
    When I run the screen that sets two Persist Variables and set values, then I can watch them on the console. But for some reason this does not work with this code:
    Code:
    #include "KMotionDef.h"
    
    #define TMP 10 // which spare persist to use to transfer data
    #include "KflopToKMotionCNCFunctions.c"
    	
    main()
    {
    
            for (;;)  //loop forever
       {
          WaitNextTimeSlice();
    
    	#define DESIRED_ENCODER_VALUE_1 VALUE1_DVAR
    	#define DESIRED_ENCODER_VALUE_2 VALUE2_DVAR
    	
    	double VALUE1_DVAR;
    	double VALUE2_DVAR;	
    
    		ClearBit(144);
    		SetBit(145);
    		
    		while (ch4->Position > DESIRED_ENCODER_VALUE_2);
    		ClearBit(145);
    		SetBit(144);
    		
    		while (ch4->Position < DESIRED_ENCODER_VALUE_1);
    		
    	}
        
    	return 0;
    	    
    }
    For example, I INPUT values 40000 and -25000, but in reality, the value at which the switch direction is close to zero.

    Due to my inexperience, I can not understand where the error is.

    Best Regards.



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

    Default Re: Problem jig grinding machine.

    Hi vadim_cnc,

    The values you want are stored in Persistent UserData variables. You need to get the values from there. Try this:


    Code:
    #include "KMotionDef.h"
    #define TMP 10 // which spare persist to use to transfer data
    #include "KflopToKMotionCNCFunctions.c"
    
    #define VALUE1_DVAR 10
    #define VALUE2_DVAR 11
    
    main()
    {
        for (;;)  //loop forever
        {
            ClearBit(144);
            SetBit(145);
    
            while (ch4->Position > GetUserDataDouble(VALUE1_DVAR));
            ClearBit(145);
            SetBit(144);
    
            while (ch4->Position < GetUserDataDouble(VALUE2_DVAR));
        }
    
        return 0;
    }
    Regards

    Last edited by TomKerekes; 11-30-2016 at 01:59 PM. Reason: extra curly bracket
    TK
    http://dynomotion.com


Page 1 of 3 123 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

Problem jig grinding machine.
Problem jig grinding machine.