Arduino mega 2560 pwm timer controls -


i'm trying use mirror galvo controlled mega 2560 direct laser. first test want laser move along 1 axis jumping equal intervals, i'm having trouble. i'd know whether there obvious problems in code (which suspect may case i'm new timers , interrupts)?

void setup() {   tccr3b = _bv(cs30); //high freq ~50khz   pinmode(5, output); }      void loop() {  int output1= 5;  while(output1<255){   analogwrite(5,output1);   output1+=40;   delay(500);  }  output1=5; } 

when run code mirror achieve full 5 degree range of movement should. problem instead of moving equal intervals mirror rotates equivalent of .8 deg on suppose first 2 iterations of while loop, mirror jump around 3.5deg of rotation. mirror goes rotating small increments again .75 deg last few iterations of while loop.

i tried using own settings timer , pwm settings, did not work either:

void setup() {               tccr3a = tccr3b = 0;    tccr3a =  _bv(com3a1) | _bv(wgm31); //non-inverting    tccr3b = _bv(cs30) | _bv(wgm32) | _bv(wgm33); //prescalar=1, fast pwm    icr3= 500;    ocr3a= 6;    pinmode(5, output); }  void loop() {   while(ocr3a<500){     ocr3a+=80;     delay(500);   }   ocr3a=6; } 

using second code mirror rotates constant 1 degree , stays put there.

edit: have current gain circuit between arduino , mirrors, i've tested both circuit , mirrors function generator. off function generator work fine.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -