Need Help! Problem jig grinding machine.


Page 1 of 3 123 LastLast
Results 1 to 20 of 55

Thread: Problem jig grinding machine.

  1. #1
    Registered
    Join Date
    Nov 2016
    Posts
    28
    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
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    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

    Regards
    TK http://dynomotion.com


  3. #3
    Registered
    Join Date
    Nov 2016
    Posts
    28
    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
    28
    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
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    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

    Regards
    TK http://dynomotion.com


  6. #6
    Registered
    Join Date
    Nov 2016
    Posts
    28
    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
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    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

    Regards
    TK http://dynomotion.com


  8. #8
    Registered
    Join Date
    Nov 2016
    Posts
    28
    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
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    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
    Regards
    TK http://dynomotion.com


  10. #10
    Registered
    Join Date
    Nov 2016
    Posts
    28
    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
    28
    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
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    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
    Regards
    TK http://dynomotion.com


  13. #13
    Registered
    Join Date
    Nov 2016
    Posts
    28
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    Hi Tom.
    Your code works fine big thanks!
    One small note, when I press the button to start the screen that sets two Persist Variables shutdown KmotionCNC.
    Is it possible to keep running at one time KmotionCNC and Screen that sets two Persist Variables?

    Best Regards.



  14. #14
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    Hi vadim_cnc,

    The KMotionCNC Screen Editor works as one screen that can be customized in different ways. The KMotionCNC Screen doesn't shut down but rather it changes to look like the other screen.

    You basically have two options:

    #1 put the Variables on the main screen (I thought you already had that) so you have only one screen.

    #2 Add a new button on both screens to switch to the other screen.

    HTH
    Regards

    Regards
    TK http://dynomotion.com


  15. #15
    Registered
    Join Date
    Nov 2016
    Posts
    28
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    Quote Originally Posted by TomKerekes View Post
    #2 Add a new button on both screens to switch to the other screen.
    Hi Tom.
    Thank you, realize your option # 2. All transitions running back and forth fine.
    One question. In the Screen Editor, I saw MotionButton style and ToggleButton, if I could use one of these styles in order to:
    For example: press the button and hold it at the same time some BIT were turned on, and when I let go of the button, this BIT immediately switched off.

    P.S.
    I tried to choose those styles, but they work like simple button. Maybe I do something wrong.

    Best Regard.



  16. #16
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    Hi vadim_cnc,

    We don't have a momentary push button like that (other than the Jog buttons that have a somewhat fixed functionality and are labeled as "Motion Buttons").

    What exactly are you trying to do?

    Regards

    Regards
    TK http://dynomotion.com


  17. #17
    Registered
    Join Date
    Nov 2016
    Posts
    28
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    I am trying something like the manual mode, with instant control bits. I also tried to do a BIT turn off via the time or distance. Everything works, but there are bumps.

    P.S.
    I can also implement it in terms of physical buttons.

    Best Regard.



  18. #18
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    Hi vadim_cnc,

    We added a Momentary button style to drive an IO Bit in the latest Release. See:

    http://www.cnczone.com/forums/dynomo...ml#post1972492

    Regards

    Regards
    TK http://dynomotion.com


  19. #19
    Registered
    Join Date
    Nov 2016
    Posts
    28
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    Hi Tom!
    Could you tell us more how the Momentary button style and how rather to use this button style.


    I tried to use the physical buttons with this code, but it looks like he still is not perfect.

    Code:
    #include "KMotionDef.h"
    
    	main() 
    {
    	for (;;)
    	WaitNextTimeSlice();
    	
    	if (ReadBit(145) || ReadBit(144))    // to protect against accidental clicks while working
    		{
    			ClearBit(136);  // opto input
    			ClearBit(137);  // opto input
    		} 
    	if (ReadBit(136)) // opto input, 24V if the physical button is pressed
    		{
    			SetBit(144);
    			ClearBit(145);
    		}
    	else
    			ClearBit(144);
    			ClearBit(145);
    			
    	if (ReadBit (137)) // opto input, 24V if the physical button is pressed
    		{
    			SetBit(145);
    			ClearBit(144);
    		}
    	else 
    			ClearBit(145);
    			ClearBit(144); 
    		
    return 0;	
    }




  20. #20
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4043
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    Hi vadim_cnc,

    Here is a Video showing how the Momentary and Toggle Buttons work.



    Regarding your C Program:

    #1 please indent your programs with spaces properly so they are readable. That would have helped find one of your bugs.

    #2 The "for" statement will loop only the next single statement unless curly brackets {} are used to form a block to repeat. So this code:

    Code:
    for (;;)
        WaitNextTimeSlice();
    loops forever doing nothing. No code after this will be executed.

    #3 You can not Set or Clear Inputs. You only can read them.

    #4 The logic of your code will Set a bit and Clear a bit in the same loop. make sure your logic only sets a bit or clears the bit. Never both.

    HTH
    Regards

    Attached Files Attached Files
    Regards
    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.