Setting S in Tool Setup

Moderators: TomKerekes, dynomotion

User avatar
TomKerekes
Posts: 2676
Joined: Mon Dec 04, 2017 1:49 am

Re: Setting S in Tool Setup

Post by TomKerekes » Wed May 29, 2019 4:54 pm

Hi Bill,
Do I need to change anything in the init file when I switch these jumpers? In Kmotion (alone), do I need to init the kflop by running my init code first, or do I just run the PWM c code alone and check for voltage change?
I don't think anything needs to be changed in the Init file.

I like to keep things simple and test one thing at a time. So for this test all you might need is the PWM signal. You might need the part of the Init file that starts up the other PWM for the charge pump.
Would re-setting these jumpers to 2-3 put me in a mode where I can only output to 4 of my 5 step/dir axes? Or as long as I have free IO channels can I initialize these for step/dir output? I have 2 controller/steppers on my x axis, one each for y and z, and a rotational A-axis for 5 axes total. Or is the 4 axis limit only when using encoders for feedback to the Kflop?

I'm not sure I understand all the manual says about this:

"Use Jumper depending the the axis that fence to using" ;) C68-R3_USER_MANUAL.PDF Page 2
Good question. Changing all the jumpers will probably limit to 4 axes as described. But I would think only changing the jumpers marked 1_1 and 1_14 would still allow 5 axes to work. Probably KFLOP Step/Dir 0, 1, 2, 3, 5.

You might want to ask CNC4PC to better document what the C68 does or release the schematic.
Regards,

Tom Kerekes
Dynomotion, Inc.

Bill D
Posts: 9
Joined: Sat May 25, 2019 7:12 pm

Re: Setting S in Tool Setup

Post by Bill D » Wed May 29, 2019 8:28 pm

Hi Tom. Well... Hmm....

Take 1
1- moved all but the first two jumpers we discussed from 1-2 to 2-3. Left 1_1/3_6 and 1_17/3_7 on 1-2
2- powered up board. By default, I0 bit 33 was in input mode but high(?).
3- ran init routine. Bit 33 remained input/high. Dir leds for drivers 1-4 came on, but not 5 like before (all jumpers 1-2).
4- Ran 50% pwm routine. Bit 27 went to output, state blinking check mark, relay 1 led on, 4.5v on voltmeter.
5- At same time, Dir led for drive channel 5 turned on (?!?)
6- In digital IO screen, turned bit 27 off by clearing check in output box.
7- Could not turn bit 33 from input/high to input/low. Clicked output box, bit switched to output/low, and I could then set it to output high.
8- Re-set bit 27 to output, verified 4.5v, relay 2 led lit.
9- Left on while fiddling. At 25-30 sec mark, VFD Fault led blinked on, board shut down, VFD Fault led went off, board re-set, then repeated this again. It appeared to happen a little sooner the 2nd/3rd time
10- Switched bit 33 to low, re-set bit 27 to output, relay 1 led came on, whole thing reset as before in 30 seconds

11- Wondered if my ancient analog voltmeter might be drawing too much current, disconnected from board, same results
11.5- Verified that jumper for C62 VFD alarm function WAS set to disabled...

Take 2
12- Updated Init code to set bit 33 as output
13- Set all C68 jumpers to 2-3
14- Powered up board, bit 33 still defaulted to input/high with earlier wierd behaviour
15- Ran Init, bit 33 went to output/low, first 4 dir leds came on
16- Ran PWM code, bit 27 came up as output/flashing, relay 1 came on, 4.5v on VM, 5th dir led came on
17- In 30 seconds or so, VFD fault led came on, board stopped, VFD fault led went off, board (I think only C62, since bit settings remained constant) re-initialized, repeated
18- Same behavior with bit 33 high, only relay 2 led on, as expected

Take 3
19- Repeated (roughly) above tests (all but 2 jumpers 2-3 / all jumpers 2-3) with VFD powered, in case there might be some internal fault mode happening with the power off. Spindle ran at 165/400 Hz, 4.5V analog output, CW and CCW. Same thing, but now with lots of relay noise; did not let it recycle. Fault time varied from nearly right away to 30 seconds or so.

Take 4
19- Noted that although the VFD alarm jumper was set to disabled, there was a VFD alarm mode (?) jumper to be set depending on the VFD internal fault circuitry. Broke jumper on removal, left jumper off
20- Everything ran for 2-3 minutes. Was patting myself on the back when it recycled. Subsequently recycled at previous rates, CW/CCW.

Have not tried it with VFD fault mode jumper on the other position, but do not think this matters....

Previously checked and verified that all my different grounds were isolated from each other...

********************************

Do you know if anyone has generated a script to run the HY Modbus-ish command implementation and send them directly from the Kflop UART to the VFD RS-485 port via a 3.3v compatible rs323-rs485 adapter card? I noted a few nice examples of "orthodox Modbus" codes implemented for this purpose, but only for other VFDs.

I ran the VFD decently from a USB to RS485 converter with a Mach 3 driver. I found, however, that the more USB activity I had, the sooner I would get a UC100 dongle connection fault. Using my USB MPG to ratchet speeds and feeds up and down on the fly made this noticeably worse. I am leery of the Mach3/USBto rs485 setup from this experience (swore off using Mach 3 again), and wonder how much better the Kflop might behave under Mach 3.

*********************************
My HY VFD came with one of the connector stickers on upside down... Who knows what may have happened inside the thing with the resulting connections I made before discovering the problem. It did run reliably in manual speed mode forever, and in RS-485 mode (just lost UC100 connectivity to the PC well into complex cuts reliably also).

