Hello Guest it is March 28, 2024, 08:38:11 AM

Author Topic: short pulse output with macro  (Read 5856 times)

0 Members and 1 Guest are viewing this topic.

short pulse output with macro
« on: April 26, 2015, 12:42:00 AM »
I am sending pulses to arduino from Mach with coding similar to this

activatesignal(output1)
sleep(110)
deactivatesignal(output1)

If I reduce the delay below 100 then most of the time arduino doesn't pick the deactivate signal. Is there a workaround for this. I need to output a pulse of 50 ms.

Zafar

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: short pulse output with macro
« Reply #1 on: April 26, 2015, 05:45:35 AM »
It seems like you have two issues. 1) generating accurate pulses below 100ms and 2) having the Arduino detect the trailing edge. The two shouldn't be related so more info would help.

As far as 1), in my experience sleeps below 100ms do tend to be inaccurate.

Could you not have the Arduino just detect the leading edge of an arbitrary length pulse and do the 50ms timing itself?
Re: short pulse output with macro
« Reply #2 on: April 26, 2015, 10:03:55 AM »
Arduino sometimes skips the leading edge too if it is less than 100 ms. I guess it is due to 100 ms refresh cycle for macros. I actually need to send output to arduino within 10 ms of an input. Seems like it is not possible with macros. It is a punching machine capable of doing 350 ppm. But because of this problem I am getting just 200 :(

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: short pulse output with macro
« Reply #3 on: April 26, 2015, 11:11:29 AM »
Arduino sometimes skips the leading edge too if it is less than 100 ms.

Sorry but I don't get this. How can it miss the leading edge due to the pulse width - doesn't make sense.

I actually need to send output to arduino within 10 ms of an input.

So the Arduino sends a pulse to Mach and within 10ms Mach has to send a pulse back? is that correct?

Sorry I'm just a bit confused as to what this has to do with your original requirement for a 50ms pulse from Mach to your Arduino.
Re: short pulse output with macro
« Reply #4 on: April 26, 2015, 11:48:54 AM »
Sorry but I don't get this. How can it miss the leading edge due to the pulse width - doesn't make sense.

It's actually like this:
In a macro named M20 I include the commands

activatesignal(output1)
sleep(80)
deactivatesignal(output1)

Output1 goes directly to arduino which turns on a solenoid which causes press shaft to turn. When I execute M20 in MDI then sometimes the arduino simply doesn't register it.

I am now planning to use arduino interrupt pins and trigger the solenoid on the leading edge. This might solve the problem.

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: short pulse output with macro
« Reply #5 on: April 26, 2015, 11:57:52 AM »
I am now planning to use arduino interrupt pins and trigger the solenoid on the leading edge. This might solve the problem.

I think you can count on it.  ;)

Offline beefy

*
  •  138 138
    • View Profile
Re: short pulse output with macro
« Reply #6 on: July 21, 2015, 05:39:18 PM »
I am sending pulses to arduino from Mach with coding similar to this

activatesignal(output1)
sleep(110)
deactivatesignal(output1)

If I reduce the delay below 100 then most of the time arduino doesn't pick the deactivate signal. Is there a workaround for this. I need to output a pulse of 50 ms.

Zafar

I was using that exact same code for my plasma torch to do hole centre marking. Once I started going under 100 the torch would not even fire. It would be good to have been able to check if there was even a signal being generated at the output pin but don't have such instrumentation.

I ended up designing an Arduino circuit board to give me the pulse duration I needed (plus a few other features, good old Ardy).

Keith.