Skip to content

A3144HallSensor

Alex Krieg edited this page Sep 27, 2020 · 5 revisions

Hardware


Functions

  • A3144(byte pin,bool activeHigh = false);
  • ~A3144();
  • void OnChange(void (*p_func)(bool));
  • void OnTriggerHigh(void (*p_func)());
  • void OnTriggerLow(void (*p_func)());
  • void OnHigh(void (*p_func)());
  • void ticksPerRevolution(unsigned int ticks);
  • void update();
  • unsigned long counts();
  • float rpm();
  • bool state();
  • void reset();


A3144(byte pin,bool activeHigh = false);

Description

  • Constructor
  • Needs the pin on which the sensor is connected to.
  • Needs a definition, if the sensor pulls the voltage down when it is actuated.
  • Standard for the A3144 is false.

Syntax

A3144 myHallSensor(2); A3144 myHallSensor(2,true); HallSensor myHallSensor(2); HallSensor myHallSensor(2,true);


~A3144();

Description

  • Destrucktor

Syntax

delete &myHallSensor;


Events

You do not know how events work?
Look over here

void OnChange(void (*p_func)(bool));

  • Is executed when the state of the sensor has changed.
  • ONE value accepted. Gives the state of the sensor.
  • NO return values.

void OnTriggerHigh(void (*p_func)());

  • Is executed when the state of the sensor is rising.
  • NO value accepted.
  • NO return values.

void OnTriggerLow(void (*p_func)());

  • Is executed when the state of the sensor is falling.
  • NO value accepted.
  • NO return values.

void OnHigh(void (*p_func)());

  • Is executed when the sensor is actuated.
  • NO value accepted.
  • NO return values.

void ticksPerRevolution(unsigned int ticks);

Description

  • Defines how many ticks or activations of the sensor it needs per revolution on a shaft.
  • Useful for encoders on motors.

Syntax

myHallSensor.ticksPerRevolution(100);


void update();

Description

  • Checks the state of the sensor.
  • Triggers the events.

Syntax

myHallSensor.update();


unsigned long counts();

Description

  • Returns the amount of activations of the sensor.

Syntax

unsigned int counts = myHallSensor.counts();


float rpm();

Description

  • Returns the rpm (revolution per minute).
  • Useful for encoders on motors.

Syntax

float rpm = myHallSensor.rpm();


bool state();

Description

  • Returns the state of the sensor.

Syntax

bool state = myHallSensor.state();


void reset();

Description

  • Resets some variables such as counts.

Syntax

myHallSensor.reset();