Ltalionis / arduino-timerone

Automatically exported from code.google.com/p/arduino-timerone
0 stars 0 forks source link

The period isn't correct. why? #6

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Timer1.initialize(500); 
2. Timer1.pwm(9, 512, 500);

What is the expected output? What do you see instead?
The output should be a 0.5 ms period square wave, and it isn't.

What version of the product are you using? On what operating system?
TimerOne-v8, Arduino 1.0, 328P chip, Linux 64 bits

Please provide any additional information below.

Original issue reported on code.google.com by xpeoxove...@hotmail.com on 30 Dec 2011 at 3:16

GoogleCodeExporter commented 9 years ago
How close is it? Can you include a screen capture or picture of the waveform on 
your O-Scope?  I'm unable to replicate this.  My scope shows a close-to square 
wave.  At faster frequencies (above 1khz/below 1mS) the timing get's less and 
less accurate. See issue 1 for more info why: 
http://code.google.com/p/arduino-timerone/issues/detail?id=1

Original comment by lex.v.ta...@gmail.com on 1 Feb 2012 at 5:50

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hi. The scope was malfunction... Now that I replaced it, everything works fine. 
Thanks.

And, this instructins also work well:
  /*
  TCCR1A = _BV(COM1A1) | _BV(COM1B1); //activates the output pins 
  TCCR1B = _BV(WGM13) | _BV(CS10); //phase and frequency correct pwm mode, prescale by /1
  ICR1 = 4000; //(16*10^6)/(2*1*4000) = 2000 Hz -> T = 0.5 ms
  OCR1A = 2000; //float dc = (dCyclePerc/100)*4000; OCR1A = dc;
  //OCR1B = 2000; */

  TCCR1A = 0b10100000;
  TCNT1 = 0x0000;
  TCCR1B = 0b00010001; //phase and frequency correct pwm mode, prescale by /1
  ICR1 = 4000; //(16*10^6)/(2*1*4000) = 2000 Hz -> T = 0.5 ms
  OCR1A = 2000;
  OCR1B = 30;

  /*
  TCCR1A = _BV(COM1A1) | _BV(COM1B1) | _BV(WGM11); //activates the output pins 
  TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); //fast pwm mode, prescale by /1
  ICR1 = 7999; //(16*10^6)/(1*(1+7999)) = 2000 Hz -> T = 0.5 ms
  OCR1A = 4000;
  //OCR1B = 4000;*/

  /*
  TCCR1A = 0b10100010;
  TCNT1 = 0x0000;
  TCCR1B = 0b00000010; //phase correct pwm mode 9 bits, prescale by /8 -> (16*10^6)/(2*8*511) = 2000 Hz -> T = 0.5 ms
  OCR1A = 256;
  //OCR1B = 256;*/

Original comment by xpeoxove...@hotmail.com on 12 Feb 2012 at 1:37

GoogleCodeExporter commented 9 years ago
Whew! Good tools make all the difference.

Original comment by lex.v.ta...@gmail.com on 12 Feb 2012 at 4:10