# real number from pic ???

Discussion in 'Embedded Systems and Microcontrollers' started by capacitor1, Jan 12, 2013.

1. ### capacitor1 Thread Starter New Member

Jan 12, 2013
10
0
Hi!

I have an angle in the microcontroller from 0 to 360 , and I want to calculate its Sin , and display this number as analog .

I use CCS compiler , and I think that the Math library exists.

the hard thing how to convert the number from 0 to 1 ( if we neglige the negatif numbers ) , and with 3 digits after the point . (0.000,0.001,....,0.999,1.000) to a voltage .

Ex: if the angle=60 : sin(60)=0.8660254≈0.866 ===> 0.866V

thanks

2. ### MrCarlos Active Member

Jan 2, 2010
400
134
Hello Capacitor1

especially reads the content of the page 363.
It says SinE3 function is implemented as a lookup table.

File size:
2.2 MB
Views:
13
3. ### Markd77 Senior Member

Sep 7, 2009
2,803
594
If you want to output the voltage to read on a multimeter, etc, you can use a PWM pin / software PWM, and a resistor capacitor filter to make it into a stable voltage.

4. ### nigelwright7557 Senior Member

May 10, 2008
488
71
When I did assembler I just used a 90 value look up table.
I mirrored for 90-180 then made negative from 180-359 degrees.

5. ### capacitor1 Thread Starter New Member

Jan 12, 2013
10
0
Hi

thanks for your help, but the second part that i have to convert it to a real number in volts ??

6. ### WBahn Moderator

Mar 31, 2012
18,085
4,917
What do you mean "convert it to a real number in volts"? This doesn't make a lot of sense, just like saying "display this number as analog" doesn't make a lot of sense in your first post.

Are you saying that you need to output a representation of it as an analog voltage? If so, what conversion factor are you trying to get (how many volts per degree)? What about negative angles?

7. ### thatoneguy AAC Fanatic!

Feb 19, 2009
6,357
718
If you want AC out, You will need a DAC (Digital to Analog Converter

An approximation can be made with PWM + low pass filter.

Depends on the accuracy you desire as to which method you choose.