CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

I want to get the sine wave using excel.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ertansuluagac



Joined: 13 Jul 2017
Posts: 135
Location: IZMIR

View user's profile Send private message Send e-mail

I want to get the sine wave using excel.
PostPosted: Thu Dec 26, 2019 9:21 am     Reply with quote

hello everyone.
PIC16F1784 dac output from I want to get the sine wave using excel.
How can I do?

The outputs for the sine wave was calculated as follows, the values were rounded to the nearest integer value:

#define WAVE_POINTS 100

DEGREE_INC_VALUE = 360 / WAVE_POINTS = 360 / 100 =
DEGREE_INC_VALUE = 3.6
For outputs 0 - 99:
Output[i] = (DAC_MAX_VALUE / 2) (sin(i * DEGREE_INC_VALUE) + 1)
_________________
Es
temtronic



Joined: 01 Jul 2010
Posts: 9163
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Dec 26, 2019 10:02 am     Reply with quote

One way is to send the data as 'CSV' (Comma Separated Variables) to a PC terminal program and have it save to a file (maybe named 'DACoutput.CSV')
You then open Excel and import' 'DACoutput.CSV'.
The numbers wll 'magically' be put into a spreadsheet.
You should also send 'start of data', 'end of data' markers just so you know all data is sent.

Jay
ertansuluagac



Joined: 13 Jul 2017
Posts: 135
Location: IZMIR

View user's profile Send private message Send e-mail

PostPosted: Thu Dec 26, 2019 10:38 am     Reply with quote

ex_sine.c in made in this sample from ccs .how these values are formed. and how it applies to Excel.
Code:

BYTE CONST SINE_WAVE[200] = {
128,132,136,139,143,147,150,154,158,161,165,169,172,176,179,
182,186,189,192,195,199,202,204,207,210,213,215,218,220,223,
225,227,229,231,233,235,237,238,240,241,242,243,244,245,246,
247,247,247,248,248,248,248,248,247,247,247,246,245,244,243,
242,241,240,238,237,235,233,231,229,227,225,223,220,218,215,
213,210,207,204,202,199,195,192,189,186,182,179,176,172,169,
165,161,158,154,150,147,143,139,136,132,128,124,120,117,113,
109,106,102,98,95,91,87,84,80,77,74,70,67,64,61,57,54,52,49,
46,43,41,38,36,33,31,29,27,25,23,21,19,18,16,15,14,13,12,11,
10,9,9,9,8,8,8,8,8,9,9,9,10,11,12,13,14,15,16,18,19,21,23,
25,27,29,31,33,36,38,41,43,46,49,52,54,57,61,64,67,70,74,77,
80,84,87,91,95,98,102,106,109,113,117,120,124};

_________________
Es
temtronic



Joined: 01 Jul 2010
Posts: 9163
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Dec 26, 2019 12:31 pm     Reply with quote

here's what I think
1st sine waves are AC( + and - values) , PIC DAC is DC ( +ve only)

Those numbers represent an 'offset' sine wave broken into 200 points. So 360* / 200 = 1.8* ( * means degrees) uisng 8 bit 'math'.

The numbers are unsigned integers ( 0 - 255)

'128' is the middle and so represents the 'zero' voltage line
'248' represent the maximum positive level
'8' represents the maximum negative level

The more 'points', the smoother the sinewave will be,but requires more time to create it. Usually you add an R-C filter to the DAC output and you'll get a very nice 'sine' wave. Using a 16 or 32bit DAC will result in an even better 'sine wave' but costs more money in hardware.

Others will reply,hopefully with better explanations.

Jay
ertansuluagac



Joined: 13 Jul 2017
Posts: 135
Location: IZMIR

View user's profile Send private message Send e-mail

PostPosted: Thu Dec 26, 2019 1:03 pm     Reply with quote

how do i apply these values to excel. I want to see the sinus wave in excel.
_________________
Es
ertansuluagac



Joined: 13 Jul 2017
Posts: 135
Location: IZMIR

