Gtojacob

Help: Basic Program Question

11 posts in this topic

I need help to make a program for school using ONLY 1 counter, And ONE Push button, And one output. Basically the push button needs to be pressed 5 times and the output turns on. Press the button 5 more times output turns off. 5 more times the output turns on (and so on). I am using the DN bit off the counter to seal in the output, then resetting the counter but I can not figure out how to get the output to turn off after the second 5 pushes of the button. can use, Latch/unlatch, ONS. No second counter is allowed or math instruction, timers, sequencer, etc. Any help is greatly appreciated.

Share this post


Link to post
Share on other sites

Latch / Unlatch is the key to your problem. Counter done and output not on, latch. Counter done and output on, Unlatch. Use the ONS in front of the latch unlatch.

Share this post


Link to post
Share on other sites

Is a compare instruction considered a math instruction?

Share this post


Link to post
Share on other sites

Another approach

counter preset = 10

think about count accumulated in binary what bits are on when count = 5 

turn on output and hold in

counter dn can reset and break hold in for output

 

 

Share this post


Link to post
Share on other sites

Sorry forgot to mention counter needs to have a preset of 5. and compare instruction is not allowed .

Share this post


Link to post
Share on other sites
8 hours ago, vds said:

Counter.jpg

If you don't put a one shot between the button and counter the switch contacts will "bounce" and you'll get a burst of counts.

Share this post


Link to post
Share on other sites
3 hours ago, Michael Lloyd said:

If you don't put a one shot between the button and counter the switch contacts will "bounce" and you'll get a burst of counts.

I politely disagree - the CTU instruction will itself look for a rising edge on the enable. The only true way to fix this is to use a short de-bounce timer - but...well ... that's an "advanced" instruction for this exercise... ;-)

cheers!

vds

Share this post


Link to post
Share on other sites
9 hours ago, Gtojacob said:

Sorry forgot to mention counter needs to have a preset of 5. and compare instruction is not allowed .

Search the forum for flip flop. The flip flop will control the output

counter done will toggle flip flop

1 person likes this

Share this post


Link to post
Share on other sites
20 hours ago, Michael Lloyd said:

Latch / Unlatch is the key to your problem. Counter done and output not on, latch. Counter done and output on, Unlatch. Use the ONS in front of the latch unlatch.

Counter would need to be reset parallel with latch/unlatch also 

Share this post


Link to post
Share on other sites

This logic works and fulfills all of your requirements, single counter, preset of 5 and no math instructions used. Tested operation and it works. Not sure if I should post this, as this is a school assignment but I see that other forum members have already posted logic.

CCI09262017.JPG

1 person likes this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now