Go Down

Topic: Change the Sine wave frequency (Read 11778 times) previous topic - next topic

so3ody


Grumpy_Mike


Mike thats all what I have

No you have been making changes to the code so I would like at least to see the changes.

If I put that code into the arduino IDE it will not compile.
I have not got the files:-
"asf.h"
"conf_board.h"
"conf_clock.h"
There is also no setup or loop functions. Arduino IDE code will not compile without those.

Have you actually been trying to write any code or are you just trawling round the internet at random grabbing code with absolutely no idea of what is going on and getting mugs to try and modify it to what you want?

so3ody

Ah now I know what you mean  :)

yes im trying to write the code.. as you can see
but I have problems cause im new in programming microcontroller

so3ody

Mike It dindt work

So this is what I modified

I added a new variable
Code: [Select]
static uint_32t counterIncrement ;

then I replaced

Code: [Select]
ul_count++;
with
Code: [Select]
ul_count+=counterIncrement

and then

Code: [Select]
if (ul_count >= size) {
ul_count = 0;
}


with
Code: [Select]
if ((ul_count /10) >= size) {
ul_count -= size * 10;
}


I just recive nonsence

can you tell me whats wrong ? Thankls in advance

AWOL

Code: [Select]
// The size of the sine array is 120Phase accumulators are much easier to implement if the table size is an integer power of two in length.
log2 (120) is not an integer.

Grumpy_Mike

Quote
can you tell me whats wrong ?

How can I when you will not give me the code that YOU have changed?
How do I know you have done the changes correctly.
I told you three things to do. You have told me about two of them.
What about the third?

so3ody

Mike I already posted the changes and I posted my whole project folder as well


those are the changes and I changed them due to the 3 things you told me


please check my last two posts

Grumpy_Mike

Quote
Mike I already posted the changes and

Where?
I can see no evidence of any changes to the main.c file

so3ody

Hi I changed  following


line 107

Code: [Select]
static uint32_t counterIncrement ;

line 116

I replaced
Code: [Select]
ul_count ++

with
Code: [Select]
ul_count+=counterIncrement ;   

Line  130,131

Code: [Select]
if (ul_count >= size) {
//ul_count = 0; }


replaced with

Code: [Select]
if ((ul_count /10) >= size) {
ul_count -= size * 10;
}

Grumpy_Mike

Quote
Hi I changed  following....

You did on that new code you posted but not on the last code you posted. Are you jerking me about?

You have not changed lines 140, 141, 142 like I told you to:-
Quote
When you come to use ul_count as an index to your lookup table you actually use ul_count divided by 100.

so3ody

#25
Jun 02, 2014, 09:10 pm Last Edit: Jun 02, 2014, 09:23 pm by so3ody Reason: 1
Hi Mike thanks for your reply and help I really appreciate it :)
No im not  jerking about you. I just had to modifiy the code again from my home pc. cause im not at the college any more !

I modified the last issue  line 140-142 which I forgot

I cant test it now cause I dont have my arduino board at home and no osciloscope  but I will let you tomorrow know it if works or not thanks alot  again

Grumpy_Mike

Quote
...... which I forgot

Which is why I asked to see your code.

Also you have:-
Code: [Select]
static uint32_t counterIncrement ;
But you have not defined it to be any value!

OK,
Just realised that in one piece I assumed the value in the counter was 10 times more that the increment, but I think we are working on 100 times so that code should be:-
Code: [Select]

if ((ul_count /100) >= size) {
ul_count -= size * 100;
}

so3ody

Thanks mike I insert the counterIncrement  with many vlaues like 100,200 aand 250

I will tell you tomorrow if it will work

Thanks alot :)

so3ody

Morning Mike

It dosent work correctly I always get a wrong frequency when I give
counterIncrement a value of 250 I recive 213 Hz, 100->85 Hz,300->250 Hz

I modified everything as you said

Please check line
Code: [Select]

107
116
130,131
140,141,142

I attached the modified code
PS Do I have to change or modifiy the sine array ?
thanks in advance

AWOL

4MB of attached code?
Get real.

Go Up