Jump to content




Testing Redstone Pulse Width


  • You cannot reply to this topic
4 replies to this topic

#1 Yurameki

  • Members
  • 25 posts

Posted 10 July 2012 - 04:27 PM

Ok, pretty simple issue I think. I know how to fire something when a bundled input lights up or check to see if it's on. But I want to come up with a CPU efficient and accurate way to measure a redstone pulse in ticks when it comes in. Was hoping someone could provide some guidance or if I should just be using tiny sleep increments and check to see if the input is still on each tick? Thanks!

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 10 July 2012 - 05:46 PM

I don't know what the resolution of os.clock is, but if it is fine enough, you could keep track of the start and end times of the pulse.

What is this for?

#3 Yurameki

  • Members
  • 25 posts

Posted 10 July 2012 - 06:22 PM

I'm working on a pretty complicated inventorying system taking a lot of different inputs from different devices. Working first with redstone tubes to try to get it functional. Basically I need the computer watching bundles on 3 sides and counting accurate pulses which may vary in width.

#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 11 July 2012 - 05:20 AM

If all you need is to count pulses (and don't care about the width), you'd be better off just using os.pullEvent() to wait for a redstone change to occur, then handling it appropriately.

#5 Yurameki

  • Members
  • 25 posts

Posted 11 July 2012 - 05:27 AM

I may need to figure out widths to recognize different signal types...not sure that's why I'm looking into how to do it in case I need to.

That said, if I set event handles for state changes and when it changes immediately register another event for a state change I should in theory never miss it turning off so I know to start watching for the same pulse, right?





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users