Forum Software Ferduino code Driver sure electronics

Driver sure electronics  [SOLVED]


Post Number:#1 Post Fri Feb 27, 2015 4:44 am
Posts: 15
Topics: 5
Images: 3
Solve rating: 0
Joined: Wed Nov 19, 2014 6:16 am
Topics: 5
Age: 57
Gender: None specified
National Flag:
France
hello Fernando
I just installed my lighting, and am having a problem on my driver .
I have an unbearable whistle.
I tried another program the ACKduino and when I change the SetPinFrequency has 20000Hz hiss disappears .
    RetCode = SetPinFrequency(Eclairage1, 20000);
    if (RetCode == false ) {Serial.println("SetPinFrequency Eclairage1 =fasle" ); }
    RetCode = SetPinFrequency(Eclairage2, 20000);
    if (RetCode == false ) {Serial.println("SetPinFrequency Eclairage2 =fasle" ); }
    RetCode = SetPinFrequency(Eclairage3, 20000);
    if (RetCode == false ) {Serial.println("SetPinFrequency Eclairage3 =fasle" ); }
    RetCode = SetPinFrequency(Eclairage4, 20000);
    if (RetCode == false ) {Serial.println("SetPinFrequency Eclairage4 =fasle" ); }
    RetCode = SetPinFrequency(Eclairage5, 20000);
    if (RetCode == false ) {Serial.println("SetPinFrequency Eclairage5 =fasle" ); }
    RetCode = SetPinFrequency(MoonPin, 20000);
    if (RetCode == false ) {Serial.println("SetPinFrequency MoonPin =fasle" ); }


is it possible to change this frecance in your program?

thank you for your help
Last edited by Fernando Garcia on Fri Feb 27, 2015 9:27 am, edited 1 time in total.
Reason: Please use tags [code][/code] to post codes here.

Post Number:#2 Post Fri Feb 27, 2015 10:01 am
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

Hi!

I don't know the divisor for 20 KHz but, try this method:

Arduino mega pins and hardware Timers

Pin Timer
46 OC5A
45 OC5B
44 OC5C
13 OC0A //Caution: this one directly effects major timing { i.e delay and millis}
12 OC1B
11 OC1A
10 OC2A
9 OC2B
8 OC4C
7 OC4B
6 OC4A
5 OC3A
4 OC0B //Caution: this one directly effects major timing { i.e delay and millis}
3 OC3C
2 OC3B

All that is really important above is the numbers. They tell you what timers there on.
For example pin 2 is OC3B which is timer 3.

another way to look at this is:
timer 0 —– pin 4, 13
timer 1 —– pin 11, 12, 13
timer 2 —– pin 9, 10
timer 3 —– pin 2, 3, 5
timer 4 —– pin 6, 7, 8
timer 5 —– pin 44, 45, 46

————————————————————————————–

TIMER 0 (Pin 4, 13)
Value Divisor Frequency
0×01 1 62.5035 KHz
0×02 8 7.8125 KHz
0×03 64 976.5 Hz // default
0×04 256 244.1 Hz
0×05 1024 61.0 Hz
Code: TCCR0B = (TCCR0B & 0xF8) | value ;
————————————————————————————-

TIMER 1 (Pin 11, 12)
Value Divisor Frequency
0×01 1 31.374 KHz
0×02 8 3.921 KHz
0×03 64 490.1 Hz // default
0×04 256 122.5 Hz
0×05 1024 30.63 Hz
Code: TCCR1B = (TCCR1B & 0xF8) | value ;
————————————————————————————–

TIMER 2 (Pin 9, 10)
Value Divisor Frequency
0×01 1 31.374 KHz
0×02 8 3.921 KHz
0×03 32 980.3 Hz
0×04 64 490.1 Hz // default
0×05 128 245 hz
0×06 256 122.5 hz
0×07 1024 30.63 hz
Code: TCCR2B = (TCCR2B & 0xF8) | value ;
—————————————————————————————-

