Pattern Detection 1 cycle

Thread Starter

Christopher Siguan

Joined Nov 4, 2018
10
Hello guys, how to achieve this using logic gates or other methods.

How to detect this pattern below as one complete cycle?

Initial: (First)
A1 = 0
B1 = 1

Then: (Second)
A2 = 1
B2 = 0

Final: (Third) Back to Initial
A3 = 0
B3 = 1

Equals = 1 complete cycle
Output = 1

Will this involved some gates latching?

Thanks for any input.
 

AlbertHall

Joined Jun 4, 2014
12,625
If no other states are possible then the output is simply a copy of the B input (or the inverse of the A input.
If the other input states are possible and to be considered then you should specify actions for all those possible states.
 

dl324

Joined Mar 30, 2015
18,326
Post a timing diagram. Your usage of A1/B1, A2/B2, ... is ambiguous; we don't change signal names when they change state.
 

WBahn

Joined Mar 31, 2012
32,823
Is this homework of some kind? If so, we can move it to Homework Help where it will get more focused attention.
 

Thread Starter

Christopher Siguan

Joined Nov 4, 2018
10
hahah..yeah I know guys it sounds homework but it isn't.

So, basically the Rpi will send a signal to A1 to rotate the motor foward to B1, B1 will have a micro switch and when activated it will reverse the motor and back to A1, A1 micro switch will detect that the reversing is complete. and then stop the motor.

But then another sequence has to be activated after the 1 cycle is complete. Basically, after 1 cycle is completed another motor needs to be activated.

I'm thinking of nested while loops to check GPIO pin status but then it might be CPU intensive and crash Rpi.

Any ideas on how to accomplish this?

Thanks.
 

Thread Starter

Christopher Siguan

Joined Nov 4, 2018
10
Post a timing diagram. Your usage of A1/B1, A2/B2, ... is ambiguous; we don't change signal names when they change state.
Yes it sounds ambiguous, i'm planning to use a micro switch. So, basically when it's at rest its zero the moment the motor move forward it will release the micro switch and thus change its state.

The motor spindle has an extension that will depressed the micro switch so the moment it moves forward it will release the spindle and micro switch will change its state. So, A and B are just two micro switches, the number A1, A2, A3 represents the movement.

A1 - depressed state
A2 - micro switch is release and motor is moving forward
A3 - micro switch is depressed again after 1 cycle the motor has reversed back
 

LesJones

Joined Jan 8, 2017
4,511
For my logic there is only one signal A for the state of the micro switch and that can only be A=1 or A =0. If we say for the depressed state of the micro switch A = 1 then A strarts out as 1 (Your state A1) it then changes to a zero (Your state A2) It then changes back to a 1 (Your state A3)
A picture of the device showing the device and micro switches would help. You only have two logic signals A & B From your first post it looks as though you have 6 logic signals.
You have three states.
State 1 A = 0, B = 1
State 2 A = 1, B = 0
State 3 A = 0, B = 1

In logical terms state 1 and state 3 are the same so you realy only have 2 states. Also B always equals NOT A

I have just noticed that AlbertHall has already said what I have just said in post #2 Fist time I read the thread I was confused by you six apparent logic signals.

Les.
 

LesJones

Joined Jan 8, 2017
4,511
Looking at your description of the physical system it seems that there is one micro switch at the rest position (we will call that switch B and it will be closed in the rest position. so we will say B = 1.) There is a second micro switch A at the point where the motor is reversed. We will say it is closed when the motor is at this point so A = 1 at this point. The way I see it there are more than 3 states.

State 1 System at rest position (Not moving.) so B = 1 and A = 0 Forward drive off (= 0) Reverse drive off (= 0)
State 2 Motor is driving forward between rest position and reversing position. so B = 0, A = 0 Forward drive on (= 1) Reverse drive off (= 0)
State 3 Motor reaches reversing position still moving forward so B = 0. A = 1, Forward drive on (= 1) Reverse drive off (= 0)

I assume that you use the signal from micro switch A to reverse the motor. You may also stop the motor at this point for a time. If so this woud be another state.

State 4 The motor has reversed but not yet moved away from micro switch A so B = 0, A = 1 Forward drive off (= 1) Reverse drive off (= 1)
State 5 The motor has moved away from micro switch A so B = 0, A = 0 Forward drive off (= 1) Reverse drive off (= 1)

The motor reaches Micro switch B which I assume causes the motor to stop. so we are back at state 1.

This means that you have 4 signals Switch A, switch B, drive forward and drive reverse.

Have I described your system correctly ?

Les.
 

Thread Starter

Christopher Siguan

Joined Nov 4, 2018
10
Looking at your description of the physical system it seems that there is one micro switch at the rest position (we will call that switch B and it will be closed in the rest position. so we will say B = 1.) There is a second micro switch A at the point where the motor is reversed. We will say it is closed when the motor is at this point so A = 1 at this point. The way I see it there are more than 3 states.

State 1 System at rest position (Not moving.) so B = 1 and A = 0 Forward drive off (= 0) Reverse drive off (= 0)
State 2 Motor is driving forward between rest position and reversing position. so B = 0, A = 0 Forward drive on (= 1) Reverse drive off (= 0)
State 3 Motor reaches reversing position still moving forward so B = 0. A = 1, Forward drive on (= 1) Reverse drive off (= 0)

I assume that you use the signal from micro switch A to reverse the motor. You may also stop the motor at this point for a time. If so this woud be another state.

State 4 The motor has reversed but not yet moved away from micro switch A so B = 0, A = 1 Forward drive off (= 1) Reverse drive off (= 1)
State 5 The motor has moved away from micro switch A so B = 0, A = 0 Forward drive off (= 1) Reverse drive off (= 1)

The motor reaches Micro switch B which I assume causes the motor to stop. so we are back at state 1.

This means that you have 4 signals Switch A, switch B, drive forward and drive reverse.

Have I described your system correctly ?

Les.
Hi Les yes, basically that is how it will work.

Once the motor is back at state 1, there would be sequence 2 that does same operation.

So that is where i am really confused how to achieve this, if it is possible.

How i will detect the sequence 1 is done and the circuit is ready to start sequence 2.

Can this be done by logic gates? or it will involved a much more complex process which I don't know, :)

Thank you in advance for any ideas and inputs.
 

LesJones

Joined Jan 8, 2017
4,511
First you need to detect micro switch A (The one that detects the position to reverse.) And use this to set a latch. I think the simplest way to do this is with a D type flipflop. The data input to the flip flop would be tied high. The clock input would be connected to the A micro switch output via an inverter. When the A micro switch is actuated it's output goes high whch causes the ouput of the inverter output to go low. (Nothing happens to the output of the flipflop on the high to low transition of the clock pulse.) When the output of micro switch A goes low (As the motor starts in the reverse direction) the output of the inverter goes high. At this point the low to high transition of the clock transfers the state of the data input to the Q output. As the data input is held high the Q output goes high. if you do a logical AND of the Q output and the output of the B micro switch the output of the AND gate goes high when the motor returns to the rest position. Once you have used this information that the cycle has completed you will have to pulse the reset pin of the flipflop ready for it to indicate another full cycle has finished.

Les.
 

Thread Starter

Christopher Siguan

Joined Nov 4, 2018
10
Hi Les, Thank you I will give it a shot and update this. Cheers!

Hi Les, for the clock input what IC to use? Thanks.
 
Last edited by a moderator:

LesJones

Joined Jan 8, 2017
4,511
I don't understand your question. The description of the logic was conceptual. You need to provide more information on your project, A proper description of the mechanical side (Probably with pictures and the schematic of the existing circuit. For example you have given no information on if the micro switches are only to be connected to this add on logic or if the contacts are allready connected to something else. Threre are also other practical considerations such as debouncing micro switch contacts. It may even be cheaper to use a small microcontroller such as a PIC12F1840 or ATtiny 13a etc. You have given no information of you skill level so we have no idea what methods are practical to implement. As you aready seem to be using a Raspbery Pi you may even be able to implement this function in software. I would not be able to suggest how to do it in software as I am useless at "C" programming. (I work with assembler.)

Les.
 
Top