View previous topic :: View next topic |
Author |
Message |
hayee
Joined: 05 Sep 2007 Posts: 252
|
generating pulses. |
Posted: Thu Nov 05, 2009 4:21 am |
|
|
Hi,
I want to generate pulses according to the values which are read by the keypad.
The pattern of pulses is like that what ever I entered a value from keypad it subtract 0.1 from that value, the value which comes after subtracting becomes ON_Time and the OFF_Time is 0.1
Suppose I have enter value 10.00 which is in seconds
ON_Time = (10 - 0.1) = 9.9 sec
OFF_Time = 0.1 sec
9.9 sec pulse is high and 0.1 sec pulse is low.
If value is entered 999.99 secs then
ON_Time = (999.99 - 0.1) = 999.89 sec
OFF_Time = 0.1 sec
Generate these pulses continuously for a certain amount of time.
Range of values entered from keypad is from 0.5 sec to 999.99 secs.
Any ideas. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Nov 05, 2009 1:29 pm |
|
|
Use a timer interrupt to create a software PWM generator. To find
routines for this, search the forum for: software PWM
Example:
http://www.ccsinfo.com/forum/viewtopic.php?t=37807
In main(), use a while() loop to call the CCS keypad driver, kbd.c.
Take the keypad input and use it to set the global pwm variables
which will be used inside the Timer interrupt routine to create
the desired PWM duty cycle and period.
You have to do this project. I don't want to do it for you. |
|
|
hayee
Joined: 05 Sep 2007 Posts: 252
|
|
Posted: Fri Nov 06, 2009 10:43 pm |
|
|
Do you think that when i enter 999.99 sec it will generate pulses of (freq=1/999.99secs) using PWM.
if entered value is 0.5 sec,the frequency will be freq=1/.5sec =>2Hz
if entered value is 999.99sec,the freq will be freq=1/999.99sec => 0.001Hz
Is there any other way to do this without using PWM? |
|
|
|