Using g-code values to control PWM

More
16 Aug 2021 14:51 #217890 by Krokrs
Hello,
 am trying to assign values from g-code (for example when i use M3 F1500) to control the value of PWM (pwmgen.0.value). Any idea what to add to the .hal script (or .ini ?) to make it work ?
Thx, Krokrs

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

More
16 Aug 2021 18:02 #217905 by chris@cnc
One way could be to set a dummy axis like w. 
If you write G0 W-5.00 and your PWM output is scaled to 10, PWM have 50% output power.

one expample of my used hal and ini.
# -----------PWM Generator signals/setup---
setp   hm2_7i76e.0.pwmgen.pwm_frequency 20000
setp   hm2_7i76e.0.pwmgen.00.output-type 1
setp   hm2_7i76e.0.pwmgen.00.scale  10

# -------------dummy axis control ------------------
net halui.program.is-running   => hm2_7i76e.0.pwmgen.00.enable                
net w-enable    <= joint.6.amp-enable-out        
net w-pos-cmd   <= joint.6.motor-pos-cmd
net w-pos-cmd   => joint.6.motor-pos-fb     hm2_7i76e.0.pwmgen.00.value
ini section
#************  dummy axis setup ******************************
[AXIS_W]
MAX_VELOCITY = 1000.0
MAX_ACCELERATION = 1000.0
MIN_LIMIT = -10.0
MAX_LIMIT = 0.5

[JOINT_6]
TYPE = LINEAR
HOME = 0.0
FERROR = 10.0
MIN_FERROR = 1.0
MAX_VELOCITY = 1000.0
MAX_ACCELERATION = 1000.0
MIN_LIMIT = -10.0
MAX_LIMIT = 0.5
HOME_OFFSET = 0.0
HOME_SEQUENCE = 5

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

More
16 Aug 2021 23:53 #217933 by andypugh
You can use spindle speed, as you suggest, then the HAL would need something like
net pwm-dc spindle.0.speed-out => pwmgen.0.value

Or you can use M67:
net pwm-dc motion.analog-out-00 => pwmgen.0.value

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

More
17 Aug 2021 13:40 #217982 by Krokrs
Hi, probably missunderstanding.
When I set M1 S1500, the spindle is not moving. Any of this M and S commands, which control the spindle aren´t doing anything.
So my solution is, that i connected PWM convertor and few other things and now am controlling speed of the spindle by the value of pwmgen.0.value.
And now the problem - i need the pwmgen.0.value to read the values from S-commmands. How to do it - i have no clue :D
Your solution is not working for me throughout in my view it´s because of my bad description of the problem.

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

More
17 Aug 2021 14:20 #217986 by andypugh
Do you want the pwmgen to control the spindle, or to control something else (like laser intensity?)

Can you attach your HAL file?
The following user(s) said Thank You: Krokrs

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

More
18 Aug 2021 07:04 #218043 by Krokrs
Solved !
It was just a basic thing - I didn´t watch properly the things & when i fixed one thing, it works. But thanks from help :)
Krokrs

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

Time to create page: 0.062 seconds
Powered by Kunena Forum