Thanks for any thoughts you may have on all this, Tom.

Bill Dodson

User avatar
TomKerekes
Posts: 2676
Joined: Mon Dec 04, 2017 1:49 am

Re: Setting S in Tool Setup

Post by TomKerekes » Thu May 30, 2019 12:15 am

Hi Bill,

So in summary it works! You can now command analog voltages?

I don't know anything about your VFD. You would need to research what causes it to fault.
14- Powered up board, bit 33 still defaulted to input/high with earlier wierd behaviour
I don't see that as weird or surprising. An undriven signal may float high or low. When changed to an Output it would drive to the default low state. A toggle would be required to set it high.
Do you know if anyone has generated a script to run the HY Modbus-ish command implementation
no. I would expect a KFLOP/Modbus/VFD connection to work reliably.
Regards,

Tom Kerekes
Dynomotion, Inc.

Bill D
Posts: 9
Joined: Sat May 25, 2019 7:12 pm

Re: Setting S in Tool Setup

Post by Bill D » Fri Jul 05, 2019 11:51 pm

Hi Tom,

I fixed a ground loop in my system and now the controller stays happy while the spindle runs.

My init file initializes PWM1 on Bit 27, sets it to 128, and turns the Bit on. In the Kmotion Digital I/O screen Bit 27 Output box comes up as unchecked. Checking the Bit27 Output box starts a blinking check mark in the State box, trips the FW relay and yields 5v at the VFD speed output. Un-checking the Bith27 Output box turns the relay and voltage off.

Bit 33 (fwd/rev toggle) is checked for output after init but its State is unchecked or off. If Bit 33 state is checked on and then Bit 27 Output box is checked, the Bit 27 State box gets the blinking check mark, the Rev relay is toggled, and the VFD control output reads 5v again. Fine so far.

In the tool setup screen M3 is set to two bits; 33 to 0 and 27 to 1. M4 is set to two bits; 33 to one and 27 to 1. M5 is set to two bits; 27 to 0 and 33 to 0.

With the default PWM=128 above, the Start CW button in KmotionCNC has no effect. An led lights up for bit 33 when the Start CCW is pressed, and goes off when the Off button is pressed.

I would like to get the CW, CCW and OFF buttons to work. I seem to recall them working with the PWM preset to 128 with some combination of init file entries, but never with anything I could pass to the system with the S command.

Once that is happening, I have tried setting the S boxes to DAC, PWM1, any number of +/- scalers, and any number of ranges, and sending any number of Sxxxxx commands to the spindle, and the nothing occurs. My spindle turns 24000 rpm on a count of 255/10V as maximum.

Is there something I should do in the MySpindleDefs.h? I have tried a number of variants and no joy. I still do not seem to be a response to setting a speed. I read something about the PWM counts being negative, and tried setting negative scaler values and setting a negative range with no luck.

Thanks,

Bill Dodson

User avatar
TomKerekes
Posts: 2676
Joined: Mon Dec 04, 2017 1:49 am

Re: Setting S in Tool Setup

Post by TomKerekes » Sat Jul 06, 2019 5:20 pm

Hi Bill,
My init file initializes PWM1 on Bit 27, sets it to 128, and turns the Bit on.
Turning the bit on isn't appropriate and doesn't do anything as the PWM is controlling the bit. Also the Bit should be configured as an Output with SetBitDirection(27,1); so it will be driven instead of floating as an input. To avoid having the Spindle on at this point set the PWM value to 0 instead of the test value of 128.
Checking the Bit27 Output box starts a blinking check mark in the State box, trips the FW relay and yields 5v at the VFD speed output.
Good. This makes sense because you left the bit as an input as described above. This proves that the PWM hardware works when configured properly.
Bit 33 (fwd/rev toggle) is checked for output after init but its State is unchecked or off. If Bit 33 state is checked on and then Bit 27 Output box is checked, the Bit 27 State box gets the blinking check mark, the Rev relay is toggled, and the VFD control output reads 5v again. Fine so far.
Correct. It seems your Init Program correctly configured Bit 33 as an Output even though it did not Bit 27 and proves the Direction Control works via Bit 33
Un-checking the Bith27 Output box turns the relay and voltage off.
You shouldn't really do this. Making the pin an input leaves it floating in an uncontrolled manner. To set the PWM to 0% change the PWM value from 128 to 0.
In the tool setup screen M3 is set to two bits; 33 to 0 and 27 to 1. M4 is set to two bits; 33 to one and 27 to 1. M5 is set to two bits; 27 to 0 and 33 to 0.
None of this or the rest of your post is really appropriate. Because your hardware should set the PWM value to zero to turn off the spindle, and restore the previous value when turned back on and so forth, there isn't a means of toggling bits to do this. Also your system uses a PWM not a DAC so the simplified DAC writing option is not appropriate.

Instead C Programs will be used to perform the necessary steps. I've attached the C68 C Programs that control the PWM and Direction Output, scale the PWM appropriately, and that allow changing the speed while the spindle is off, remembering the setting, then applying it when turned on and so forth. All you should need to change is the scaling FACTOR from (255.0/1000.0) to (255.0/24000.0).

HTH
Attachments
SpindlePWMDir.c
(1.21 KiB) Downloaded 175 times
SpindleOnCWPWMDir.c
(1.25 KiB) Downloaded 163 times
SpindleOnCCWPWMDir.c
(1.25 KiB) Downloaded 156 times
SpindleOffPWMDir.c
(656 Bytes) Downloaded 167 times
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply