Difference between revisions of "Hw output pwm add"

From Sim Innovations Wiki
Jump to navigation Jump to search
Line 11: Line 11:
! Argument !! Type !! Description
! Argument !! Type !! Description
|-
|-
| '''hw_output_pwm_id''' || ''String'' || This value can be used for further reference.  
| '''hw_output_pwm_id''' || ''ID'' || This value can be used for further reference.  
|}
|}



Revision as of 14:23, 12 July 2018

Description

hw_output_pwm_id = hw_output_pwm_add(hw_id, frequency_hz, initial_duty_cycle)

hw_output_pwm_add is used to add a hardware PWM output to your instrument.

Return value

Argument Type Description
hw_output_pwm_id ID This value can be used for further reference.

Arguments

# Argument Type Description
1 hw_id String The is the reference to the input. You can choose to bind to an existing Hardware ID (Hardware_id_list).
2 frequency_hz Number The frequency of the PWM output signal, in Hz.
3 initial_duty_cycle Number The initial PWM duty cycle. Range 0.0 - 1.0, 0.0 being off, and 1.0 on.

Example

-- Bind to Raspberry Pi 2, Header P1, Pin 40
-- PWM frequency is set to 1 kHz, with a duty cycle of 50%.
output_id = hw_output_pwm_add("RPI_V2_P1_40", 1000, 0.5)

-- We can change the duty cycle runtime, in this case 20%
hw_output_pwm_duty_cycle(output_id, 0.2)