586,103 active members*
3,361 visitors online*
Register for free
Login
Results 1 to 11 of 11
  1. #1
    Join Date
    Mar 2010
    Posts
    813

    UCCNC Controlling HY VFD via Macro

    With the help and idea of Vmax549 I aborted trying to manipulate the Modbus plugin to control my HY VFD and now attempting with the use of macros. I have 2 macros listed below and with inputting with UCCNC MDI I can turn spindle on/off.

    //Turns spindle ON

    System.IO.Ports.SerialPort myPort = new System.IO.Ports.SerialPort("COM1");

    myPort.Open();
    byte[] bytestosend = { 0x01, 0x3, 0x01, 0x01, 0x33, 0x88 };

    myPort.Write(bytestosend, 0, bytestosend.Length);
    exec.Wait(10);


    myPort.Close();

    __________________________________________________ ____________________

    //Turns spindle OFF

    System.IO.Ports.SerialPort myPort = new System.IO.Ports.SerialPort("COM1");

    myPort.Open();
    byte[] bytestosend = { 0x01, 0x3, 0x01, 0x08, 0xf1, 0x8e };

    myPort.Write(bytestosend, 0, bytestosend.Length);
    exec.Wait(10);


    myPort.Close();

    __________________________________________________ _____________________


    What I'm trying to accomplish now is a Macro loop with "bool stateofmyLED = AS3.GetLED(50)" spindle CW led. Is it possible to call a macro within a macro? Or should it be written as 1 macro. Hoping for some info on best approach from you experienced macro writers. It will be extremely appreciated by me and for the safety of my monitor.

  2. #2
    Join Date
    Oct 2005
    Posts
    1145

    Re: UCCNC Controlling HY VFD via Macro

    HIYA Dan, What you want is one master Macroloop that does it all including setting teh RPM . You also would need to convert teh RPM into a HZs value for the VFD Then you would need to calculate a CRC . There IS a C# script for that as well.

    (;-) TP

  3. #3
    Join Date
    Mar 2010
    Posts
    813

    Re: UCCNC Controlling HY VFD via Macro

    Thanks TP, that will be my end result goal. Right now I'm working on trying to send "spindle on" string when spindle CW led is on, and "spindle off" string when spindle led is off. Once I accomplish this all move on to CWW than RPM.

    The most frustrating part is I have to run in UCCNC each edit to see if have any errors. I'm using Notepad++.

  4. #4
    Join Date
    Mar 2010
    Posts
    813

    Tested and Working

    Thanks to Vmax549 he slapped this together in minuets for me and saved me weeks of work...LOL

    I added CCW and tested and working great! TP if you could send/link me that script it would be much appreciated.

    -----------------------------------------------------------------------------------------------------------------------------------------


    if ( AS3.GetLED(50) == true ) // IF LED is active



    {

    //Turns spindle ON CW
    System.IO.Ports.SerialPort myPort = new System.IO.Ports.SerialPort("COM1");
    myPort.Open();
    byte[] bytestosend = { 0x01, 0x3, 0x01, 0x01, 0x31, 0x88 };
    myPort.Write(bytestosend, 0, bytestosend.Length);
    exec.Wait(10);
    myPort.Close();
    }



    else



    if ( AS3.GetLED(51) == true ) // IF LED is active



    {

    //Turns spindle ON CCW
    System.IO.Ports.SerialPort myPort = new System.IO.Ports.SerialPort("COM1");
    myPort.Open();
    byte[] bytestosend = { 0x01, 0x3, 0x01, 0x11, 0x30, 0x44 };
    myPort.Write(bytestosend, 0, bytestosend.Length);
    exec.Wait(10);
    myPort.Close();
    }



    else



    {

    //Turns spindle OFF
    System.IO.Ports.SerialPort myPort = new System.IO.Ports.SerialPort("COM1");
    myPort.Open();
    byte[] bytestosend = { 0x01, 0x3, 0x01, 0x08, 0xf1, 0x8e };
    myPort.Write(bytestosend, 0, bytestosend.Length);
    exec.Wait(10);
    myPort.Close();
    }



    // EOF


    // EOF


    // EOF

  5. #5
    Join Date
    Mar 2010
    Posts
    813

    Re: UCCNC Controlling HY VFD via Macro

    hello all,

    I'm trying to put a simple and temporary Sset together and can't seem to get it to work. Please tell me where I'm going wrong.


    if (AS3.Getfield(869) == 24000

    {

    etc etc

    }

  6. #6
    Join Date
    Mar 2003
    Posts
    35538

    Re: UCCNC Controlling HY VFD via Macro

    I guess I need more info on what exactly the question is?
    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)

  7. #7
    Join Date
    Mar 2010
    Posts
    813

    Re: UCCNC Controlling HY VFD via Macro

    I sorry.... but I think my problem is with " if (AS3.Getfield(869) == 24000)"

    The rest of the code is the same as I posted above except with a different string so I know that works with no errors.
    __________________________________________________ ____________

    if (AS3.Getfield(869) == 24000)


    {

    System.IO.Ports.SerialPort myPort = new System.IO.Ports.SerialPort("COM1);

    myPort.Open();
    byte[] bytestosend = { 0x01, 0x5, 0x03, 0x34, 0x15, 0x00, 0X82, 0Xd0 };
    myPort.Write(bytestosend, 0, bytestosend.Length);
    exec.Wait(10);
    myPort.Close();
    }


    EOF

  8. #8
    Join Date
    Oct 2005
    Posts
    1145

    Re: UCCNC Controlling HY VFD via Macro

    if (AS3.Getfielddouble(869) == 24000)
    {

    etc etc ;

    }


    One thing to remember is IF you use teh Getfield() call teh value is a string not a double. To to be able to do any math with it you will need to convert it to double.

    (;-) TP

    //EOF

  9. #9
    Join Date
    Mar 2003
    Posts
    35538

    Re: UCCNC Controlling HY VFD via Macro

    if (AS3.Getfield(869) == 24000)

    Missing ) at the end.
    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. #10
    Join Date
    Mar 2010
    Posts
    813

    Re: UCCNC Controlling HY VFD via Macro

    Thank you TP that was it!

    I'm sure you see where I'm going with this. To be able to use the "AS3.Getfield" and round to the closest choice of 12 rpm settings will be fine for me. maybe tweak down the road with a script. Excited on getting up and running.

    Thanks again for all you help,
    Dan

  11. #11
    Join Date
    Mar 2010
    Posts
    813

    Re: UCCNC Controlling HY VFD via Macro

    Quote Originally Posted by ger21 View Post
    if (AS3.Getfield(869) == 24000)

    Missing ) at the end.
    Yes Ger I seen that, and was a mistake from my cut and paste. I edited post but you were quicker than me.

    Thanks for your reply

Similar Threads

  1. UCCNC Macro sharing
    By BanduraMaker in forum UCCNC Control Software
    Replies: 64
    Last Post: 02-04-2023, 12:17 AM
  2. UCCNC Camera/Laser Edge finder offset macro
    By Jon.N.CNC in forum UCCNC Control Software
    Replies: 14
    Last Post: 03-10-2019, 07:42 AM
  3. Uccnc - macro dialog box, how?
    By robertspark in forum UCCNC Control Software
    Replies: 4
    Last Post: 06-27-2016, 04:17 AM
  4. UCcnc macro scripting suggestions
    By vmax549 in forum UCCNC Control Software
    Replies: 5
    Last Post: 08-07-2015, 06:49 PM
  5. Replies: 2
    Last Post: 12-19-2012, 01:28 PM

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
  •