Setting up Remora for laser cutting

More
07 Jun 2021 20:30 - 07 Jun 2021 20:40 #211446 by Doogie
I have LinuxCNC v2.9.0-pre0 running on an rPi controlling a 3D printer via Remora on a LPC176x controller board and now want to get the laser cutter operational before I get to the 3040 CNC. I have the X, Y motion set and working but enabling the spindle and PWM on the heat-bed output FET isn't working for me. It was doing fine controlled by a PID process but now it needs to be controlled by the spindle commands(M3,M4,M5,Sxxx).

I saw that @Aaroncnc got his CNC mill spindle under VFD control using this section of hal config:
loadrt pwmgen output_type=0
addf pwmgen.update servo-thread
addf pwmgen.make-pulses base-thread
net spindle-speed-cmd spindle.0.speed-out => pwmgen.0.value
net spindle-on spindle.0.on => pwmgen.0.enable
net spindle-pwm pwmgen.0.pwm => parport.0.pin-09-out
setp pwmgen.0.scale 1800

I have the heat-bed pwm output on remora.SP.0 but can't seem to get the output FET working. halscope shows remora.SP.0 turning on/off with this but I don't see the FET responding.
loadrt scale count=1
        addf scale.0 servo-thread
        #setp scale.0.gain 0.002
        setp scale.0.gain 1.000
        net spindle-speed-scale spindle.0.speed-out => scale.0.in
        net spindle-cw <= spindle.0.forward
        net spindle-cw => remora.output.1
        net spindle-speed scale.0.out => remora.SP.0

Laser cutter gcode CAM software will use the Sx of the spindle speed control to vary the laser power and 32bit controllers use
S0 and S1000 as Min / Max values. Any hints or ideas would be helpful. Thx
Last edit: 07 Jun 2021 20:40 by Doogie.

Please Log in or Create an account to join the conversation.

More
07 Jun 2021 21:05 - 07 Jun 2021 21:27 #211448 by Aaroncnc
hmm, this may be best done over a live chat.
I played alot with the pwm gen.
i used both the remora gen and using linux cnc and just told remora to give me a standard output.
Both have ups and downs.
are you on any fo the linux cnc IRC?

here is some code from my config for my skr.14 board.
{
	"Thread": "Servo",
	"Type": "Digital Pin",
		"Comment":			"IO spindle pwm",
		"Pin":				"1.0",
		"Mode":				"Output",
		"Data Bit":			2
	},
	{
	"Thread": "Servo",
	"Type": "PWM",
		"Comment": 			"SPI Spindle PWM",
		"SP[i]": 			3,
		"PWM Pin": 			"1.28"
	},


here is from my hal file
# Initialize the pwmgen
	loadrt pwmgen output_type=0
	addf pwmgen.update servo-thread
	addf pwmgen.make-pulses servo-thread
	setp pwmgen.0.pwm-freq 0.0 #set to zero for PDM
	setp pwmgen.0.scale 12000.0 
	setp pwmgen.0.offset 0.000
	setp pwmgen.0.dither-pwm true
	setp pwmgen.0.min-dc 0.00 # min output duty cycle --> lowest possible spindle speed
	setp pwmgen.0.max-dc 1 # max output duty cycle  --> highest possible spindle speed

	net spindle-pwm           pwmgen.0.pwm           => remora.output.2
in the above i can swap between using the built in pwm gen of remora or use linux cnc just with a change of my hal file. as remora will have pins setup to do both.

I am attaching my hal file for using the remora built in pwm generator. as remora needs a 0-100 number over spi for the built in generator to work.
it also needs a ABS (absolute component to fix the negative number problem, if i ran my spindle one way everything worked but tried the other direction and it would not, remora cant handle negative numbers yet for spindle pwm. maybe we should raise this as an issue to make the user config a bit better.)
Attachments:
Last edit: 07 Jun 2021 21:27 by Aaroncnc.
The following user(s) said Thank You: Doogie

Please Log in or Create an account to join the conversation.

More
07 Jun 2021 22:34 #211452 by Doogie
Thanks! I'll take a look at your hal file and see if I can get LinuxCNC pwm handling this at first and later Remora. Unlike a CNC, laser cutters/engravers will do lots of fast power changes when engraving so it might be better there in the long run. For laser cutters at least.

I'm not on the LinuxCNC IRC channel and it's been years since I've connected onto one. Let me look at your hal file and try a few things before seeing what IRC looks like these days. It was text based the last time I used it, it's been THAT long ago.

Please Log in or Create an account to join the conversation.

More
07 Jun 2021 23:10 #211454 by Aaroncnc
to turn off the pid
setp pid.0.Pgain 20 -> setp pid.0.Pgain 0

Please Log in or Create an account to join the conversation.

