Sorting digital signals

aarg:
...and mark time of pulses?

by mark time if you mean the time for which the pulse is HIGH, then it is about 50 - 80 microseconds

So,

loop() {
digitalWrite(outPin, digitalRead(in1Pin) != LOW && digitalRead(in2Pin) == LOW ? HIGH : LOW);
}

or just:

digitalWrite(outPin, digitalRead(in1Pin) && !digitalRead(in2Pin));

bitoff_arduino:
I want to have an output HIGH when the pulse is shorter, i.e. at 2,5,8.

Your diagram is certainly much clearer but I can't say the same for the description of the problem.

I can see where @MarkT is coming from but I'm not sure it captures the issue.

The problem I have is your comment "I want to have an output HIGH when the pulse is shorter". But you can only know that the pulse is short AFTER it has happened.

For example (referring to the red diagram in Reply #15) when pulse 3 starts it is impossible to know whether it will be a long pulse or a short pulse. And by the time you have figured that it was a short pulse it will be too late to do anything.

This looks more and more like an XY problem. Please tell us what all this is for and someone might be able to give some useful advice.

...R

bitoff_arduino:
I have two digital pulses and would like to generate an output based on some boolean logic.

Would a hardware solution be acceptable? I think this could be done with a 74HC123 timer.

Isn't #12 enough?

Edit: NO :slight_smile:

J-M-L:
Isn't #12 enough?

Assuming you mean Reply #12 I don't see how that limits output to the situation where the red pulse is short.

...R

Ignore my post - answered without reading all the intermediary replies which was a bad idea :wink:

The state machine would be

States are rest, waiting for trigger, false event, active

You start at rest, when you receive a red HIGH you go to waiting for trigger, if yellow appears in a given timeout and red stayed high then you go to false event state otherwise you go to active and wait until red goes back down to go to rest again.

Would that work?

If i understand correctly, you want to:

  • on rising edge of red:
    set 'did_i_see_yellow' variable to false

  • all the time:
    if yellow is high, set did_i_see_yellow to true

  • on falling edge of red:
    if you didn't see yellow, you have a complete red pulse with no yellow in it, so set pin C high

How long should pin C remain high? (i.e. when should it go low again?)
At the next rising edge of red? or yellow? or either?

J-M-L:
Would that work?

I may well be misunderstanding what is in your mind but I don't think it complies with this requirement from Reply #15

I want to have an output HIGH when the pulse is shorter, i.e. at 2,5,8. Else output LOW.

However this all seems totally academic as we seem to have a lot more interest in the problem than the OP has :slight_smile:

...R

Yeah OP not very active :slight_smile:

Looking at his pictures he is saying he wants the red bar when there are no yellow bar appearing/overlapping

J-M-L:
Looking at his pictures he is saying he wants the red bar when there are no yellow bar appearing/overlapping

And only the narrow red bars, if I understand it correctly.

...R

Which post#26 state machine would do

J-M-L:
Which post#26 state machine would do

Your Reply #26 does not mention measuring the width of the red pulse.

Also, I have the impression that the OP wants the output to be HIGH simultaneously with the short red pulse being HIGH and that the output should never be HIGH if the red pulse is long.

...R

Ok my assumption based on the drawing was that yellow was always low during the short red pulse whilst yellow was going high at some point during the long red pulses...

Who knows... (besides the OP but seems MIA)

Robin2:
Your Reply #26 does not mention measuring the width of the red pulse.

Also, I have the impression that the OP wants the output to be HIGH simultaneously with the short red pulse being HIGH and that the output should never be HIGH if the red pulse is long.

...R

Yes Exactly. I understand that with the Puls Width method, i can only get an output after the short pulse has occured.

bitoff_arduino:
Yes Exactly. I understand that with the Puls Width method, i can only get an output after the short pulse has occured.

I don't know of any arrangement that could identify a short pulse before the pulse is complete unless there is a repeating sequence in which the short pulse always occurs after some other series of pulses.

For example pulse K always appears after the sequence A M B so if you can identify that pulses A, M and B have happened you would know that the next one would be a K - always. So you would measure A, M and B but there would be no need to measure K.

We are now at Reply #35 and we still have no idea what you are trying to create even though I asked you to tell us in Reply #22.

...R

I have a camera system which images some biological samples and simulatenously produces digital signals based on image characteristics.

Now I would like to sort some of these images based on this digital signal.My signal of interest is the one with shorter pulse width.

The suggested state machine solution looks good to me as it looks to reject the long pulse width signals and hence generates an output for the remaining short pulse width signals.

The pulse width method would produce an output after checking the pulse width of signals, which if i have understood correctly would require keeping track of pulse width of all digital pulses and
generating an output whenever pulse width is smaller than a threshold.

Robin2:
unless there is a repeating sequence in which the short pulse always occurs after some other series of pulses.

This is not the case, there is no repetition.

bitoff_arduino:
This is not the case, there is no repetition.

You are only replying to small pieces of the comments. You need to describe the whole system.

In Reply #34 you seem to be implying that identifying (or responding to) the short pulse after it has happened is not satisfactory Then in Reply #37 you seen to acknowledge that you can't detect the short pulse until afterwards but you have not linked the two issues so it is very hard to know what you really need.

Can you describe what you want to happen in words and without graphs taking account of all that we have said. Never mind whether it can be done or how it might be done. Just tell us in detail what your camera is perceiving and exactly what you want to happen and when.

I suspect it can be done, but until you tell us what is needed I can't suggest how.

...R

Robin2:
You are only replying to small pieces of the comments. You need to describe the whole system.

In Reply #34 you seem to be implying that identifying (or responding to) the short pulse after it has happened is not satisfactory Then in Reply #37 you seen to acknowledge that you can't detect the short pulse until afterwards but you have not linked the two issues so it is very hard to know what you really need.

I suspect it can be done, but until you tell us what is needed I can't suggest how.

...R

Thank you so much for all the comments.

Output after a pulse has occured is acceptable for now but it's not the preferred solution.

The camera just outputs these two digital signals. This is the data i receive, and whatever needs to be done has to be done after the camera stage. I just want an arduino to receive these two digital signals and give me an output when the short pulses occur.