How hard would this be to do?

Thread Starter

mwh624

Joined Nov 6, 2009
28
I want to create a program that has two "modes". The first mode will be a "teach" mode and the second will be a "run" mode. I'd have a switch to toggle between modes. When in "teach" mode, the program records the sequence of a single push button. "On" would be when the button is pushed and "off" would be when the button is not pushed. When switched to "run" mode, the program would execute the recorded sequence.

From the reading up I've done, I'd have an infinite loop executing the "run" sequence with an interupt to execute the "teach" sequence.

Am I on the right track?
 

kubeek

Joined Sep 20, 2005
5,794
I am not sure if you want the sequence to repeat indefinitely or just once, but that doesn´t matter much. Recording and playing back a sequence of clicks should be very easy to do.
Are you familiar with some brand of microcontrollers or are you starting from scratch?
 

Thread Starter

mwh624

Joined Nov 6, 2009
28
I am pretty much starting from scratch. Always wanted to learn and figure I now have a somewhat challenging (for me) but attainable project goal as a reason to learn.
I have been mulling over the internet, trying to learn what I can from posted sample code, data sheets and forums and am fairly certain I will be using a PIC micro controller. Initially I was leaning towards the 16F877a as there seems to be a lot of useful information and sample projects posted, however, I wouldn't be against using a smaller and cheaper one as the 16F877a seems to be overkill for what I am looking to do.

Any recommendations on a PIC for my application?

I have downloaded MPLAB IDE and will be programming using HI-TECH C.

I will want the "run" sequence to repeat on an endless loop.

Thanks for taking the time to read.

-Matt
 

ErnieM

Joined Apr 24, 2011
8,377
Sorry but just what is the unit learning? How many times the button was pressed, or how long it was pressed (and released) each time?

There is nothing hard to do here as it is running at "human" speed. But how many pressed for how long and how accurate needs to be known before the amount of memory can be computed.
 

John P

Joined Oct 14, 2008
2,025
You haven't said what the processor is meant to do in response to the button, or when playing back a sequence. And how long do you want the sequence to be, how much precision is there in the timing?

My favorite is the PIC16F690. Cheap and versatile.
 

Thread Starter

mwh624

Joined Nov 6, 2009
28
Thanks all for taking the time to read.
In my end product, I will be driving a small DC motor. The PIC will output to some kind of transistor as the motor is 6 volts 2A.

Overall, I guess what I am "teaching" the pic is the output sequence where a button pushed in = HIGH = dc motor ON and when the button is not pressed = dc motor OFF. I'd like to be able to "teach" up to five ON-OFF cycles.

A sample off the complete sequence might look like:

_____-----__-_________--_--------------_____ (REPEAT)
OFF

The on-off cycles will be variable with ON times of 1-10 seconds and OFF times of 1-10 seconds.

As far as accuracy, +/- 0.1 seconds will be fine for my application (and I think I can get away with using an internal oscillator).
 

Markd77

Joined Sep 7, 2009
2,806
Memory isn't going to be a problem then, a byte can store 25.5 seconds at 0.1 second resolution and you are going to need 10 bytes for 5 on and 5 off periods.
If you want to store the sequence when power is turned off then a PIC with EEPROM would be needed, the PIC12F675 for example. If that is not needed then it could be done with the smallest PICs, the PIC10F200 or PIC10F202.
 

Thread Starter

mwh624

Joined Nov 6, 2009
28
I didn't think about what would happen if I turned the system off. Thanks for mentioning it.
After reading the data sheet, I think I am going to go with the 12F675. Thanks for the recommendation.
 
Top