Using g-code values to control PWM

More
5 years 2 months ago #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 to join the conversation.

More
5 years 2 months ago #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.
Code:
# -----------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
Code:
#************  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 to join the conversation.

More
5 years 2 months ago #217933 by andypugh
You can use spindle speed, as you suggest, then the HAL would need something like
Code:
net pwm-dc spindle.0.speed-out => pwmgen.0.value

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

Please Log in to join the conversation.

More
5 years 2 months ago #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 to join the conversation.

More
5 years 2 months ago #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?

Please Log in to join the conversation.

More
5 years 2 months ago #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 to join the conversation.

Time to create page: 0.088 seconds
Powered by Kunena Forum