Hello Guest it is March 29, 2024, 01:40:18 AM

Author Topic: Send PWM signal from Geckodrive G540 to PC  (Read 2241 times)

0 Members and 1 Guest are viewing this topic.

Send PWM signal from Geckodrive G540 to PC
« on: June 28, 2019, 12:41:37 AM »
I'm new to this forum, so sorry if I make some mistake.

However, I've been looking everywhere to see if it'd be possible to send a PWM signal over the parallel port, from a Geckodrive G540 to a PC, as input that Mach3 would recognize (maybe a 50% signal does something, while a 75% does something else).

We're building a machine that needs an input to the computer to tell it to either reverse feed, continue forward, or stay stationary. Our plan was to just use the 4th axis limit switch on the terminal block's pin 4 (we don't have a fourth axis), but I think that's meant to transmit a normal binary on-off signal.

Will that pin work if we somehow send a PWM signal through it? If not, what's the best next move?

Offline Tweakie.CNC

*
  • *
  •  9,196 9,196
  • Super Kitty
    • View Profile
Re: Send PWM signal from Geckodrive G540 to PC
« Reply #1 on: June 28, 2019, 01:19:11 AM »
Quote
However, I've been looking everywhere to see if it'd be possible to send a PWM signal over the parallel port, from a Geckodrive G540 to a PC, as input that Mach3 would recognize (maybe a 50% signal does something, while a 75% does something else).

That would not be possible.

Mach3 can generate a variable PWM signal (based on the S word in the Gcode) which could then be sent via the Parallel Port to the Gecko G540.

Quote
We're building a machine that needs an input to the computer to tell it to either reverse feed, continue forward, or stay stationary

Sounds like an ideal job for Mach3 or Mach4 but we would need some more detail of what you are intending to achieve.

Tweakie.
PEACE

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: Send PWM signal from Geckodrive G540 to PC
« Reply #2 on: June 28, 2019, 10:43:48 AM »
If you convert the PWM signal to an analog voltage, there are motion controllers that can accept analog inputs.
UC300ETH and CS Labs controllers have analog inputs.
Gerry

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

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Send PWM signal from Geckodrive G540 to PC
« Reply #3 on: June 28, 2019, 03:38:38 PM »
Hi,
I assume that you are using a parallel port into which you have your G540 plugged in?

The G540 and parallel port is a great combination and is very simple. It has some limitations, particularly it has very
few inputs. This is fixed by the parallel port itself.

If you had a second port on a PCI card you will have more inputs. You could, and I would recommend, that you set Mach
to treat the second port pins 2-9 as inputs. The second port would then give another 13 inputs and 4 outputs.

You could then use several inputs to signal Mach and with a Brain (ladder logic code) Mach could determine what is required
from the several different options, ie de-code the inputs.

You would require a PCI card with a parallel port. Beware that not all, in fact not many work. I know PMDX sell a card which
has proven to work. You would also need a simple parallel port BOB, and it would need to be bidirectional, a C10 at $23.00
would be a cheap solution.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Send PWM signal from Geckodrive G540 to PC
« Reply #4 on: June 28, 2019, 05:57:24 PM »
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Send PWM signal from Geckodrive G540 to PC
« Reply #5 on: June 28, 2019, 08:46:32 PM »
Wow, I'm amazed at the amount of support here. Thanks everyone!

In response to Tweakie's ask for more detail, we're running a sinker EDM machine with a microcontroller that acts as a voltage sensor. If the capacitor voltage drops too low, the controller tells Mach3 to reverse feed to avoid shorting out, and if it goes too high, it tells it to feed normally. If the voltage is in the middle, the sinker just sits stationary. All the voltage analysis is done on the microcontroller, so the problem is just how we communicate those three different states from the microcontroller to Mach3. Since you said you can't PWM the limit switch pin on the G540, I think that means this isn't possible with only one pin.

In response to ger21, that seems like a good idea. Do you mean that I could get a separate controller (I assume those boards replace a smoothstepper or something similar) and use the controller's pins? I assume I'd need some kind of breakout board to make use of the extra inputs safely.

In response to joeaverage, are you saying I could just plug in another PCIE parallel card, plug in a breakout board, and use that for a ton more inputs? I know I'd still need to process the input (it'll probably just be binary to decimal), and I was planning to use Brains, but other than that is the config as simple as defining the new inputs appropriately in Mach3? In that case, this seems like it'd give us a ton more input options.

Another thing though, I just saw something online about how you can put multiple limit switches on one pin. That would free up an extra pin, and then (with two pins) I could have up to four states, which would be fine. Would you all recommend putting multiple switches on one pin? It seems very simple but I know I may be missing something.
Re: Send PWM signal from Geckodrive G540 to PC
« Reply #6 on: June 28, 2019, 10:14:29 PM »
Hi,

