Difference between revisions of "Hw adc input add"

From Sim Innovations Wiki
Jump to navigation Jump to search
Line 1: Line 1:
== Description ==
== Description ==


  '''hw_adc_input_id = hw_adc_input_add(name, callback)''' (from AM 3.5)
  '''hw_adc_input_id = hw_adc_input_add(name, callback)''' (from AM/AP 3.5)
  '''hw_adc_input_id = hw_adc_input_add(name, hysteresis, callback)''' (from AM 3.5)
  '''hw_adc_input_id = hw_adc_input_add(name, hysteresis, callback)''' (from AM/AP 3.5)
  '''hw_adc_input_id = hw_adc_input_add(hw_id, callback)'''
  '''hw_adc_input_id = hw_adc_input_add(hw_id, callback)'''
  '''hw_adc_input_id = hw_adc_input_add(hw_id, hysteresis, callback)'''
  '''hw_adc_input_id = hw_adc_input_add(hw_id, hysteresis, callback)'''

Revision as of 12:13, 2 October 2018

Description

hw_adc_input_id = hw_adc_input_add(name, callback) (from AM/AP 3.5)
hw_adc_input_id = hw_adc_input_add(name, hysteresis, callback) (from AM/AP 3.5)
hw_adc_input_id = hw_adc_input_add(hw_id, callback)
hw_adc_input_id = hw_adc_input_add(hw_id, hysteresis, callback)

hw_adc_input_add is used to add a hardware ADC input to your instrument.

Return value

Argument Type Description
hw_adc_input_id ID This value can be used for further reference. Functions such as hw_adc_input_read can use this hw_adc_input_id. Its good practice to store this hw_input_id in your logic code.

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 hysteresis Number (Optional) Hysteresis value between 0.0 and 1.0. Increase the hysteresis if your ADC source is unstable. Default is 0.02.
3 callback Function This function will be called when the ADC input value changes. The callback will provide one argument, value, which ranged from 0.0 to 1.0 (in most cases ranges from GND -> VCC).

Example

-- Callback function which is called when the ADC input state changes
-- 0.0 : GND (lowest voltage)
-- 1.0 : VCC (highest voltage)
function adc_input_change(value)
  print("new value= " .. tostring(value) )
end

-- Bind to the first pin of hardware port A
hw_adc_input_add("HW_PORT_A1", adc_input_change)