Timers 3, 4, 5 Oddly do not use the divisors the data sheet says: Below are actual measured values!

TIMER 3 ( Pin 2, 3, 5)
Value Divisor Frequency
0×01 1 31.374 KHz
0×02 8 3.921 Khz
0×03 64 490.1 Hz // default
0×04 256 122.5 Hz
0×05 1024 30.63 Hz
Code: TCCR3B = (TCCR3B & 0xF8) | value ;
—————————————————————————————-

TIMER 4 (Pin 6, 7, 8)
Value Divisor Frequency
0×01 1 31.374 KHz
0×02 8 3.921 Khz
0×03 64 490.1 Hz // default
0×04 256 122.5 Hz
0×05 1024 30.63 Hz
Code: TCCR4B = (TCCR4B & 0xF8) | value ;
—————————————————————————————-

TIMER 5 (Pin 44, 45, 46)
Value Divisor Frequency
0×01 1 31.374 KHz
0×02 8 3.921 Khz
0×03 64 490.1 Hz // default
0×04 256 122.5 Hz
0×05 1024 30.63 Hz
Code: TCCR5B = (TCCR5B & 0xF8) | value ;
—————————————————————————————-

To set your timer just add it to your sketch:
Here’s and example for Pins 9 and 10 on Timer 2 @ 490.1Hz;

void setup () {
TCCR2B = (TCCR2B & 0xF8) | 0×04;
}


Source: http://sobisource.com/arduino-mega-pwm- ... r-control/

Best regards.

I have a problem to post this message ignore it please.

blablablablablablablablablablablablablablablablablablablablablablablablalablablablablablablablablablalablablablablablablablablablalablablablablablablablablabla
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#3 Post Fri Feb 27, 2015 2:50 pm
Posts: 15
Topics: 5
Images: 3
Solve rating: 0
Joined: Wed Nov 19, 2014 6:16 am
Topics: 5
Age: 57
Gender: None specified
National Flag:
France
.thank you for your answer
but in which file I can find that.
because it exceeds but skills.

Post Number:#4 Post Sat Feb 28, 2015 10:16 am
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

Before ask you need try understand my answer.

This is not clear for you?

void setup () {
TCCR2B = (TCCR2B & 0xF8) | 0×04;
}
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#5 Post Wed Mar 04, 2015 7:47 am
Posts: 15
Topics: 5
Images: 3
Solve rating: 0
Joined: Wed Nov 19, 2014 6:16 am
Topics: 5
Age: 57
Gender: None specified
National Flag:
France
hello Fernando
thank you to bend you to my brobleme
I understand that I must write this am , to change the pin 9 and 10 for a frequency balance 64 490.1 Hz
void setup () {
TCCR2B = (TCCR2B & 0xF8) | 0×04;
}

