Laser spindle enable

Alright I have upgraded my 3d printer and have swapped out my GRBL board on my lowrider2 to the Creality 4.2.7 board which is an STM32f103ret6 running marlin.
I have a 7w laser that I am trying to configure to work with the pinout of the board.
The board has a BLtouch port that has 2 hardware PWM Pins I believe the BLtouch IN is on pin PB1 and the BLtouch OUT is on PB0. There is also a filament runout sensor that that is on PA1 of the STM32f103ret

SO in the marlin pin_CREALITY_v4 I edited line 64 to…

#define SPINDLE_LASER_PWM_PIN PB0 // BLTouch OUT “SERVO0_PIN” default
changed to SPINDLE_LASER_PWM_PIN

I plan on using either the PB1 as the SPINDLE_LASER_ENABLE … since I read somewhere in marlin comments that the enable has to be a digital pin… I plan on using a TTL relay that I have in stock to enable disable the power. would it be possible to use the " filament runout sensor on PA1 as the SPINDLE_LASER_ENABLE pin on the STM32103ret6, I would change Line 75-77:

//

// Filament Runout Sensor CHANGE TO SPINDLE_ENABLE

//

#ifndef FIL_RUNOUT_PIN

#define FIL_RUNOUT_PIN PA4 // “Pulled-high”

#endif

to something like…
#ifndef SPINDLE_LASER_ENA_PIN

#define SPINDLE_LASER_ENA_PIN PA4 // “Pulled-high”

or in Configuration_adv.h line 2962 in marlin bugfix 2.0
enable/define SPINDLE_SERVO? Currently with just the SPINDLE_LASER_PWM_PIN and line 2960 in configuration_adv.h I have LASER_FEATURE enabled. I am getting error on compile stating

#error “(SPINDLE|LASER)_FEATURE requires SPINDLE_LASER_ENA_PIN or SPINDLE_SERVO to control the power.”

Im confused in the SPINDLE_LASER_ACTIVE_STATE on line 2962 which is set low by default. Id assume the PWM would enable disable the laser depending on the PWM state.

only thing I can think is to add that SPINDLE_LASER_ENA_PIN to either the PA1 or PB1 with the relay, or could I set it to the same PIN # as the SPINDLE_LASER_PWM_PIN maybe with some VAR that state if >0 enabled
before I go and mess up all the code tinkering I rather see if anyone has any suggestions,

on the GRBL shield with ver GRBL 1.1 I was using It with laserGRBL and it set the endstop z+ I belive its Arduino D11 and I didnt have any enable disable pin just used the M3 M5 S Gcode commands…

The laser had 0 documentation and It has a weird driver I cant find documentation on… everything I found using that board type is using the part cooling fan with the m103 106 commands but… this thing drive thing is “12v input” but when I probe the laser out it’s 7.06v on the laser out… the pwm has 3 pins going into it 12v pwm ground


So I’m not sure if I can use those pins seeing as that driver module is operating the fan on the driver board and on the laser with 12v and the laser is being driven by that pwm which is maxed at 7v I guess I could put a buck converter on the part fan to drop to the 7v and plug the fan into the hot end heat sink fan port and bypass the driver that came with the laser. But in my research I saw that someone had issues with using the part cooling fan on the 4.2.7 board because it was only outputting a pwm @ 7khz or so and wasn’t enough to power the laser…
if not I can just keep using the grbl board , just trying to reuse something I already own to work as a standalone board, I am planing on putting an extruder and hot end on the low rider for large prints for mold making. And rather just have my carriage assembled with all the tools on it so i can just send gcode and not have to swap tools on and off.

Thanks,
Sean

This is stock marlin firmware buck converter 24v to 7v straight from power supply. Only positive is connected to laser, negative is connected to part cooling fan pin on 4.2.7 board (stm32f103ret).

:thinking:

Just tested from positive of part cooling fan to buck @ 7v to positive of laser and ground of part cooling fan to negative of laser same result

