@@ -42,8 +42,6 @@ class VoltageLevelConverter:
42
42
----------
43
43
analogue_digital_range : float
44
44
The range of analogue voltage values.
45
- max_voltage : float
46
- Maximum voltage.
47
45
scaling_factor : float
48
46
A scaling factor calculated elsewhere that scales the heightmap appropriately based on the type of channel
49
47
and sensor parameters.
@@ -52,32 +50,27 @@ class VoltageLevelConverter:
52
50
values. Typically 12, hence 2^12 = 4096 sensitivity levels.
53
51
"""
54
52
55
- def __init__ (
56
- self , analogue_digital_range : float , max_voltage : float , scaling_factor : float , resolution : int
57
- ) -> None :
53
+ def __init__ (self , analogue_digital_range : float , scaling_factor : float , resolution : int ) -> None :
58
54
"""
59
55
Convert arbitrary height levels from the AFM into real world nanometre heights.
60
56
61
57
Parameters
62
58
----------
63
59
analogue_digital_range : float
64
60
The range of analogue voltage values.
65
- max_voltage : float
66
- Maximum voltage.
67
61
scaling_factor : float
68
62
A scaling factor calculated elsewhere that scales the heightmap appropriately based on the type of channel
69
63
and sensor parameters.
70
64
resolution : int
71
65
The vertical resolution of the instrumen. Dependant on the number of bits used to store its
72
66
values. Typically 12, hence 2^12 = 4096 sensitivity levels.
73
67
"""
74
- self .ad_range = int (analogue_digital_range , 16 )
75
- self .max_voltage = max_voltage
68
+ self .ad_range = analogue_digital_range
76
69
self .scaling_factor = scaling_factor
77
70
self .resolution = resolution
78
71
logger .info (
79
72
f"created voltage converter. ad_range: { analogue_digital_range } -> { self .ad_range } , "
80
- f"max voltage: { max_voltage } , scaling factor: { scaling_factor } , resolution: { resolution } "
73
+ f" scaling factor: { scaling_factor } , resolution: { resolution } "
81
74
)
82
75
83
76
@@ -100,7 +93,8 @@ def level_to_voltage(self, level: float) -> float:
100
93
float
101
94
Real world nanometre height for the input height level.
102
95
"""
103
- return (self .ad_range * level / self .resolution ) * self .scaling_factor
96
+ multiplier = - self .ad_range / self .resolution * self .scaling_factor
97
+ return level * multiplier
104
98
105
99
106
100
# pylint: disable=too-few-public-methods
@@ -263,6 +257,7 @@ def load_asd(file_path: Path, channel: str):
263
257
scanner_sensitivity = header_dict ["scanner_sensitivity" ],
264
258
phase_sensitivity = header_dict ["phase_sensitivity" ],
265
259
)
260
+
266
261
analogue_digital_converter = create_analogue_digital_converter (
267
262
analogue_digital_range = header_dict ["analogue_digital_range" ],
268
263
scaling_factor = scaling_factor ,
@@ -739,64 +734,68 @@ def create_analogue_digital_converter(
739
734
file. Note that this is file specific since the parameters will change between files.
740
735
"""
741
736
# Analogue to digital hex conversion range encoding:
742
- # unipolar_1_0V : 0x00000001 +0.0 to +1.0 V
743
- # unipolar_2_5V : 0x00000002 +0.0 to +2.5 V
744
- # unipolar_5_0V : 0x00000004 +0.0 to +5.0 V
745
- # bipolar_1_0V : 0x00010000 -1.0 to +1.0 V
746
- # bipolar_2_5V : 0x00020000 -2.5 to +2.5 V
747
- # bipolar_5_0V : 0x00040000 -5.0 to +5.0 V
737
+ # unipolar_1_00V : 0x00000001 +0.00 to +1.00 V
738
+ # unipolar_2_50V : 0x00000002 +0.00 to +2.50 V
739
+ # unipolar_9.99v : 0x00000003 +0.00 to +9.99 V
740
+ # unipolar_5_00V : 0x00000004 +0.00 to +5.00 V
741
+ # bipolar_1_00V : 0x00010000 -1.00 to +1.00 V
742
+ # bipolar_2_50V : 0x00020000 -2.50 to +2.50 V
743
+ # bipolar_5_00V : 0x00040000 -5.00 to +5.00 V
744
+
745
+ converter : VoltageLevelConverter
748
746
749
747
if analogue_digital_range == hex (0x00000001 ):
750
748
# unipolar 1.0V
751
749
mapping = (0.0 , 1.0 )
752
750
converter = UnipolarConverter (
753
- analogue_digital_range = analogue_digital_range ,
754
- max_voltage = 1.0 ,
751
+ analogue_digital_range = 1.0 ,
755
752
resolution = resolution ,
756
753
scaling_factor = scaling_factor ,
757
754
)
758
755
elif analogue_digital_range == hex (0x00000002 ):
759
756
# unipolar 2.5V
760
757
mapping = (0.0 , 2.5 )
761
758
converter = UnipolarConverter (
762
- analogue_digital_range = analogue_digital_range ,
763
- max_voltage = 2.0 ,
759
+ analogue_digital_range = 2.5 ,
760
+ resolution = resolution ,
761
+ scaling_factor = scaling_factor ,
762
+ )
763
+ elif analogue_digital_range == hex (0x00000003 ):
764
+ mapping = (0 , 9.99 )
765
+ converter = UnipolarConverter (
766
+ analogue_digital_range = 9.99 ,
764
767
resolution = resolution ,
765
768
scaling_factor = scaling_factor ,
766
769
)
767
770
elif analogue_digital_range == hex (0x00000004 ):
768
771
# unipolar 5.0V
769
772
mapping = (0.0 , 5.0 )
770
773
converter = UnipolarConverter (
771
- analogue_digital_range = analogue_digital_range ,
772
- max_voltage = 5.0 ,
774
+ analogue_digital_range = 5.0 ,
773
775
resolution = resolution ,
774
776
scaling_factor = scaling_factor ,
775
777
)
776
778
elif analogue_digital_range == hex (0x00010000 ):
777
779
# bipolar 1.0V
778
780
mapping = (- 1.0 , 1.0 )
779
781
converter = BipolarConverter (
780
- analogue_digital_range = analogue_digital_range ,
781
- max_voltage = 1.0 ,
782
+ analogue_digital_range = 1.0 ,
782
783
resolution = resolution ,
783
784
scaling_factor = scaling_factor ,
784
785
)
785
786
elif analogue_digital_range == hex (0x00020000 ):
786
787
# bipolar 2.5V
787
788
mapping = (- 2.5 , 2.5 )
788
789
converter = BipolarConverter (
789
- analogue_digital_range = analogue_digital_range ,
790
- max_voltage = 2.0 ,
790
+ analogue_digital_range = 2.5 ,
791
791
resolution = resolution ,
792
792
scaling_factor = scaling_factor ,
793
793
)
794
794
elif analogue_digital_range == hex (0x00040000 ):
795
795
# bipolar 5.0V
796
796
mapping = (- 5.0 , 5.0 )
797
797
converter = BipolarConverter (
798
- analogue_digital_range = analogue_digital_range ,
799
- max_voltage = 5.0 ,
798
+ analogue_digital_range = 5.0 ,
800
799
resolution = resolution ,
801
800
scaling_factor = scaling_factor ,
802
801
)
0 commit comments