ADC data 00 to FF should be converted to 0 to 25.5 msec in controller

Status
Not open for further replies.

prakashvenugopal

Advanced Member level 1
Joined
Jun 1, 2011
Messages
473
Helped
15
Reputation
30
Reaction score
15
Trophy points
1,298
Activity points
4,973
Hi all,

I am using 16F785 controller. In that, i am using internal adc to convert my 0 to 5V into
00 to FF (0 to 255) Value. My requirement is, i have to convert this 00 to FF adc data into 0 to 25.5 msec.

Say for example,
If Data = 00 --> 0 msec
If Data = 255 --> 25.5 msec

How to generate this. kindly let us know.

Regards,
V. Prakash
 

Hi,

for precise timing:
I´d use a timer/counter running with 10kHz (or integer multiple)
This gives an exact timing in steps of 0.1ms.

There is a lot of information missing.
* what is this "timing" used for? internal delay, output signal, anything else?
* what is starting this "timing"? key press, one shot, automatic repaet with which repeat rate?
* if output: what is the idle state and what is the active state?

Klaus
 
This sounds to me like a very simple linear equation is required - 'y=mx+c' level coding.
What about this problem is more difficult than that?
Susan
 
Hi,

Sorry for the late reply. i have to use this 0 to 25.5 msec for debounce the input. I am using the Potentiometer to adc input
to generate 0 to 5V and the same have to be convert the linear output:

0 to 5V --> 0 to 25.5 msec.

Do you have a code example related to this, Kindly share.

Regards,
V. Prakash
 

Hi,

we don´t write code.
We help to fix coding mistakes.

You at least should have an idea what/how to do. What about draing a flow chart?


Klaus
 

Hello!

Sorry for the late reply. i have to use this 0 to 25.5 msec for debounce the input.

Debouncing suggest that you want to use a button and prevent it to bounce, right?
I don't quite understand why you would use a potentiometer for that, but I will suppose
you want to use the potentiometer value to setup the delay used to debounce the button.

1. Setup a timer with interrupt, let's call it TimerA. Don't start it now.

2. Read the value of the potentiometer, set its value (or something proportional) to timerA.

3. Setup your pushbutton with an interrupt

4 on Button interrupt, disable button interrupts so that you cannot have a second edge,
and then fire TimerA (the time of which is proportional to your pot)

5. On TimerA interrupt, enable button interrupts again, and process your button event.

That's about it.

Dora.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…