linnarsson-lab / Py_TC-720

Python library to control the TC-720 temperature controller
MIT License
1 stars 8 forks source link

Implementing Ramp/Soak PID values #6

Open matiasandina opened 1 month ago

matiasandina commented 1 month ago

I am trying to see if I can recreate the PID behaviors from software using your functions.

I am not sure I understood the manual properly, but

PROPORTIONAL BANDWIDTH RAMP/SOAK ARRAY INDEX
Write Command: 82
Read Command: NA
Interpret: Acceptable values range from 0 to 7. This is the index number is used to set which PROGRAM STEP the
PROPORTIONAL BANDWIDTH RAMP/SOAK ARRAY VALUE will be written. (Reference PROGRAM STEP number in TE
Technology’s LabVIEW-based GUI, Ramp Soak programming). The index number + 1 = PROGRAM STEP number.
70. PROPORTIONAL BANDWIDTH RAMP/SOAK ARRAY VALUE
Write Command: 83
Read Command: 84
Interpret: When writing, first use the PROPORTIONALBANDWIDTH RAMP/SOAK ARRAY INDEX command to set the
index value. Then use the write command to write the PROPORTIONAL BANDWIDTH RAMP/SOAK ARRAY VALUE.
When reading, just send the index value (0 to 7) with the Read Command to receive back the value at the indexed
location.

Which I implemented with:

    def get_location_proportional(self, location):
        """Get the proportional bandwidth for a specific ramp/soak location."""
        # Set the index for the location (use command 82)
        self.send_message(self.message_builder('82', self.int_to_hex(location)), write=True)
        # Now read the proportional value at the specified index (use command 84)
        self.send_message(self.message_builder('84'))
        return self.response_to_int(self.read_message()) / 100  # Convert and scale

    def set_location_proportional(self, location, bandwidth):
        """Set the proportional bandwidth for a specific ramp/soak location."""
        # Set the index for the location (use command 82)
        self.send_message(self.message_builder('82', self.int_to_hex(location)), write = True)
        # Now write the proportional value at the specified index (use command 83)
        hex_value = self.int_to_hex(int(bandwidth * 100))
        self.send_message(self.message_builder('83', hex_value), write=True)

I added some print statements to send_message() to try to see what the actual messages sent/received are. The controller seems to acknowledge indexing and change of temps, but not really changing it. I would appreciate any pointers and help. I am happy to contribute these developments to the code base

>>> set_location_proportional(controller, 1, 10)
Sending message: *8200012b
Controller's response was
b'*0001c1^'
Sending message: *8303e86b
Controller's response was
b'*03e800^'
>>> controller.get_location_proportional(1,)
Sending message: *8200012b
Controller's response was
b'*0001c1^'
Sending message: *8400002c
3.0
matiasandina commented 3 weeks ago

I think I have implemented a working function with added PID controls for ramp/soak mode I am happy to integrate it with yours if you are willing

https://github.com/matiasandina/phdutils/tree/main/tc720