User Tools

Site Tools


Sidebar

Home



Expressions


About

Functions

   expr_list()

   exec()
   return()
   if()
   for()
   loop()
   nop()

  Output
   print()
   clear()
   debug()

  Math
   abs()
   sign()

   sqr()
   sqrt()

   min()
   max()

   inc()
   dec()

   rand()

   none()
   nan()

   def()
   defnz()

   is_none()
   is_num()
   is_str()
   is_valid()

   bool()

  Rounding
   round()
   roundup()
   floor()
   ceil()
   trunc()
   center()
   centerex()

   s8()
   u8()
   s16()
   u16()
   s32()
   u32()

  Trigonometric
   pi()
   sin()
   cos()
   tan()
   asin()
   acos()
   atan()
   atan2()

   rad2deg()
   deg2rad()

  Logarithmic
   e()
   pow()
   exp()
   exp10()
   exp2()
   log()
   log10()
   log2()

  Bitwise
   bit()
   not()
   and()
   or()
   xor()
   nand()
   nor()
   xnor()
   shl()
   shr()

  Logical
   lnot()
   land()
   lor()
   lxor()
   lnand()
   lnor()
   lxnor()

  Relational
   eq()
   ne()
   gt()
   lt()
   ge()
   le()

  Date & Time
   date()
   datetime()
   year()
   month()
   day()
   hour()
   minute()
   second()
   millisec()

  Strings
   str()
   strlen()
   padleft()
   padright()
   hex()
   bin()
   chr()
   match()

  Parameters
   param_get()
   param_set()
   param_remove()
   param_persistent()

  Coordinates & Units
   to_motor()
   to_motor_xy()
   to_motor_uv()

   to_work()
   to_work_xy()
   to_work_uv()

   mm_to_unit()
   unit_to_mm()

   mm_to_setunit()
   setunit_to_mm()

   unit_to_setunit()
   setunit_to_unit()

   setunit()

  Commands
   estop()
   stop()
   pause()
   start()

   open()
   close()

   settings()
   exit()
   exitforce()

   output()
   output_pwm()
   output_rc()

   mist()
   flood()
   spindle()

   extout1()
   extout2()

   jog()
   jog_axis()
   jog_stop()

   speed_override()
   spindle_override()

   thc()

   cmd_list()
   cmd_count()

   cmd_get_id()
   cmd_get_name()
   cmd_get_displayname()

   cmd_is_enabled()
   cmd_is_checked()

   cmd_exec()

   open_file()
   open_code()
   start_file()
   start_code()
   test_file()
   test_code()

   run()

   py_list()
   py()
   py_term()
   py_msg()

  UI
   is_visible()
   show()
   hide()

   set_status()
   set_progress()

   is_ui_ready()

  Message
   msg()
   msgerr()

   msg_show()

   msg_count()
   msg_is_active()

   msg_click_ok()
   msg_click_cancel()

   bubble()

  Dialog
   dlg_file_open()
   dlg_file_save()

   dlg_new()
   dlg_init()
   dlg_update()
   dlg_clear()

   dlg_show()
   dlg_abort()

   dlg_is_valid()
   dlg_keep_open()
   dlg_callback()

   dlg_modal()
   dlg_set_resizable()
   dlg_set_pos()
   dlg_set_size()
   dlg_set_btn()
   dlg_set_name()
   dlg_set_color()

   dlg_add_separator()
   dlg_add_image()
   dlg_add_label()
   dlg_add_checkbox()
   dlg_add_num_input()
   dlg_add_txt_input()
   dlg_add_dropbox()
   dlg_add_button()

   dlg_comp_pos()
   dlg_comp_size()
   dlg_comp_color()
   dlg_comp_font()
   dlg_comp_name()
   dlg_comp_value()
   dlg_comp_callback()

   dlg_draw_line()
   dlg_draw_arrow()
   dlg_draw_circle()
   dlg_draw_rect()

   dlg_click_apply()
   dlg_click_ok()
   dlg_click_close()

   dlg_has_btn_apply()
   dlg_has_btn_ok()
   dlg_has_btn_close()

  Points
   points_count()
   points_clear()
   points_add()
   points_get()
   points_set()
   points_delete()
   points_load()
   points_save()

  File
   file_delete()
   file_open()
   file_close()
   file_read()
   file_append()
   file_flush()

  Array
   array_new()
   array_delete()
   array_isvalid()
   array_size()
   array_clear()
   array_resize()
   array_insert()
   array_remove()
   array_copy()
   array_printstring()
   array_printdata()
   array_setstring()
   array_getstring()
   array_setdata()
   array_setdata16()
   array_setdata32()
   array_setdata64()
   array_setdataflt32()
   array_setdataflt64()
   array_getdata()
   array_getdata16()
   array_getdata32()
   array_getdata64()
   array_getdataflt32()
   array_getdataflt64()
   array_crc16()
   array_crc32()

  Serial
   serial_list()
   serial_info()
   serial_open()
   serial_close()
   serial_config()
   serial_write()
   serial_writedata()
   serial_writedata16()
   serial_writedata32()
   serial_writearray()
   serial_writeflush()
   serial_read()
   serial_readdata()
   serial_readarray()
   serial_readflush()
   serial_addlistener()
   serial_remlistener()

  USB
   usb_list()
   usb_info()
   usb_open()
   usb_close()
   usb_read()
   usb_readdata()
   usb_readarray()
   usb_write()
   usb_writedata()
   usb_writearray()
   usb_addlistener()
   usb_remlistener()

  Hash
   crc16()
   crc32()
   sha256()
   sha256_f()
   md5()
   md5_f()

  Crypt
   aes256_encrypt()
   aes256_encrypt_f()
   aes256_decrypt()
   aes256_decrypt_f()

  Colors
   rgb_to_hue()
   rgb_to_saturation()
   rgb_to_lightness()
   rgb_to_name()

  Camera
   cam_grab()
   cam_color()
   cam_rect()

  Sound
   beep()
   siren()
   sound_load()
   sound_unload()
   sound_play()
   sound_stop()
   sound_is_playing()

  MIDI
   midi_note_on()
   midi_note_off()
   midi_ctrl()
   midi_prog()
   midi_play()
   midi_stop()
   midi_is_playing()

   midiin_channel()
   midiin_prog()
   midiin_note()
   midiin_ctrl()

  Misc
   sleep()

   url()
   rubik()

  PoKeys
   pk_digital()
   pk_analog()

Operators

Events

expr:functions:func-output_pwm

output_pwm()

Controls a PWM output on the machine by setting the duty cycle and optionally the frequency.

Syntax

output_pwm(pin, duty)
output_pwm(pin, duty, frequency)

Parameters

Parameter Type Description
pin Number The output pin number to control.
duty Number Duty cycle percentage (0.0 - 100.0).
frequency Number (Optional) PWM frequency in Hz. (0 - 500000) optional

Return Value

  • `0` if the PWM output was successfully set.
  • `None` if an error occurs.

Examples

Set output pin 1 to 50% duty cycle

output_pwm(1, 50);  

Set output pin 2 to 75% duty cycle at 1 kHz

output_pwm(2, 75, 1000);

Set output pin 6 to 20% duty cycle at default frequency

output_pwm(6, 20);

See also

expr/functions/func-output_pwm.txt · Last modified: by andrej

Page Tools