Continue to Site

# [General]using 10bits ADC result with 16bits timer result

Status
Not open for further replies.

#### Issak Sdu

##### Member level 1
Problem statement

i'm using 10bit ADC to measure the voltage on potentiometer (real angle of rotation of a DC motor, which varies from -45° to +45° or 0° to 90°).

i'm using 16bit Timer to measure the width of a square signal (desired angle of rotation of the DC motor, which varies from 1ms to 2ms like RC servos).

i want use integer calclations in order to avoid converting my results of ADC and Timer into real numbers.

Question

How can i rescale the 10bit result from ADC to its corresponding 16bit result from Timer ?

try shifting left 6 bits, e.g.
Code:
  i <<= 6;

Issak Sdu

### Issak Sdu

Points: 2
try shifting left 6 bits, e.g.
Code:
  i <<= 6;

A multiplication by 2^6.

thanks

hello

timer depends of
FOSC MCU
prescaler value

at least you can use long integer for calculation
and scaleing all your physical measures .

your request is not so clear:
is the potentiometer used as position measure of Angle DC motor ?
if yes , why do you want the correspondance with timer ?
do you have allready some code to propose ?

your request is not so clear:
is the potentiometer used as position measure of Angle DC motor ?
if yes , why do you want the correspondance with timer ?
do you have allready some code to propose ?

Actually i'm trying to make an RC Servo controller (position regulation) by implementing different different control laws and compare with available Rc servos based on PID control.

hello

One (rotative) potentiometer to give the position target
A linear potentiometer to get the position
A DC moteur mechanical coupled to the linear potentimeter..

Algorythm control use Proportional + integral
error positioning * Gain + time loop until error near zero
Nota: power supply of DC motor controller (PMW) is a big parameter too ! act as a super-Gain.

One (rotative) potentiometer to give the position target
A linear potentiometer to get the position
A DC moteur mechanical coupled to the linear potentimeter..

you are not too far.

One potentiometer is coupled to the last gear set to give the real position
The target position is given by a square signal just like RC servos do.

And yes, i will implement PID, fuzzy logic, and other control methods

Status
Not open for further replies.