diff options
-rw-r--r-- | plugins/ufo/uca-ufo-camera.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/plugins/ufo/uca-ufo-camera.c b/plugins/ufo/uca-ufo-camera.c index 4c278ef..4f83fcc 100644 --- a/plugins/ufo/uca-ufo-camera.c +++ b/plugins/ufo/uca-ufo-camera.c @@ -403,9 +403,8 @@ uca_ufo_camera_trigger (UcaCamera *camera, GError **error) static gdouble total_readout_time (UcaUfoCamera *camera) { - gdouble clock_period; - gdouble exposure_time; - gdouble foo; + gdouble clock_period, foo; + gdouble exposure_time, image_readout_time, overhead_time; guint output_mode; guint roi_height; @@ -415,12 +414,12 @@ total_readout_time (UcaUfoCamera *camera) "roi-height", &roi_height, NULL); - clock_period = camera->priv->frequency == FPGA_40MHZ ? 1 / 40000000.0 : 1 / 48000000.0; + clock_period = camera->priv->frequency == FPGA_40MHZ ? 1 / 40.0 : 1 / 48.0; foo = pow (2, output_mode); image_readout_time = (129 * clock_period * foo) * roi_height; overhead_time = (10 /* reg73 */ + 2 * foo) * 129 * clock_period; - return exposure_time + overhead_time + image_readout_time; + return exposure_time + (overhead_time + image_readout_time) / 1000 / 1000; } static void @@ -433,21 +432,26 @@ uca_ufo_camera_set_property(GObject *object, guint property_id, const GValue *va { const guint frequency = priv->frequency == FPGA_40MHZ ? 40 : 48; const gdouble user_exposure_time = g_value_get_double(value); - pcilib_register_value_t reg_value = (pcilib_register_value_t) ((1e6 * user_exposure_time * frequency) / 129.0); + pcilib_register_value_t reg_value = (pcilib_register_value_t) (1e6 * user_exposure_time * frequency / 129.0 - 0.43 * 10); pcilib_write_register(priv->handle, NULL, "cmosis_exp_time", reg_value); } break; - case PROP_FRAME_RATE: + case PROP_FRAMES_PER_SECOND: { gdouble readout_time; - gdouble frame_rate; - guint trigger_period; + gdouble frame_period; + guint32 trigger_period; - frame_rate = g_value_get_double (value); + frame_period = 1.0 / g_value_get_double (value); readout_time = total_readout_time (UCA_UFO_CAMERA (object)); - trigger_period = (guint) (1. / ((frame_rate - 1. / readout_time) * 8 * 1e-9)); - g_object_set (object, "ufo-trigger-period", &trigger_period, NULL); + if (frame_period < readout_time) { + g_warning ("Frame period higher than readout time %f\n", readout_time); + break; + } + + trigger_period = (guint32) ((frame_period - readout_time) / (8.0 * 1e-9)); + g_object_set (object, "ufo-trigger-period", trigger_period, NULL); } break; case PROP_ROI_X: @@ -465,7 +469,7 @@ uca_ufo_camera_set_property(GObject *object, guint property_id, const GValue *va GINT_TO_POINTER (property_id)); if (reg_info != NULL) { - pcilib_register_value_t reg_value; + pcilib_register_value_t reg_value = 0; reg_value = g_value_get_uint (value); pcilib_write_register (priv->handle, NULL, reg_info->name, reg_value); @@ -520,14 +524,14 @@ uca_ufo_camera_get_property(GObject *object, guint property_id, GValue *value, G case PROP_EXPOSURE_TIME: { const gdouble frequency = priv->frequency == FPGA_40MHZ ? 40.0 : 48.0; - g_value_set_double (value, read_register_value (priv->handle, "cmosis_exp_time") * 129.0 / frequency / 1e6); + g_value_set_double (value, (read_register_value (priv->handle, "cmosis_exp_time") + 0.43 * 10) * 129.0 / frequency / 1e6); } break; case PROP_FRAMES_PER_SECOND: { gdouble delay_time; gdouble framerate; - guint trigger_period; + guint32 trigger_period; g_object_get (object, "ufo-trigger-period", &trigger_period, NULL); |