Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Laser control output does not match set value #18848

Closed
ryanaukes opened this issue Jul 29, 2020 · 20 comments
Closed

[BUG] Laser control output does not match set value #18848

ryanaukes opened this issue Jul 29, 2020 · 20 comments

Comments

@ryanaukes
Copy link

ryanaukes commented Jul 29, 2020

Bug Description

Laser output does not match the set value. When I set the laser to full power, I get the (correct) output of 5V, but when the value is just 1 unit lower, it immediately drops to 0.18V. For values from 0 to 254, the output scales from 0V to 0.19V.

My Configurations

Marlin.zip

Steps to Reproduce

  • Download marlin 2.0.6
  • Enable LASER_FEATURE

Expected behavior:

The laser pwm output should match the set value

Actual behavior:

When I set the laser to full power, I get the (correct) output of 5V, but when the value is just 1 unit lower, it immediately drops to 0.19V. For values from 0 to 254, the output scales from 0V to 0.19V. I measured everything with a multimeter because I don't have a osciloscope, but when I connect the laser, it it barely turns on when the power is set to anything below 255.

Additional Information

@ryanaukes ryanaukes changed the title [BUG] Laser control mixing up percentage and pwm [BUG] Laser control output does not match set value Jul 29, 2020
@ellensp
Copy link
Contributor

ellensp commented Jul 29, 2020

Config files need to be in a zip archive. then you just drop the zip in the boy of a reply.
Output is PWM, you need a scope,
"Most current DMM's have a display update of 3 readings per sec." it will miss most of the 5v pulses

@ryanaukes
Copy link
Author

Thanks for your reply. I know a multimeter is not optimal for measuring pwm duty cycle, but I have no osciloscope.
However, i have been measuring it this way before and it always worked (it took the weighted average voltage).
When I connect the laser, it barely turns on when the power is set to anything below 255.
That's why I measured the voltages and discovered this problem. I will try to upload my config files later today!

@ellensp
Copy link
Contributor

ellensp commented Jul 29, 2020

Still need config files.So we can replicate settings, see version, determine motherboard type etc.

@boelle
Copy link
Contributor

boelle commented Jul 29, 2020

@ryanaukes

Configurations, please
Please ZIP up your Configuration.h and Configuration_adv.h files (as
requested in the Issue template) and drop them into your next reply.
We'll check them over and see if anything is amiss.

RTFT

@ryanaukes
Copy link
Author

ryanaukes commented Jul 29, 2020

@boelle @ellensp

I updated my post, this time using the right format and included the config files. Sorry, I am not used to using Github. I hope everything is correct now.

@ellensp
Copy link
Contributor

ellensp commented Jul 29, 2020

Well first thing I notice is you have Dual X and Dual Y stepper motors and 1 extruder... so you seem to have modified the pins file to add in an extra stepper driver, and perhaps the laser pin...
Please provide your modified pins.h file also.

@ryanaukes
Copy link
Author

ryanaukes commented Jul 29, 2020

First of all, thanks for checking! That's correct. I am using a CNC machine with two steppers and two endstops on both the x and y axis. I am not using a extruder, but since marlin (at least according to the cnc documentation) needs at least one extruder, I changed the pins according to the CNC documentation. Here is the pins file. I am using the servo pins to control relays, so I am using pin 44 as the laser pwm pin.
pins_RAMPS.zip

@ellensp
Copy link
Contributor

ellensp commented Jul 30, 2020

you can set extruders to 0 in marlin...

@ellensp
Copy link
Contributor

ellensp commented Jul 30, 2020

It does look like something is wrong

I just have LED on pin 44.

If I use pin 44 just as a PWM with M42 P44 S240 I see the following in M43 and the led is quite bright.

PIN: 44 Port: L5 <unused/unknown>PWM: 240 TIMER5C PWM: 240 WGM: 1 COM5C: 0 CS: 3 TCCR5A: 9 TCCR5B: 3 TIMSK5: 0

