totally overwhelmed! start over info
Moderators: TomKerekes, dynomotion
totally overwhelmed! start over info
after hours of trying to get anything going i have the thought of starting fresh with some questions
i have no idea where to start but need to get my head straight ......
1 i save my servo .c file on desktop and have my user button set to this
i do this to separate it from the rest for my sanity.
is this bad and it must be in the in the C programs section of kmotion? or is it fine?
2 i am very confused on the kflop config and downloading thing.
if i have a .c file i made on the desktop and a user button to it, will it run that or does it need to be downloaded to kflop first or every time
edited???
3 if i download a bunch of dead and nonfunctional C programs will they stack up and conflict new more productive programs when downloaded?
i feel like there is a ton of stuff happening behind the curtain if you know what i mean
4 how do i know what all is downloaded on the kflop?
5 i think there used to be a youtube video on the process of downloading and such?
i have no idea where to start but need to get my head straight ......
1 i save my servo .c file on desktop and have my user button set to this
i do this to separate it from the rest for my sanity.
is this bad and it must be in the in the C programs section of kmotion? or is it fine?
2 i am very confused on the kflop config and downloading thing.
if i have a .c file i made on the desktop and a user button to it, will it run that or does it need to be downloaded to kflop first or every time
edited???
3 if i download a bunch of dead and nonfunctional C programs will they stack up and conflict new more productive programs when downloaded?
i feel like there is a ton of stuff happening behind the curtain if you know what i mean
4 how do i know what all is downloaded on the kflop?
5 i think there used to be a youtube video on the process of downloading and such?
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: totally overwhelmed! start over info
Hi turbothis,
However running a bad/buggy/unknown C Program can modify or corrupt KFLOP in an indeterminate manner. If you suspect you have modified or corrupted KFLOP then re-boot KFLOP to assure it is in a virgin default state.
It is fine.1 i save my servo .c file on desktop and have my user button set to this
i do this to separate it from the rest for my sanity.
is this bad and it must be in the in the C programs section of kmotion? or is it fine?
Pushing the User Button will compile the program, download the program to the specified Thread (killing and overwriting any previous program in that Thread), and execute the Program.if i have a .c file i made on the desktop and a user button to it, will it run that or does it need to be downloaded to kflop first or every time
edited???
No Programs don't "stack up". Each Thread Space can hold one Program at a time. Downloading a Program to a Thread will completely overwrite any previous program.3 if i download a bunch of dead and nonfunctional C programs will they stack up and conflict new more productive programs when downloaded?
i feel like there is a ton of stuff happening behind the curtain if you know what i mean
However running a bad/buggy/unknown C Program can modify or corrupt KFLOP in an indeterminate manner. If you suspect you have modified or corrupted KFLOP then re-boot KFLOP to assure it is in a virgin default state.
You must keep track of what you are doing. Re-boot KFLOP to assure it is in a virgin default state. We do not recommend flashing configuration or Programs to KFLOP. If you have done this KFLOP can be set back to its default state by re-Flashing "New Version".4 how do i know what all is downloaded on the kflop?
You might see this article.5 i think there used to be a youtube video on the process of downloading and such?
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: totally overwhelmed! start over info
great
thanks
so i run the phase find and get some info on the A axis servo
2048 encoder 6 pole motor
should be 0.000366 right?
REPORT
------
0 Position = 8192 PhaseAngle = 3.520000
1 Position = 16384 PhaseAngle = 6.518000
2 Position = 16384 PhaseAngle = 6.404000
3 Position = 0 PhaseAngle = 0.382000
Counts per rev = 8192
Counts per cycle = 2732
Counts per cycle (rounded to 16)= 2736
invDistPerCycle (rounded)= 0.000365497076
Commutation offset = 1945
Input Gain Specified = -1.000
REPORT
------
0 Position = -2 PhaseAngle = 0.492000
1 Position = 8191 PhaseAngle = 3.519000
2 Position = 8191 PhaseAngle = 3.404000
3 Position = -1 PhaseAngle = 0.380000
Counts per rev = 8193
Counts per cycle = 2707
Counts per cycle (rounded to 16)= 2704
invDistPerCycle (rounded)= 0.000369822485
Commutation offset = 1924
Input Gain Specified = -1.000
REPORT
------
0 Position = 0 PhaseAngle = 0.491000
1 Position = 8192 PhaseAngle = 3.519000
2 Position = 8192 PhaseAngle = 3.404000
3 Position = -8192 PhaseAngle = -2.615000
Counts per rev = 8192
Counts per cycle = 2705
Counts per cycle (rounded to 16)= 2704
invDistPerCycle (rounded)= 0.000369822485
Commutation offset = 1924
Input Gain Specified = -1.000
REPORT
------
0 Position = 8192 PhaseAngle = 3.518000
1 Position = 16384 PhaseAngle = 6.519000
2 Position = 0 PhaseAngle = 0.382000
3 Position = -8192 PhaseAngle = -2.613000
Counts per rev = 8192
Counts per cycle = 2730
Counts per cycle (rounded to 16)= 2736
invDistPerCycle (rounded)= 0.000365497076
Commutation offset = 1917
Input Gain Specified = -1.000
REPORT
------
0 Position = 8192 PhaseAngle = 3.518000
1 Position = 16384 PhaseAngle = 6.519000
2 Position = 16384 PhaseAngle = 6.405000
3 Position = -1 PhaseAngle = 0.381000
Counts per rev = 8192
Counts per cycle = 2730
Counts per cycle (rounded to 16)= 2736
invDistPerCycle (rounded)= 0.000365497076
Commutation offset = 1948
Input Gain Specified = -1.000
i do not know why but i cant get a Z index to work on any bits but 36
40, 44 and 48 should be Z+ right? followed by Z-
thanks
so i run the phase find and get some info on the A axis servo
2048 encoder 6 pole motor
should be 0.000366 right?
REPORT
------
0 Position = 8192 PhaseAngle = 3.520000
1 Position = 16384 PhaseAngle = 6.518000
2 Position = 16384 PhaseAngle = 6.404000
3 Position = 0 PhaseAngle = 0.382000
Counts per rev = 8192
Counts per cycle = 2732
Counts per cycle (rounded to 16)= 2736
invDistPerCycle (rounded)= 0.000365497076
Commutation offset = 1945
Input Gain Specified = -1.000
REPORT
------
0 Position = -2 PhaseAngle = 0.492000
1 Position = 8191 PhaseAngle = 3.519000
2 Position = 8191 PhaseAngle = 3.404000
3 Position = -1 PhaseAngle = 0.380000
Counts per rev = 8193
Counts per cycle = 2707
Counts per cycle (rounded to 16)= 2704
invDistPerCycle (rounded)= 0.000369822485
Commutation offset = 1924
Input Gain Specified = -1.000
REPORT
------
0 Position = 0 PhaseAngle = 0.491000
1 Position = 8192 PhaseAngle = 3.519000
2 Position = 8192 PhaseAngle = 3.404000
3 Position = -8192 PhaseAngle = -2.615000
Counts per rev = 8192
Counts per cycle = 2705
Counts per cycle (rounded to 16)= 2704
invDistPerCycle (rounded)= 0.000369822485
Commutation offset = 1924
Input Gain Specified = -1.000
REPORT
------
0 Position = 8192 PhaseAngle = 3.518000
1 Position = 16384 PhaseAngle = 6.519000
2 Position = 0 PhaseAngle = 0.382000
3 Position = -8192 PhaseAngle = -2.613000
Counts per rev = 8192
Counts per cycle = 2730
Counts per cycle (rounded to 16)= 2736
invDistPerCycle (rounded)= 0.000365497076
Commutation offset = 1917
Input Gain Specified = -1.000
REPORT
------
0 Position = 8192 PhaseAngle = 3.518000
1 Position = 16384 PhaseAngle = 6.519000
2 Position = 16384 PhaseAngle = 6.405000
3 Position = -1 PhaseAngle = 0.381000
Counts per rev = 8192
Counts per cycle = 2730
Counts per cycle (rounded to 16)= 2736
invDistPerCycle (rounded)= 0.000365497076
Commutation offset = 1948
Input Gain Specified = -1.000
Code: Select all
#include "KMotionDef.h"
// Drive a 3 Phase motor that has a Z index by
// 3 phase driving the coils (like a stepping motor)
// two revs each direction (two z pulses)
// monitor how many counts/cycle and counts/rev
// (including direction)and also determine the commutation
// offset by recording the phase angle at the index
// (which will be where zero is set) and offsetting by 1/4 of a cycle
//
// Set the following parameters according to your situation
// See the report generated on the Console Screen
#define DAC_CHAN 0 // which pair of PWM channels used
#define ENCODER_CHAN 1 // which encoder we are connected to
#define ENCODER_GAIN -1 // Set to -1 if desired to reverse axis direction
#define AMPLITUDE 100 // Set how hard to drive the coils pwm counts
#define Z_BIT_NUMBER 36 // What bit the Z index is connected to
#define AXIS_CHAN 0 // Axis channel to be used and configured
#define Ncycles 4 // don't change this
// x must be in the range 0->1 returns sin(x) and sin(x+120 degrees)
float Sine3PH (float x, float *sin2);
// put a voltage v on a 3 Phase motor at specified commutation angle
void Write3PH_DACs(CHAN *ch0, float v, double angle_in_cycles);
// return fractional part of a huge number accurately
float fractionf(double v);
void main()
{
float mid,k=0,dk=0.2,A=AMPLITUDE; // set coil current amplitude
int i,ignore=300,kpos[Ncycles],zmark,m=0;
double cnts_per_cycle,p0[Ncycles];
CHAN *ch = &chan[AXIS_CHAN];
// rotate until we find the index mark
ch->Enable=FALSE;
ch->InputMode=ENCODER_MODE;
ch->InputChan0=ENCODER_CHAN;
ch->OutputChan0=DAC_CHAN;
ch->OutputChan1=DAC_CHAN+1;
ch->OutputMode=NO_OUTPUT_MODE;
ch->InputGain0=ENCODER_GAIN;
for (;;)
{
WaitNextTimeSlice();
k+= dk;
Write3PH_DACs(ch,A, k/1000.0); // move the pole
zmark = ReadBit(Z_BIT_NUMBER);
if (!zmark && ignore>0) ignore--;
if (ignore==0 && zmark) // check for index mark
{
p0[m]=ch->Position; // save position
kpos[m]=k; // save phase angle
if (++m == Ncycles)
{
ch->Position=0; // set current position to Zero
break;
}
if (m==2) dk = -dk;
ignore=300;
}
}
Write3PH_DACs(ch,0,0); // turn off the coil
printf("\nREPORT\n------\n");
for (i=0; i<Ncycles; i++)
printf("%d Position = %6.0f PhaseAngle = %f\n",i,p0[i],kpos[i]/1000.0);
printf("Counts per rev = %6.0f\n",p0[1]-p0[0]);
cnts_per_cycle = (p0[1]-p0[0])/(kpos[1]-kpos[0])*1000.0;
printf("Counts per cycle = %6.0f\n",cnts_per_cycle);
// round to 16
if (cnts_per_cycle>0)
cnts_per_cycle = ((int)(cnts_per_cycle/16.0 + 0.5))*16.0;
else
cnts_per_cycle = ((int)(cnts_per_cycle/16.0 - 0.5))*16.0;
printf("Counts per cycle (rounded to 16)= %6.0f\n",cnts_per_cycle);
ch->invDistPerCycle = 1.0/cnts_per_cycle;
printf("invDistPerCycle (rounded)= %15.12f\n",ch->invDistPerCycle);
mid = (kpos[2]+kpos[1])/2000.0;
mid = mid - (int)mid;
ch->CommutationOffset = mid*cnts_per_cycle + 0.25*fast_fabs(cnts_per_cycle);
printf("Commutation offset = %6.0f\n",ch->CommutationOffset);
printf("Input Gain Specified = %6.3f\n",ch->InputGain0);
}
// put a voltage v on a 3 Phase motor at specified commutation angle
void Write3PH_DACs(CHAN *ch, float v, double angle_in_cycles)
{
float theta,sin1f;
if (angle_in_cycles<0)
theta = 1.0f-fractionf(-angle_in_cycles);
else
theta = fractionf(angle_in_cycles);
DAC(ch->OutputChan0, (int)(v * Sine3PH(theta,&sin1f)));
DAC(ch->OutputChan1, (int)(v * sin1f));
}
i do not know why but i cant get a Z index to work on any bits but 36
40, 44 and 48 should be Z+ right? followed by Z-
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: totally overwhelmed! start over info
Hi turbothis,
3 / (2048 x 4) = 0.0003662109375
Its important to enter the exact number otherwise after many many revolutions the commutation will drift off.
The exact number would be:so i run the phase find and get some info on the A axis servo
2048 encoder 6 pole motor
should be 0.000366 right?
3 / (2048 x 4) = 0.0003662109375
Its important to enter the exact number otherwise after many many revolutions the commutation will drift off.
I don't understand what you are doing or asking.i do not know why but i cant get a Z index to work on any bits but 36
40, 44 and 48 should be Z+ right? followed by Z-
nan = "not a number" which is caused by a division by zero. Earlier we asked you to not set any Axis resolution to 0 count/inch. It appears you failed to this.not sure what the "-nan (ind)" means
Selecting Lathe mode in the Tool Setup - Trajectory Planner should only be used with the Basic Lathe 2 Axis Main Dialog Face. For your special (3 Axis XZA?) Lathe configuration you will need to create a custom Screen with the Screen Editor.i have my X axis code working fine in basic lathe 2 axis mode. when i switch to the basic 4 axis mode (so i can have A axis spindle) now the Z buttons run the X axis motor and read out.
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: totally overwhelmed! start over info
i have all the axis parameters set and still get the "nan"
all the Z index encoder inputs for the axis are bit 36, 40, 44, and 48 right?
i can only get bit 36 to read a Z index pulse
thanks
all the Z index encoder inputs for the axis are bit 36, 40, 44, and 48 right?
i can only get bit 36 to read a Z index pulse
thanks
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: totally overwhelmed! start over info
Hi turbothis,
Please post a screen shot of your KMotionCNC | Tool Setup | Trajectory Planner settings so we can check them for you.i have all the axis parameters set and still get the "nan"
There aren't any dedicated Z index inputs. Any KFLOP input can be used as long as it is interfaced and configured properly. You would need to inform us input you are using. Please put more effort into your questions. Normally for differential encoder Z signals they can be connected to the 8 differential inputs on Kanalog JP2 which normally map to KFLOP IO36-43 respectively. It isn't clear why you are incrementing by 4.all the Z index encoder inputs for the axis are bit 36, 40, 44, and 48 right?
i can only get bit 36 to read a Z index pulse
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: totally overwhelmed! start over info
this is the code i am testing and cant get a Z index on bit 40?
if i change it to bit 36 and wire the Z to this then it works
Code: Select all
#include "KMotionDef.h"
// Home and set the commutation for a 3 phase brushless motor
// that is driven using two DAC Outputs
//
// Phase rotates until index mark is located and Encoder Zeroed
// Function definitions
// x must be in the range 0->1 returns sin(x) and sin(x+120 degrees)
float Sine3PH (float x, float *sin2);
// put a voltage v on a 3 Phase motor at specified commutation angle
void Write3PH_DACs(CHAN *ch2, float v, double angle_in_cycles);
// return fractional part of a huge number accurately
float fractionf(double v);
void main()
{
float k=0,A=200; // set coil current amplitude DAC units
double p0;
// define the axis as 3 phase BRUSHLESS_3PH_MODE
ch2->InputMode=ENCODER_MODE;
ch2->OutputMode=NO_OUTPUT_MODE;
ch2->Vel=500;
ch2->Accel=50000;
ch2->Jerk=300000;
ch2->P=1;
ch2->I=0;
ch2->D=0;
ch2->FFAccel=0;
ch2->FFVel=0;
ch2->MaxI=200;
ch2->MaxErr=1e+006;
ch2->MaxOutput=500;
ch2->DeadBandGain=1;
ch2->DeadBandRange=0;
ch2->InputChan0=2;
ch2->InputChan1=2;
ch2->OutputChan0=0;
ch2->OutputChan1=1;
ch2->MasterAxis=-1;
ch2->LimitSwitchOptions=0x0;
ch2->SoftLimitPos=1e+030;
ch2->SoftLimitNeg=-1e+030;
ch2->InputGain0=-1;
ch2->InputGain1=1;
ch2->InputOffset0=0;
ch2->InputOffset1=0;
ch2->OutputGain=1;
ch2->OutputOffset=0;
ch2->SlaveGain=1;
ch2->BacklashMode=BACKLASH_OFF;
ch2->BacklashAmount=0;
ch2->BacklashRate=0;
ch2->invDistPerCycle=0.0003662109375;
ch2->Lead=0;
ch2->MaxFollowingError=1000000;
ch2->StepperAmplitude=20;
ch2->iir[0].B0=1;
ch2->iir[0].B1=0;
ch2->iir[0].B2=0;
ch2->iir[0].A1=0;
ch2->iir[0].A2=0;
ch2->iir[1].B0=1;
ch2->iir[1].B1=0;
ch2->iir[1].B2=0;
ch2->iir[1].A1=0;
ch2->iir[1].A2=0;
ch2->iir[2].B0=1;
ch2->iir[2].B1=0;
ch2->iir[2].B2=0;
ch2->iir[2].A1=0;
ch2->iir[2].A2=0;
// rotate until we find the index mark
ch2->Enable=FALSE;
for (;;)
{
WaitNextTimeSlice();
Write3PH_DACs(ch2,A, ++k/1000.0); // move the pole
if (ReadBit(40)) // check for index mark
{
p0=ch2->Position; // save position
ch2->Position=0; // set current position to Zero
ch2->CommutationOffset = 1920; // from auto phase find
printf("Position = %f\n",p0);
break;
}
}
EnableAxisDest(2,0.0f); // Enable servo at destination of 0
DefineCoordSystem(0,-1,1,2); // define which axes are in use
// Loop forever outputting Servo output to dual DAC_SERVO_MODE
for (;;)
{
CHAN *ch=ch2;
if (ch->Enable) // if axis enabled commutate and output else command zero to DACs
Write3PH_DACs(ch, ch->Output, (ch->Position + ch->CommutationOffset) * ch->invDistPerCycle);
else
Write3PH_DACs(ch, 0.0, 0.0);
}
}
// put a voltage v on a 3 Phase motor at specified commutation angle
void Write3PH_DACs(CHAN *ch, float v, double angle_in_cycles)
{
float theta,sin1f;
if (angle_in_cycles<0)
theta = 1.0f-fractionf(-angle_in_cycles);
else
theta = fractionf(angle_in_cycles);
DAC(ch->OutputChan0, (int)(v * Sine3PH(theta,&sin1f)));
DAC(ch->OutputChan1, (int)(v * sin1f));
}