587,215 active members*
3,416 visitors online*
Register for free
Login
IndustryArena Forum > Machine Controllers Software and Solutions > Dynomotion/Kflop/Kanalog > need help to get kflop and and Kmotion up and running
Page 3 of 6 12345
Results 41 to 60 of 106
  1. #41
    Join Date
    May 2006
    Posts
    4047

    Re: need help to get kflop and and Kmotion up and running

    Hi Jossa,

    it is now done, and all 4 pins is set as outputs when i push INIT in KMotionCNC.exe and i can enable the relays via buttons.. IE, i have M3 assigned to set pin 29 high and and M5 assigned to set it to 0.. so i can basically control a spindle with it now..

    is this thinking right? or is it done differently normaly?
    That is a perfectly normal way to do things if your spindle can be switched with a single bit.


    i guess what i am struggling with understanding is how programs are put into Kmotion? (how does Kflop know what i program and what i want it to do)
    when i edit something in KMotion.exe and download it, or make a reference to a C program in KMotionCNC.exe.. how is that program enterd into the Kflop?
    KMotion.exe is only used to create and test the C Programs. After that KMotion.exe is never used. It doesn't "put" or do anything permanently to KFLOP. When you push a button in KMotionCNC configured to execute a C Program KMotionCNC gets the Program, compiles it, downloads it, and runs it all in the blink of an eye.

    could SimpleHomeIndexFunctionTest.c be used in normal operation?
    Yes. You might assign it to a User Button in KMotionCNC called "Home". You will of course need to change the speeds, bit numbers, etc... for your system

    also, do you think this would work with KmotionCNC?
    https://littlemachineshop.com/produc...ory=1963256893
    No, I think that is built specifically for Mach3. The best approach is to wire an MPG directly to KFLOP. That makes it deterministically responsive without any potential latency caused by the PC/USB/Windows.

    HTH
    Regards
    TK
    http://dynomotion.com

  2. #42
    Join Date
    Dec 2013
    Posts
    159

    Re: need help to get kflop and and Kmotion up and running

    That is a perfectly normal way to do things if your spindle can be switched with a single bit.
    '
    i see, so it becomes like a safety thing almost.. i am asking because i don't know so thanks for clearing that up.



    KMotion.exe is only used to create and test the C Programs. After that KMotion.exe is never used. It doesn't "put" or do anything permanently to KFLOP. When you push a button in KMotionCNC configured to execute a C Program KMotionCNC gets the Program, compiles it, downloads it, and runs it all in the blink of an eye.
    ok.. so if i understand you right..

    1. first you create a init file and edit the "kmotiondef.h" file.. and since there is a #include "KMotionDef.h" in the header of the file it is also included (can you include unlimited amounts of files?)
    2. inside the init file you have included the axis information so that is also persistently programmed into the controller
    3. then when you push the "compile" button the current active file + all the included files in that is made into like machine code and made ready to download
    4. if i in KMotionCNC bind the Home button to "SimpleHomeIndexFunctionTest.c" how is that uploaded into the controller? (if it is not #included in the initial compile and upload?)


    i am strugeling with understanding the workflow and what happens in the different stages..


    Yes. You might assign it to a User Button in KMotionCNC called "Home". You will of course need to change the speeds, bit numbers, etc... for your system
    yes of course, it is just meant as a way to get me up and running. i see..
    what do you think of the inductive sensors i got? would they work with the inputs? (see included PDF)

    also, can a home switch work as a limit switch simultaneously?

    Attachment 261572


    No, I think that is built specifically for Mach3. The best approach is to wire an MPG directly to KFLOP. That makes it deterministically responsive without any potential latency caused by the PC/USB/Windows.
    so any Chinese MPG with a pulse gen and no LCD would work? .. with a parallel output and not a usb one i guess?

  3. #43
    Join Date
    May 2006
    Posts
    4047

    Re: need help to get kflop and and Kmotion up and running

    HI jossa,

    ok.. so if i understand you right..

    first you create a init file and edit the "kmotiondef.h" file.. and since there is a #include "KMotionDef.h" in the header of the file it is also included (can you include unlimited amounts of files?)
    No don't ever edit the KMotionDef.h file. That contains all the definitions of the functions and variables in KFLOP's Firmware. You edit the Init file. You can include any number of other files of your own if you wish. Including other files is probably not useful in your case.

    inside the init file you have included the axis information so that is also persistently programmed into the controller
    Not sure what you mean here by persistently. When the Init.c file run it sets the axis parameters in KFLOP. Those parameter thereafter remain set until changed by something else or power loss.

    then when you push the "compile" button the current active file + all the included files in that is made into like machine code and made ready to download
    Correct

    if i in KMotionCNC bind the Home button to "SimpleHomeIndexFunctionTest.c" how is that uploaded into the controller? (if it is not #included in the initial compile and upload?)
    In exactly the same way as the Init or any other program. There is no "initial compile and upload" (we prefer to use the word "download" as KFLOP is considered below the Host PC as shown in the Video). Whenever you push a User Button the associated C program will be compiled, downloaded, and executed.



    what do you think of the inductive sensors i got? would they work with the inputs? (see included PDF)
    Those 2 wire sensors operate different than simple switches. When a normal physical switch "opens" they completely open and stop all current flow. However because these devices always need power and don't have enough wires to supply power they work differently. When they "open" they don't completely "open" rather they still pass a little current to keep them alive (2ma). 2ma of current is probably enough to keep a KSTEP input turned on. To use these type of sensors with KSTEP you will probably need to add a shunt resistance across KSTEP (ie 500 ohms) so that most of the 2ma passes through the shunt resistor and only a little passes through the KSTEP opto input.

    also, can a home switch work as a limit switch simultaneously?
    Yes, but it makes things more complicated because the limit switch function will need to be disabled while the homing takes place and then re-enabled afterward. Actually the SimpleHomeIndexFunctions.c has that functionality.

    HTH
    Regards
    TK
    http://dynomotion.com

  4. #44
    Join Date
    Dec 2013
    Posts
    159

    Re: need help to get kflop and and Kmotion up and running

    No don't ever edit the KMotionDef.h file. That contains all the definitions of the functions and variables in KFLOP's Firmware. You edit the Init file. You can include any number of other files of your own if you wish. Including other files is probably not useful in your case.
    i did not mean to say i have edited KMotionDef.h, sorry about that..
    what i trying to say is that i need to include the file in the init file that is compiled and downloaded..


    Not sure what you mean here by persistently. When the Init.c file run it sets the axis parameters in KFLOP. Those parameter thereafter remain set until changed by something else or power loss.
    ok, what i meant is if it is lost after a reboot, and you answered that.. and the init file with all the files that is included is sent to the controller each time i press INIT in KMotionCNC.exe? (not the actual file but the machine code is sent)



    In exactly the same way as the Init or any other program. There is no "initial compile and upload" (we prefer to use the word "download" as KFLOP is considered below the Host PC as shown in the Video). Whenever you push a User Button the associated C program will be compiled, downloaded, and executed.
    aha... so the plugin for Mach 3 is like a translator that translates between machine code/C and whatever Mach 3 uses?
    i think i am beginning to understand it all now..



    Those 2 wire sensors operate different than simple switches. When a normal physical switch "opens" they completely open and stop all current flow. However because these devices always need power and don't have enough wires to supply power they work differently. When they "open" they don't completely "open" rather they still pass a little current to keep them alive (2ma). 2ma of current is probably enough to keep a KSTEP input turned on. To use these type of sensors with KSTEP you will probably need to add a shunt resistance across KSTEP (ie 500 ohms) so that most of the 2ma passes through the shunt resistor and only a little passes through the KSTEP opto input.
    between GND and the actual input?



    Yes, but it makes things more complicated because the limit switch function will need to be disabled while the homing takes place and then re-enabled afterward. Actually the SimpleHomeIndexFunctions.c has that functionality.
    i see.. not that high priority yet so i will have a look at that later





    one more thing..

    how do you normally deal with the emergency stop?

    i have a input on my BLDC driver, it is just a simple, "cut the circuit and the motor stops" type of circuit..
    but i would have to stop the steppers from moving to minimize the harm done..

    would this be done on the Kstep?
    and just cutting the power can't be good for the drivers i imagine..

    is it handled in software or in hardware (relay cutting power etc.)?

  5. #45
    Join Date
    May 2006
    Posts
    4047

    Re: need help to get kflop and and Kmotion up and running

    between GND and the actual input?
    No think again, that would cause more current to flow through the KSTEP opto all the time.



    EStop is a complex subject. It is up to you to handle it properly for your situations. There have been many discussion about it. You might read through this Thread:

    Yahoo! Groups

    Regards
    TK
    http://dynomotion.com

  6. #46
    Join Date
    Dec 2013
    Posts
    159

    Re: need help to get kflop and and Kmotion up and running

    doh! major fault there.. in series with the load would do what you described, parallel just messes it up..
    not thinking before i wrote that.




    regarding the Estop..

    i found the following:

    at the top, define a name for the relevant input:
    // INPUTS
    #define ESTOP 169 // OptoIn 1 - low when in e-stop

    then within the main forever loop:
    // E-STOP STUFF
    if(!ESTOP){ // If estop bit is not active, then we're in an E-Stop state
    ClearBit(45) // so disable the drives
    }
    w
    is there a routine called ESTOP in kflop? or have he just named the input ESTOP and the magic happens in the ClearBit(45)? (What does Clearbit (45) do?)

    i also see a guy posting this:


    #define ESTOP 1046


    // Handle ESTOP
    result = Debounce(ReadBit(ESTOP),&ecount,&elast,&elastsolid );
    if (result == 1)
    {

    DoPC(PC_COMM_ESTOP);
    but i am not sure about witch one is most relevant..

    what i want to to is to stop the steppers from the Kflop in software and also cut the power to Kstep so that it is totally stopped..


    ..


    and with the steppers it apear that that the norm is to just cut the power to the AC side of the stepper PSU.. and i will add a relay in my cabinet for doing that.

    I should of maybe been a bit clearer in my description, but by removing power I disconnect the 240Vac input to the power supply, as is normally recommended, not cutting the DC feed direct to the KStep (I'm using a basic linear supply for reference).





    one more thing..
    how would you explain the threads inside Kflop?

    i see the go from 1 to 7

    remember i am a dummy! :P so it needs to for dummy's!

  7. #47
    Join Date
    May 2006
    Posts
    4047

    Re: need help to get kflop and and Kmotion up and running

    Hi Jossa,

    doh! major fault there.. in series with the load would do what you described, parallel just messes it up..
    not thinking before i wrote that.
    No that still doesn't sound right. This is what I was thinking:
    Attachment 261978

    Regarding ESTOP the second is probably more useful. But to disconnect power from going into KSTEP this will need to be done through external wiring as you describe. It won't involve KSTEP or software.


    how would you explain the threads inside Kflop?
    i see the go from 1 to 7
    See: KMotion/KFlop Multi-tasking

    Regards
    TK
    http://dynomotion.com

  8. #48
    Join Date
    Dec 2013
    Posts
    159

    Re: need help to get kflop and and Kmotion up and running

    ok, i see.. nice TomCad!
    so it is in a sense powered through the optocoupler?

    Lowest operating current is 2 mA and the shunt resistor is allowing the sensor to be powered without enabling the LED?


    how would this setup work with my cnc4pc A60 Inductive PNP - NC sensor?
    would it still not work? (they are much easier to mount to my mill then the new ones)





    i am thinking that i should stop the program also, so it is easier to start up again.. but maybe i am wrong here and to just cut the power to the drive is enough
    ok, so what is the snippet of code doing then? and should it be in the INIT file?


    Code:
    #define ESTOP 1046    <----- is it just setting a value to estop? is it a pin?
    
    
    // Handle ESTOP
    result = Debounce(ReadBit(ESTOP),&ecount,&elast,&elastsolid);   <------ is this saying to check the bit defined as ESTOP and if 1/active then do something?
    if (result == 1)
    {
    
    DoPC(PC_COMM_ESTOP);    <----- this i am not sure about..

    is it missing code? my friend says it is calling for something and it is not included in the code i have pasted..







    thanks for the link.. it explained it well

  9. #49
    Join Date
    Jun 2013
    Posts
    1041

    Re: need help to get kflop and and Kmotion up and running

    If you are using the same proximity sensors I am (also bought from cnc4pc) and connecting to optos then this is the diagram Tom gave me. It worked perfectly.

  10. #50
    Join Date
    Jun 2013
    Posts
    1041

    Re: need help to get kflop and and Kmotion up and running

    Sorry try again.

    Also here's a link to the thread discussing a lot of things you might run into like mpg and spindle control.

    http://www.cnczone.com/forums/dynomo...04522-cnc.html

    Ben

  11. #51
    Join Date
    Dec 2013
    Posts
    159

    Re: need help to get kflop and and Kmotion up and running

    yes i am using this:

    CNC4PC



    thanks for the diagram an confirmation on the sensor..



    can you tell me what you are doing for E stop on your kflop?
    thinking wiring and code..

  12. #52
    Join Date
    Jun 2013
    Posts
    1041

    Re: need help to get kflop and and Kmotion up and running

    Sorry but I do not have a estop. I know that's terrible but it is the way it is. I have used the estop button on the kmotion cnc screen and so far no issues and works perfectly. I consider estop a personal choice but would never recommended against it for anyone else's setup.

    Ben

  13. #53
    Join Date
    May 2006
    Posts
    4047

    Re: need help to get kflop and and Kmotion up and running

    Hi jossa,

    I think your sensors are PNP (output switches to + supply) which are unlike Ben's sensors that were NPN (output switches to GND).

    But good point if you are willing to add an external resistor to invert the drive they might work. I couldn't find a spec on your sensor to see how much current they can drive. But consider this circuit. The resistor keeps KSTEP's opto LED on. But when the PNP sensor drives the output high it will supply the current to the resistor and turn off the KSTEP's opto LED.

    Attachment 262000

    Regarding EStop: That User had a EStop signal input into Input bit 1046 in his system. He defined the symbol ESTOP to represent the number 1046 so that his code would be more readable instead of just using the number 1046. It also has the advantage that if the number is used many places he can just redefine the symbol and automatically everywhere the symbol is used will now use the new value.

    The code reads the defined input and passes the result to a function called Debounce. The Debounce function does two things: #1 it "debounces" the switch because most mechanical switches do not always make a clean perfect switch on and off, but actually bounce where the switch closes and opens rapidly for a few milliseconds before finally settling out into a fully open or closed state. #2 it detects not when the switch is active or inactive, but rather when it changes state to active or inactive. The function takes care to return a value of 1 one and only one time when the switch settles into an active state.

    There is also a function call of: DoPC(PC_COMM_ESTOP); The function DoPC sends a numeric code up to the PC running KMotionCNC to tell it to do something. In this case it is requesting to push the STOP button. This will in turn disable all the axes channels and abort the GCode Interpreter if it is running.

    Both of these functions must be copied and included into your C program. The Debounce Function can be copied from the ExternalButtons.c example. The DoPC function can be copied from the KFLOPtoPCCmdExamples.c

    HTH
    Regards
    TK
    TK
    http://dynomotion.com

  14. #54
    Join Date
    Jun 2013
    Posts
    1041

    Re: need help to get kflop and and Kmotion up and running

    The sensors he linked to are the same three wire switches I have. I don't think anything changed about them.

    Ben

  15. #55
    Join Date
    May 2006
    Posts
    4047

    Re: need help to get kflop and and Kmotion up and running

    Hi Ben,

    Interesting. If yours are really PNP then I don't understand how they can be working.

    Regards
    TK
    http://dynomotion.com

  16. #56
    Join Date
    Jun 2013
    Posts
    1041

    Re: need help to get kflop and and Kmotion up and running

    I will post the schematics if I can still find them. You helped me figure out how to wire them and the dwg I posted came from you. I looked at the link he posted and am sure they are the same sensors. I almost want to say the actual schematics that are provided with them show wiring for both npn and pnp. I will double check to make sure and post the schematic that came with the sensors.

    Ben

  17. #57
    Join Date
    Jun 2013
    Posts
    1041

    Re: need help to get kflop and and Kmotion up and running

    If you follow the link I posted in the same post as I put the diagram from you you can see our original discussion. If you read paragraph 1 of the first post in the thread it tells the wire colors and there use. Then read post 5 and you will see how we decided to wire them. If you follow Jossa's link in post 51 of this thread you will see that the picture of the sensor at the top shows the same wire colors and uses as in post 1 of my thread. I have the greatest respect for you Tom and you have never steered me wrong so I hate to disagree with you at all. I do know that using the diagram from you got me wired up and homing in no time. It has worked flawlessly with repeatability in tenths for at least a year.

    Ben

  18. #58
    Join Date
    Dec 2013
    Posts
    159

    Re: need help to get kflop and and Kmotion up and running

    Quote Originally Posted by bhurts View Post
    Sorry but I do not have a estop. I know that's terrible but it is the way it is. I have used the estop button on the kmotion cnc screen and so far no issues and works perfectly. I consider estop a personal choice but would never recommended against it for anyone else's setup.

    Ben
    hehe don't worry, we are not judging you! i know the feeling, it it works and it is not essential for operation, it could wait.. but i am trying to remedy that by getting the E stop into my planing and therefore into my final design.

    Quote Originally Posted by TomKerekes View Post
    Hi jossa,

    I think your sensors are PNP (output switches to + supply) which are unlike Ben's sensors that were NPN (output switches to GND).

    But good point if you are willing to add an external resistor to invert the drive they might work. I couldn't find a spec on your sensor to see how much current they can drive. But consider this circuit. The resistor keeps KSTEP's opto LED on. But when the PNP sensor drives the output high it will supply the current to the resistor and turn off the KSTEP's opto LED.

    Attachment 262000

    Regarding EStop: That User had a EStop signal input into Input bit 1046 in his system. He defined the symbol ESTOP to represent the number 1046 so that his code would be more readable instead of just using the number 1046. It also has the advantage that if the number is used many places he can just redefine the symbol and automatically everywhere the symbol is used will now use the new value.

    The code reads the defined input and passes the result to a function called Debounce. The Debounce function does two things: #1 it "debounces" the switch because most mechanical switches do not always make a clean perfect switch on and off, but actually bounce where the switch closes and opens rapidly for a few milliseconds before finally settling out into a fully open or closed state. #2 it detects not when the switch is active or inactive, but rather when it changes state to active or inactive. The function takes care to return a value of 1 one and only one time when the switch settles into an active state.

    There is also a function call of: DoPC(PC_COMM_ESTOP); The function DoPC sends a numeric code up to the PC running KMotionCNC to tell it to do something. In this case it is requesting to push the STOP button. This will in turn disable all the axes channels and abort the GCode Interpreter if it is running.

    Both of these functions must be copied and included into your C program. The Debounce Function can be copied from the ExternalButtons.c example. The DoPC function can be copied from the KFLOPtoPCCmdExamples.c

    HTH
    Regards
    TK
    thanks for the explanation Tom!

    i am having trouble finding what pin he used on his setup.. 1046 is it a physical pin?


    Quote Originally Posted by TomKerekes View Post
    Hi Ben,

    Interesting. If yours are really PNP then I don't understand how they can be working.

    Regards
    could they be mislabeled? we are after all talking about the Chinese here.. would not be the first time.. can i measure them to help confirm what type of transistors they are?

    Quote Originally Posted by bhurts View Post
    I will post the schematics if I can still find them. You helped me figure out how to wire them and the dwg I posted came from you. I looked at the link he posted and am sure they are the same sensors. I almost want to say the actual schematics that are provided with them show wiring for both npn and pnp. I will double check to make sure and post the schematic that came with the sensors.

    Ben
    yes please! all schematics you have is welcome..
    what did you edit the code to?

  19. #59
    Join Date
    Jun 2013
    Posts
    1041

    Re: need help to get kflop and and Kmotion up and running

    I am still trying to find the schematics that came with the sensors. Did yours come with a diagram folded up with it inside a small bag like mine did? If so could you try posting it? I did confirm that my sensors are the same ones you linked to and I'm sure that's how I wired it through a snapamp opto input. I believe the optos on kstep should work the same but Tom would have to confirm that. I will post my code but it will probably have to be changed slightly for your use. This should be fairly easy and I can probably help with it.

    Ben

  20. #60
    Join Date
    Dec 2013
    Posts
    159

    Re: need help to get kflop and and Kmotion up and running

    mine did not come with any papers, just in a plastic bag..
    it is a label on the sensor itself explaining the pin out..

    ok.. i will try to wire it up like that

    yes please. code is really welcome, it is easier to see how it is done then..

Page 3 of 6 12345

Similar Threads

  1. Questions about Kmotion (Kflop+SnapAmp)
    By Buruhazard in forum Dynomotion/Kflop/Kanalog
    Replies: 58
    Last Post: 05-26-2017, 06:48 PM
  2. KMotion/KFlop Test Version 4.33a Available - Videos
    By TomKerekes in forum Dynomotion/Kflop/Kanalog
    Replies: 0
    Last Post: 05-23-2014, 08:00 AM
  3. Is Kflop/Kmotion CNC right for me?
    By Phy6 in forum Dynomotion/Kflop/Kanalog
    Replies: 6
    Last Post: 04-01-2014, 01:19 AM
  4. KMotion/KFlop Version 4.31 Released
    By TomKerekes in forum Dynomotion/Kflop/Kanalog
    Replies: 0
    Last Post: 03-12-2014, 11:08 PM
  5. Kmotion/KFLOP - Z axis as DRO
    By drb_001 in forum Dynomotion/Kflop/Kanalog
    Replies: 2
    Last Post: 05-29-2013, 05:33 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
  •