535,192 active members*
4,124 visitors online*
Register for free
Login
IndustryArena Forum > Machine Controllers Software and Solutions > Dynomotion/Kflop/Kanalog > starting my C program, any guidance would be apreciated.
Page 5 of 6 3456
Results 81 to 100 of 108
  1. #81
    Junior Member
    Join Date
    May 2006
    Posts
    3611

    Re: starting my C program, any guidance would be apreciated.

    What is a "variable speed control wheel"?

    JP15 are inputs. Do you know the difference between inputs and outputs?
    TK
    http://dynomotion.com

  2. #82

    Re: starting my C program, any guidance would be apreciated.

    Quote Originally Posted by TomKerekes View Post
    What is a "variable speed control wheel"?
    see picture
    Quote Originally Posted by TomKerekes View Post
    JP15 are inputs. Do you know the difference between inputs and outputs?
    yes, so Jp13 then.

  3. #83
    Junior Member
    Join Date
    May 2006
    Posts
    3611

    Re: starting my C program, any guidance would be apreciated.

    So the solenoid somehow causes the crank to rotate?
    TK
    http://dynomotion.com

  4. #84

    Re: starting my C program, any guidance would be apreciated.

    Yes

  5. #85
    Junior Member
    Join Date
    May 2006
    Posts
    3611

    Re: starting my C program, any guidance would be apreciated.

    So how do you expect that would work?
    TK
    http://dynomotion.com

  6. #86

    Re: starting my C program, any guidance would be apreciated.

    I'm thinking that currently there is a 2 solenoid controlled pneumatic valve attached to this pneumatic thing (see Pic), it turns what used to be the hand wheel on my mill, It was working with the system I replaced and if air is activated one way it will increase the speed, if activated the other way it decreases the speed. If I can get help writing the C-code for it, I believe that when the g-code calls for an "S"whatever it will speed up or down.

    I also have a pneumatic breaking system on this mill which activates an air cylinder to break the spindle when mill spindle is stopped.It will released when you run a program and spindle is activated. Would be kinda nice to have both working.

    I do have an encoder attached to the spindle but it's not displaying RPM yet.

  7. #87
    Junior Member
    Join Date
    May 2006
    Posts
    3611

    Re: starting my C program, any guidance would be apreciated.

    Are there 2 solenoids? Do you have the specifications for the solenoids with regard to the current?
    TK
    http://dynomotion.com

  8. #88

    Re: starting my C program, any guidance would be apreciated.

    Quote Originally Posted by TomKerekes View Post
    Are there 2 solenoids?
    Yes
    Quote Originally Posted by TomKerekes View Post
    Do you have the specifications for the solenoids with regard to the current?
    the Solenoids are Versa products KXX-4333-HC-3TC-24VDC PSI 29-175 10.5W, I can't find any other information on the online.

  9. #89
    Junior Member
    Join Date
    May 2006
    Posts
    3611

    Re: starting my C program, any guidance would be apreciated.

    10.5 Watts @ 24V is less than 1 Amp so it should work with Kanalogs SWx outputs. A reverse diode across the coil is required otherwise switching off could cause a spark and damage. Connect like this:

    Attachment 456320
    TK
    http://dynomotion.com

  10. #90

    Re: starting my C program, any guidance would be apreciated.

    Can I connect it to JP13 without a reverse diode (don't have any).
    Attached Thumbnails Attached Thumbnails JP13.png  

  11. #91
    Junior Member
    Join Date
    May 2006
    Posts
    3611

    Re: starting my C program, any guidance would be apreciated.

    No. Do not use JP13 it can't handle the current and would also need a reverse diode. Kanalog Opto Outputs are limited to 0.025 Amps. Your solenoid requires about 0.4A. Also connecting A supply directly to the opto output, as you show, without any load to limit the current would cause damage. That would be like wiring AC power directly to a light switch without any light bulb in the circuit. If you turned on the switch it would blow the fuse or worse. The load needs to be in series not parallel.
    TK
    http://dynomotion.com

  12. #92

    Re: starting my C program, any guidance would be apreciated.

    Ok, I think It may already have a diode in the selenoid switch so I should be good.

  13. #93

    Re: starting my C program, any guidance would be apreciated.

    I tried to make a C-program to run the spindle break which is operated by an air cylinder. I was able to get a c-code program to validate and compile, but it will not command the air valve. Here is my program, do you see anything I need to correct. I need the air cylinder to expand when the spindle turns off and contract when on. The picture is how I have the air solenoid connected per our earlier conversation.

    All the information/lessons I find about C-code is making programs with math equations, is there somewhere you know of that shows how to make programs needed for Kflop?


    #include "KMotionDef.h"

    #define SPINDLEAXIS_7
    #define SPINDLECW_BIT 156
    #define SPINDLECCW_BIT 153
    #define SOLENOID_BIT 159

    main()
    {
    if
    SPINDLEAXIS_7 (1) // spindle on
    ClearBit(159);
    else
    SetBit(159);
    }
    Attached Thumbnails Attached Thumbnails JP8.png  

  14. #94

    Post Re: starting my C program, any guidance would be apreciated.

    I havent had a chance to try this out but, would this fix it?

    #include "KMotionDef.h"

    #define SPINDLEAXIS_7
    #define SPINDLECW_BIT 156
    #define SPINDLECCW_BIT 153
    #define SOLENOID_BIT 159

    main()

    if
    {
    (SPINDLEAXIS_7 = Active) // spindle on
    ClearBit(159);
    }
    else
    {
    SetBit(159);
    }

  15. #95
    Junior Member
    Join Date
    May 2006
    Posts
    3611

    Re: starting my C program, any guidance would be apreciated.

    You need to explain what you mean by:

    I need the air cylinder to expand when the spindle turns off and contract when on.
    Enabled?

    #define statements basically do text substitution allowing you to give a symbolic name to something. Sort of like Find and Replace. It has 2 parts. The first is the name you choose to use. The second is the thing to substitute when that name is found. So for example:

    #define SOLENOID_BIT 159

    Defines 159 to be substituted for SOLENOID_BIT. So now you could code:

    ClearBit(SOLENOID_BIT);

    The advantage is that instead of using magic numbers (159) you can then use names to make the code more understandable. Furthermore if the thing is used in more than one place, for example in your SetBit and ClearBit, if you ever were to change where the Solenoid was connected to say 158 all you would need to do is change the #define one place and everything would be updated.

    If you make defines and don't use them anywhere you are just adding confusion.

    #define SPINDLEAXIS_7

    Tells the compiler to replace SPINDLEAXIS_7 with nothing. So your program becomes:

    Code:
    main()
    {
        if (1) // spindle on
            ClearBit(159);
        else
            SetBit(159);
    }
    (Notice I posted the code using the # code tag so the code is properly indented and readable unlike how you just posted it as text making it difficult to read)

    In the C Language zero is FALSE and non-zero (ie 1) is TRUE. Since the 'if' condition is always TRUE then your program will always Clear Bit 159. So your program boils down to:

    Code:
    main()
    {
        ClearBit(159);
    }

    I assume you need to Set the bit to release the brake? Did you test it using the Digital IO Screen?

    Anyways it isn't clear you need any Spindle testing. Another approach is that you already have an Init program to enable the axes and the Spindle. Why not just release the Brake at the same time enabling the Spindle? Do you ever need to re-apply the Brake?

    You might also read our wiki and look at some of the many C examples.
    TK
    http://dynomotion.com

  16. #96

    Wink Re: starting my C program, any guidance would be apreciated.

    Quote Originally Posted by TomKerekes View Post
    You need to explain what you mean by:

    Enabled?
    Ok, maybe Enabled wasn't the best term. Spindle on and turning CW or CCW is what I meant.

    Quote Originally Posted by TomKerekes View Post
    #define statements basically do text substitution allowing you to give a symbolic name to something. Sort of like Find and Replace. It has 2 parts. The first is the name you choose to use. The second is the thing to substitute when that name is found. So for example:

    #define SOLENOID_BIT 159

    Defines 159 to be substituted for SOLENOID_BIT. So now you could code:

    ClearBit(SOLENOID_BIT);

    The advantage is that instead of using magic numbers (159) you can then use names to make the code more understandable. Furthermore if the thing is used in more than one place, for example in your SetBit and ClearBit, if you ever were to change where the Solenoid was connected to say 158 all you would need to do is change the #define one place and everything would be updated.

    If you make defines and don't use them anywhere you are just adding confusion.

    #define SPINDLEAXIS_7

    Tells the compiler to replace SPINDLEAXIS_7 with nothing. So your program becomes:

    Code:
    main()
    {
        if (1) // spindle on
            ClearBit(159);
        else
            SetBit(159);
    }
    (Notice I posted the code using the # code tag so the code is properly indented and readable unlike how you just posted it as text making it difficult to read)
    So if I have multiple Solenoids how does the computer/kflop tell them apart? Do I just use something like Sol159 and no define?

    Quote Originally Posted by TomKerekes View Post
    In the C Language zero is FALSE and non-zero (ie 1) is TRUE. Since the 'if' condition is always TRUE then your program will always Clear Bit 159. So your program
    I assume false = off and true = on?

    Quote Originally Posted by TomKerekes View Post
    I assume you need to Set the bit to release the brake? Did you test it using the Digital IO Screen?
    Yes, I believe so, It appears that this solenoid is normally open so when the G-code sees an M5 or M30 the spindle stops and at the same time the solenoid activates the air to the extend side of the air cylinder and applys the spindle break. When the spindle encounters a start rotating command the solenoid should be energized and close/or route the air to the other side of the cylinder which retracts the cylinder rod and stops applying pressure to the spindle break. I tested it with KmotionCNC by running the spindle CW and CCW.

    Quote Originally Posted by TomKerekes View Post
    Anyways it isn't clear you need any Spindle testing. Another approach is that you already have an Init program to enable the axes and the Spindle. Why not just release the Brake at the same time enabling the Spindle? Do you ever need to re-apply the Brake?
    I need the brake on to change tools, anytime the spindle is not rotating, and off anytime the spindle rotates.

    Quote Originally Posted by TomKerekes View Post
    You might also read our wiki and look at some of the many C examples.
    I have but not finding anything which suits my specific need which I understand. I have also watched a few Youtube videos but they mostly talk about making mathematical equations, which I don't really understand how to convert it from 123456789 to a name or thing and how the computer/control board knows what I'm saying to it.
    I'm sure the control/computer, you are saying WTF is this guy saying. You don't know of a way to translate this to Redneck dumbass do you? Anyway thanks for the help I am tracking somewhat.

  17. #97

    Re: starting my C program, any guidance would be apreciated.

    I have tested the solenoid and air cylinder using the Digital IO Screen, and it works. What i need to happen is when the spindle is not rotating the solenoid is not energized (like it is now), but when the spindle rotates the solenoid needs to be energized. How/where do I insert the code to make it work this way; at the end of my Init program?

  18. #98

    Re: starting my C program, any guidance would be apreciated.

    Test
    [#Code:]
    main()

    if (SPINDLEAXIS_7==1)
    {SetBit(159);
    }
    else()
    {ClearBit(159);
    }[#Code:]

  19. #99
    Junior Member
    Join Date
    May 2006
    Posts
    3611

    Re: starting my C program, any guidance would be apreciated.

    So if I have multiple Solenoids how does the computer/kflop tell them apart? Do I just use something like Sol159 and no define?
    Each IO has a different Bit number. If you define a name to represent the number it should be unique and not contain the number itself in case the IO ever changes.


    I assume false = off and true = on?
    Sort of but true and false is somewhat different than on and off. 5 > 4 is true, 4 > 5 is false. Its referred to as a condition. Note in C to check for equality the == operator is used and the check of inequality != is used. The = operator is reserved as an assignment. For example x=5; sets the variable x to 5 it does not compare x to 5. To compare x to 5 you would code if (x==5) ...


    Yes, I believe so, It appears that this solenoid is normally open so when the G-code sees an M5 or M30 the spindle stops and at the same time the solenoid activates the air to the extend side of the air cylinder and applys the spindle break. When the spindle encounters a start rotating command the solenoid should be energized and close/or route the air to the other side of the cylinder which retracts the cylinder rod and stops applying pressure to the spindle break. I tested it with KmotionCNC by running the spindle CW and CCW
    This is confusing to me. You describe it as already working properly so what is the point of all this? But yes, since you have C Programs to start the Spindle CW and start the Spindle CCW and to stop the Spindle I would add code to those to release and set the brake appropriately. If you look at them by default they set and clear bits normally used to enable/disable and set the direction of the spindle that your system probably doesn't need.

    A side issue is that most systems don't like to be enabled with a brake on. If the spindle can't move and there is a small error the servo may try really hard to correct the error and apply maximum torque. This might make the motor hot and so forth. Also when the brake is released there might be a violent jump. So whenever the brake is applied you might want to disable the servo and then re-enable it when re-started.
    TK
    http://dynomotion.com

  20. #100

    Re: starting my C program, any guidance would be apreciated.

    Quote Originally Posted by TomKerekes View Post
    Each IO has a different Bit number. If you define a name to represent the number it should be unique and not contain the number itself in case the IO ever changes.
    Ok, I get it.
    Quote Originally Posted by TomKerekes View Post
    Sort of but true and false is somewhat different than on and off. 5 > 4 is true, 4 > 5 is false. Its referred to as a condition. Note in C to check for equality the == operator is used and the check of inequality != is used. The = operator is reserved as an assignment. For example x=5; sets the variable x to 5 it does not compare x to 5. To compare x to 5 you would code if (x==5) ...
    Ok, that explains why I can't get = to work.

    Quote Originally Posted by TomKerekes View Post
    This is confusing to me. You describe it as already working properly so what is the point of all this? But yes, since you have C Programs to start the Spindle CW and start the Spindle CCW and to stop the Spindle I would add code to those to release and set the brake appropriately. If you look at them by default they set and clear bits normally used to enable/disable and set the direction of the spindle that your system probably doesn't need.

    A side issue is that most systems don't like to be enabled with a brake on. If the spindle can't move and there is a small error the servo may try really hard to correct the error and apply maximum torque. This might make the motor hot and so forth. Also when the brake is released there might be a violent jump. So whenever the brake is applied you might want to disable the servo and then re-enable it when re-started.
    Bad explanation on my part, It didn't work in KMOTIONCNC but does work in the Digital IO, so I just have to get my C-codes working properly.

Page 5 of 6 3456

Similar Threads

  1. Mini mill conversion Input apreciated
    By crl1_1 in forum Benchtop Machines
    Replies: 0
    Last Post: 07-27-2018, 07:14 AM
  2. Starting mid program... can it be done?
    By Brian L in forum Milltronics
    Replies: 5
    Last Post: 07-10-2014, 02:55 PM
  3. Starting at New CNC Build -- Guidance Needed!!
    By dtmille2 in forum DIY CNC Router Table Machines
    Replies: 21
    Last Post: 01-02-2013, 05:00 AM
  4. Need some guidance on starting out
    By AlanDv in forum DIY CNC Router Table Machines
    Replies: 2
    Last Post: 08-20-2011, 05:13 AM
  5. starting program
    By chucker in forum Fanuc
    Replies: 2
    Last Post: 11-10-2009, 07:28 PM

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
  •