Hello Guest it is April 29, 2024, 06:19:57 AM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - KentCNC

Pages: « 1 2 3 4 5 »
11
Mach4 General Discussion / How to Exit Screen Script
« on: March 23, 2021, 11:40:57 AM »
I have two very simple question that I cannot find answers to.

1) How do I exit a screen script. I have a simple script add to the button up script. I have an If statement that when true I want to exit the code and not continue with the lines below it.

2) I want to use mc.mcCntlSetLastError(inst, "Yadda yada")to display a message to the user and not require an acknowledgment via a message box. I have the message at the beginning of a screen script. Later in that script I have a FOR loop that I am treating as a timer. The problem is that the message will not be displayed until the end when the timer completes and the rest of the routing finishes. How can I get that message to appear as soon as it is hit in the code and not wait for completion of execution of the entire script?

12
Mach4 General Discussion / Re: What does .PlcCycle() Do?
« on: March 10, 2021, 11:32:55 PM »
Thank you for the response. I recently converted from Mach3 to Mach4. I needed to get my spindle up and running which I controlled via modBus. I found some very helpful code that a person had written using PMC along with some custom code. That was enough to get me started but I never like implementing something that has pieces I do not understand. I have since converted everything to be Lua in the ScreenLoad and PLC areas and stopped using the PMC code. I still have a lot to learn, but am making very good progress. Always thankful for everyone's help on the forum!

13
Loading 4612 fixed whatever was broken. It works now.

14
I am using 4517. I will upgrade to the latest release. It works on the computer on my machine but does not work on my laptop. I know at one time it did work on my laptop. Not a big deal as now I am getting comfortable coding in Lua. I am really liking what can be done in Mach4 compared to Mach3. I had developed a couple brains in Mach3 and that was painful.

15
Mach4 General Discussion / Re: How Are Encoders Configured in Mach4?
« on: February 24, 2021, 07:44:35 PM »
Thanks yet again! I see that you access that via the Events tab of the main screen. The properties tab has the "PLC Interval" Does that mean that all PLC functions use that same interval? I was hoping to use 10msec for the racking detection. The interval property is currently set at 50. I am not sure if it would cause issues if I had all PLC scripts run at 10msec if I change that setting.

I hope others also benefit from this exchange as I feel a bit guilty asking you so many questions. One day I hope to start paying forward this help.

16
Mach4 General Discussion / Re: How Are Encoders Configured in Mach4?
« on: February 24, 2021, 07:24:35 PM »
Hopefully one last question. Where do you place the function for running this Lua code in the PLC ? There is no folder named PLC. Is the code actually placed in the PMC folder? I read the scripting manual and watched a couple videos and this basic question was not covered.

17
Mach4 General Discussion / Re: How Are Encoders Configured in Mach4?
« on: February 24, 2021, 05:14:43 PM »
Thank you again and again for your helpful responses. It was relatively easy to get the basic operation of my machine converted from Mach3 to Mach4. The one basic function I needed was to get ModBus control of the spindle. I started with a fantastic document created by Bill Caldwell. He went into great detail for controlling a Huanyang VFD. I have a Hitachi VFD that uses a combination of coils and registers (Huanyang only uses registers) so I modified his code. He explained that he started in the PMC and then modified some of his code. I like to fully under stand the code I implement even if it starts out as someone else's. Much more than you wanted to know, but I wanted to give you perspective on where I am with my Mach4 learning journey.

When do you use PMC versus PLC? What is the PMC? I was obviously confused and thought that the PMC and PLC were one of the same.

I don't want to wear out your patience, so feel free to ignore these last questions. You have already been very helpful to me and have me well on my way to implementing the racking detection code!

Kent

18
Mach4 General Discussion / Re: How Are Encoders Configured in Mach4?
« on: February 24, 2021, 03:58:35 PM »
Thank you! I will give this a try this evening. I have verified that I can see the values via the register diagnostics screen.

Now I have another newbie question. The reason I want to read these two encoders is so I can stop the machine if they differ by more than a given count. One encoder monitors the move on one side of the gantry and the other encoder monitors the opposite side. This will ensure that gantry is not damaged if one side stops being driven for whatever reason.

In order to monitor this at a given interval, I assume I place the code into the PMC folder of Mach4. Is that correct?

How do I set the interval for running this code? This relates to another post I made but have yet to get a response. There is an interval that can be specified for the PMC module when editing the main screen. However, code that I implemented (by starting with code someone else created) for ModBus spindle control had two areas that appear to control the PLC interval. One was the following function (however that function did not appear to be called anywhere in the code I was using for ModBus spindle control):

function VFD_Spindle_Controller.GetCycleInterval()
    return 10
end

The other area that I did not understand that may control the interval the code is called is at the end of the main function call for the ModBus spindle control: function VFD_Spindle_Controller.PlcCycle()

Can you educate me on this.

Thank you again!
Kent

19
Mach4 General Discussion / Re: How Are Encoders Configured in Mach4?
« on: February 24, 2021, 10:46:29 AM »
Thank you for the reply.

I am running an Ethernet SmoothStepper.

I don't have the Aux. Positions tab when selecting Control Configurations.

I can see the encoders on the encoders diagnostics screen. They are listed as Encoder_0 and Encoder_1. I see the counts change when the y-axis moves, so now I just need to figure out how to read those encoder registers using LUA. I assume I would put this in the PMC. My goal is to monitor the counts of the encoders on each side of the gantry and if they vary by more than a specific number of counts I will stop the machine. My goal is to have racking detection for the gantry so that nothing is damaged if one side stops being driven for some reason.

Thank you for your help!

20
Mach4 General Discussion / Re: What does .PlcCycle() Do?
« on: February 23, 2021, 08:01:10 PM »
Yes, I am using code that stared with the PMC. This is a function in the code that I assume is related, but not named PlcCyle.

function VFD_Spindle_Controller.GetCycleInterval()
    return 10
end

Not sure what that function does. I don't see it called anywhere in the code.

When I enable this code as a PMC object for the screen, there is a refresh interval that can be specified. So I ma trying to figure out what controls the PLC cycle. The field in the PMC object screen, the .GetCycleInterval appended to the function above or the .PlcCycle() at the end of the main function I wrote/modified.

The good news is that I have been successful with controlling my spindle via ModBus. However, I want to fully understand what the code does.

Pages: « 1 2 3 4 5 »