7i96s Flash for additional PWM and Wiring for laser
- SneakyGamer
- Offline
- New Member
-
Less
More
- Posts: 8
- Thank you received: 0
23 Dec 2024 07:10 #317178
by SneakyGamer
7i96s Flash for additional PWM and Wiring for laser was created by SneakyGamer
So finally on my holiday break and looking to try and connect my 40w Diode laser to my machine
want to get some guidance before i flash my 7i96s and cause my whole CNC to stop working.
would like to be able to use the spindle control, whether that is scalled or as a percentage to adjust the 0-5v for the intensity of the laser
so i understand that i have to flash the board with 7i96s_2pwmd.zip, which will add PWMGen 1 to STEP4+/STEP4-
Is how i have the diagram, would this be the correct way i need to wire to the board?
also is this the correct coding i need to add into my hal/ini file?
(HAL)
# Enable PWM generator on channel 0
etp hm2_7i96s.0.pwmgen.00.enable true
# Set the PWM frequency (adjust based on laser specs)
setp hm2_7i96s.0.pwmgen.00.scale 5000 # Example: Scale to 5000 RPM for 0-5V lasers
# Link PWM output to motion spindle speed command
net laser-power motion.spindle-speed-out => hm2_7i96s.0.pwmgen.00.value
# Link PWM enable to motion spindle enable
net laser-enable motion.spindle-on => hm2_7i96s.0.pwmgen.00.enable
# Link motion spindle-on signal to a GPIO pin
net laser-on motion.spindle-on => hm2_7i96s.0.gpio.000.out
(INI)
[SPINDLE]
SPINDLE_TYPE = PWM
MAX_SPINDLE_SPEED = 5000
# Match the scale in HAL MIN_SPINDLE_SPEED = 0
want to get some guidance before i flash my 7i96s and cause my whole CNC to stop working.
would like to be able to use the spindle control, whether that is scalled or as a percentage to adjust the 0-5v for the intensity of the laser
so i understand that i have to flash the board with 7i96s_2pwmd.zip, which will add PWMGen 1 to STEP4+/STEP4-
Is how i have the diagram, would this be the correct way i need to wire to the board?
also is this the correct coding i need to add into my hal/ini file?
(HAL)
# Enable PWM generator on channel 0
etp hm2_7i96s.0.pwmgen.00.enable true
# Set the PWM frequency (adjust based on laser specs)
setp hm2_7i96s.0.pwmgen.00.scale 5000 # Example: Scale to 5000 RPM for 0-5V lasers
# Link PWM output to motion spindle speed command
net laser-power motion.spindle-speed-out => hm2_7i96s.0.pwmgen.00.value
# Link PWM enable to motion spindle enable
net laser-enable motion.spindle-on => hm2_7i96s.0.pwmgen.00.enable
# Link motion spindle-on signal to a GPIO pin
net laser-on motion.spindle-on => hm2_7i96s.0.gpio.000.out
(INI)
[SPINDLE]
SPINDLE_TYPE = PWM
MAX_SPINDLE_SPEED = 5000
# Match the scale in HAL MIN_SPINDLE_SPEED = 0
Please Log in or Create an account to join the conversation.
- PCW
-
- Away
- Moderator
-
Less
More
- Posts: 18941
- Thank you received: 5230
23 Dec 2024 16:00 #317206
by PCW
Replied by PCW on topic 7i96s Flash for additional PWM and Wiring for laser
That looks close if the laser driver uses PWM and not 0 to 5V analog
Notes:
The STEP+ pin will start up in the high state so for safety you should use the STEP- pin
and invert the PWM output in the hal file. I would change the hal setup to:
# invert pwm output
setp hm2_7i96s.0.pwmgen.01.out0.invert_output true
# Set the PWM frequency (adjust based on laser specs)
setp hm2_7i96s.0.pwmgen.01.scale 5000 # Example: Scale to 5000 RPM for 0-5V lasers
# Link PWM output to motion spindle speed command
net laser-power motion.spindle-speed-out => hm2_7i96s.0.pwmgen.01.value
# Link PWM enable to motion spindle enable
net laser-enable motion.spindle-on => hm2_7i96s.0.pwmgen.01.enable
# Link motion spindle-on signal to a 7I96S SSR output pin
net laser-enable hm2_7i96s.0.ssr.00.out-00
(PWM channel 0 is for the analog spindle out on TB2 pins 22..24)
Notes:
The STEP+ pin will start up in the high state so for safety you should use the STEP- pin
and invert the PWM output in the hal file. I would change the hal setup to:
# invert pwm output
setp hm2_7i96s.0.pwmgen.01.out0.invert_output true
# Set the PWM frequency (adjust based on laser specs)
setp hm2_7i96s.0.pwmgen.01.scale 5000 # Example: Scale to 5000 RPM for 0-5V lasers
# Link PWM output to motion spindle speed command
net laser-power motion.spindle-speed-out => hm2_7i96s.0.pwmgen.01.value
# Link PWM enable to motion spindle enable
net laser-enable motion.spindle-on => hm2_7i96s.0.pwmgen.01.enable
# Link motion spindle-on signal to a 7I96S SSR output pin
net laser-enable hm2_7i96s.0.ssr.00.out-00
(PWM channel 0 is for the analog spindle out on TB2 pins 22..24)
The following user(s) said Thank You: SneakyGamer
Please Log in or Create an account to join the conversation.
- SneakyGamer
- Offline
- New Member
-
Less
More
- Posts: 8
- Thank you received: 0
23 Dec 2024 23:29 - 23 Dec 2024 23:30 #317245
by SneakyGamer
Replied by SneakyGamer on topic 7i96s Flash for additional PWM and Wiring for laser
ooh ok thanks
yeah oversight, should be channel 1 if im using step/dir4
# Enable PWM generator on channel 1
setp hm2_7i96s.0.pwmgen.01.enable true
or do i not need this command if im replacing it with the invert
# invert pwm output
setp hm2_7i96s.0.pwmgen.01.out0.invert_output true
yeah oversight, should be channel 1 if im using step/dir4
# Enable PWM generator on channel 1
setp hm2_7i96s.0.pwmgen.01.enable true
or do i not need this command if im replacing it with the invert
# invert pwm output
setp hm2_7i96s.0.pwmgen.01.out0.invert_output true
Last edit: 23 Dec 2024 23:30 by SneakyGamer.
Please Log in or Create an account to join the conversation.
- PCW
-
- Away
- Moderator
-
Less
More
- Posts: 18941
- Thank you received: 5230
24 Dec 2024 00:16 #317248
by PCW
Replied by PCW on topic 7i96s Flash for additional PWM and Wiring for laser
I would not permanently enable the pwmgen with setp but rather enable it by
connecting it to spindle-on as shown.
Inverting the PWM output and using the STEP- pin is needed because it guarantees that the
PWM pin is low before LinuxCNC is running, during power up, and after a fault (watchdog bite)
connecting it to spindle-on as shown.
Inverting the PWM output and using the STEP- pin is needed because it guarantees that the
PWM pin is low before LinuxCNC is running, during power up, and after a fault (watchdog bite)
Please Log in or Create an account to join the conversation.
- SneakyGamer
- Offline
- New Member
-
Less
More
- Posts: 8
- Thank you received: 0
26 Dec 2024 02:44 #317383
by SneakyGamer
Replied by SneakyGamer on topic 7i96s Flash for additional PWM and Wiring for laser
Thankyou so far for the help PCW
but unfortunetly no luck with the coding side of things
managed to eventually sucessfully flash the mesa board with the 7i96s_2pwmd.bin after a few complications of mesaflash not being able to detect my board.
but afterwards all seemed to operate my existing cnc with no issues,
however as soon as i tried to update any of the hal or ini for the laser, linuxcnc failed to boot giving me the debug prompt.
is there any way to determine from the debug prompt message it provides what it doesnt like??
have provided my current working hal and ini, does not have any of the new additonal code that id need to run laser off spindle
but unfortunetly no luck with the coding side of things
managed to eventually sucessfully flash the mesa board with the 7i96s_2pwmd.bin after a few complications of mesaflash not being able to detect my board.
but afterwards all seemed to operate my existing cnc with no issues,
however as soon as i tried to update any of the hal or ini for the laser, linuxcnc failed to boot giving me the debug prompt.
is there any way to determine from the debug prompt message it provides what it doesnt like??
have provided my current working hal and ini, does not have any of the new additonal code that id need to run laser off spindle
Please Log in or Create an account to join the conversation.
- PCW
-
- Away
- Moderator
-
Less
More
- Posts: 18941
- Thank you received: 5230
26 Dec 2024 03:14 #317386
by PCW
Replied by PCW on topic 7i96s Flash for additional PWM and Wiring for laser
Start LinuxCNC from a terminal window and the error messages will be displayed there.
Please Log in or Create an account to join the conversation.
- roland100
- Offline
- New Member
-
Less
More
- Posts: 6
- Thank you received: 0
21 Jul 2025 18:20 #332140
by roland100
Replied by roland100 on topic 7i96s Flash for additional PWM and Wiring for laser
Hello PCW,
I flashed my 7i96s with 7i96s_2pwmd.bin and put this line to my custom.hal:
# invert pwm output
setp hm2_7i96s.0.pwmgen.01.out0.invert_output true.
When I start linuxcnc i get the error message
"parameter hm2_7i96s.0.pwmgen.01.out0.invert_output not found"
The hmid-output looks correct:
TB2 2,3 25 IOPort PWM 1 PWM (Out)
TB2 4.5 26 IOPort None
I flashed my 7i96s with 7i96s_2pwmd.bin and put this line to my custom.hal:
# invert pwm output
setp hm2_7i96s.0.pwmgen.01.out0.invert_output true.
When I start linuxcnc i get the error message
"parameter hm2_7i96s.0.pwmgen.01.out0.invert_output not found"
The hmid-output looks correct:
TB2 2,3 25 IOPort PWM 1 PWM (Out)
TB2 4.5 26 IOPort None
Please Log in or Create an account to join the conversation.
- PCW
-
- Away
- Moderator
-
Less
More
- Posts: 18941
- Thank you received: 5230
21 Jul 2025 18:36 #332142
by PCW
Replied by PCW on topic 7i96s Flash for additional PWM and Wiring for laser
Did you enable 2 PWMGens in the hal file?
Please Log in or Create an account to join the conversation.
- roland100
- Offline
- New Member
-
Less
More
- Posts: 6
- Thank you received: 0
21 Jul 2025 19:15 #332144
by roland100
Replied by roland100 on topic 7i96s Flash for additional PWM and Wiring for laser
Hello PCW,
I managed to get rid of the error messages by changing these values in the hal file:
num-pwmgens = 2 (from 1) and
num-stepgens = 4 (from 5)
Now I also can see pwmgen.01 in the halcmd show all *pwmgen*:
roland@linuxCNC:~$ halcmd show all *pwmgen*
Loaded HAL Components:
ID Type Name PID State
Component Pins:
Owner Type Dir Value Name
36 bit IN FALSE hm2_7i96s.0.pwmgen.00.enable <== spindle-enable
36 float IN 0 hm2_7i96s.0.pwmgen.00.value <== spindle-vel-cmd-rpm
36 bit IN FALSE hm2_7i96s.0.pwmgen.01.enable
36 float IN 0 hm2_7i96s.0.pwmgen.01.value
Pin Aliases:
Alias Original Name
Signals:
Type Value Name (linked to)
Parameters:
Owner Type Dir Value Name
36 bit RW FALSE hm2_7i96s.0.pwmgen.00.offset-mode
36 s32 RW 1 hm2_7i96s.0.pwmgen.00.output-type
36 float RW 18000 hm2_7i96s.0.pwmgen.00.scale
36 bit RW FALSE hm2_7i96s.0.pwmgen.01.offset-mode
36 bit RW TRUE hm2_7i96s.0.pwmgen.01.out0.invert_output
36 bit RW FALSE hm2_7i96s.0.pwmgen.01.out0.is_opendrain
36 s32 RW 1 hm2_7i96s.0.pwmgen.01.output-type
36 float RW 5000 hm2_7i96s.0.pwmgen.01.scale
36 u32 RW 0x005B8D80 hm2_7i96s.0.pwmgen.pdm_frequency
36 u32 RW 0x00004E20 hm2_7i96s.0.pwmgen.pwm_frequency
Parameter Aliases:
Alias Original Name
hm2_7i96s.0.pwmgen.01.out0.invert_output hm2_7i96s.0.gpio.025.invert_output
hm2_7i96s.0.pwmgen.01.out0.is_opendrain hm2_7i96s.0.gpio.025.is_opendrain
is this correct ?
Tahnks a lot and good night
I managed to get rid of the error messages by changing these values in the hal file:
num-pwmgens = 2 (from 1) and
num-stepgens = 4 (from 5)
Now I also can see pwmgen.01 in the halcmd show all *pwmgen*:
roland@linuxCNC:~$ halcmd show all *pwmgen*
Loaded HAL Components:
ID Type Name PID State
Component Pins:
Owner Type Dir Value Name
36 bit IN FALSE hm2_7i96s.0.pwmgen.00.enable <== spindle-enable
36 float IN 0 hm2_7i96s.0.pwmgen.00.value <== spindle-vel-cmd-rpm
36 bit IN FALSE hm2_7i96s.0.pwmgen.01.enable
36 float IN 0 hm2_7i96s.0.pwmgen.01.value
Pin Aliases:
Alias Original Name
Signals:
Type Value Name (linked to)
Parameters:
Owner Type Dir Value Name
36 bit RW FALSE hm2_7i96s.0.pwmgen.00.offset-mode
36 s32 RW 1 hm2_7i96s.0.pwmgen.00.output-type
36 float RW 18000 hm2_7i96s.0.pwmgen.00.scale
36 bit RW FALSE hm2_7i96s.0.pwmgen.01.offset-mode
36 bit RW TRUE hm2_7i96s.0.pwmgen.01.out0.invert_output
36 bit RW FALSE hm2_7i96s.0.pwmgen.01.out0.is_opendrain
36 s32 RW 1 hm2_7i96s.0.pwmgen.01.output-type
36 float RW 5000 hm2_7i96s.0.pwmgen.01.scale
36 u32 RW 0x005B8D80 hm2_7i96s.0.pwmgen.pdm_frequency
36 u32 RW 0x00004E20 hm2_7i96s.0.pwmgen.pwm_frequency
Parameter Aliases:
Alias Original Name
hm2_7i96s.0.pwmgen.01.out0.invert_output hm2_7i96s.0.gpio.025.invert_output
hm2_7i96s.0.pwmgen.01.out0.is_opendrain hm2_7i96s.0.gpio.025.is_opendrain
is this correct ?
Tahnks a lot and good night
Please Log in or Create an account to join the conversation.
- PCW
-
- Away
- Moderator
-
Less
More
- Posts: 18941
- Thank you received: 5230
21 Jul 2025 19:36 #332145
by PCW
Replied by PCW on topic 7i96s Flash for additional PWM and Wiring for laser
Looks OK
You can also simply delete the num_xxxx=n stanzas in the hal file
and all hardware in a particular configuration will be enabled.
You can also simply delete the num_xxxx=n stanzas in the hal file
and all hardware in a particular configuration will be enabled.
Please Log in or Create an account to join the conversation.
Moderators: PCW, jmelson
Time to create page: 0.074 seconds