xy-plotter / xy

:pencil2: node.js for Makeblock XY plotter v2.0
MIT License
24 stars 6 forks source link

Servo goes down at the beginning of every run #11

Closed jvolker closed 6 years ago

jvolker commented 6 years ago

The servo goes down at the beginning of every run drawing a dot at [0,0]. Is there a way to prevent that?

Thanks.

arnaudjuracek commented 6 years ago

I did some research, and it appears that the problem is linked to the way the Arduino servo library works (1, 2, 3).

At the beginning of every run the serial port is opened, which mean that the plotter's board is reset and setup again, calling servo.attach(), which in turn setup the servo, drawing a dot.

I never encounter this problem on my personal setup because the [0,0] is usually outside the canvas. You might want to try to disable the servo setup as mentionned in the SO answer [1].

jvolker commented 6 years ago

Thanks.

I've now solved it by doing what is suggested in 2.

I changed the following lines in setup() from:

  servoPen.attach(servopin);
  delay(100);
  servoPen.write(servo_position);
  delay(1000);

to:

  servoPen.write(servo_position);
  servoPen.attach(servopin);
  delay(1000);

You might want to try to disable the servo setup as mentionned in the SO answer [1].

That didn't work, unfortunately.