charlesbaynham / DigitalTemperatureController

Schematic, PCB and source code for a high-precision digital temperature controller
10 stars 5 forks source link

ES pins floating or driven high for 2 channel configuration. #3

Open han94ros opened 2 years ago

han94ros commented 2 years ago

Hi Charles

I would like to first of all thank you for posting this project on GitHub, I really enjoyed going through your microcontroller C++ code and expanding my knowledge of C++ from the more basic concepts to more sophiscated methods e.g usage of pointers to pointers, references to pointers and virtualisation.

As you may know I am working alongside Sarah (Sr group at the University of Birmingham) to get the 2 channel board configuration running. The first change I have made is in the Pins.h file to uncomment pin_2chan.h and comment pins_4chan.h. However when uploading this code, whilst enabling the vertical switch, I get the error that 'ES_FLOAT_ON' is not referenced in the subsequent files e.g V4_OPA_OutputChannelBipolar.cpp.

An ad hoc solution would be to enter const bool ES_FLOAT_ON = false; in the pins_2chan.h file. I have set the ES pins to be driven high because you have done the same for the 4 channel configuration in the latest version version 5 in Pin_4chan.h file. Would I be right in doing this, I wanted to ask you before implementing it? I have read through all of the manual but I don't know if I have missed a step.

PS: On an unrelated note, I have seen your posts on the M-labs forum regarding the ARTIQ scheduler, I had also posted on the same thread. Given your experience with ARTIQ would you be willing to have a one-off 15 minute zoom meeting to discuss your ARTIQ system. I understand it is a completely different experimental setup but I would really appreciate an opportunity to talk to someone else working on an ARTIQ system and discuss issues regarding experimental scheduling and the compiler.

charlesbaynham commented 2 years ago

Hi @han94ros !

Not at all, I'm pleased you're making use of it. To be honest, I got a bit carried away with the OOP structures on this project: having learnt how, I forgot to ask why. Maybe if I were to redo it I'd use fewer fancy features and shrink the code a lot, but there you go.

I should explain the existence of the pins_4chan.h and pins_2chan.h files: once, there was a version of this board which only had two OPA output stages, using the OPA549 for higher currents. The version of the board that you have however uses 4x OPA548 devices instead. In this way it is the "4 channel version", although those four channels are actually used to implement two bipolar output channels. Unless you've redesigned the PCB itself or rolled back to a much older version, you should therefore use the four-channel set of pin connections in pins_4chan.h.

And yes, I'd be happy to chat both about ARTIQ and this! I'll send you an email.

han94ros commented 2 years ago

I will clarify the PCB design and get back to you.

QiushuoSun commented 2 years ago

Dear Charles,

Thank you again for this design and replies, they have been very useful!

I am using BPA and BPB as two output channels. The onboard thermistors are used as set resistors, so 1t, 2t are used as inputs.

As you suggested, pin_4chan.h is used.

By doing these, I was able to conduct most of the commands, including 'LOCK'. However, the temperature could not get stable at the setpoint. I have tried it on two completely different systems to make sure that the oscillation was not caused by the system, but I observed at least 0.01 volt fluctuation in both cases, by reading the output from 'ERRO' function. I tried to modify the PID parameters to improve this, however, changing PID parameters didn't seem to affect the temperature oscillation. For example, I changed P gain from 10 to 1 to 0.1, the amplitude of the oscillation didn't change much.

My colleague Roshan, who has also read your code, suggested that the class TemporaryLooper might be helpful with achieving autotuning function. I tried to include this class in the controller.h by uncommenting the line, however, it failed to find 'IOInterface.h' file that was called in 'TemporaryLooper.h'.

I wonder please could you help with the current oscillation issue? Any ideas could be useful.

Thank you for your help. I really appreciate your patience :)

Best regards, Sarah

charlesbaynham commented 2 years ago

Hi Sarah,

Great to hear you've got the board working! If you've got ERRO? 1t producing a value which relates to your temperature and you can drive current via the outputs using e.g. VOLT BPA 1 then you've got everything set up correctly.

It sounds like you're able to lock to the setpoint but are still setting oscillations. Just to confirm that everything is working, I'd suggest locking to a different setpoint and making sure that the temperature responds and that you then see oscillations at this new temperature. If that's the case, from here it's just a matter of tuning the PID parameters. TemporaryLooper was indeed made so that things like autotuning could be implemented. I didn't do this in the end, so you'd have to add this yourself. If you make it, please do contribute it back to this repository!

However, you'll probably find it much easier to tune manually. I'd suggest the Ziegler-Nichols rules as a decent starting point: https://en.wikipedia.org/wiki/Ziegler%E2%80%93Nichols_method.