Quote
Another thing though, I just saw something online about how you can put multiple limit switches on one pin. That would free up an extra pin, and then (with two pins) I could have up to four states, which would be fine. Would you all recommend putting multiple switches on one pin? It seems very simple but I know I may be missing something.

I have always argued against linking all the switches to one, or a few pins. I'm a lone voice against this practice however.
Many people do it just exactly to free up another input for some other purpose. My concern is that when you link all your
limits and home switches to one pin then Mach loses the ability to distinguish between a limit event or a home event and cant
even distinguish which axis.

If however you use a second parallel port card now you could have one pin for each home switch, one pin for each limit switch,
a total of 9 input pins and still have inputs to spare.

If you were to use an Ethernet SmoothStepper (ESS) you could have up to 51 inputs and outputs, with a maximum of 31 inputs.
Is that enough? If not consider a UC300, now you have up to 85 inputs and outputs, which if I'm not mistaken, means you
can have up to 57 inputs.

As interesting as that is.....there maybe a solution for your EDM sinker problem.

With Plasma Tables a very important control strategy is THC (torch height control). If the torch height is too high the voltage
of the plasma arc increases beyond optimum. A voltage measuring device (THC unit) would signal Mach 'Torch Down' and
Mach will lower the torch.  This is usually done in realtime such that the torch voltage is controlled in a feedback loop.

You might be able to use the same strategy for your EDM machine. If you have a microcontroller that determines whether
the die needs to go up it could signal Mach to do so using THC_UP and THC_DOWN signals. If you do not have a up/down,
ie binary signal, you could make it by having a comparator and a reference voltage, a simple electronic circuit. It would
produce a signal up or down (binary).

I presume that you need the die to retract very quickly after detecting an impending short circuit event? If you need response
in the sub millisecond range then you must have a realtime controller. While not without its shortcomings Machs parallel port
is such a realtime controller and can support THC. Most of the external controllers like the ESS or UC300 also support
THC in Mach3.

Recently Mach4 has a script based THC feature added. It is done in software and is an order of magnitude slower than a realtime
THC solution, we anticipate in the range of several milliseconds. The advantage of that solution is that you can script your own
solution with all the processing power that Mach can bring to bear. The only question is.....'will millisecond response be
adequate to prevent my sinker die from shorting out?'

At the current time there are only two controllers that support realtime (read fast) THC support in Mach4, including the ESS.
Effectively Mach4 requires an external controller like the ESS. Mach4 does have a parallel port called Darwin ($25 licence fee applies)
but it does NOT nor will ever have realtime THC support.

The upshot is that if you wish to go for a Mach4 solution and thereby take advantage of the superior scripting flexibility that it brings
then you would require not only the purchase of Mach4 ($200) but an ESS ($190) also. I would guess therefore that you would
wish to stick with Mach3 and avoid the cost. I think you could use some workarounds to get Mach3 to perform as you wish
but you will have to code in VB, and good luck to you. There are plenty of VB masters on the forum but I'm not one of them.
In fact it was to avoid VB that I moved to Mach4 in the first place. If you want to do a Mach4 solution I'll back you but I'm
not going to 'bust a gut' over Mach3.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Send PWM signal from Geckodrive G540 to PC
« Reply #7 on: June 29, 2019, 02:48:14 AM »
Quote
My concern is that when you link all your limits and home switches to one pin then Mach loses the ability to distinguish between a limit event or a home event and cant
even distinguish which axis.

From what I've read, Mach3 can home each axis in sequence so that it knows which one is homing when. I know that would be slower, but other than that is there another reason why it's worse? Also, should I have separate home switches and limit switches? The machines I've used, for example, on the x-axis, have one switch that homes and limits on the left and another switch that homes and limits on the right, and all of those are hooked to one pin. Admittedly each axis still has its own pin. I think this is how the G540 expects you to set it up too since it only has one pin per axis.

Quote
If you were to use an Ethernet SmoothStepper (ESS) you could have up to 51 inputs and outputs, with a maximum of 31 inputs. Is that enough? If not consider a UC300, now you have up to 85 inputs and outputs, which if I'm not mistaken, means you can have up to 57 inputs.

This sounds great. We were considering a SmoothStepper anyway, so this sounds like this is an easy way to go. I assume I'd still want optical isolation (or a breakout board with the same) on those extra inputs? Either way this sounds like a solution.

As to what you said about THC, I like that even better, but from what I've read THC only tells one axis (presumably the Z axis) to move up/down. I'm concerned that if I wanted to do more complex cuts it wouldn't work right; if, say, I had a sinker that was angled or flanged. Also, does that mean that the sinker would always be moving, since THC only has up and down? I also wonder if the sinker might plunge too far if it somehow bored all the way through; then it'd never have the signal to stop because the capacitor voltage would stay high. What part of the THC system prevents that? Of course, if THC allows more complex control, that would solve this all. I still feel like the best solution would be to forward/reverse feed.

