Forum

Welcome Guest 

Show/Hide Header

Welcome Guest, posting in this forum requires registration.





Pages: [1]
Author Topic: Replacing servo and pen with laser
e_thirteen
Newbie
Posts: 5
Permalink
Post Replacing servo and pen with laser
on: January 22, 2016, 07:25
Quote

I'm totally new to all of this stuff (electronics / art / coding) but after tinkering for a few weeks I got a little carried away with the possibilities and decided to try replacing the pen and servo with a laser to see if some time-lapse video kind of thing would be possible.

I simply removed the motor and the gears from the servo and re-soldered (or rather, duct-taped some of the wiring, as seen in this photo :P) with a laser. I'd like to, however, keep the laser on when the laser (formerly servo) is commanded to penlift down. Right now, as expected, it simple sends one impulse that causes the laser to blink when commanded either penlift up or down.

I presume I may be able to make some changes to the script in the penlift.io file, but it may not be so simple?! I was hoping someone with much more experience than I may be able to help or point me in the right direction.

Any suggestions and help is welcome and much appreciated! Thanks!

PS: awesome project Sandy!
Image

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Replacing servo and pen with laser
on: January 22, 2016, 07:34
Quote

Hi, good idea!

It's probably pretty straightforward - there's a variable in the firmware called isPenUp, which is true if the pen is up (ie it's not drawing), and false if the pen is down (ie drawing).

So if you can use the value of that variable to control your laser pin, then I think that'd work.

You're right, the best place to actually put this control is in penlift.ino, there's two functions there (https://github.com/euphy/polargraph_server_a1/blob/master/penlift.ino#L57-L96) which you can replace with something as simple as

void penlift_penUp()
{
  digitalWrite(PEN_HEIGHT_SERVO_PIN, LOW);
  isPenUp = true;
}

void penlift_penDown()
{
  digitalWrite(PEN_HEIGHT_SERVO_PIN, HIGH);
  isPenUp = false;
}

Not tested it, and assumes your laser control pin is the same as the pin the servo would be connected on (pin 9?).

good luck,
sn

e_thirteen
Newbie
Posts: 5
Permalink
Post Re: Replacing servo and pen with laser
on: January 22, 2016, 08:21
Quote

Awesome -- thanks so much Sandy! Should have mentioned, however, I'm running a PolargraphSD, so presumably putting in the same code into penlift.io in the polarshield sub-folder? If different would you be able to help me out ever so slightly? Sorry for the dumb questions!

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Replacing servo and pen with laser
on: January 22, 2016, 08:42
Quote

Aye that file (penlift.ino) should be pretty much identical in both projects so give it a shot. Not dumb question at all!

e_thirteen
Newbie
Posts: 5
Permalink
Post Re: Replacing servo and pen with laser
on: January 22, 2016, 10:19
Quote

Hi Sandy, thanks so much for your help. I managed to compile and upload, but still doesn't seem to work. Right now, the laser doesn't blink on the pen up, and blinks once on the pen down. I am still hooked up to the same pin, and since some change occurred, it seems like we're on the right track. Any ideas as to why this might be happening? Thanks so much again!

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Replacing servo and pen with laser
on: January 22, 2016, 22:38
Quote

Have you got the laser LED working before? Does it take a high signal to turn on and low signal to turn off? I've never used a gizmo like that before.

sn

kongorilla
Pro
Posts: 362
Permalink
kongorilla
Post Re: Replacing servo and pen with laser
on: January 22, 2016, 23:16
Quote

@e_thirteen -- Your method of doing this is better than what I did, so keep going...BUT...if you get frustrated there is a code-free fallback plan (using the servo as a switch) --
https://www.youmagine.com/designs/kongorilla-s-led-light-painting-gondola

e_thirteen
Newbie
Posts: 5
Permalink
Post Re: Replacing servo and pen with laser
on: January 23, 2016, 08:18
Quote

@sandy -- thanks for your response! Yes, the first thing I tried was to simply have the laser hooked up to the wires going into the same pin, leaving the white wire out. This powered the laser, but it would be always be on. I then removed the board from the servo and hooked the laser up to the servo then back to the same wire going into the same pin. This caused the laser to turn on/off (pen up/pen down), but wouldn't stay on.

@kongorilla -- thanks for sharing and for the encouragement, great idea!
Image

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Replacing servo and pen with laser
on: January 23, 2016, 23:29
Quote

I tried changing the pin definition line to use the built-in LED on the arduino:

const byte PEN_HEIGHT_SERVO_PIN = 13;

And it works as expected, so lighting up when I do a pen-down and going off when I do a pen up. I can't think why pin 9 would be any different, but I haven't got a loose LED to connect up to test it.

e_thirteen
Newbie
Posts: 5
Permalink
Post Re: Replacing servo and pen with laser
on: January 28, 2016, 03:05
Quote

I also tried the same and it works as expected too. I'm thinking it is a hardware issue, and by the looks of it need to figure out a way to amplify power going to the laser.

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Replacing servo and pen with laser
on: January 28, 2016, 19:41
Quote

Did you try to run the laser off a different pin instead?

You should be a little ginger about driving things using the regular pins on an arduino because it's not hard to fry them. But if you've managed to drive the led using a different sketch, can that be true?

sn

Pages: [1]
Mingle Forum by cartpauj
Version: 1.0.34 ; Page loaded in: 0.044 seconds.