Hello Guest it is April 28, 2024, 07:06:25 PM

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 - mcardoso

Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 »
211
Wow, that is powerful.

Here is what I am thinking, simplified for readability

Code: [Select]
---------------------------------------------------------------
-- Screen Load Script --
---------------------------------------------------------------
--Create a Timer which resumes the co-routine when expired

Panel = wx.wxPanel (wx.NULL, wx.wxID_ANY, wx.wxDefaultPosition, wx.wxDefaultSize ) --Starts a Timer to handle drive response
Timer = wx.wxTimer(Panel)
Panel:Connect(wx.wxEVT_TIMER, function(event)
coroutine.resume(DriveComm) --Restart Communications without giving new parameters, we want the old ones to persist
end)

DriveComm = coroutine.create(DriveCommunications(a, b, c, d)

    local saveA = a   --We want to save the parameters passed into the function so they persist after the Yield and Resume
    local saveB = b
    local saveC = c
    local saveD = d

    Calculate transmission

    Send Transmission

    Timer:Start(5) --Start a 5ms timer

    coroutine.yield(U3K) --pause script execution, coroutine becomes suspended

    Read Drive Response

    return data1

    return data2

end )


So I can simply call the coroutine/function by adding the code below to anything like a signal scrpt, plc script, button script, etc. The coroutine should be created in a suspended state at the top of the function.

Code: [Select]
done, data1, data2 = coroutine.resume(DriveComm, a, b, c, d)


It sounds like once you reach the end of the coroutine, it becomes dead and cannot be called again. This is not ideal since I want to periodically call this as long as it is not already running. How do you restart a dead coroutine? Online references aren't yet clear to me about this.

Thanks!

212
Interesting question here...

I am writing a communications script (serial) to some servo drives. I want to abstract the communications so I can use a call like this anywhere in mach.

CurrentPosition = DriveCommunications (Position), where position is a parameter code to be read from the drive.

When DriveCommunications() is called, it assembles an ASCII string complete with a checksum and writes it over the serial port. It then analyzes the response, checks for errors, and returns the result.  The whole thing is a bit more complicated, but that's the just of it.

Once a transmission is sent to the drive, a brief delay (a couple milliseconds) must be enacted to allow the drive to respond before reading the serial buffer. I successfully added a delay using wxTimer for a different script, but that calls a new function which makes returning a value from DriveCommunications() impossible AFAIK. I could also just use a plain old delay, but I don't want to block other functions from executing during this time. I am hoping to get this to the point where I can stream data from the drives and not interfere with other Mach functions.

My question is, is there a way to break out of the middle of a function, but return to execute the remaining code after a short while?

213
Ah! That might explain the confusion. I'm coming from Mach 3 and I am used to placing the jog mode in Incremental before tapping the keyboard arrow keys to bump the axes incrementally. I did not know of the CTRL key stroke for incremental jogging. Can the on screen keypad only be placed in Incremental mode when keyboard jogging is disabled then?

214
SwiftyJ, I would most likely want to use the keyboard for incremental jogging but I also have a touchscreen on the computer so that is an option. Neither allow me to jog incrementally. The mode is always set to continuous.

215
Mach4 General Discussion / Working Script - Universal MPG pendant
« on: March 12, 2019, 08:58:44 PM »
I purchased a 4 axis universal (15 wire pigtail) pendant off of ebay for $50. I have been working with Andy at Warp9TD (Smoothstepper) to get it working with Mach 4.

I won't bother to recreate the instructions, Andy at Warp9TD did a great job here (https://warp9td.com/index.php/faq/faq-pendants-and-mpgs#WireAMultiWirePendant). The things that tripped me up were the counts per detent = 4, and I incorrectly mapped the MPG to ESS Encoder 0 instead of Encoder Aux 0. Once that last one was corrected it worked perfectly.

I haven't had a chance to use it in practice yet, but I expect it will be in my top 3 favorite changes to this machine. In the past I found edge finding to be a huge chore, this will save me so much time.

Following the instructions, I set the velocity and acceleration to 100%. This nearly shook the paint off of the walls when jogging in .01 steps due to the outrageous acceleration on my machine's servos. I found 10% acceleration was snappy but much smoother, I might even go less. There is a small but still noticeable delay (might only be a few dozen milliseconds) from the click of the MPG to motion on the axis. I don't find it annoying as it is only noticeable when moving single steps, but it is present. My step settings are .0001, .001, and .01 which corresponds to (very roughly) 1, 10, and 100ipm respectively when the wheel is spun at a quick clip

In the 3 axis mach profile, I will map the 4th axis on the pendant to the spindle. In my 4 axis profile, it will jog the rotary table.


216
Answered #6 myself. In the Mach Control MPG mapping, I had entered ESS Encoder 0 rather than ESS Encoder Aux 0. User error. :o

217
In addition to the issues I mentioned above, I have 2 more:

5) Clicking The Jog Mode button (Continuous/Incremental) does not allow me to enter Incremental mode. I can change the incremental step size but it always jogs in continuous mode. Is there some special mode I need to be in to allow incremental jogging?

6) I have an MPG which is tied to the ESS Aux Encoder 0 and then that is tied to Mach's MPG#7. When I call mcMPGSetAxis(), I see the correct arguments in the log file, but no motion occurs.  Is there a way I need to enable the MPG jogging?

218
Mach4 General Discussion / Re: Notepad ++ Add M4 API
« on: March 12, 2019, 09:15:19 AM »
Perfect  ;D

Thank you

219
Mach4 General Discussion / Notepad ++ Add M4 API
« on: March 11, 2019, 10:40:26 AM »
Hi All,

Is there any way to integrate the Mach 4 API calls into notepad++ so it recognizes the commands? Pretty much just for the autofill text.


220
Craig, Thanks for the quick response!

I think I roughly understand the interplay between Mach and a motion controller (and I totally agree that it is pretty amazing that Mach works at all). It seems to me that the ESS is not responding appropriately to my limit inputs occasionally, but there might be something else going on. I'll post this question over at the Warp 9 forum and see if anyone has experience with what I am seeing.

I have not modified any of the scripts except for a small chunk of code to control 2 outputs to my power drawbar. Any limit messages that I am seeing must be built into Mach.

I will play around with my outputs to see what all is actually happening. I understood that the ESS pulls outputs LOW when not in control, so I wouldn't expect anything to happen. Maybe there is something about my PDB script that is susceptible to false triggers.

Again, thanks for the response


Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 »