587,213 active members*
3,158 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 2 of 6 1234
Results 21 to 40 of 106
  1. #21
    Join Date
    Dec 2013
    Posts
    159

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

    a friend suggested that it is to be set in tool setup screen in KMotionCNC.exe..

    as a variable... is this right?


    it is not logical and i would not know this without help... :P

  2. #22
    Join Date
    May 2006
    Posts
    4047

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

    eem.. i am already stuck.. i don't know what i am looking at..
    i can't see anything in the Spindle_S_Kstep.c file that has anything to do with my spinle speed... am i on the wrong file?
    Can you find the variable called "speed"?

    Can you see how it is set from persist Variable #1 passed from the KMotionCNC program?

    Can you see how it is divided by RPM_FACTOR to be a value from 0 to 1 (no voltage to full voltage) and passed to the function to be corrected and output?

    a friend suggested that it is to be set in tool setup screen in KMotionCNC.exe..

    as a variable... is this right?
    Yes the whole idea of what we are trying to do is to setup KMotionCNC so that it can pass the S RPM word to KFLOP so KFLOP can set that RPM. So we want to configure KMotionCNC "S" to set the desired RPM in some unused persist Variable in KFLOP and execute this program in some unused Thread.

    HTH
    Regards
    TK
    http://dynomotion.com

  3. #23
    Join Date
    Dec 2013
    Posts
    159

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

    Can you find the variable called "speed"?
    what exactly does it say? and in what? in the "Spindle_S_Kstep.c" file there is 2 direct refferences to speed, and 1 to RPM..
    you need to remember that i need to be spoon fed this in a step by step manor, it is not something normal for me to program this..


    Can you see how it is set from persist Variable #1 passed from the KMotionCNC program?

    Can you see how it is divided by RPM_FACTOR to be a value from 0 to 1 (no voltage to full voltage) and passed to the function to be corrected and output?
    ..


    Yes the whole idea of what we are trying to do is to setup KMotionCNC so that it can pass the S RPM word to KFLOP so KFLOP can set that RPM. So we want to configure KMotionCNC "S" to set the desired RPM in some unused persist Variable in KFLOP and execute this program in some unused Thread.
    yes i know that, and i want nothing else then that.... but i still don't have any idea on how to do it.. and what a "unused persist Variable" and a "unused Thread" is..

  4. #24
    Join Date
    Dec 2013
    Posts
    159

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

    ok.. my friend found something new..

    i missed it when you said
    For KMotionCNC there is an example C Program that can be used. Configure KmotionCNC | Tool Setup | S | Exec Prog for this program using Thread #2 and to pass the Speed in Var #1.

    C:\KMotion433f\C Programs\KStep\KMotionCNC\Spindle_S_Kstep.c

    How good is your math? See if you can change the calculations for your 400 RPM offset from zero.

    Regards
    in the Tool setup page i am to set the last line named "S" to "exec prog" and refer to Spindle_S_Kstep.c


    are we setting the S-slider in the KMotionCNC interface to adjust the value / variable that we pass to the speed-variable in Spindle_S_Kstep.c, which again calculates the correct analog output according to the given speed / RPM_FACTOR, and then pass that to the controller?

    (this is my friend that found it out, not me!)


    but i still don't understand the calculation and math problem...

  5. #25
    Join Date
    May 2006
    Posts
    4047

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

    what exactly does it say? and in what? in the "Spindle_S_Kstep.c" file there is 2 direct refferences to speed, and 1 to RPM..
    you need to remember that i need to be spoon fed this in a step by step manor, it is not something normal for me to program this..
    float speed = *(float *)&persist.UserData[1]; // value stored is actually a float

    This line of code creates a floating point variable called "speed" and loads it with the RPM value passed from KMotionCNC in UserData Variable #1. The variable "speed" can then be used in formulas as the desired speed in RPM.



    in the Tool setup page i am to set the last line named "S" to "exec prog" and refer to Spindle_S_Kstep.c
    Correct. And also set Var=1 (so the speed is passed down to UserData Variable #1) and Thread=2 (to execute the program in Thread #2)


    are we setting the S-slider in the KMotionCNC interface to adjust the value / variable that we pass to the speed-variable in Spindle_S_Kstep.c, which again calculates the correct analog output according to the given speed / RPM_FACTOR, and then pass that to the controller?
    Sort of. But the C Program resides in the Controller (KFLOP). So the speed / RPM_FACTOR is a calculation that converts the speed in RPM passed down to KFLOP into a fraction of full speed (a number from 0 to 1).

    More than just the Slider whenever the Speed in GCode (or the Slider) is changed this is how it configured to make the change occur. The Slider changes the SRO (Spindle Rate Override). So say the GCode S Speed is set at 1000RPM and the Slider is moved to 1.1. Then KMotionCNC sends a new speed of 1100RPM to KFLOP.


    but i still don't understand the calculation and math problem...
    Your system is special because 0V drives 282.52 RPM instead of 0 RPM like most systems. As you stated:

    0V = 400RPM on motor = 282.52 RPM on spindle
    5V = 3600RPM on motor = 2542.70 RPM on spindle

    so instead of a single divide like this:

    speed/RPM_FACTOR

    you would need a subtract and divide by the RPM Range like:

    (speed - 282.52)/(2542.70 - 282.52)

    If you plug in speed values between 282.52 and 2542.70 and do the math the result should be between 0 and 1.

    HTH
    Regards
    TK
    http://dynomotion.com

  6. #26
    Join Date
    Dec 2013
    Posts
    159

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

    we have tried to do as you say, by using the following code:


    Code:
    #include "KMotionDef.h"
    #include "..\CorrectAnalogFunction.c"
    
    #define RPM_FACTOR 500 // RPM for full duty cycle (max analog out)
    
    // desired speed is passed in variable 1
    
    
    main()
    {
    	float speed = *(float *)&persist.UserData[1];  // value stored is actually a float	                                                            
    	speed = (speed - 282.52) /(2542.70 - 282.52);      //here is what we tried 
    	
    	FPGA(KAN_TRIG_REG)=4;  			// Mux PWM0 to JP7 Pin5 IO 44 for KSTEP 
    	SetBitDirection(44,1);  		// define bit as an output
    	FPGA(IO_PWMS_PRESCALE) = 46;  	// divide clock by 46 (1.4 KHz)
    	FPGA(IO_PWMS+1) = 1;  			// Enable
    	
    	FPGA(IO_PWMS) = CorrectAnalog(speed/RPM_FACTOR);  	// Set PWM
    }

    and here is what what we connected up to test with:
    Attachment 260672

    the voltage on JP33 pin 7 and 5 is measured to 4.98V DC


    and the result was that when we had the S slider in KMotionCNC to 0,1 the output was 0,0024V and at setting 2 (highest the slider can go) the maximum output we achieved was 0,789V


    then we tried the example file KStepPWMCorrected.c and tried to test the output that way, but all we got was the same result...

    so what is wrong here? is it in the way it is connected?

  7. #27
    Join Date
    May 2006
    Posts
    4047

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

    Hi Jossa,

    Since you are doing a new formula then you don't want also do the old formula (division by RPM_FACTOR). Remove the old RPM_FACTOR definition and do not divide by it. So do this:

    Code:
    #include "KMotionDef.h"
    #include "..\CorrectAnalogFunction.c"
    
    // desired speed is passed in variable 1
    
    main()
    {
    	float speed = *(float *)&persist.UserData[1];  // value stored is actually a float	                                                            
    	speed = (speed - 282.52) /(2542.70 - 282.52);      //here is what we tried 
    	
    	FPGA(KAN_TRIG_REG)=4;  			// Mux PWM0 to JP7 Pin5 IO 44 for KSTEP 
    	SetBitDirection(44,1);  		// define bit as an output
    	FPGA(IO_PWMS_PRESCALE) = 46;  	// divide clock by 46 (1.4 KHz)
    	FPGA(IO_PWMS+1) = 1;  			// Enable
    	
    	FPGA(IO_PWMS) = CorrectAnalog(speed);  	// Set PWM
    }
    Also it all depends on the RPM setting in KMotionCNC. The slider only adjusts the RPM by a percentage. You must set the Base RPM with an S command. Type S2542 in the MDI and send it.

    But I suspect there is some other hardware problem as well. To test if the hardware is working test with the diagnostic program from the previous posts where you were able to output voltages. Does that output higher voltages like 4V?

    Regards
    TK
    http://dynomotion.com

  8. #28
    Join Date
    Dec 2013
    Posts
    159

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

    update:

    tried connecting it to a external 5V PSU (the one that runs KFLOP) and now it works.. low is 0.016V and max is 5V...


    the code used is:

    #include "KMotionDef.h"
    #include "..\CorrectAnalogFunction.c"

    #define RPM_FACTOR 500 // RPM for full duty cycle (max analog out)
    // desired speed is passed in variable 1


    main()
    {
    float speed = *(float *)&persist.UserData[1]; // value stored is actually a float
    speed -= 282.52;


    FPGA(KAN_TRIG_REG)=4; // Mux PWM0 to JP7 Pin5 IO 44 for KSTEP
    SetBitDirection(44,1); // define bit as an output
    FPGA(IO_PWMS_PRESCALE) = 46; // divide clock by 46 (1.4 KHz)
    FPGA(IO_PWMS+1) = 1; // Enable

    FPGA(IO_PWMS) = CorrectAnalog(speed/RPM_FACTOR); // Set PWM
    }

    what is wrong, and how do we take into account the offset in this?

  9. #29
    Join Date
    Dec 2013
    Posts
    159

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

    disregard last post.. did not see it..


    your code works.
    #include "KMotionDef.h"
    #include "..\CorrectAnalogFunction.c"

    // desired speed is passed in variable 1

    main()
    {
    float speed = *(float *)&persist.UserData[1]; // value stored is actually a float
    speed = (speed - 282.52) /(2542.70 - 282.52); //here is what we tried

    FPGA(KAN_TRIG_REG)=4; // Mux PWM0 to JP7 Pin5 IO 44 for KSTEP
    SetBitDirection(44,1); // define bit as an output
    FPGA(IO_PWMS_PRESCALE) = 46; // divide clock by 46 (1.4 KHz)
    FPGA(IO_PWMS+1) = 1; // Enable

    FPGA(IO_PWMS) = CorrectAnalog(speed); // Set PWM
    }
    slider control's it from 0 to 5v


    diagnostics program also works.. 0 to 5V

    so using external PSU works. But from the BLDC controller's 5V output it don't work



    the problem is when getting power from the BLDC controller.. it is 5 volts, but maximum output i can set is 0,79V

  10. #30
    Join Date
    Dec 2013
    Posts
    159

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

    hmmm..

    any ideas on why it wont work?




    the next problems is:


    • Setting up the 4 relay card, CNC4PC C36

    product page

    product manual]404 Not Found

    my plan is to have one canal for flood cooling and one for a solenoid to a future power draw bar.. the rest is spare for later

  11. #31
    Join Date
    May 2006
    Posts
    4047

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

    Hi Jossa,

    hmmm..

    any ideas on why it wont work?
    You would need to debug things like that yourself. Measure voltages to find the issue. Is there +5V across KSTEP JP33 pins 5 and 7? What is the output voltage (pin6) relative to pin 7 (GND)? What is the output voltage when unloaded?


    Regarding C36. Looks like that should connect to any of KFLOP IO pins.

    Regards
    TK
    http://dynomotion.com

  12. #32
    Join Date
    Dec 2013
    Posts
    159

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

    I know that it is not your job to debug that.. i was just asking if you could see a connection..

    The voltage is 4.98V without load and 4,98V connected to pin 7 and 5.. voltage on 6 and 7 is 0,79V...



    How do i adress a spesific funtion to a adress (output)
    I asume that it is done in KMotionCNC-tool setup?

  13. #33
    Join Date
    May 2006
    Posts
    4047

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

    Hi jossa

    The voltage is 4.98V without load and 4,98V connected to pin 7 and 5.. voltage on 6 and 7 is 0,79V...
    You aren't being very detailed or specific in your replies. It doesn't seem logical that the circuit would behave differently when supplied with a one +5V supply or another +5V supply. So we must be miss communicating somewhere. You might describe step-by-step what you are doing when using KFLOP +5V and then when using the Motor Control's +5V. When I asked about loaded and unloaded I meant to say the output (JP33 Pin6 connection). Not whether the supply was loaded or not. Testing unloaded would be with only the meter and noting else connected to pin 6 (referenced to pin7). I suspect it may have something to do with grounding. For example if you are using the Motor Control's +5V supply which has no Gnd connection to KFLOP but still referencing your measurement to KFLOP or earth GND.

    How do i adress a spesific funtion to a adress (output)
    I asume that it is done in KMotionCNC-tool setup?
    It depends what the function is and how it needs to be used. The simplest thing is to assign an M Code in KMotionCNC Tool Setup to turn on or off a bit. This can be any bit number. The first step would be to wire up the relay driver to an IO and toggle the bit on the Digital IO Screen to see if it functions correctly.

    Regards
    TK
    http://dynomotion.com

  14. #34
    Join Date
    Dec 2013
    Posts
    159

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

    You aren't being very detailed or specific in your replies. It doesn't seem logical that the circuit would behave differently when supplied with a one +5V supply or another +5V supply. So we must be miss communicating somewhere. You might describe step-by-step what you are doing when using KFLOP +5V and then when using the Motor Control's +5V. When I asked about loaded and unloaded I meant to say the output (JP33 Pin6 connection). Not whether the supply was loaded or not. Testing unloaded would be with only the meter and noting else connected to pin 6 (referenced to pin7). I suspect it may have something to do with grounding. For example if you are using the Motor Control's +5V supply which has no Gnd connection to KFLOP but still referencing your measurement to KFLOP or earth GND.
    i am sorry about that, and yes we might have a communication problem, you see English is not my first language and i live in Europe.. so that might account for any weird phrasing and strange sentences i make..

    i have tried many different ways, and i cant get the on board 5V on the BLDC controller to control through the Kflop, but if i use a external 5V it works (the PWM output on kflop, so the issue is with the crappy Chinese controller)..
    an i have just spoken to a guy on the forums that is also using a BLDC controller like mine, and he was indicating that you can supply the controller with external 5V if you solder off a connection..
    so i will try that.


    It depends what the function is and how it needs to be used. The simplest thing is to assign an M Code in KMotionCNC Tool Setup to turn on or off a bit. This can be any bit number. The first step would be to wire up the relay driver to an IO and toggle the bit on the Digital IO Screen to see if it functions correctly.
    i see.. and the way to understand this is:
    IE.

    to connect a home switch to the kflop/kstep the way i would find out the bit number is by looking at the pin out for JP33 and find the physical pin:

    JP33, pin 14 / Opto IN 5 / 173 Input ...

    from that i would read that the bit number is 173 and it is named Opto IN 5...

    it could be seen in the Digital I/O in Kmotion.exe if the input is high/low

    Am i right so far?

    where would the programming of homing switches be done? is that also in KMotionCNC / Tool setup / I/O bit ? or is it in C programming direct?


    on a side note, the sensors i had laying around is a Pepperl+Fuchs NBN4-12GM40-Z0-V1
    i include a datasheet for it below, do you think this sensor would work with kflop?

    Attachment 261142

    .......


    i also have one more thing, when i have all the functions i want in software, how do i consolidate it into the Kmotion controller?
    it might be a silly question but how is everything tied together in the final "version" of my program?

  15. #35
    Join Date
    Dec 2013
    Posts
    159

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

    We tried what you suggested; toggling the bit on the Digital IO screen, and it works.
    We also assigned the M3 button to toggle that bit, and it works after setting the bit as Output in the Digital IO screen in KMotion.
    What I need to know is how to "permanently" set the bit as an Output, so I don't need to do it everytime the program is restarted.
    Is there a way to do this in the graphical interface?

    Or could this be done in code, by setting a button as:

    (Button): Execute Prog: Thread: 2 (or some other unused thread), VAR: 0 (since we pass no var), C File: custom C-file with the following code:

    #include "KMotionDef.h"

    main()
    {
    // In this example I want to use bit 29

    setBitDirection(29, 1); // Set bit 29 to be an output <-- Is it OK to call setBitDirection() for every execution? This should probably be set "globally" first?
    setBit(29); // Set bit 29 state to 1 (on)
    }

    ... and then use clearBit(29) for another button to clear it.


    Am I completely off here?

  16. #36
    Join Date
    Jun 2013
    Posts
    1041

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

    I ran into the same issue with setting to output. I will post the c program I use when I get by the shop. It is really simple but will need to be added to your init program or run each time you power up.

    Ben

  17. #37
    Join Date
    May 2006
    Posts
    4047

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

    Hi jossa,

    You are correct. You can set the bit as an output in your Initialization C program then it will only execute once. Note that SetBitDirection starts with a capital 'S' C programs are case sensitive.

    SetBitDirection(29, 1); // Set bit 29 to be an output

    Regards
    TK
    http://dynomotion.com

  18. #38
    Join Date
    Dec 2013
    Posts
    159

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

    Is this done in InitStepDir3Axis.C since i use StepDir controlled steppers.?

    and how is everything tied together when i am finished?
    is the KMotionDef.h also uploaded since it is included? and how about the stepper info and Mcode assignments...


    i have seen the flash presentation in the help section, but i am not sure about it even after watching it..


    one more thing, after i have assigned an input as a home switch, what is required to make it work as a X axis home switch? is the assignment and definition done in C also?

  19. #39
    Join Date
    May 2006
    Posts
    4047

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

    Hi Jossa,

    Is this done in InitStepDir3Axis.C since i use StepDir controlled steppers.?
    Yes you would add the SetBitDirection() it to whatever initialization C program you have created. If using KSTEP that would usually be InitKStep3Axis.c not the one you specified.

    and how is everything tied together when i am finished?
    is the KMotionDef.h also uploaded since it is included? and how about the stepper info and Mcode assignments...

    i have seen the flash presentation in the help section, but i am not sure about it even after watching it..
    It would help if you understood the conceptual difference between KFLOP and the PC. Nothing is really uploaded to the PC. The C Programs and (Header files) reside on the PC. They don't need to be tied together or sent anywhere. Pushing buttons and running M Codes will be configured to run these programs and do things to KFLOP. The KMotionCNC configuration is automatically saved in the Data directory. There is nothing you really need to do other than back up all the files in case something happens to your PC (like it crashes or is stolen).

    one more thing, after i have assigned an input as a home switch, what is required to make it work as a X axis home switch? is the assignment and definition done in C also?
    Yes Homing is handled in KFLOP as a C Program so any method or input can be used. For standard Homing you don't need to write any C Code and just specify the Homing parameters for your system and call a standared function to Home. See

    SimpleHomeIndexFunctionTest.c

    Regards
    TK
    http://dynomotion.com

  20. #40
    Join Date
    Dec 2013
    Posts
    159

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

    Yes you would add the SetBitDirection() it to whatever initialization C program you have created. If using KSTEP that would usually be InitKStep3Axis.c not the one you specified.
    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?


    It would help if you understood the conceptual difference between KFLOP and the PC. Nothing is really uploaded to the PC. The C Programs and (Header files) reside on the PC. They don't need to be tied together or sent anywhere. Pushing buttons and running M Codes will be configured to run these programs and do things to KFLOP. The KMotionCNC configuration is automatically saved in the Data directory. There is nothing you really need to do other than back up all the files in case something happens to your PC (like it crashes or is stolen).
    yes it would, ... 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?




    Yes Homing is handled in KFLOP as a C Program so any method or input can be used. For standard Homing you don't need to write any C Code and just specify the Homing parameters for your system and call a standared function to Home. See

    SimpleHomeIndexFunctionTest.c

    could SimpleHomeIndexFunctionTest.c be used in normal operation?



    also, do you think this would work with KmotionCNC?
    https://littlemachineshop.com/produc...ory=1963256893

Page 2 of 6 1234

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
  •