@@ -22,8 +22,18 @@ impl Mpsu50Metadata {
2222
2323 //TODO: verify for Trebuchet PSU (model: MPSU50-2ST)
2424 // Add ranges
25- base. add_range ( "source.levelv" . to_string ( ) , -50.1 , 50.1 ) ;
26- base. add_range ( "source.leveli" . to_string ( ) , -5.0 , 5.0 ) ;
25+ let max_supported_voltage = 50.1 ;
26+ let max_supported_current = 5.0 ;
27+ base. add_range (
28+ "source.levelv" . to_string ( ) ,
29+ -max_supported_voltage,
30+ max_supported_voltage,
31+ ) ;
32+ base. add_range (
33+ "source.leveli" . to_string ( ) ,
34+ -max_supported_current,
35+ max_supported_current,
36+ ) ;
2737
2838 base. add_range ( "source.limiti" . to_string ( ) , 0.01 , 5.1 ) ;
2939
@@ -33,11 +43,14 @@ impl Mpsu50Metadata {
3343 // when pulse mode is off
3444 let exclude_i = NumberLimit :: new ( -10.0e-9 , 10.0e-9 , false , None ) ;
3545 let mut region_map_metadata = RegionMapMetadata :: new ( None , exclude_i) ;
36- region_map_metadata. add_region ( 1 , 0.0 , 0.0 , 50.0 , 1.0 ) ;
37- region_map_metadata. add_region ( 1 , 0.0 , 0.0 , 10.0 , 5.0 ) ;
38- region_map_metadata. add_region ( 1 , 0.0 , 0.0 , -10.0 , -5.0 ) ;
39- region_map_metadata. add_region ( 1 , 0.0 , 0.0 , -50.0 , -1.0 ) ;
40- base. add_region_map ( "psu.region" , region_map_metadata) ;
46+
47+ region_map_metadata. add_region ( 1 , 0.0 , 0.0 , 10.0 , max_supported_current) ;
48+ region_map_metadata. add_region ( 1 , 0.0 , 0.0 , -10.0 , -max_supported_current) ;
49+
50+ Self :: add_1st_quadrant_curved_region ( 10.0 , 50.0 , 0.001 , 0.0 , & mut region_map_metadata) ; //First quadrant curve
51+ Self :: add_3rd_quadrant_curved_region ( -10.0 , -50.0 , -0.001 , 0.0 , & mut region_map_metadata) ; //Third quadrant curve
52+
53+ base. add_region_map ( "50 V" , region_map_metadata) ; //Use source range to identify region map
4154
4255 base. add_overrange_scale ( 1.002 ) ;
4356
@@ -46,6 +59,44 @@ impl Mpsu50Metadata {
4659 // Initialize additional properties
4760 }
4861 }
62+
63+ fn add_1st_quadrant_curved_region (
64+ voltage_start : f64 ,
65+ voltage_max : f64 ,
66+ step : f64 , // Use the step parameter to finely control the approximation
67+ current : f64 , // Fixed current for the curve
68+ region_map_metadata : & mut RegionMapMetadata ,
69+ ) {
70+ // Add region maps iteratively as small rectangles to approximate the curve
71+
72+ let mut v1 = voltage_start;
73+
74+ while v1. abs ( ) <= voltage_max. abs ( ) {
75+ let v2 = v1 + step;
76+ let i2 = voltage_max / v2. abs ( ) ;
77+ region_map_metadata. add_region ( 1 , v1, current, v2, i2) ;
78+ v1 += step;
79+ }
80+ }
81+
82+ fn add_3rd_quadrant_curved_region (
83+ voltage_start : f64 ,
84+ voltage_max : f64 ,
85+ step : f64 , // Use the step parameter to finely control the approximation
86+ current : f64 , // Fixed current for the curve
87+ region_map_metadata : & mut RegionMapMetadata ,
88+ ) {
89+ // Add region maps iteratively as small rectangles to approximate the curve
90+
91+ let mut v1 = voltage_start;
92+
93+ while v1. abs ( ) <= voltage_max. abs ( ) {
94+ let v2 = v1 + step;
95+ let i2 = voltage_max / v2. abs ( ) ;
96+ region_map_metadata. add_region ( 1 , v2, i2, v1, current) ;
97+ v1 += step;
98+ }
99+ }
49100}
50101
51102impl Metadata for Mpsu50Metadata {
0 commit comments