I have a new project with a small router using KFlop with KStep. I have got the axes configured and working but need help getting the spindle working using a VFD.
Have been through the KStep/KFlop help but the setup instructions seem patchy to me. Is there any step by step instructions that I can use tat shows exactly what code I need and where?
I am using a Sunfar E300 series VFD that takes an analog input from 0 to 10V to control speed (0 to 60,000rpm) and a direction digital pin (that possibly needs a relay).
Following though the "Using KStep" document, I am unsure which C file I should be writing the PWM configuration code too:
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
I have set up channel 7 to use no input and DAC Servo output (using the template provided). However, I haven't been able to save this channel in my INT C program file like the other 4 channels I have used for the 4 axis. At this point I am not getting any signal from IO 44 from KStep.
That code would be included in the C program that you use to initialize your system. That way when you initialize your system the PWM will be also initialized and configured.
You don't need an Axis Channel to write to the PWM and the PWM is not a Kanalog DAC so you can not use DAC Servo Output mode.
Instead configure the example provided in the previous email for the S Action in KMotionCNC Tool Setup. In this way when speed is changed in KMotionCNC the program will be invoked and the speed will be written to the PWM and the KStep Analog Output should change.
I still aren't having any luck. I have set the S Action to execute ...\KMotionCNC\Spindle_S_Kstep.c and I have written those 4 lines of code previously mentioned in my INIT file. But when I run some G-code there is no signal sent to my VFD.
I was expecting you to post your modified Spindle_S_Kstep.c. But if you haven't modified it then as I stated in the last email it by default expects the Speed an Var #1. The idea is that KMotionCNC and the C Program must match and use the same variable for communication. If you read the Spindle_S_Kstep.c Program there is a comment:
// desired speed is passed in variable 1
Here is the line of code that reads Var #1:
float speed = *(float *)&persist.UserData; // value stored is actually a float
I have checked and the variables do match (both KMotionCNC and Splindle_S_KStep are set to 1). I have also checked for a signal coming out of pin 5 I/O44 on JP7 which appears to simply have 3.3V.
Do I also need to set JP6 pin 5 to out PWM or is that taken care of?
I have attached my Spindle_S_Kstep.c. I have set the variable to 1 (on both KMotionCNC and Splindle_S_KStep), should they be set to something else?
The max RPM_FACTOR is set at 500 RPM. What S RPM are you commanding? 500 or more would always set the PWM to 100% duty cycle which may be why you seethe output always 3.3V. Try S250 to get a 50% duty cycle.
No you do not have to configure JP6 pin 5 as you are not using it.
How is your Analog signal wired? Do you realize you must supply a voltage on AnalogVcc and AnalogGnd?