More
07 Jun 2021 23:32 #211459 by Doogie
I trimmed your hal parts to what I think might be needed(no encoders, no PID, etc) and see on the halscope my SP.0 operating but nothing usable on the heat-bed output FET. With smoothieware running the laser that's the pin used to control the laser so I was just sticking with what was before. I recently learned that the PWM freq needs to be between 200-400 Hz so I'll have to look into that too.

Here's the trimmed hal config segments related to spindle:
#PID stuff
loadrt abs count=1

# Initialize the scale (This is used to scale the encoder pulse to RPM)
# Scaling factor 300 pulses per revolution x 60 sec per min = 18000 *4 for quad = 72000
loadrt scale count=1
addf scale.0 servo-thread


# Initialize the pwmgen
loadrt pwmgen output_type=0
addf pwmgen.update servo-thread
addf pwmgen.make-pulses servo-thread #base
setp pwmgen.0.pwm-freq 0.0 #was 50 set to zero for PDM
setp pwmgen.0.scale 6600.0 #4000
setp pwmgen.0.offset 0.000
setp pwmgen.0.dither-pwm true
setp pwmgen.0.min-dc 0.01 # min output duty cycle --> lowest possible spindle speed
setp pwmgen.0.max-dc 1 # max output duty cycle --> highest possible spindle speed

#spindle DAC 0-10 control
setp scale.0.gain 0.02 #0.002
addf abs.0 servo-thread


# Initialize the sum2
loadrt sum2 count=1
addf sum2.0 servo-thread

# Initialize the inverter for negative feedback
loadrt invert count=1
addf invert.0 servo-thread


# Spindle PID closed loop controler
net spindle-cw <= spindle.0.forward => remora.output.1
net spindle-on spindle.0.on => remora.output.0
#net spindle-pwm pwmgen.0.pwm => remora.output.2

net spindle-speed-scale spindle.0.speed-out => scale.0.in
net spindle-speed-abs scale.0.out => abs.0.in
net spindle-speed-DAC abs.0.out => remora.SP.0

Please Log in or Create an account to join the conversation.

More
07 Jun 2021 23:46 #211461 by Doogie
geesh, on halscope I was seeing spindle.0.on and not SP.0... When I setup the 2 pin monitoring I did not move positions vertically so when I thought I was seeing SP.0 it was just spindle.0.on instead.

Please Log in or Create an account to join the conversation.

More
08 Jun 2021 00:04 #211464 by Aaroncnc
So we're you able to get pwm working?

Please Log in or Create an account to join the conversation.

More
08 Jun 2021 00:17 - 08 Jun 2021 00:38 #211465 by Doogie
no, not yet. I had thought I was seeing something on halscope related to remora.SP.0 which is pin 2.5 on the MKS Sbase v1.3 board but I was not seeing any movement and instead it was spindle.0.on signal moving.

not working. I have to step back and start reading how to use this hal and what I'm actually doing.
It's just copy and paste with vague understanding of what's going on.

BTW, I've gone back to the trimmed version of your hal config and I'm seeing the remora.SP.0 pin changing signal level when I increase the spindle frequency( the + / - buttons in Axis GUI ). I would have expected to see pulse width variations, not amplitude variations.
But you probably needed your VFD to take 0-10V instead of PWM...
Last edit: 08 Jun 2021 00:38 by Doogie.

Please Log in or Create an account to join the conversation.

More
08 Jun 2021 00:42 #211468 by Doogie
I see now, you are feeding your pwm to a DAC... I may just need to NOT do that and somehow set the spindle pwm to remora.SP.0.

net spindle-speed-scale spindle.0.speed-out => scale.0.in
net spindle-speed-abs scale.0.out => abs.0.in
net spindle-speed-DAC abs.0.out => remora.SP.0

Please Log in or Create an account to join the conversation.

More
08 Jun 2021 01:01 #211471 by Doogie
So here's one of the things I don't get, the pin is already assigned as PWM to Remora in config.txt and I should be able to manipulate it just like I did with cooling fan speed which only took one label assignment( net ext0-cooling-SP => remora.SP.2 ) and with custom M commands the fan speed was pwm'ed by the gcode.

Here, the spindle stuff is already defined so I can't just set something like spindle-SP => remora.SP.0 and then create M3,M4 and M5 commands because they are already handled as spindle commands within LinuxCNC.

I also keep running across typing issues like this so I have to figure out what type of data spindle-pwm is and convert it to a float and I'm guessing then scale it to get it in the data rance expected.
./3Dprinter.hal:73: Signal 'spindle-pwm' of type 'bit' cannot add pin 'remora.SP.0' of type 'float'

Please Log in or Create an account to join the conversation.

Time to create page: 0.079 seconds
Powered by Kunena Forum