I do not understand is how I should change place or write ( in libraries, in ferduino code file ... )
I would like to avoid making a big stupidity and everything explode :D %-(

To set your timer just add it to your sketch:
Here’s and example for Pins 9 and 10 on Timer 2 @ 490.1Hz;

thank you for your help .

Post Number:#6 Post Wed Mar 04, 2015 9:27 am
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

Put in the tab setup.
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#7 Post Wed Mar 04, 2015 10:37 am
Posts: 15
Topics: 5
Images: 3
Solve rating: 0
Joined: Wed Nov 19, 2014 6:16 am
Topics: 5
Age: 57
Gender: None specified
National Flag:
France
I'm really sorry but trying several places in the file I have the following errors.
setup : 4 error: stray '\' in program
setup.ino: in function 'void setup()'
setup:4: error: expected ';' before 'u00d704

Post Number:#8 Post Wed Mar 04, 2015 7:32 pm
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

Try this:

//For Arduino Mega1280, Mega2560, MegaADK, Spider or any other board using ATmega1280 or ATmega2560**
 
//---------------------------------------------- Set PWM frequency for D4 & D13 ------------------------------
 
//TCCR0B = TCCR0B & B11111000 | B00000001;    // set timer 0 divisor to     1 for PWM frequency of 62500.00 Hz
//TCCR0B = TCCR0B & B11111000 | B00000010;    // set timer 0 divisor to     8 for PWM frequency of  7812.50 Hz
  TCCR0B = TCCR0B & B11111000 | B00000011;    <// set timer 0 divisor to    64 for PWM frequency of   976.56 Hz (Default)
//TCCR0B = TCCR0B & B11111000 | B00000100;    // set timer 0 divisor to   256 for PWM frequency of   244.14 Hz
//TCCR0B = TCCR0B & B11111000 | B00000101;    // set timer 0 divisor to  1024 for PWM frequency of    61.04 Hz
 
 
//---------------------------------------------- Set PWM frequency for D11 & D12 -----------------------------
 
//TCCR1B = TCCR1B & B11111000 | B00000001;    // set timer 1 divisor to     1 for PWM frequency of 31372.55 Hz
//TCCR1B = TCCR1B & B11111000 | B00000010;    // set timer 1 divisor to     8 for PWM frequency of  3921.16 Hz
  TCCR1B = TCCR1B & B11111000 | B00000011;    // set timer 1 divisor to    64 for PWM frequency of   490.20 Hz
//TCCR1B = TCCR1B & B11111000 | B00000100;    // set timer 1 divisor to   256 for PWM frequency of   122.55 Hz
//TCCR1B = TCCR1B & B11111000 | B00000101;    // set timer 1 divisor to  1024 for PWM frequency of    30.64 Hz
 
//---------------------------------------------- Set PWM frequency for D9 & D10 ------------------------------
 
//TCCR2B = TCCR2B & B11111000 | B00000001;    // set timer 2 divisor to     1 for PWM frequency of 31372.55 Hz
//TCCR2B = TCCR2B & B11111000 | B00000010;    // set timer 2 divisor to     8 for PWM frequency of  3921.16 Hz
//TCCR2B = TCCR2B & B11111000 | B00000011;    // set timer 2 divisor to    32 for PWM frequency of   980.39 Hz
  TCCR2B = TCCR2B & B11111000 | B00000100;    // set timer 2 divisor to    64 for PWM frequency of   490.20 Hz
//TCCR2B = TCCR2B & B11111000 | B00000101;    // set timer 2 divisor to   128 for PWM frequency of   245.10 Hz
//TCCR2B = TCCR2B & B11111000 | B00000110;    // set timer 2 divisor to   256 for PWM frequency of   122.55 Hz
//TCCR2B = TCCR2B & B11111000 | B00000111;    // set timer 2 divisor to  1024 for PWM frequency of    30.64 Hz
 
 
//---------------------------------------------- Set PWM frequency for D2, D3 & D5 ---------------------------
 
//TCCR3B = TCCR3B & B11111000 | B00000001;    // set timer 3 divisor to     1 for PWM frequency of 31372.55 Hz
//TCCR3B = TCCR3B & B11111000 | B00000010;    // set timer 3 divisor to     8 for PWM frequency of  3921.16 Hz
  TCCR3B = TCCR3B & B11111000 | B00000011;    // set timer 3 divisor to    64 for PWM frequency of   490.20 Hz
//TCCR3B = TCCR3B & B11111000 | B00000100;    // set timer 3 divisor to   256 for PWM frequency of   122.55 Hz
//TCCR3B = TCCR3B & B11111000 | B00000101;    // set timer 3 divisor to  1024 for PWM frequency of    30.64 Hz
 
 
//---------------------------------------------- Set PWM frequency for D6, D7 & D8 ---------------------------
 
//TCCR4B = TCCR4B & B11111000 | B00000001;    // set timer 4 divisor to     1 for PWM frequency of 31372.55 Hz
//TCCR4B = TCCR4B & B11111000 | B00000010;    // set timer 4 divisor to     8 for PWM frequency of  3921.16 Hz
  TCCR4B = TCCR4B & B11111000 | B00000011;    // set timer 4 divisor to    64 for PWM frequency of   490.20 Hz
//TCCR4B = TCCR4B & B11111000 | B00000100;    // set timer 4 divisor to   256 for PWM frequency of   122.55 Hz
//TCCR4B = TCCR4B & B11111000 | B00000101;    // set timer 4 divisor to  1024 for PWM frequency of    30.64 Hz
 
 
//---------------------------------------------- Set PWM frequency for D44, D45 & D46 ------------------------
 
//TCCR5B = TCCR5B & B11111000 | B00000001;    // set timer 5 divisor to     1 for PWM frequency of 31372.55 Hz
//TCCR5B = TCCR5B & B11111000 | B00000010;    // set timer 5 divisor to     8 for PWM frequency of  3921.16 Hz
  TCCR5B = TCCR5B & B11111000 | B00000011;    // set timer 5 divisor to    64 for PWM frequency of   490.20 Hz
//TCCR5B = TCCR5B & B11111000 | B00000100;    // set timer 5 divisor to   256 for PWM frequency of   122.55 Hz
//TCCR5B = TCCR5B & B11111000 | B00000101;    // set timer 5 divisor to  1024 for PWM frequency of    30.64 Hz


Source: http://arduino-info.wikispaces.com/Ardu ... -Frequency
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#9 Post Thu Mar 05, 2015 4:00 am
Posts: 15
Topics: 5
Images: 3
Solve rating: 0
Joined: Wed Nov 19, 2014 6:16 am
Topics: 5
Age: 57
Gender: None specified
National Flag:
France
hello.
I copied the file as it setup.ino

//**************** PCF8575 ****************
  pinMode (temporizador1, OUTPUT);         // Pino 80;
  pinMode (temporizador2, OUTPUT);         // Pino 81;
  pinMode (temporizador3, OUTPUT);         // Pino 82;
  pinMode (temporizador4, OUTPUT);         // Pino 83;
  pinMode (temporizador5, OUTPUT);         // Pino 84;
  pinMode (solenoide1Pin, OUTPUT);         // Pino 85;

//For Arduino Mega1280, Mega2560, MegaADK, Spider or any other board using ATmega1280 or ATmega2560**
 
//---------------------------------------------- Set PWM frequency for D4 & D13 ------------------------------
 
//TCCR0B = TCCR0B & B11111000 | B00000001;    // set timer 0 divisor to     1 for PWM frequency of 62500.00 Hz
//TCCR0B = TCCR0B & B11111000 | B00000010;    // set timer 0 divisor to     8 for PWM frequency of  7812.50 Hz
  TCCR0B = TCCR0B & B11111000 | B00000011;    <// set timer 0 divisor to    64 for PWM frequency of   976.56 Hz (Default)
//TCCR0B = TCCR0B & B11111000 | B00000100;    // set timer 0 divisor to   256 for PWM frequency of   244.14 Hz
//TCCR0B = TCCR0B & B11111000 | B00000101;    // set timer 0 divisor to  1024 for PWM frequency of    61.04 Hz
 


erreur: setup:62: error; expected primary-expression before '<' token

Post Number:#10 Post Thu Mar 05, 2015 5:44 am
Posts: 15
Topics: 5
Images: 3
Solve rating: 0
Joined: Wed Nov 19, 2014 6:16 am
Topics: 5
Age: 57
Gender: None specified
National Flag:
France
sorry I have not seen the < .
I deleted it is the programming that compiles .
I test tonight and I inform you.

Post Number:#11 Post Fri Mar 06, 2015 2:31 pm
Posts: 15
Topics: 5
Images: 3
Solve rating: 0
Joined: Wed Nov 19, 2014 6:16 am
Topics: 5
Age: 57
Gender: None specified
National Flag:
France
hi Fernando .
problem solved . : -bd
the driver no longer any noise.
a big thank you . ^ : ) ^
remains only a sd card problem , I dig on the site.




Return to Ferduino code





Who is online

Users viewing this topic: No registered users and 1 guest