584,826 active members*
5,275 visitors online*
Register for free
Login
Page 2 of 29 123412
Results 21 to 40 of 574
  1. #21
    Join Date
    Mar 2010
    Posts
    813

    Re: Hunayang VFD Macro

    Hello All,

    I attached a revised version of the Hunayang Macro below. Once again a big thanks goes to Vmax549 who written a bypass to frequency write. What this does is it only writes frequency to VFD when its changed. It uses the Getvar and Setvar that only works with the newer version of UCCNC, if older versions are used it will give a script error.

    This was written for a Hunayang VFD, but with a little editing of strings that it sends to VFD, it can be used with any VFD,




    Attachment 340060

  2. #22
    Join Date
    Apr 2013
    Posts
    1899

    Re: Hunayang VFD Macro

    Quote Originally Posted by Dan911 View Post
    Hello All,

    I attached a revised version of the Hunayang Macro below. Once again a big thanks goes to Vmax549 who written a bypass to frequency write. What this does is it only writes frequency to VFD when its changed. It uses the Getvar and Setvar that only works with the newer version of UCCNC, if older versions are used it will give a script error.
    I am not sure it is a good idea to send only on change. One advantage of Modbus is that it is self correcting, meaning that in case the VFD for some reason would lose the set data, it is corrected in the next packet because it is periodically resent. Also, the script does not have any error handling, it assumes that the VFD will receive the message without error. If there is noise or any other disturbance on the line the message will be discarded and the VFD will not act as expected, and if there is just one single message which is sent the VFD will not work as expected. There is no control of the VFD response, so UCCNC has no idea if the message was received or not. This script fills a gap in absence of a real plugin, but it is just a quick and easy solution, not very well designed technically. It works, and that's fine, but there are some issues connected to handling communication this way, so I would not rely on this in any critical or professional situation.

    Issues with this solutions are:

    • Missing error handling. This is very serious, especially if messages are only sent once.
    • Lack of locking COM resource at the start of UCCNC. Continuously opening/closing COM is not a good solution at all.
    • Timing. It relies on UCCNC macro loop timing, which is far too fast for this purpose.
    • Lack of localization. Will be fixed in next UCCNC release, but for now anyone living outside of USA and/or using other than US English Windows should add these two lines at the beginning of the code:


    Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US", false);
    Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US", false);

    If those lines are not added the macro should only work when called as an M-code, not if it is in a macro loop. You and Vmax have not seen this since you are using the "right" Windows. I spent the whole weekend fighting with a short macro which worked well if called manually but failed in macro loop and I could not understand why, so I gave up and sent a mail to Balázs during the evening. He replied pretty fast with those two lines and after adding those lines the macro worked even in macro loop. This will be corrected in the next UCCNC release, but for now it may be necessary to inform users about it.

    Those are just some of the things why I can not see this as anything other than a gap filler in waiting for a better plugin. Don't misunderstand me, I am really glad Vmax came up with this solution, but it is not very well written and is not going to be better if the periodic sending is removed, quite the opposite, more complicated and risky to use.

    Quote Originally Posted by Dan911 View Post
    This was written for a Hunayang VFD, but with a little editing of strings that it sends to VFD, it can be used with any VFD,
    In my opinion, it isn't a good idea at all to use this script to control any VFD which uses Modbus. The built in functions in UCCNC are miles better than this solution, even if this solution works for HY VFD which is not following any Modbus standards. For any device using Modbus as it supposed to be used, this function can be solved in a few lines of code, so even if this may be adjustable for other devices, it is better to use the built in functions for handling datacom and Modbus.

  3. #23
    Join Date
    Oct 2005
    Posts
    1145

    Re: Hunayang VFD Macro

    HIYA A_C Please free free to update teh script to your standards (;-). OR write a pnew plugin just for teh HY VFD.

    There are many modbus variants( flavors) out there that require single shot control. Some even warn about excessive writes to the mem chips. How valid the MEM problem is I have no idea and don't really care.

    Some who use teh mobus protocal to a point also require single shot writes for control. Hypertherm's rs485 modual for there plasma units is one of those as well. It uses a variant of modbus ASCII.

    IF all controls were fully compliant to the "default" Modbus standard there would be no need for scripts like what Dan created.

    The quest cam up as to comercial applications. Would I use this approach ??? NOPE neither would I be using a HY VFD either (;-)

    Is this a work around to a known problem for teh DIY cnc world?? SURE IS

    So in this case does teh Modbus plugin work for teh HY VFD ?? NOPE

    Does it work for a Hypertherm RS 485 control for plasma ?? NOPE

    Does Dan's method work (;-) YEP

    Can it be made better ?? Sure it can . Please free free to update it then repost it back here for everyone like Dan did.

    (;-) TP

  4. #24
    Join Date
    Mar 2010
    Posts
    813

    Re: Hunayang VFD Macro

    I didn't no much about Modbus standard until I started on this project, but isn't Modbus standard just a universal form of communication?? If I modified the string in script to communicate with any other VFD wouldn't that be somewhat Modbus standard?

    I spent a good amount of time monitoring how HY plugin, SpindleTalker and the Modbus plugin in UCCNC communicated through serial port and you wouldn't no the difference if just monitoring with a serial port monitor with all including script.

    If you or anyone feel sending frequency just once is not good then edit script to send 2x,5x,10x or just remove the compare and have it send continually.

    It you or anyone thinks a macroloop is to fast add "exec.Wait(??);" to each string send to your preference.

    I was never completely happy with opening and closing of port but it hasn't caused any problems. If there's noise problems on system its going to cause problems everywhere.

  5. #25
    Join Date
    Apr 2013
    Posts
    1899

    Re: Hunayang VFD Macro

    Quote Originally Posted by Dan911 View Post
    I didn't no much about Modbus standard until I started on this project, but isn't Modbus standard just a universal form of communication??
    That's just it. Modbus is a well defined standard, but the HY is NOT talking Modbus, it is talking a misinterpreted Modbus. If you need to send read commands to write and must create a special interface to handle that then that is totally wrong and twisted and is NOT Modbus. That's why you could not make it work with UCCNC or Mach3. Both of those have Modbus interfaces but both assumes that the connected units use Modbus, not a twisted form of communication.

    Quote Originally Posted by Dan911 View Post
    If I modified the string in script to communicate with any other VFD wouldn't that be somewhat Modbus standard?
    I don't know if it ever can be modified to become Modbus standard, but why would anyone do that when there is already a nice interface in UCCNC which supports Real Modbus? Using that interface reduces the macro complexity and the number of lines to very few, so why would this be an interesting solution to any REAL Modbus unit users? It is OK for the HY, and perhaps a few more, but any standard Modbus device is better handled by UCCNC.

    Quote Originally Posted by Dan911 View Post
    I spent a good amount of time monitoring how HY plugin, SpindleTalker and the Modbus plugin in UCCNC communicated through serial port and you wouldn't no the difference if just monitoring with a serial port monitor with all including script.
    I am not sure I understand what you mean. I know you spent a great amount of time on this, but what you mean by no difference?

    Quote Originally Posted by Dan911 View Post
    If you or anyone feel sending frequency just once is not good then edit script to send 2x,5x,10x or just remove the compare and have it send continually.

    It you or anyone thinks a macroloop is to fast add "exec.Wait(??);" to each string send to your preference.
    Of course it is possible to modify the macro, I was just point it out that by sending the message only once you are taking a risk and remove a safety feature which is built in in Modbus by default. It is absolutely NOT safe to send a message only once and ASSUME that it is received without error in 100% of the cases. If you do that you need to read back the answer also and check for confirmation, that is the least you can do if you are concerned about the data.

    Quote Originally Posted by Dan911 View Post
    I was never completely happy with opening and closing of port but it hasn't caused any problems. If there's noise problems on system its going to cause problems everywhere.
    Communication issues are not always connected to noise, so there is no warranty that you will get problems elsewhere just because you occasionally would miss a beat.. I mean, in serial communication it is enough if a single bit is changed and the checksum will be wrong so the whole message will be discarded by the VFD, assuming it checks the checksum.

  6. #26
    Join Date
    Mar 2010
    Posts
    813

    Re: Hunayang VFD Macro

    Hi A_C,

    I would appreciate if you give this a try and let me know how it works, I used your strings from your Brains thread in the Mach3 forum. You my have to add lines above like you mentioned because of the windows problem.



    EFC 5610>>>>>>>>>>>>> Attachment 340134


    Thanks Dan

  7. #27
    Join Date
    Apr 2013
    Posts
    1899

    Re: Hunayang VFD Macro

    Hi Dan,
    I'm currently on a business trip in Brussels and won't be back home before Thursday, so I can't try it out. Also, as I said before, why would anyone with a real Modbus VFD would be interested in using this? The macro I am using works fine, it requires less lines and together with the built-in functions in UCCNC it is in my opinion a better solution. Never the less, I will try this one out for you, but can't promise to spend time on it if it is not working. ...just got my food in the restaurant I am in... will get back later.

    Edit:

    OK, now I am back in my hotel...

    I don't mean to be rude, just that I see no point in this for anyone else except for those who have non-Modbus VFDs. Compare the macro I have, with the one you have and need:

    Code:
    // ----------------------------------------------------------------------------------------------------
    //
    // M300 Macro for Set spindle speed via Modbus
    //
    // When this macro is called it will check the Set Spindle Speed and the Speindle Speed Override DRO
    // and will calculate the matching frequency. This is set in Modbus register which is sent to the VFD.
    //
    // This macro works with any VFD as long as the VFD calculates the frequency using the formula:
    //
    //	f = RPM / 0.6
    //
    // If a diifferent formula is used it can easily be changed in the last line.
    //
    // ----------------------------------------------------------------------------------------------------
    //
    //    Constants
    //
    ushort SSetDRO = 869;                 // Defined by UCCNC			
    ushort SspeedOverrideDRO = 233;  // Defined by UCCNC	
    ushort VFDFrequencyRegister = 1;  // User definable within the limits of UCCNC Modbus registers
    ushort MaximumRPM = 24000;        // User definable within the limits of VFD and the motor
    //
    //    Variables
    //
    string SspeedOverride;
    int    IndexOfPercentSign;
    string SSpeedOverride;
    double RealRPM;
    //
    //    Program starts here
    //
    //    The first two lines need to be added if the macro is run as a macro loop in Windows computers
    //    which use something else than US English floating point and number representation.
    //
    Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US", false);
    Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US", false);
    //
    // ----------------------------------------------------------------------------------------------------
    //
    //
    // Get the string of Spindle speed override percent, strip off the '%' sign.
    //
    SspeedOverride = AS3.Getfield(SspeedOverrideDRO);
    IndexOfPercentSign = SspeedOverride.IndexOf('%');
    //
    //    Necessary to check for zero to prevent the macro from crashing when UCCNC is started, 
    //    because the macro starts before UCCNC initialized the string. The code will only be executed
    //    if UCCNC is ready for running.
    //
    if (IndexOfPercentSign > 0)    // IndexOfPercentSign is zero only if the string is not initialized    
    {
        SSpeedOverride = SspeedOverride.Substring(0, IndexOfPercentSign);
    //
    // Calculate the real RPM by multiplying the set spindle RPM with the override percent.
    //
        RealRPM = ( AS3.Getfielddouble(SSetDRO) * ( (double) Convert.ToDouble (SSpeedOverride) / 100));
        if (RealRPM > MaximumRPM)
        {
            RealRPM = MaximumRPM;    // Force maximum RPM to prevent exception
        }
    //
    // Calculate the matching RPM frequency and send the value to UCCNC Modbus register.
    //
        exec.SetModbusregister(VFDFrequencyRegister, (ushort) Convert.ToUInt16(RealRPM / 0.6));
    }
    //
    // ------------------------------------------------------------------------------------------------------
    //
    //    End of program
    I made some small changes on my way to Brussels, so the above code is not the one I tested last night, but it is not shorter than the one I have at home, I just tidied up a little. It is only 10 lines of code, including the two you don't need and an additional two testing the maximum speed, if you remove all the comment lines. OK, it is only for handling the spindle speed, but the CW/CCW/OFF takes only another six lines or so, if it would be added to the same code. I have a different macro for that, because I think it is better to keep them separate, but it could easily be added to this and the code would still be pretty clear and understandable. I don't have the code for that here with me, so I can't show it now, but it sure is simpler and more straight forward than yours.

  8. #28
    Join Date
    Mar 2010
    Posts
    813

    Re: Hunayang VFD Macro

    Yes, I did compare it to the one you have and need. Like you stated its missing on/cw on/ccw and off. Also you need another plugin for checksum and to run it.

    I get it, its not for you, but that's you. I configured the HY macro to control your VFD in 5-10 minuets. Not everyone has the knowledge and time to write macro's and was only pointing out that this macro was easy to configure to work any VFD.

    Dan

  9. #29
    Join Date
    Apr 2013
    Posts
    1899

    Re: Hunayang VFD Macro

    Quote Originally Posted by Dan911 View Post
    Yes, I did compare it to the one you have and need. Like you stated its missing on/cw on/ccw and off. Also you need another plugin for checksum and to run it.
    No, I don't need another plugin, except the one supplied by UCCNC, which not only calculates the checksum but manages the port handling, the transmissions and the receiving of the data as well. Of course, that is necessary to have, but it is a very well made plugin, so I'd definitely prefer using it. After all, why invent the wheel?

    Quote Originally Posted by Dan911 View Post
    I get it, its not for you, but that's you. I configured the HY macro to control your VFD in 5-10 minuets. Not everyone has the knowledge and time to write macro's and was only pointing out that this macro was easy to configure to work any VFD.

    Dan
    As I said, I will test it for you, just to see if it is working or not. It will probably work, I went through the code since I don't have much better to do right now in my hotel room, and I see no reason why it should not work. I made some reorganization as well so if it works I'll send you my version. I won't have time to completely rewrite it but made some changes because I really don't like when constants and declarations are mixed in the code and try to avoid that. It makes reading the code easier also. Never the less, I made no major changes, and if my changed version won't work, I test your original one to verify that as well, which I will do even if my version works as well, just to see if there are any differences.

    It would take more than 5-10 minutes for most people (even for me) to modify the macro for another VFD, not only because the right codes must be found in the manuals, but also because your code demands manual calculation of three checksum, and while I provided a link to a working online calculator, maybe if I or somebody else had to look for it again, that would take some time also. Some of the online calculators have errors in them, so it must be checked.

  10. #30
    Join Date
    Mar 2010
    Posts
    813

    Re: Hunayang VFD Macro

    Quote Originally Posted by A_Camera View Post
    No, I don't need another plugin, except the one supplied by UCCNC, which not only calculates the checksum but manages the port handling, the transmissions and the receiving of the data as well. Of course, that is necessary to have, but it is a very well made plugin, so I'd definitely prefer using it. After all, why invent the wheel?
    The wheel hasn't been invented for the HY VFD and UCCNC yet, thats why the title of thread is Hunayang VFD macro. I couldn't agree more that the UCCNC Modbus plugin is well written, but unfortantatly it dont work with the HY VFD. I think Vmax549 did an amazing job bringing this Macro to life and it will continually get better. I posted as an open source and everyone is welcomed to use, help improve and even bash like yourself.

    Dan

  11. #31
    Join Date
    Apr 2013
    Posts
    1899

    Re: Hunayang VFD Macro

    Quote Originally Posted by Dan911 View Post
    The wheel hasn't been invented for the HY VFD and UCCNC yet, thats why the title of thread is Hunayang VFD macro. I couldn't agree more that the UCCNC Modbus plugin is well written, but unfortantatly it dont work with the HY VFD. I think Vmax549 did an amazing job bringing this Macro to life and it will continually get better. I posted as an open source and everyone is welcomed to use, help improve and even bash like yourself.

    Dan
    I am sorry if you take my comments as bashing. I don't waste my time on bashing, I have better things to do than that.

    The "why invent the wheel " comment was for Modbus units like mine, not the HY. I thought I was extremely clear with that.

  12. #32
    Join Date
    Apr 2013
    Posts
    1899

    Re: Hunayang VFD Macro

    Quote Originally Posted by Dan911 View Post
    The wheel hasn't been invented for the HY VFD and UCCNC yet, thats why the title of thread is Hunayang VFD macro. I couldn't agree more that the UCCNC Modbus plugin is well written, but unfortantatly it dont work with the HY VFD. I think Vmax549 did an amazing job bringing this Macro to life and it will continually get better. I posted as an open source and everyone is welcomed to use, help improve and even bash like yourself.

    Dan
    Hi Dan,

    I came home a day earlier and run a quick test of your script, added only the two necessary lines:

    Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US", false);
    Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US", false);

    and changed COM1 to COM4 and 9600 to 38400, which is my USB stick parameter.

    No error message, but it is not working. This means that I will not continue with the "tidying up" of the code, I don't have time to debug this.

    This is what I meant by "inventing the wheel". There is a working solution, so why would anyone with a working solution and a VFD which is really Modbus compliant be interested in this solution? Sorry if that is "bashing" for you, but it is my opinion.

  13. #33
    Join Date
    Mar 2003
    Posts
    35538

    Re: Hunayang VFD Macro

    It's for the Huanyang VFD's, not for people that can use Modbus.
    Gerry

    UCCNC 2017 Screenset
    http://www.thecncwoodworker.com/2017.html

    Mach3 2010 Screenset
    http://www.thecncwoodworker.com/2010.html

    JointCAM - CNC Dovetails & Box Joints
    http://www.g-forcecnc.com/jointcam.html

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  14. #34
    Join Date
    Apr 2004
    Posts
    733

    Re: Hunayang VFD Macro

    Dan,
    I tested out your macro and a big THANK YOU!!!!! It works great, no problems getting it to run. Thanks again.

  15. #35
    Join Date
    Mar 2010
    Posts
    813

    Re: Hunayang VFD Macro

    Quote Originally Posted by jfong View Post
    Dan,
    I tested out your macro and a big THANK YOU!!!!! It works great, no problems getting it to run. Thanks again.
    Hi Jfong, thanks for your feedback. I'm happy to see another Hunayang owner using it. I've done some tweaking to the macro and after I fully test and if all good I will post it.

    Thanks again,
    Dan

  16. #36
    Join Date
    Mar 2010
    Posts
    813

    Re: Hunayang VFD Macro

    Hi Jfong,

    Below is a new version of the Hunayang VFD macro for UCCNC. If you are using the macro I first posted I suggest switching to this one. Here's a list of what I added.

    1. I guess it could be called "error handling". If the macro don't receive a response from VFD it will continually send string until it responds. You will also get a warning in the UCCNC status message box. I've had yet to see this message in use/testing but it's there in case computer or VFD hip-cups.

    2. The Macro will now periodically send strings to what ever conditions/strings in use. This is easily editable in minutes within the macro. I have it set to resend every 3 min.

    I hope you and others will find this macro as useful as I do.

  17. #37
    Join Date
    Apr 2004
    Posts
    733

    Re: Hunayang VFD Macro

    Great thanks. I'll give this a try this weekend. I need to make some xmas ornaments.

  18. #38
    Join Date
    Mar 2010
    Posts
    813

    Re: Hunayang VFD Macro

    I posted a link to download the HY macro this afternoon and it wasn't until i went to cut something tonight I realized it was the wrong file. It was the same file but I was playing around with delays "exec,wait()" and made the button response a little sluggish. The correct one below.




    Attachment 342236

  19. #39
    Join Date
    Mar 2010
    Posts
    813

    Re: Hunayang VFD Macro

    Quote Originally Posted by A_Camera View Post
    Issues with this solutions are:

    • Missing error handling. This is very serious, especially if messages are only sent once.
    • Lack of locking COM resource at the start of UCCNC. Continuously opening/closing COM is not a good solution at all.
    • Timing. It relies on UCCNC macro loop timing, which is far too fast for this purpose.
    • Lack of localization. Will be fixed in next UCCNC release, but for now anyone living outside of USA and/or using other than US English Windows should add these two lines at the beginning of the code:


    Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US", false);
    Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US", false);
    Hi AC,
    Obviously I value your input and is why I addressed each of your issues.

    "Missing error handling. This is very serious, especially if messages are only sent once."

    Macro will now continually resend string until a response from VFD, also every 2-3 minutes strings(packets) will be resent.

    "Lack of locking COM resource at the start of UCCNC. Continuously opening/closing COM is not a good solution at all."

    OMG... this one had me beating my head against the wall and was the F-ing simplest. goto/start duh...

    port now opens with UCCNC and closes with UCCNC

    "Timing. It relies on UCCNC macro loop timing, which is far too fast for this purpose."

    This was a lot of trial and error, actually 100ms was enough for send and recieve after sent string. Have it set to 1000ms, this was the max before noticing a delay after pushing cw/ccw button. Frequency is set to 2000ms since you could never notice any difference.


    "Lack of localization. Will be fixed in next UCCNC release, but for now anyone living outside of USA and/or using other than US English Windows should add these two lines at the beginning of the code:"

    Like you posted... It will be addressed in next release, otherwise add the two lines you posted.

    I basically had to rewrite to accommodate the port issue and want to do some thorough testing before posting since I have 3 versions posted already. If anyone wants to take a look before, LMK and I will send.

    Dan

  20. #40
    Join Date
    Mar 2010
    Posts
    813

    Re: Hunayang VFD Macro

    Hello All,

    Below is a link for a plugin to control your Huanyang VFD/spindle with UCCNC. Enclosed in zip file is a step by step instructions.

    Dan

    Attachment 346212

Page 2 of 29 123412

Similar Threads

  1. Accessing Macro Variable from another macro
    By ex-egll in forum Mach Wizards, Macros, & Addons
    Replies: 1
    Last Post: 02-01-2014, 06:52 AM
  2. Replies: 2
    Last Post: 12-19-2012, 01:28 PM
  3. Replies: 3
    Last Post: 02-13-2012, 07:20 PM
  4. Replies: 2
    Last Post: 03-27-2009, 09:15 PM
  5. Convert Fanuc Macro to Fadal Macro
    By bfoster59 in forum Fadal
    Replies: 1
    Last Post: 11-09-2007, 06:41 AM

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
  •