Not exactly the same, I have a 5w laser I was trying to setup ON my 3d printer, but im using the same 4.2.7 board. I had a laser hooked up to my Rambo on my MPCNC once and it worked WAY better. Unfortunately im mid Primo upgrade and nothing is hooked up. Another instance when an O scope would come in handy!

Just got back to this… I know the pwm controller outputs 7v to the laser… so I am assuming it’s 7v @ 1 amp thus being a 7 watt laser… with the buck boost converter module that I have a generic lm2596… which I’m regulating the 24v to 7 v and connecting it the typical way of - of laser to - of fan port k1 and the + of the laser to either the fan k1 or the ps and as in the video did not work. I tried using the filament runout pin as the laser enable to switch on a relay … that didn’t work. I put the laser to the pwm signal which I re mapped as shown above… and that wasn’t giving me any pwm signal… but at the same time I’m not going to stick the pwm which is a + to the - of the laser… but I’m not 100% sure but I believe those pwm pins on the bk touch port are 5v regulated :woman_shrugging: Not sure but then I would have to either boost the 5v to 7 v… or 12v to go into the lasers pwm controller ( which I fried the diode off the board fiddling with it… so that’s not really an option, either way the laser pwm board asks for 12v not sure if the pwm has to be 12v cuz it says it’s ttl pwm I assume it’s 5v… which should be fine for the pwm board which would work in theory off that bl touch in or out ports… which I have to check if there is a diode in the circuit preventing out put and input from labels bl touch in out… either way I can use the out … and it should send a 5v pwm signal ( if that bl touch port is infact 5v ) then I can power the pwm module ( if I can fix that microscopic diode if I can even find out what type of diode that was… the circuit board is all black so it’s nearly impossible to trace the circuit to fix it. I have that option , or I got to get that 5v or the fan 24v to 7v and have the pwm triggering in or on the ground cable is that even possible :woman_shrugging:… seems like it is how the k1 fan port works… if all available instructions say to do it that way. So I suspect that in fact whatever soft pwm is in marlin, or the actual circuit is doing something to the frequency or signal of the k1 - or ground pin. I’m going to see if i can run it on the GRBL board now that I fried the 12v pwm board… and see if with the lm2596 board set to 7v… and see if that works… but I believe that the pwm signal being on the - or ground end isn’t going to work… and the pwm signal going through the lm2596 is going to re smooth the signal since it has its own smoothing circuit…

If you got that same board as mine for the laser handy … what size diode is that… and your output voltage on the laser pin on yours I assume would display 5v since it’s a 5w laser compared to what I was getting 7v for the 7 watt version … if anyone has that info that would be much appreciated

I Don’t have it torn apart at the moment but I did get it working better, oddly I used the other fan port and it started to behave as expected.

Yeah I noticed on the other fan port when messing with the gcode command for the p1 fan it would make the other cpu fan or p2 I guess do stuff too… they must have them paired in some way… but I’ll give it a shot! Thanks iseman!

I’m actually waiting on some stepper motors to add to the gantry system to turn this thing into a pick and place machine / cnc… I kinda want to leave the grbl board running the cnc and some how link the two boards up one to run the steppers and the other to run all the gantry stuff lots of digging around … but I think I might switch to a board that has the uart control of the TMC I think I can get a lot more use out of the drivers features in pick and place application

I have the low rider set up 4x8 sized table and there is a lot of space around the work area that can be set up for the pnp tools and what not so I might as well give it a whirl… the low rider seems perfectly set up for pnp… and without using its z axis… make another z axis that sits on the large gantry itself… then all the weight issues of the gantry disappear… but it sits a nice height from the work space in its z0 position so the nema 8 I have coming in with a small actuator should hang on just fine without having to remove my main spindle I want to experiment research more on soldering paste and using laser to solder the pads🤷‍♀️ Experiments…

interesting setup idea. I think the laser for the solder might… well I have no idea… id be cautious though since its more reflective in its liquid form. Also wouldn’t you want the solder pads soldered from the bottom? Regardless I wish you well! In regards to the two fan ports they are definitely connected as they both respond to the M106/107 fo rme, but I cant explain it beyond that, it started working and my wife put me to work instantly!

Lol, yeah I’m up in the air with the whole soldering thing… I guess I could make a huge heated bed lol! I haven’t really reflowed anything yet… So when I get there I’ll cross that bridge I got however long it takes something to get ere from China :woman_shrugging: Or where ever they have those nema 8 motors stashed away… whoever makes those things is keeping those things undercover… just want to get all These boards to jive… I’m thinking Linux cnc or a combo of the two… i just downloaded this openpnp thing… got to figure it out on my raspi 4… it’s having some issues I think I got to download some dependencies … but it’s on my windows 10 for now gonna plug in a bunch of boards and see what the hell happens… see if I can just configure all the diffrent stuff in the Linux cnc or openpnp… if I can’t figure it out I’m looking at some de soldering of the motor drivers and try and mill out some cheap copper PCBs I have to make a daughter board … that way I can set them up in uart vs the mandatory standalone mode on the creality board… I think that whole debug mode or whatever makes up sensorless homing will be a nice feature for limit switch end stop kinda ordeal … I’ll take that luck and hopefully I got it jiving by the time the motors get here.

I just downloaded the latest nightly for marlin and its config files…

There are a bunch of new options in the config files for the 4.2.7 which include:
PWM / soft PWM fan control settings which have decent notes in them…
In advanced settings they added some pwm,fast pwm, pid fan scaling , pwm freq option…
a synchronous laser control for the m106/7

I havent messed with anything with the new stuff but I got the 4.2.7 to run the laser off the PB1 pin which is the BLTIN which is Pwm worked very steady solid freq from 0-5 v,

#define SPINDLE_LASER_PWM_PIN PB1 // BLTouch IN changed to
SPINDLE_LASER_PWM_PIN
you might need to have a spindle enable if it doesnt compile right

#define SPINDLE_LASER_ENABLE_PIN xx   // digital pin
#define SPINDLE_LASER_PWM_PIN    yy   // digital pin - MUST BE HARDWARE PWM
#define SPINDLE_DIR_PIN          zz   // digital pin

Going to mess with the new features for the fan controller options and frequency stuff this weekend… since my laser needs 7v for the 7w and I broke that ttl pwm board I have to hack something together for 7v not the 5v that the bltouch in( pb1) pin can output but if your laser is 5v on the output or your using the ttl driver you’ll be good with that setup granted your not using the bl touch port. But I’ve been looking through the new as of 2/5/2021 bug fix marlin firmware and the creality 4.2.7 board since it’s not uart connected we lose some features of the tmc 2209. In the configuration_adv.h file around line 2640 “use stallguard to home “ if you read the comment it says to connect the stepper driver DIAG1 pin to X/y end stop pin. I might break out the DIAG1 pin on all the steppers jumper wire them to the limit switch connectors and see what happens from there. Never needed to use diagnostics ports on steppers before so this is all new to me… but once I’m done going through the stm32f103 pinout ( this is first time compiling stm32) not to familiar with the GPIOs functionality… but I assume if you can use proximity limit switches and adjust for sensitivity that I will be able to get a read out from the DIAG1 pins through the jumped limit switch port, allowing for sensorless homing . I’m going to investigate more if that DIAG1 and the INDEX pin or debug pins of the tmc2209 can be used even if the driver is not in uart mode , or what I’m doing is actually putting it into uart mode.

For the pick and place , the sensorless homing or those debug pins and the right sensitivity settings, can probably be used to trigger the machine when the nozzle with or without the component connected can be the z height trigger , since what it’s sensing for is the difference current or whatever when the motors load goes up when it starts to hit something …