Skip to content
Snippets Groups Projects
Commit 93d27600 authored by esarrey's avatar esarrey
Browse files

More comments

parent dad48349
No related branches found
No related tags found
No related merge requests found
......@@ -24,11 +24,12 @@ class HallSensor:
"""
Initialize the HallSensor object.
"""
self.hall_sensor = MP.HallProbe()
self.reserved = False
self.hall_sensor = MP.HallProbe()
self.reserved = False
# Define the speed of the sensor, see the corresponding sampling rate in the function "get_sampling_rate"
self.hall_sensor.Speed = 1
# The sampling rates are coded as follows: 15: 4.17Hz, 14: 6.25Hz, 13: 8.33Hz, 12: 10Hz, 11: 12.5Hz, 10: 16.7Hz, 9: 16.7Hz, 8: 19.6 Hz, 7: 33.2 Hz, 6: 39Hz, 5: 50Hz, 4: 62Hz, 3: 123Hz, 2: 242 Hz, 1: 470 Hz resp. maximum.
self.hall_sensor.Speed = 1
# Set a default aquisition time
self.set_aquisition_time(0.5)
......@@ -41,8 +42,8 @@ class HallSensor:
time (float): The desired acquisition time in seconds.
"""
# Parameter 0: filter off, 2...255: number of filter points
self.hall_sensor.Filter = max(min(255, round(time * self.get_frequency())), 0)
self.aquisition_time = self.hall_sensor.Filter / self.get_frequency()
self.hall_sensor.Filter = max(min(255, round(time * self.get_sampling_rate())), 0)
self.aquisition_time = self.hall_sensor.Filter / self.get_sampling_rate()
def read_mT(self) -> float:
"""
......@@ -61,17 +62,19 @@ class HallSensor:
"""
Perform zeroing of the Hall probe. This should be done at 0 magnetic field.
"""
# Ask the sensor to start zeroing
self.hall_sensor.Zero = True
while self.hall_sensor.Zero:
pass
def get_frequency(self) -> float:
# Wait for the zeroing to be done
while self.hall_sensor.Zero: pass
def get_sampling_rate(self) -> float:
"""
Specific to the sensor used for this application!
Convert the speed byte to the aquisition frequency used by the sensor.
Convert the speed byte to the sampling rate used by the sensor.
Returns:
float: The aquisition frequency used by the sensor
float: The sampling rate used by the sensor
"""
index_to_frequency_dict = {
15: 4.17,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment