![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
MH K8 firmware with HV control.
Fork of muonhunter-K8 by
Diff: hvcontrol.cpp
- Revision:
- 2:66a2e52ad175
- Parent:
- 0:52895a475820
- Child:
- 4:87037e41c888
--- a/hvcontrol.cpp Tue Oct 04 11:21:03 2016 +0000 +++ b/hvcontrol.cpp Tue Oct 04 16:45:02 2016 +0000 @@ -17,14 +17,10 @@ return (int)(T); } - float to_adc_voltage(float voltage_){ return voltage_/(divider_value * voltage_ref); } - - float from_adc_voltage(float adc_v){ return adc_v * divider_value * voltage_ref; } public: int *hvparams; //array is indexed with the frequency - Ticker hvtick; - + HVControl(PinName oscillator_pin_, PinName measure_pin_) { max_freq = 10000; //default maximum frequency min_freq = 1000; //default minimum frequency @@ -38,18 +34,9 @@ freq = max_freq; } - void control_voltage(void){ - - } - void set_voltage(int target_v){ - float err = 0; - if(measure()){ - - }else{ - shutdown(); - } - - } + float from_adc_voltage(float adc_v){ return adc_v * divider_value * voltage_ref; } + + float to_adc_voltage(float voltage_){ return voltage_/(divider_value * voltage_ref); } bool measure(void){ AnalogIn probe(measure_pin); @@ -95,15 +82,17 @@ DigitalOut pwm_(oscillator_pin); pwm_.write(1); freq = 0; - bool m; - m = measure(); + measure(); while(voltage > safe_voltage){ - m = measure(); + measure(); wait(1); } } - float get_voltage(void){ return voltage; } + float get_voltage(void){ + measure(); + return voltage; + } int *get_hvparams(void){ return hvparams; }