Need Help! Strange problem with Mach3 and Kflop when using MPG


Results 1 to 12 of 12

Thread: Strange problem with Mach3 and Kflop when using MPG

  1. #1
    Registered
    Join Date
    Mar 2015
    Posts
    8
    Downloads
    0
    Uploads
    0

    Default Strange problem with Mach3 and Kflop when using MPG

    I have recently tried to upgrade my old Bridgeport Series II to use a KFLOP control board with Mach3

    I've had the machine for a couple of years now with Mach3 and a 3 axis controller board from Automation Technology Inc (3 Axis CNC USB Card Mach3 200KHz Breakout Board Stepper Motor | Stepper Motor Driver | CNC Router | Laser Machine | 3D Printers For Sale), and a HuanYang VFD. It worked fairly well, but I wanted to improve performance add a 4th axis, and add encoders because it would sometimes stall and then continue machining where it wasn't supposed to.

    Anyway, after some searching I heard about Dynomotion and was impressed with their KFLOP board and bought one. I have been having quite a bit of fun going through it and getting everything running. I made a simple custom breakout board to isolate the inputs and have slowly been getting it going. After reading through the forum about MPGs, I learned that my existing wireless "Mach3 MPG" (from China) wasn't going to work very well so I got a wired MPG on ebay (Universal CNC 4 Axis MPG Pendant Handwheel & Emergency Stop for Siemens US UPS | eBay) and figured out how to wire it up to the KFLOP Board. I didn't have enough inputs left on my Break-Out Board so I built a little micro controller circuit to go between the MPG Pendant and KFLOP, It translates the selector switches into a serial word and implements a two wire serial interface which I could easily decode in the KFLOP board.

    After a bit of a learning curve, I have the MPG running very smoothly. But there seems to be some problems with it working with Mach3. When I am simply jogging around with the MPG the DROs on Mach3 seem to be working great. But when I load a gcode program that's when things start to go wrong. If I start up Mach 3 and use the keyboard to jog around and then <Ref All Home> then run my little test program (generated by Fusion 360) it runs fine. But if I try to use the MPG to move an axis, (like I wanted to zero the tool length) then when I push Cycle Start the Z-axis moves to the home position and than rapidly back to the zero position. And then the program won't run and I have to hit the Stop button (not the ESTOP) rewind and then try again, sometimes it will run the second time sometimes it wont. I'm sure that I've got something wrong in my Kflop program and the MPG section is fighting the Mach3 commands or something, But I've been all over the code and I can't seem to see what is wrong. So any help would be appreciated!

    I posted some videos of what it is doing on YouTube if anyone is interested:






    I'm including a zip file of the KFLOP Code.

    I would really like to get this working well in Mach3, I've been using it for a couple of years now and I've grown used to it. I am using the Mach3 VFD-Drive-by-royaumedeole.fr to drive the VFD. I have a 6 pole hall effect pickup on the spindle which I use to read the spindle speed. That all seems to be working very well. I was able to re-write the mach3 probing routines, and they were working well until I added the MPG code. Now if I try to probe after using the MPG it sometimes goes in the wrong direction. Again if I only use the keyboard in Mach3 to jog, then everything seems to be working OK.

    Thanks for any advice!

    Dan M.

    Similar Threads:
    Attached Files Attached Files


  2. #2
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2378
    Downloads
    0
    Uploads
    0

    Default Re: Strange problem with Mach3 and Kflop when using MPG

    Hi Dan,

    I think your MPG code might be caught in a MoveExp() motion forever. An Exponential Move to a target will never complete. It will just keep driving gradually closer and closer to the Target. This motion will conflict with any other motion commands that are given to the axis. After the Operator stops jogging either after a certain amount of time or when the destination gets very close to the Target then a single normal Move should be made to the Target to terminate any motion. I don't see your code doing that. You might look at the MPGSmooth.c as an example.

    HTH
    Regards

    TK
    http://dynomotion.com


  3. #3
    Registered
    Join Date
    Mar 2015
    Posts
    8
    Downloads
    0
    Uploads
    0

    Default

    Quote Originally Posted by TomKerekes View Post
    Hi Dan,

    I think your MPG code might be caught in a MoveExp() motion forever. An Exponential Move to a target will never complete. It will just keep driving gradually closer and closer to the Target. This motion will conflict with any other motion commands that are given to the axis. After the Operator stops jogging either after a certain amount of time or when the destination gets very close to the Target then a single normal Move should be made to the Target to terminate any motion. I don't see your code doing that. You might look at the MPGSmooth.c as an example.

    HTH
    Regards

    I'll try that tomorrow and let you know. Thanks for the quick response.



  4. #4
    Registered
    Join Date
    Mar 2015
    Posts
    8
    Downloads
    0
    Uploads
    0

    Default Re: Strange problem with Mach3 and Kflop when using MPG

    Quote Originally Posted by xdmattz View Post
    I'll try that tomorrow and let you know. Thanks for the quick response.
    I simplified my MPG program and made it look more like the MPG Smooth example. It is working much better now!

    I didn't realize that the MoveExp would asymptotically approach the target but never get there. I guess it makes sense if you take 63% of the distance every time.

    Now that it is working, I have more questions!

    Since I'm trying to keep Mach3 as my main interface, I've been trying to figure out the communication between Mach3 and KFLOP. I looked at the probing and rigid tapping code and I see that there are values in the Persist.UserData[] array for communicating with Mach3. Is there a master list of all the variables? I have the list of OEM numbers from Mach, but it looks like you are using UserDRO numbers too. Does KFLOP define any of these specifically, or can they be used arbitrarily?

    Also I mentioned before that I made my own break-out board. I would like to make another one, but with more I/O available. Is the communication protocol with the Konnect proprietary? Or would you be willing to share it? It would be much simpler to make something that uses that interface, then I could add the connectors, isolated power supplies, relays etc for the design that I'm thinking of.

    Your KFLOP design is an amazing amount of engineering capability for the price.

    Thanks again!

    Dan M.



  5. #5
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2378
    Downloads
    0
    Uploads
    0

    Default Re: Strange problem with Mach3 and Kflop when using MPG

    Hi Dan,

    Regarding persist variables: Only SetOEMDRO/GetOEMDRO DROs 1000 - 1050 are possibilities to be written/read correspondingly from persist variables 0-99 by Basic Code. See:
    Mach3 Plugin Passing DROs

    The "list of OEM numbers from Mach" shouldn't really be relevant. Unfortunately its up to you keep track of which ones are used in your system and avoid any conflicts. 50-62 are used by probing. Those should be the only ones that are assigned by the plugin.

    Regarding Konnect Protocol: here is a Thread with some links to some info on the protocol it uses.
    KKonnect - KFlop

    HTH
    Regards

    TK
    http://dynomotion.com


  6. #6
    Registered
    Join Date
    Mar 2015
    Posts
    8
    Downloads
    0
    Uploads
    0

    Default Re: Strange problem with Mach3 and Kflop when using MPG

    Thanks again Tom!

    Now I'm going to need another KFLOP board for development! (don't want to take down my working machine for testing)

    If I can create an interface board that is usable I wouldn't mind sharing the design. What is the best method for doing that?


    Dan M.



  7. #7
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2378
    Downloads
    0
    Uploads
    0

    Default Re: Strange problem with Mach3 and Kflop when using MPG

    Hi Dan,

    It would be great if you could share your design. Make a page for it in the wiki. If you need help let us know.
    Dynomotion

    Regards

    TK
    http://dynomotion.com


  8. #8
    Registered
    Join Date
    Mar 2015
    Posts
    8
    Downloads
    0
    Uploads
    0

    Default Re: Strange problem with Mach3 and Kflop when using MPG

    It seems like these things always take so much longer than they ought to, but I was finally able to make some progress on an interface board design. I have been able to get a xilinx CPLD implementation of the KFLOP - Konnect interface working, but it was a real struggle. Partly because I'm not really a digital logic designer, and partly because the links that you referred to for the Konnect protocol were a little unclear... KKonnect - KFlop (I know you, Tom, didn't write them) So here are the results of my experience, maybe someone else can be helped by it.

    The thing that was the most confusing is that the scope plots only showed the first four clock pulses after the start pulse, like this plot
    Strange problem with Mach3 and Kflop when using MPG-kflop-konnect-write1-jpg
    I could not for the life of me figure out how you got 16 output bits and 32 input bits plus a signature byte with only 4 clock pluses! Plus it was mentioned that the 0xa5 signature byte is optional... It is NOT optional. It wasn't until I was trying to write the 0xa5 at each of the four clock pulses, just to get the Kmotion console not to give me a com error that I spanned out my logic analyzer (Analog Discovery) and saw that the total write/read cycle lasts for two thread periods.
    Strange problem with Mach3 and Kflop when using MPG-kflop-konnect-write2-jpg

    Once I figured that out the rest was pretty straight forward. I wrote the CPLD code in verilog, and compiled it using the xilinx ISE 14 tools. I simulated everything on EDAPlayground, so anyone can take a look at it. EDAPlayground KFLOP-Konnect. BTW, EDA Playground is an awesome tool if your not really a digital HW person and want to learn.

    I have a lashed up prototype based on an old Digilent/Xilinx CPLD eval board that seems to be working so now I feel like I can progress with designing an interface board.
    Here is a really short video clip of it running.


    As usual, as soon as something works it generates more questions. Now that I'm trying to figure out exactly how to wire everything up for the schematic, how do you get 8 channels of step/dir (or pwm/dir) and 8 channels of encoder input from the KFLOP board? From my initial look, I can get 4 channels of step/dir and encoder input from JP7, and either 4 channels of step/dir OR 4 channels of encoder input on JP5. Can JP5 be divided into two step/dir and two encoder inputs? (giving 6 channels of control) or is there some other trick that can put step and direction out on JP4 or JP6?

    Thanks for everything!

    Dan M.

    Attached Thumbnails Attached Thumbnails Strange problem with Mach3 and Kflop when using MPG-kflop-konnect-write1-jpg   Strange problem with Mach3 and Kflop when using MPG-kflop-konnect-write2-jpg  


  9. #9
    Registered
    Join Date
    Mar 2015
    Posts
    8
    Downloads
    0
    Uploads
    0

    Default Re: Strange problem with Mach3 and Kflop when using MPG

    It seems like these things always take so much longer than they ought to, but I was finally able to make some progress on an interface board design. I have been able to get a xilinx CPLD implementation of the KFLOP - Konnect interface working, but it was a real struggle. Partly because I'm not really a digital logic designer, and partly because the links that you referred to for the Konnect protocol were a little unclear... KKonnect - KFlop(I know you, Tom, didn't write them) So here are the results of my experience, maybe someone else can be helped by it.

    The thing that was the most confusing is that the scope plots only showed the first four clock pulses after the start pulse, like this plot
    Strange problem with Mach3 and Kflop when using MPG-kflop-konnect-write1-jpg
    I could not for the life of me figure out how you got 16 output bits and 32 input bits plus a signature byte with only 4 clock pluses! Plus it was mentioned that the 0xa5 signature byte is optional... It is NOT optional. It wasn't until I was trying to write the 0xa5 at each of the four clock pulses, just to get the Kmotion console not to give me a com error that I spanned out my logic analyzer (Analog Discovery) and saw that the total write/read cycle lasts for two thread periods.
    Strange problem with Mach3 and Kflop when using MPG-kflop-konnect-write2-jpg

    Once I figured that out the rest was pretty straight forward. I wrote the CPLD code in verilog, and compiled it using the xilinx ISE 14 tools. I simulated everything on EDAPlayground, so anyone can take a look at it. EDAPlayground KFLOP-Konnect. BTW, EDA Playground is an awesome tool if your not really a digital HW person and want to learn.

    I have a lashed up prototype based on an old Digilent/Xilinx CPLD eval board that seems to be working so now I feel like I can progress with designing an interface board.
    Here is a really short video clip of it running.


    As usual, as soon as something works it generates more questions. Now that I'm trying to figure out exactly how to wire everything up for the schematic, how do you get 8 channels of step/dir (or pwm/dir) and 8 channels of encoder input from the KFLOP board? From my initial look, I can get 4 channels of step/dir and encoder input from JP7, and either 4 channels of step/dir OR 4 channels of encoder input on JP5. Can JP5 be divided into two step/dir and two encoder inputs? (giving 6 channels of control) or is there some other trick that can put step and direction out on JP4 or JP6?

    Thanks for everything!

    Dan M.

    Last edited by xdmattz; 07-31-2017 at 09:23 AM. Reason: everything got duplicated


  10. #10
    Registered
    Join Date
    Mar 2015
    Posts
    8
    Downloads
    0
    Uploads
    0

    Default Re: Strange problem with Mach3 and Kflop when using MPG

    Another quick question. Is there a way to access the input and output bits as a whole word? instead of the SetBit() and ClearBit() functions? Maybe a memory mapped register?

    Dan M.



  11. #11
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2378
    Downloads
    0
    Uploads
    0

    Default Re: Strange problem with Mach3 and Kflop when using MPG

    Hi Dan,

    Thanks for taking the time to post back all the Timing information.

    As usual, as soon as something works it generates more questions. Now that I'm trying to figure out exactly how to wire everything up for the schematic, how do you get 8 channels of step/dir (or pwm/dir) and 8 channels of encoder input from the KFLOP board? From my initial look, I can get 4 channels of step/dir and encoder input from JP7, and either 4 channels of step/dir OR 4 channels of encoder input on JP5. Can JP5 be divided into two step/dir and two encoder inputs? (giving 6 channels of control) or is there some other trick that can put step and direction out on JP4 or JP6?
    The Encoder Inputs on KFLOP JP5 can be multiplexed over to KFLOP JP6. See the MuxEncoders.c example that sets the bit: ENC_4_7_JP6. Some issues with using JP6 are the 150 ohm pull down resistors (which are good for termination) but the encoder must be able to source enough current to pull them to at least a 2V level. They are also 3.3V signals and should not be driven higher than 3.8V (this is not usually a problem).

    Or as you mention the JP5 cable can be split and used for 2 Step/Dr channels and 2 Encoder Input channels.

    Another quick question. Is there a way to access the input and output bits as a whole word? instead of the SetBit() and ClearBit() functions? Maybe a memory mapped register?
    I assume you are referring to Konnect IO? Yes the call to KFLOP will configure where in memory the Konnect Outputs and Inputs will be located. Normally VirtualBits for the Outputs and VirtualBitsEx[0] for the inputs (so they can be easily accessed via SetBit/ClearBit/ReadBit functions) but any memory location can be specified.

    AddKonnect(0,&VirtualBits,VirtualBitsEx);

    HTH
    Regards

    TK
    http://dynomotion.com


  12. #12
    Registered
    Join Date
    Mar 2015
    Posts
    8
    Downloads
    0
    Uploads
    0

    Default Re: Strange problem with Mach3 and Kflop when using MPG

    Thanks again Tom,

    I'll post more as I make progress.

    Dan M.



Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

Strange problem with Mach3 and Kflop when using MPG
Strange problem with Mach3 and Kflop when using MPG