From 9db51b982f2cd1303edc0f0e07e10d5850c3f8b4 Mon Sep 17 00:00:00 2001
From: "Michael D. M. Dryden" <mdryden@chem.utoronto.ca>
Date: Mon, 16 Nov 2015 19:17:50 -0500
Subject: [PATCH] Fixes photodiode bias problem #5.

---
 dstat-interface/dstat_comm.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/dstat-interface/dstat_comm.py b/dstat-interface/dstat_comm.py
index e17b9b0..9e2641a 100644
--- a/dstat-interface/dstat_comm.py
+++ b/dstat-interface/dstat_comm.py
@@ -266,7 +266,12 @@ class PDExp(Chronoamp):
         self.commands += "R"
         self.commands[2] += "1"
         self.commands[2] += " "
-        self.commands[2] += str(int(65536-self.parameters['voltage']*(65536./3000)))
+        
+        if self.parameters['voltage'] == 0: # Special case where V=0
+            self.commands[2] += "65535"
+        else:
+            self.commands[2] += str(int(
+                            65535-(self.parameters['voltage']*(65536./3000))))
         self.commands[2] += " "
         self.commands[2] += str(self.parameters['time'])
         self.commands[2] += " "
-- 
GitLab