SimpleFOClibrary 2.4.0
Loading...
Searching...
No Matches
MagneticSensorAnalog Class Reference

#include <MagneticSensorAnalog.h>

Inheritance diagram for MagneticSensorAnalog:
[legend]
Collaboration diagram for MagneticSensorAnalog:
[legend]

Public Member Functions

 MagneticSensorAnalog (uint8_t _pinAnalog, int _min=0, int _max=0)
 
void init ()
 
float getSensorAngle () override
 
- Public Member Functions inherited from Sensor
virtual float getMechanicalAngle ()
 
virtual float getAngle ()
 
virtual double getPreciseAngle ()
 
virtual float getVelocity ()
 
virtual int32_t getFullRotations ()
 
virtual void update ()
 
virtual int needsSearch ()
 

Public Attributes

int pinAnalog
 encoder hardware pin A
 
Pullup pullup
 
int raw_count
 
- Public Attributes inherited from Sensor
float min_elapsed_time = 0.000100
 

Additional Inherited Members

- Protected Attributes inherited from Sensor
float velocity =0.0f
 
float angle_prev =0.0f
 
long angle_prev_ts =0
 
float vel_angle_prev =0.0f
 
long vel_angle_prev_ts =0
 
int32_t full_rotations =0
 
int32_t vel_full_rotations =0
 

Detailed Description

This sensor has been tested with AS5600 running in 'analog mode'. This is where output pin of AS6000 is connected to an analog pin on your microcontroller. This approach is very simple but you may more accurate results with MagneticSensorI2C if that is also supported as its skips the DAC -> ADC conversion (ADC supports MagneticSensorI2C)

Definition at line 13 of file MagneticSensorAnalog.h.

Constructor & Destructor Documentation

◆ MagneticSensorAnalog()

MagneticSensorAnalog::MagneticSensorAnalog ( uint8_t  _pinAnalog,
int  _min_raw_count = 0,
int  _max_raw_count = 0 
)

MagneticSensorAnalog class constructor

Parameters
_pinAnalogthe pin to read the PWM signal

MagneticSensorAnalog(uint8_t _pinAnalog, int _min, int _max)

Parameters
_pinAnalogthe pin that is reading the pwm from magnetic sensor
_min_raw_countthe smallest expected reading. Whilst you might expect it to be 0 it is often ~15. Getting this wrong results in a small click once per revolution
_max_raw_countthe largest value read. whilst you might expect it to be 2^10 = 1023 it is often ~ 1020. Note: For ESP32 (with 12bit ADC the value will be nearer 4096)

Definition at line 8 of file MagneticSensorAnalog.cpp.

Member Function Documentation

◆ getSensorAngle()

float MagneticSensorAnalog::getSensorAngle ( )
overridevirtual

get current angle (rad)

Implements Sensor.

Definition at line 33 of file MagneticSensorAnalog.cpp.

◆ init()

void MagneticSensorAnalog::init ( )
virtual

sensor initialise pins

Reimplemented from Sensor.

Definition at line 25 of file MagneticSensorAnalog.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ pinAnalog

int MagneticSensorAnalog::pinAnalog

encoder hardware pin A

Definition at line 25 of file MagneticSensorAnalog.h.

◆ pullup

Pullup MagneticSensorAnalog::pullup

Definition at line 28 of file MagneticSensorAnalog.h.

◆ raw_count

int MagneticSensorAnalog::raw_count

raw count (typically in range of 0-1023), useful for debugging resolution issues

Definition at line 34 of file MagneticSensorAnalog.h.


The documentation for this class was generated from the following files: