Shop OBEX P1 Docs P2 Docs Learn Events
Variable based one-shot counter — Parallax Forums

Variable based one-shot counter

SarielSariel Posts: 182
edited 2011-06-06 09:49 in Propeller 1
Hello everyone!

A little bit of background on what I am trying to do...

I have a machine that needs to have total cycles counted, and I am vexed by one small problem. The issue I am running into is this machine needs to be stopped periodically so that testing by hand can be done, so there is a chance that it will stop on the sensor that does the actual counting. Since these hand-tests could take an hour or more, using a timed one-shot is not feasible. Can anyone think of a way to do this using variables? I tried, but I am having a problem wrapping my tiny, little brain around it.

Thank you very much for any and all help you guys can offer.

Comments

  • kwinnkwinn Posts: 8,697
    edited 2011-06-06 09:14
    Since this is the prop forum and you mention variables I am assuming you are using a prop for the counting. In that case you could use the count pulse edge to increment the count rather than the signal being high or low.

    If there is a possibility the sensor can cause false pulses because of vibration or slight movement of the mechanics then you may need to add a switch or some other hardware to halt counting. Perhaps the "stop" condition could be sensed in some manner to do this automatically.

    Sorry for the vague replies, but without more details of the machinery this is the best suggestion I have.
  • SarielSariel Posts: 182
    edited 2011-06-06 09:31
    Yeah, I am going to be hooking a prop up to this thing to do some of the external work like LCD displays, cycle counts, all of that. Just some doo-dads to make the engineer's life a bit easier. It is a pretty smooth-running machine, so there is no risk of vibration or other problems. Unfortunately, because of trade secrets, I cannot go into too much detail about it. The best I can say is there is a huge wheel with a small magnet, and a stationary hall-effect sensor in a bracket that just counts revelations.
  • lonesocklonesock Posts: 917
    edited 2011-06-06 09:37
    If there is an expected period, you could track the time between pulses and filter out any counts where the time between pulses falls outside an acceptable range. For example, if you expect the period to be approximately 10 seconds, you can ignore counts where the last trigger was < 2 seconds, or > 20 seconds.

    Jonathan
  • SarielSariel Posts: 182
    edited 2011-06-06 09:37
    Just got to thinking... interesting idea about the "Switch or some other hardware to stop counting". Maybe there is somewhere in the motor controller that I can tap into to achive this. I'll go peek and maybe this thread died before it really started.

    if you expect the period to be approximately 10 seconds, you can ignore
    counts where the last trigger was < 2 seconds, or > 20 seconds.

    Brilliant. I love that idea. If the motor controller has no usable taps, I think that is what I am going to go for.
  • kwinnkwinn Posts: 8,697
    edited 2011-06-06 09:49
    At the risk of drawing someones ire or ridicule I was going to suggest using an optoisolator, diode, and resistors across the motor power leads to produce a "stop/run" signal. Lonesock's idea is simpler to implement though. No additional hardware required.
Sign In or Register to comment.