Go Down

Topic: Sorting digital signals (Read 4438 times) previous topic - next topic

bitoff_arduino

#15
Jul 21, 2017, 02:13 pm Last Edit: Jul 21, 2017, 02:19 pm by bitoff_arduino
Not really. Or not at all.

First let's deal with "not at all"

If I go back to your Original Post you said that P2 is a subset of P1. But in your diagram you seem to be treating P2 as a single pulse. A single pulse will always be a subset of a stream of pulses so the concept of subset doesn't make much sense.

If you are using a single pulse in P2 as a simplification then I don't think that makes sense. What works for one pulse won't translate to matching a train of pulses.

And now let's deal with "not really" - assuming that your description in the Original Post was wrong and you really only need to make decisions based on a single P2 pulse.

Are you saying that there should be an output if P2 is high and P1 is low? If so that should be easy to program.

And your picture in Reply #11 is very hard to read

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

bitoff_arduino

This is definitely a job for a state machine, there is state and time in this decision process as the yellow
pulses do not completely cover the red pulses, so combination logic cannot do the job.

Use micros(), not delay or delayMicroseconds, if you want to be responsive to changing inputs at all
times.

I suspect you need at least these states:

not in a pulse
in a yellow pulse only (is this valid?)
in a red pulse (for a short time only)
in a red pulse for a long enough time without seeing the yellow pulse - output HIGH
in a red + yellow pulse
in a red pulse after a yellow went away

You need to record the time when you transition from not in a pulse to in a red pulse,
and then check the elapsed micros for deciding when to transition to the output HIGH state.
Thank you this is the closest to a solution, combination solution definitely does not work here as they do not overlap perfectly.

I have never done state machine, could you write a short example of it directed towards this problem. I would be so much thankful to you.

Jiggy-Ninja

Yes the yellow is a subset of red. But they are out of sync in time. Thats why they dont overlap perfectly.
This complicates things.

How large is the offset? Is it consistent? What is the maximum and minimum mark and space times of the pulse train?
Hackaday: https://hackaday.io/MarkRD
Advanced C++ Techniques: https://forum.arduino.cc/index.php?topic=493075.0

bitoff_arduino

This complicates things.

How large is the offset? Is it consistent? What is the maximum and minimum mark and space times of the pulse train?
The offset is always consistent. Space time of pulses vary according to the experiment.

aarg

...and mark time of pulses?
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

bitoff_arduino

...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

PaulMurrayCbr

So,

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

or just:

digitalWrite(outPin, digitalRead(in1Pin)  && !digitalRead(in2Pin));
http://paulmurraycbr.github.io/ArduinoTheOOWay.html

Robin2

#22
Jul 21, 2017, 06:34 pm Last Edit: Jul 21, 2017, 06:34 pm by Robin2
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
Two or three hours spent thinking and reading documentation solves most programming problems.

dougp

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.
Everything we call real is made of things that cannot be regarded as real.  If quantum mechanics hasn't profoundly shocked you, you haven't understood it yet. - Niels Bohr

No private consultations undertaken!

J-M-L

#24
Jul 21, 2017, 07:25 pm Last Edit: Jul 21, 2017, 08:12 pm by J-M-L
Isn't #12 enough?

Edit: NO :)
Hello - Please do not PM me for help,  others will benefit as well if you post your question publicly on the forums.
Bonjour Pas de messages privés SVP, postez dans le forum directement pour que ça profite à tous

Robin2

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
Two or three hours spent thinking and reading documentation solves most programming problems.

J-M-L

#26
Jul 21, 2017, 08:11 pm Last Edit: Jul 21, 2017, 08:16 pm by J-M-L
Ignore my post - answered without reading all the intermediary replies which was a bad idea ;)

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?
Hello - Please do not PM me for help,  others will benefit as well if you post your question publicly on the forums.
Bonjour Pas de messages privés SVP, postez dans le forum directement pour que ça profite à tous

Jobi-Wan

#27
Jul 21, 2017, 09:26 pm Last Edit: Jul 21, 2017, 09:27 pm by Jobi-Wan
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?

Robin2

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
Quote
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 :)

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

J-M-L

Yeah OP not very active :)

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

Hello - Please do not PM me for help,  others will benefit as well if you post your question publicly on the forums.
Bonjour Pas de messages privés SVP, postez dans le forum directement pour que ça profite à tous

Go Up