Spindle Interface II
Moderators: TomKerekes, dynomotion
Re: Spindle Interface II
Hi Tom,
I set up channel 6 as a DAC output with the same settings in the example. That didn't work so I used channel 7 thinking that might make a difference. I set the S command in KmotionCNC to DAC with the settings in the example. See attachment 1. I followed the "Setup Gcode 4 Axis PWM SignMag.c" example but used bit 40 for CW and 41 for CCW in the init file. See attached init file.
I used the "SpindleOnCWJogV2.c" and the other 3 files for CCW, Jog and Off and modified the CW and CCW bits and SPINDLEAXIS. See attached modified SpindleOnCWJogV2.c.
I know that I will have to calibrate the output voltage to get the correct RPM's and I will have to get my C41S working with Kflop but I wanted to first get the PWM signal on pin 5 on JP6 to operate. I have had a PWM waveform along the way but couldn't vary the Pulse or shut it off without disabling the axis or running the init file again.
I removed the Spindle Axis from DefineCoordSystem6 as you recommended earlier.
When I press the ON CW nothing happens, i.e., there are no counts/sec on the console and my oscilloscope is flat lined. On the Console I can see that the program ran but the "Jogging Spindle" comes up as zeros. If I press the Off buttom I can see that program also ran. If I print speed alone without FACTOR it also comes up as zero. I tried Jog7=.25 with no luck. See attachment 2.
I'm sure I have overlooked something very obvious but have not been able to figure it out.
Jack
I set up channel 6 as a DAC output with the same settings in the example. That didn't work so I used channel 7 thinking that might make a difference. I set the S command in KmotionCNC to DAC with the settings in the example. See attachment 1. I followed the "Setup Gcode 4 Axis PWM SignMag.c" example but used bit 40 for CW and 41 for CCW in the init file. See attached init file.
I used the "SpindleOnCWJogV2.c" and the other 3 files for CCW, Jog and Off and modified the CW and CCW bits and SPINDLEAXIS. See attached modified SpindleOnCWJogV2.c.
I know that I will have to calibrate the output voltage to get the correct RPM's and I will have to get my C41S working with Kflop but I wanted to first get the PWM signal on pin 5 on JP6 to operate. I have had a PWM waveform along the way but couldn't vary the Pulse or shut it off without disabling the axis or running the init file again.
I removed the Spindle Axis from DefineCoordSystem6 as you recommended earlier.
When I press the ON CW nothing happens, i.e., there are no counts/sec on the console and my oscilloscope is flat lined. On the Console I can see that the program ran but the "Jogging Spindle" comes up as zeros. If I press the Off buttom I can see that program also ran. If I print speed alone without FACTOR it also comes up as zero. I tried Jog7=.25 with no luck. See attachment 2.
I'm sure I have overlooked something very obvious but have not been able to figure it out.
Jack
- Attachments
-
- SpindleOnCWJogV2.c
- (1.13 KiB) Downloaded 509 times
-
- Attachment 2.JPG (10.52 KiB) Viewed 12300 times
-
- Init File 071024.c
- (11.48 KiB) Downloaded 505 times
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: Spindle Interface II
Hi Jack,
Sorry I should have been more clear. Your Spindle requires a PWM signal not a DAC signal so outputting to a DAC would do nothing.
Change the S Action back to running a C Program (SpindleMillJogV2.c) and passing the Speed to it.
Change the Axis Configuration to have Velocity Feed Forward. This will cause the Axis Output to be proportional to the Jog Speed. Such as this:
Note: doing Move commands on the Step Response Screen should then cause the Spindle to move. Or Jogging the Axis from the Console Screen should set a Spindle speed.
So the overall process is:
1 - the S Command sends the Speed Command to the C Program
2 - the M3 command Jogs the Axis to the specified Speed
3 - the Axis's VFF drives the Output proportional to the current speed
4 - the Init C Program forever loop outputs the Axis's Output to the PWM
Note the idea behind using an Axis in this manner is it provides a method of gradually Accelerating (and Jerk) the Spindle to speed rather than just commanding the PWM value instantly.
HTH
Sorry I should have been more clear. Your Spindle requires a PWM signal not a DAC signal so outputting to a DAC would do nothing.
Change the S Action back to running a C Program (SpindleMillJogV2.c) and passing the Speed to it.
Change the Axis Configuration to have Velocity Feed Forward. This will cause the Axis Output to be proportional to the Jog Speed. Such as this:
Note: doing Move commands on the Step Response Screen should then cause the Spindle to move. Or Jogging the Axis from the Console Screen should set a Spindle speed.
So the overall process is:
1 - the S Command sends the Speed Command to the C Program
2 - the M3 command Jogs the Axis to the specified Speed
3 - the Axis's VFF drives the Output proportional to the current speed
4 - the Init C Program forever loop outputs the Axis's Output to the PWM
Note the idea behind using an Axis in this manner is it provides a method of gradually Accelerating (and Jerk) the Spindle to speed rather than just commanding the PWM value instantly.
HTH
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: Spindle Interface II
Hi Tom,
Appears that I'm making baby steps. I changed the S back to Execute Prog to run the mill jog program. All 4 programs are set the Var 1. Is that correct? See attachment 1.
I changed the init program back to channel 6 and did the Step Response as shown in your example. See attachment 2.
AIso changed the 4 spindle jog programs to channel 6.
When I use an M3S300 command I can read the speed on the console and I can see a waveform on my oscilloscope. However, the DRO for the forward speed begins to count up. If I enter an M3S12000 command the speed on the console screen changes, the DRO for forward speed continues to count up but the waveform doesn't change. If I move the Spindle slider up and down the speed on the console changes. Using a Jog6=0.25 prints out on the console but no change to the waveform. When I press the Off button next to the Spindle Slider the Console Screen shows Jogging Spindle Stop, the forward speed DRO begins to count down and will go to zero and stop, but the PWM waveform does not change. The Jog command doesn't seem to be working. See attached picture of my oscilloscope screen, 1 Volt/Div, 10 MicroSec/Div. attachment 3.
In my init file there is a variable DIR_BIT0 that I define as 40 (my direction bit) but there is an additional dir_bit variable. Both get used in:
OutputSignMag(6,0,DIR_BIT0); which calls
void OutputSignMag(int ch, int pwm, int dir_bit)
Could this be the problem? I put a print statement after the void line:
void OutputSignMag(int ch, int pwm, int dir_bit)
{
printf("Jogging Spindle %f counts/sec\n",dir_bit);
if (chan[ch].Enable)
I would expect to see a flood of lines printing out on the console because of the forever loop but nothing prints. It's like the function doesn't get called.
Appears that I'm making baby steps. I changed the S back to Execute Prog to run the mill jog program. All 4 programs are set the Var 1. Is that correct? See attachment 1.
I changed the init program back to channel 6 and did the Step Response as shown in your example. See attachment 2.
AIso changed the 4 spindle jog programs to channel 6.
When I use an M3S300 command I can read the speed on the console and I can see a waveform on my oscilloscope. However, the DRO for the forward speed begins to count up. If I enter an M3S12000 command the speed on the console screen changes, the DRO for forward speed continues to count up but the waveform doesn't change. If I move the Spindle slider up and down the speed on the console changes. Using a Jog6=0.25 prints out on the console but no change to the waveform. When I press the Off button next to the Spindle Slider the Console Screen shows Jogging Spindle Stop, the forward speed DRO begins to count down and will go to zero and stop, but the PWM waveform does not change. The Jog command doesn't seem to be working. See attached picture of my oscilloscope screen, 1 Volt/Div, 10 MicroSec/Div. attachment 3.
In my init file there is a variable DIR_BIT0 that I define as 40 (my direction bit) but there is an additional dir_bit variable. Both get used in:
OutputSignMag(6,0,DIR_BIT0); which calls
void OutputSignMag(int ch, int pwm, int dir_bit)
Could this be the problem? I put a print statement after the void line:
void OutputSignMag(int ch, int pwm, int dir_bit)
{
printf("Jogging Spindle %f counts/sec\n",dir_bit);
if (chan[ch].Enable)
I would expect to see a flood of lines printing out on the console because of the forever loop but nothing prints. It's like the function doesn't get called.
- Attachments
-
- Init File 071224.c
- (11.49 KiB) Downloaded 508 times
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: Spindle Interface II
Hi Jack,
Because the Feedrate changes when the Spindle Axis is Jogged that would indicate that axis 6 is still included in the Coordinate System. The Init program you posted does not include it. Also the printf added to the function not printing would indicate somehow you are not running the program you think you are. As a sanity check you might add a printf("Hello\n); at the beginning to see if that prints.
I do see a break if EStop is detected. That would terminate the loop. But it would also disable the axes so I don't think that is occurring. The Axes are enabled on the Axis Screen aren't they? There should also be a Green bar on Thread #1 on the C Programs Screen indicating the Init Program is continuously running.
It seems we are using PWM#0. Each PWM has 2 addresses: a PWM Value and an Enable. So to enable PWM#0 this should be used:
not this:
This printf has an error. It prints an integer using a floating point format. That will print garbage. But I would expect something to print. Note if you right click Validate you will be given a warning on such errors. Change:
to:
yesAll 4 programs are set the Var 1. Is that correct? See attachment 1.
Because the Feedrate changes when the Spindle Axis is Jogged that would indicate that axis 6 is still included in the Coordinate System. The Init program you posted does not include it. Also the printf added to the function not printing would indicate somehow you are not running the program you think you are. As a sanity check you might add a printf("Hello\n); at the beginning to see if that prints.
I do see a break if EStop is detected. That would terminate the loop. But it would also disable the axes so I don't think that is occurring. The Axes are enabled on the Axis Screen aren't they? There should also be a Green bar on Thread #1 on the C Programs Screen indicating the Init Program is continuously running.
It seems we are using PWM#0. Each PWM has 2 addresses: a PWM Value and an Enable. So to enable PWM#0 this should be used:
Code: Select all
FPGA(IO_PWMS + 1) = 1; // enable the PWM
Code: Select all
FPGA(IO_PWMS + 6) = 1; // enable the PWM
Code: Select all
printf("Jogging Spindle %f counts/sec\n",dir_bit);
Code: Select all
printf("Jogging Spindle %d counts/sec\n",dir_bit);
No that just the way functions (subroutines) work. dir_bit is assigned to DIR_BIT0 (which is 40) when the function is called.In my init file there is a variable DIR_BIT0 that I define as 40 (my direction bit) but there is an additional dir_bit variable. Both get used in:
OutputSignMag(6,0,DIR_BIT0); which calls
void OutputSignMag(int ch, int pwm, int dir_bit)
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: Spindle Interface II
Hi Tom,
Sorry to keep being a pain.
Now the print statement prints tons of meaningless lines so I know the function is work. I removed the print statement.
This made a big difference: FPGA(IO_PWMS + 1) = 1;
I connected the C41S and I can get 10 volts out but only 10 volts out. No matter what speed I run or what FACTOR I use. My scope shows a change in state from Off (zero volts) to On (a little over 3 volts but I can't sync the pulse stream to show the wave form). It appears like its on 100% or my 30 year old scope can't go that fast.
An M3 command with various speeds changes the DRO for the spindle set point. The console is showing the changes in speed as well but no change in voltage out of the C41S.
Running the Spindle Slider up and down shows the changes on the console but does not change the set point DRO or the voltage on the C41S.
Attached is the current init file.
Jack
Sorry to keep being a pain.
How embarrassing.somehow you are not running the program you think you are
Now the print statement prints tons of meaningless lines so I know the function is work. I removed the print statement.
This made a big difference: FPGA(IO_PWMS + 1) = 1;
I connected the C41S and I can get 10 volts out but only 10 volts out. No matter what speed I run or what FACTOR I use. My scope shows a change in state from Off (zero volts) to On (a little over 3 volts but I can't sync the pulse stream to show the wave form). It appears like its on 100% or my 30 year old scope can't go that fast.
An M3 command with various speeds changes the DRO for the spindle set point. The console is showing the changes in speed as well but no change in voltage out of the C41S.
Running the Spindle Slider up and down shows the changes on the console but does not change the set point DRO or the voltage on the C41S.
Attached is the current init file.
Jack
- Attachments
-
- Init File 071324.c
- (11.45 KiB) Downloaded 504 times
Re: Spindle Interface II
Hi Tom,
One other thing, if I reduce the MAXPWM the voltage also reduces but still will not vary with different speed inputs.
One other thing, if I reduce the MAXPWM the voltage also reduces but still will not vary with different speed inputs.
Re: Spindle Interface II
Hi Tom,
I think I found something. if I use the Jog command on the console I can vary the voltage.
Jog6=.1 0 volts
Jog6=.2 .24 V
Jog6=.4 .29 V
Jog6=.6 .44 V
Jog6=.8 2.71 V
Jog6=1 9.91 V
Not very linear and looks like I need a pretty small FACTOR. Using .0001 as the FACTOR I can now duplicate the Jog6 numbers using the M3S commands.
Any suggestions on how to fix the non linearity? Do you think my C41S has a problem? The specs say 200 Hz Recommended PWM input frequency. I think the Kflop is significantly faster. Do you think that could be the problem?
I think I found something. if I use the Jog command on the console I can vary the voltage.
Jog6=.1 0 volts
Jog6=.2 .24 V
Jog6=.4 .29 V
Jog6=.6 .44 V
Jog6=.8 2.71 V
Jog6=1 9.91 V
Not very linear and looks like I need a pretty small FACTOR. Using .0001 as the FACTOR I can now duplicate the Jog6 numbers using the M3S commands.
Any suggestions on how to fix the non linearity? Do you think my C41S has a problem? The specs say 200 Hz Recommended PWM input frequency. I think the Kflop is significantly faster. Do you think that could be the problem?
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: Spindle Interface II
Hi Jack,
Change
FPGA(IO_PWMS_PRESCALE) = 1; // set pwm period to 30 KHz
To
FPGA(IO_PWMS_PRESCALE) = 255; // set pwm period to 254Hz
To reduce the frequency to the minimum
Change
FPGA(IO_PWMS_PRESCALE) = 1; // set pwm period to 30 KHz
To
FPGA(IO_PWMS_PRESCALE) = 255; // set pwm period to 254Hz
To reduce the frequency to the minimum
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: Spindle Interface II
Hi Tom,
That was it (insert fireworks here)
Changing the frequency and changing the FACTOR to .0000442 gave me almost perfect linear voltage (or close enough for making sawdust) on my 24,000 RPM spindle.
2.47V at 6000
5.0V at 12000
7.70 at 18000
10.00 at 24000
Thank you so much. You have the patience of a saint.
Jack
That was it (insert fireworks here)
Changing the frequency and changing the FACTOR to .0000442 gave me almost perfect linear voltage (or close enough for making sawdust) on my 24,000 RPM spindle.
2.47V at 6000
5.0V at 12000
7.70 at 18000
10.00 at 24000
Thank you so much. You have the patience of a saint.
Jack
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am