Also, can I still get the few-millisecond (longer) response time you mentioned out of a Mach3 Brain? I'd guess a few milliseconds will be fine for this. I've actually found VB code that does this online, so I shouldn't need you (or anyone else) to bust their guts.

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Send PWM signal from Geckodrive G540 to PC
« Reply #8 on: June 29, 2019, 03:01:54 AM »
if you want to go the "VB script" road, you have to remember that there is only one Task (script) witch is running continious
(macropump). and this macro has a 10ms timestamp (theoreticly).
Brains are a lot faster but  there Comes the external Controller into the Focus.
i never had something else than CSLab Controllers, but with them the update of Inputs takes 10ms as well.
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Send PWM signal from Geckodrive G540 to PC
« Reply #9 on: June 29, 2019, 03:41:57 AM »
Hi,

Quote
From what I've read, Mach3 can home each axis in sequence so that it knows which one is homing when. I know that would be slower, but other than that is there another reason why it's worse?

Yes, by all means it will work. As I stated I am a lone voice is this matter. When you crash your machine because Mach can't
distinguish between an X axis X++ event from a Z axis Z-- this conversation will come to mind....'I bloody told you so'.

Quote
I assume I'd still want optical isolation (or a breakout board with the same) on those extra inputs?

I use Homan Designs MB2 bi-directional breakout boards which don't have optical isolation. I have been using them for over five
years and have had no issues due to the lack of isolation. Electronics is my thing, so if I determine a situation where I suspect
that optical isolation is required then I make it to suit. What I do not do is demand that all inputs have optical isolation.
That would make bi-directional boards impractical. If you are of the opinion that optical isolation is mandatory then be prepared
to pay for the breakout boards that can do it.

Quote
THC only tells one axis (presumably the Z axis) to move up/down. I'm concerned that if I wanted to do more complex cuts it wouldn't work right; if, say, I had a sinker that was angled or flanged.

That is correct. You are adapting a realtime, that is to say an 'on board' feature over which you have no (software)  control, to do a job
for which it was not intended. There will be limitations and incompatibilities. Whether you can live with them or mitigate them
remains to be seen.

You could of course go to a Gallil motion controller. That is programmable at board level, it is the gold standard among motion
controllers. Expect to start at $2000 for a three axis controller. You want good....you can have it, you just have to pay up!!.

Quote
Also, does that mean that the sinker would always be moving, since THC only has up and down?

In short yes, but when at optimum voltage it will move one step up, say 1um, then one step down, say 1um. In such a manner
it is quasi stationary. I think you will find most controllers, each of which enacts THC in their own way, have a 'voltage window'
such that if the actual voltage is within the target range THC_UP and THC_DOWN signals are suspended.

Quote
I also wonder if the sinker might plunge too far if it somehow bored all the way through; then it'd never have the signal to stop because the capacitor voltage would stay high. What part of the THC system prevents that?

Most THC plugins have some means of anti-dive control. For instance if a plasma cuts over a previously cut track its voltage
will spike high which in turn causes the THC unit to cause the torch to dive low. This is undesireable and much like the
break through event you have described. Most controllers offer some variation of anti-dive control. The sophistication and performance
of the anti-dive strategies offer insight into which control is better suited than another.

Quote
I still feel like the best solution would be to forward/reverse feed.

Yes I can well imagine that would be the best solution. That largely precludes THC as viable solution for a die sinker.
As TPS has pointed out that Mach3 has a defined macropump rate which would determine that a software defined feedback
loop would be very slow with a closed loop bandwidth of 5Hz or less. This I suspect would be too slow for a die sinker.

Mach4 however has a much faster, and within limits programmable PLC rate, which would allow for a software enacted feedback
control loop with a bandwidth of 20 maybe as high as 50Hz. Certainly the Mach4 THC module which I described is intended
as a software only solution for THC, so NFS believe that it has sufficient bandwidth.

If you were going to do a software solution that would accommodate things like angle cuts, flanged cuts and a mechanism to
prevent break through then Mach4 is by far the better platform to code it. TPS is one of the VB masters to whom I have
previously referred. If he is of the opinion that it can be done with VB and Mach3 then I'm sure it could be. If however he
is doubtful then I wouldn't go there.

Brains, also called PMC in Mach4 are fast but still far from realtime. To whit.....no-one has ever been able to write a Mach3
Brain that has successfully enacted THC, its just too slow.

NFS has however released the first and only software enacted THC control loop in Mach4. You make the decision.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'