508,236 active members
2,793 visitors online
Register for free
Login
Page 3 of 47 1234513
Results 25 to 36 of 563
  1. #25
    Registered
    Join Date
    Apr 2013
    Posts
    1851

    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.

  2. #26
    Registered
    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

  3. #27
    Registered
    Join Date
    Apr 2013
    Posts
    1851

    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.

  4. #28
    Registered
    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

  5. #29
    Registered
    Join Date
    Apr 2013
    Posts
    1851

    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.

  6. #30
    Registered
    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

  7. #31
    Registered
    Join Date
    Apr 2013
    Posts
    1851

    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.

  8. #32
    Registered
    Join Date
    Apr 2013
    Posts
    1851

    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.

  9. #33
    Community Moderator ger21's Avatar
    Join Date
    Mar 2003
    Posts
    34571

    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)

  10. #34
    Registered
    Join Date
    Apr 2004
    Posts
    717

    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.

  11. #35
    Registered
    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

  12. #36
    Registered
    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.

Page 3 of 47 1234513

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
  •