Hello,
I cannot figure out how set the parameters in the C program. Now when i turn on the spindle i reach the max speed at S10000 but it should be at max speed at s18000. ( S is applied by this):
#include "KMotionDef.h"
#define MAX_RPM 18000.0f
// drive PWM 0 as spindle
// PWM 0 is Kstep IO #44 JP33
main()
{
int pwm;
float speed = *(float *)&persist.UserData[0]; // value stored is actually a float
pwm = speed/MAX_RPM * 255.0f;
if (pwm > 255) pwm=255; // limit to max pwm value
printf("Spindle Set to %f pwm %d\n",speed, pwm); // print the desired speed
FPGA(IO_PWMS+1) = 1; // enable the PWM
FPGA(IO_PWMS) = pwm; // set the PWM
}
Here is my setup...
Setup:
Kflop connected to Kstep
Connections:
+5Vdc from spindle control power supply to JP33 Pin5 (AnalogVcc) on the meter is 4.70V
JP33 Pin6 (AnalogOut) to spindle control analog input (expect 0-5V) on meter at max speed is 4.33V
Analog GND to CC gnd VDF
Test Program
CProgram:
{
FPGA(KAN_TRIG_REG) = 4;
SetBitDirection(44,1); \\set pwm output
FPGA(IO_PWMS_PRESCALE) = 46; \\ prescale
FPGA(IO_PWMS) = 128; \\wave
FPGA(IO_PWMS+1) = 1;
}
Can you explain me how i have to sets prescale and wave correctly? I alreay reed the example in Help/SchematicsKStep/UsingKStep.htm#analog but i don't understand how set the prescale as the correct value ? what's the math to arrive to 46 and the relation between 8.3V and the (46 prescale) and 1.4 Khz ? and the wave how i have to calculte what is the best?
What am I doing wrong?
The inveter is a Toshiba VF-nc3 the guide if you need is simply google Toshiba_VF-nC3_User_manual_(simplified).pdf becouse the pdf is to big to attach here.
Tnks for your Help!
Pwm Spindle calibration
Moderators: TomKerekes, dynomotion
Re: Pwm Spindle calibration
If you just want to correct the maximum speed, then simply change the 255s to whatever relates to your maximum speed.
If you want to measure and correct the speed over the speed range, then look at the KStepPWMCorrected.c example in the KStep folder.
If you want to measure and correct the speed over the speed range, then look at the KStepPWMCorrected.c example in the KStep folder.
- TomKerekes
- Posts: 2677
- Joined: Mon Dec 04, 2017 1:49 am
Re: Pwm Spindle calibration
Hi arg295,
You should set the prescale to 46 to have a reasonable PWM frequency for KStep's analog circuit. The math is:
16.67MHz / 256 / (46 + 1) = 1.385KHz
If the pre-scale is not set the PWM frequency will be set too high for KSteps circuit.
Note because you are using persits variable 0 (persist.UserData[0]) KMotionCNC must be configured to use Var 0 for the S Action.
The KStep Analog output works much like a potentiometer where it can adjust between 0 - 100% of the supply voltage applied to it. So I don't understand why you refer to 8.7V when only 4.7V is being supplied?
You might use the test program to set PWM settings of 0, 64, 128, 192, 255 which correspond to 0%, 25%, 50%, 75%, 100% and record the RPM that you have in each case in order to determine the relationship and what your Spindle is capable of.
You should set the prescale to 46 to have a reasonable PWM frequency for KStep's analog circuit. The math is:
16.67MHz / 256 / (46 + 1) = 1.385KHz
If the pre-scale is not set the PWM frequency will be set too high for KSteps circuit.
Note because you are using persits variable 0 (persist.UserData[0]) KMotionCNC must be configured to use Var 0 for the S Action.
The KStep Analog output works much like a potentiometer where it can adjust between 0 - 100% of the supply voltage applied to it. So I don't understand why you refer to 8.7V when only 4.7V is being supplied?
I don't understand what you are saying here.Now when i turn on the spindle i reach the max speed at S10000 but it should be at max speed at s18000
You might use the test program to set PWM settings of 0, 64, 128, 192, 255 which correspond to 0%, 25%, 50%, 75%, 100% and record the RPM that you have in each case in order to determine the relationship and what your Spindle is capable of.
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.