Class HLC1395Pulsed

  • All Implemented Interfaces:
    Impc555, IntbMpc555HB, Ippc32, Actionable

    public class HLC1395Pulsed
    extends Task
    implements IntbMpc555HB
    Driver for up to 16 pulsed and multiplexed HLC1393 reflection distance sensors.
    The driver needs 5 digital outputs of the MPIOSM and a single analog input of QADC-A. 4 of the digital outputs are used as address channels and the fifth one is the trigger signal. The analog input is used to read the sensor values. It is highly recommended to neither use the channels AN0...AN3 nor the channels AN48...AN51 because these pins have a RC input filter on on some NTB MPC555 header boards.
    All the sensors are repetitively sampled within 16ms, regardless of the number of sensors.
    Its possible to use this driver together with QADC_AIN on the same QADC module. IMPORTANT: Connect AGnd to Gnd!
    • Method Detail

      • getInstance

        public static HLC1395Pulsed getInstance()
        Returns an instance of HLC1395Pulsed Driver
        Returns:
        Instance of HLC1395Pulsed Driver
      • read

        public short read​(int channel)
        Read the value of the given sensor number
        Parameters:
        channel - channel/sensor number
        Returns:
        converted value
      • action

        public void action()
        Background task loop: Do not call this method!
        Specified by:
        action in interface Actionable
        Overrides:
        action in class Task
      • init

        public void init​(int numberOfSensors,
                         int pinNumbers,
                         int analogInChn)
        Initialize sensors.
        Parameters:
        numberOfSensors - Number of connected sensors: 0 < numberOfSensors <= 16
        pinNumbers - Pin numbers of the 4 address pins and of the trigger pin. Use 4 bits per pin in the following order: trgPin, adr3Pin, adr2Pin, adr1Pin, adr0Pin. Example: 0xF85AC means trgPin = MPIOB15, adr3Pin = MPIOB8, adr2Pin = MPIOB5, adr1Pin = MPIOB10 and adr0Pin = MPIOB12.
        analogInChn - Pin number for the analog input channel (ANx).
      • init

        public void init​(int addr3Pin,
                         int addr2Pin,
                         int addr1Pin,
                         int addr0Pin,
                         int trgPin,
                         int analogInPin)
        Initialize sensors. Set unused address pins to -1.
        Parameters:
        addr3Pin - MPIOB pin for the address lane 3.
        addr2Pin - MPIOB pin for the address lane 2.
        addr1Pin - MPIOB pin for the address lane 1.
        addr0Pin - MPIOB pin for the address lane 0.
        trgPin - MPIOB pin for the trigger signal.
        analogInPin - ADC-A channel for the sensor signal.
      • stop

        public void stop()
        Stop reading the sensors.
      • start

        public void start()
        Start reading the sensors.
        This method must be called after the initialization or after a call of stop().