View user's profile Send private message Send e-mail

PostPosted: Thu Dec 26, 2019 1:24 pm     Reply with quote

how create this values.

#define WAVE_POINTS 100
Code:

const int8 sine_output[WAVE_POINTS] = {128, 136, 143, 151, 159, 167, 174, 182, 189, 196,
                                       202, 209, 215, 220, 226, 231, 235, 239, 243, 246,
                                       249, 251, 253, 254, 255, 255, 255, 254, 253, 251,
                                       249, 246, 243, 239, 235, 231, 226, 220, 215, 209,
                                       202, 196, 189, 182, 174, 167, 159, 151, 143, 136,
                                       128, 119, 112, 104,  96,  88,  81,  73,  66,  59,
                                        53,  46,  40,  35,  29,  24,  20,  16,  12,   9,
                                         6,   4,   2,   1,   0,   0,   0,   1,   2,   4,
                                         6,   9,  12,  16,  20,  24,  29,  35,  40,  46,
                                        53,  59,  66,  73,  81,  88,  96, 104, 112, 119};

_________________
Es
dyeatman



Joined: 06 Sep 2003
Posts: 1923
Location: Norman, OK

View user's profile Send private message

PostPosted: Thu Dec 26, 2019 1:37 pm     Reply with quote

Go here to learn how to create a graph in Excel.

https://www.workzone.com/blog/how-to-make-a-graph-in-excel/

Using that info it took me 5 minutes to create the graph using your data.
I saved the values to a CSV file (with no CRLFs except at the end) then opened the file in Excel which created one row of data.
I then used Insert Graph and selected the data to create the graph of a clean sine wave.
_________________
Google and Forum Search are some of your best tools!!!!
ertansuluagac



Joined: 13 Jul 2017
Posts: 135
Location: IZMIR

View user's profile Send private message Send e-mail

PostPosted: Thu Dec 26, 2019 2:05 pm     Reply with quote

using these values I see the sine wave. How do I make these values. so , this numbers how can create?

[WAVE_POINTS] = {128, 136, 143, 151, 159, 167, 174, 182, 189, 196,
202, 209, 215, 220, 226, 231, 235, 239, 243, 246,
249, 251, 253, 254, 255, 255, 255, 254, 253, 251,
249, 246, 243, 239, 235, 231, 226, 220, 215, 209,
202, 196, 189, 182, 174, 167, 159, 151, 143, 136,
128, 119, 112, 104, 96, 88, 81, 73, 66, 59,
53, 46, 40, 35, 29, 24, 20, 16, 12, 9,
6, 4, 2, 1, 0, 0, 0, 1, 2, 4,
6, 9, 12, 16, 20, 24, 29, 35, 40, 46,
53, 59, 66, 73, 81, 88, 96, 104, 112, 119};
how these numbers are calculated. I wrote a formula above. I think when I apply this formula to excel, these numbers occur. te te how do I apply that formula to excel.
this formula;

The outputs for the sine wave was calculated as follows, the values were rounded to the nearest integer value:


Code:

#define WAVE_POINTS 100

DEGREE_INC_VALUE = 360 / WAVE_POINTS = 360 / 100 =
DEGREE_INC_VALUE = 3.6
For outputs 0 - 99:
Output[i] = (DAC_MAX_VALUE / 2) (sin(i * DEGREE_INC_VALUE) + 1)

_________________
Es
ertansuluagac



Joined: 13 Jul 2017
Posts: 135
Location: IZMIR

View user's profile Send private message Send e-mail

PostPosted: Fri Dec 27, 2019 12:50 am     Reply with quote

does anyone know how it occurs these values?
yes, from excel in these values very beautiful sinus waves see. but, how it occurs these values
_________________
Es
ertansuluagac



Joined: 13 Jul 2017
Posts: 135
Location: IZMIR

View user's profile Send private message Send e-mail

PostPosted: Fri Dec 27, 2019 2:52 am     Reply with quote

[SOLVED]

the problem is solved.
thanks
_________________
Es
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group