But if enable laser and use M3 S240 the led is dull and m43 gives the following.

PIN: 44 Port: L5 SPINDLE_LASER_PWM_PIN PWM: 240 TIMER5C PWM: 240 WGM: 14 COM5C: 0 CS: 1 TCCR5A: 10 TCCR5B: 25 TIMSK5: 0

This is something to do with setting SPINDLE_LASER_FREQUENCY
If I turn this off I get expected results.

So that might be a short term fix while I look further.

@ellensp
Copy link
Contributor

ellensp commented Jul 30, 2020

With SPINDLE_LASER_FREQUENCY commented out.
M3 S1, results as expected.
M3S1
M3 S128, results as expected.
M3S128
M3 S254, results as expected.
M3S254

With SPINDLE_LASER_FREQUENCY enabled and set to 495hz (a freq Its already show mega can do)

M3 S10, (s1 was to glitched to capture) results are normaish.
M3S10F
M3 S128, results are abnormal.
M3S128F
M3 S254, results are abnormal.
M3S254f

@ryanaukes
Copy link
Author

Thanks! For the time being I will disable SPINDLE_LASER_FREQUENCY. Where can I find updates on when this bug is fixed?
Thanks again!

@ellensp
Copy link
Contributor

ellensp commented Jul 31, 2020

I have it working on test machine.. just checking it doesn't break anything else!
Updates will be posted here

@ellensp
Copy link
Contributor

ellensp commented Jul 31, 2020

The above PR fixes it.

@ellensp
Copy link
Contributor

ellensp commented Aug 3, 2020

This has been merged into bugfix.. now it needs retested.

@ryanaukes
Copy link
Author

ryanaukes commented Aug 4, 2020

@ellensp

Thanks! I added the changed code to my firmware and now the M3 command works as expected. I have one question however. I am using inline laser control. The inline laser control workds as expected, but now the laser is turned of when I do a G1 or G0 movement without a S?? parameter. Is this normal? I attached a gcode file. On every M3 S60 command, the laser turns on, but it turns off directly after that on the next G1 movement. When I set the laser power with an inline command, it does stay on on the next move without a S?? parameter. For example:

G1 X5 S60 // laser turns on
G1 X50 // laser stays on

But:

M3 S60 // turns the laser on
G1 X50 // laser turns off

In configuration_adv.h, I have disabled #define LASER_MOVE_G0_OFF

smiley outline.zip

@ellensp
Copy link
Contributor

ellensp commented Aug 5, 2020

That doesn't seem correct.

The way I read things when M3 is used Laser/spindle should stay on till M5 is given.

@jediminer543 and @shitcreek can you guys confirm or deny? (need someone who actually uses a laser!)

@ryanaukes
Copy link
Author

Thanks! I hope the other people you tagged can verify it and confirm it or tell me what I am doing wrong

@ellensp
Copy link
Contributor

ellensp commented Aug 9, 2020

Since you opened this as a new issue, closing this one as finished.

@ellensp ellensp closed this as completed Aug 9, 2020
@github-actions
Copy link

github-actions bot commented Oct 8, 2020

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 8, 2020
@shitcreek
Copy link
Contributor

shitcreek commented Oct 28, 2020

Sorry, just saw this now.

With LASER_POWER_INLINE it allows you to use the I parameter with M3, thus M3 Sxxx I won't immediately turn on the laser until there is a move command such as G1.
With LASER_MOVE_POWER, M3 is not needed as the laser can be triggered with the S parameter eg G1 Xxx Yxx S255
With LASER_MOVE_G0_OFF and LASER_MOVE_G28_OFF, M5 is not needed to turn off the laser.
G1 shouldn't be turning off the laser unless it's G1 ... S0 and you're using LASER_MOVE_POWER
Also it should be noted S0 with M3 or say G1 shouldn't turn off the laser if you're using CUTTER_POWER_RELATIVE

I hope it clears it up.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants