STC-1000+ PI (the mash control firmware)

Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum

Help Support Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
Well, my cool idea is shot then. :-( So there is a connection for another probe inside that is not used?
 
Well, my cool idea is shot then. :-( So there is a connection for another probe inside that is not used?

What was your idea. While the STC doesn't know if current is flowing through the relays it does know that it is allowing current to flow (and you can then assume that it is flowing given that you have correctly wired everything else)
I want to know what your plan is??????
 
What was your idea. While the STC doesn't know if current is flowing through the relays it does know that it is allowing current to flow (and you can then assume that it is flowing given that you have correctly wired everything else)
I want to know what your plan is??????


The idea I have is for use with HERMS setups and two units are used in conjunction. One will power the heating element in the HLT and have its temp sensor in the HLT. The other will power the pump that circulates wort through the HERMS in the HLT to heat the mash and of course will have the probe in the MT.

The MT control would be set as the master and the HLT control as the slave. Each controller has its own program to follow. The MT control's program follows its steps normally while the HLT control only jumps to its next step after receiving a signal from the MT control. Here's a simple single infusion program:

MT (master) control program
  1. Send signal (initiate heat to strike)
  2. Heat to STRIKE TEMP (turn pump on)
  3. Once at STRIKE TEMP, turn pump off
  4. Sound alarm
  5. Wait for button press
  6. Send signal (initiate lower to mash temp)
  7. Silence alarm
  8. Wait for button press
  9. Set temp to MASH TEMP
  10. Hold at MASH TEMP for 45 minutes
  11. Send signal (initiate heat to sparge)
  12. No temp control for 15 minutes
  13. Heat to SPARGE TEMP (turn pump on)
  14. Once at SPARGE TEMP, sound alarm
  15. Wait for button press
  16. Silence alarm
  17. End

HLT (slave) control program
  1. Wait for signal
  2. Heat to STRIKE TEMP +LOSS
  3. Hold at STRIKE TEMP +LOSS until signal is received
  4. Set temp to MASH TEMP +LOSS
  5. Hold at MASH TEMP +LOSS until signal is received
  6. Heat to SPARGE TEMP +LOSS
  7. Hold at SPARGE TEMP +LOSS until signal is received
  8. End

And here's a sample scenario:
  1. Water is added to HLT and MT.
  2. Program is started on HLT control then on MT control. (must be done in this order)
  3. The MT control immediately sends a signal to the HLT to initiate it's first step and powers on the pump.
  4. The HLT heats to strike temp and holds (it's strike temp is set a few degrees above the strike temp of the MT to compensate for loss in the lines)
  5. Once the MT reaches strike temp, the pump turns off, an alarm is sounded to indicate that it is time to add the grain to the mash tun, and a signal is sent to the HLT control telling it to go to the next step.
  6. The HLT control lowers its setting to the mash temp (plus a few degrees for loss).
  7. The brewer presses a button on the MT control to silence the alarm and mashes in.
  8. The brewer then presses the button again to indicate the mash in is complete.
  9. The MT control starts a timer for 45 minutes.
  10. During this 45 minute period, the MT control powers on the pump as needed to hold at mash temp.
  11. After the 45 minute period is up, the pump is turned off, a timer is set for 15 minutes, and a signal is sent to the HLT control to initiate the next step.
  12. The HLT heats to sparge temp and holds.
  13. After the 15 minute timer is up, the pump is turned on.
  14. Once the MT reaches sparge temp, an alarm sounds to indicate the mash process is complete.
  15. The brewer presses a button on the MT control to silence the alarm.
  16. The program has ended and the brewer sparges.

In this instance, there are only a few variables the brewer would need to enter.
  • STRIKE TEMP on HLT and MT
  • MASH TEMP on HLT and MT
  • SPARGE TEMP on HLT and MT
  • LOSS on HLT

Another variable that could be added is MASH TIME. The 45 in my listed program could then be changed to MASH TIME -15. And that would only be set on the MT control of course.

Step mashes could also be added and variables setup for them. Programming (for the brewer) would be super simple as the only entries that would need to be made are the variables.
 
The idea I have is for use with HERMS setups and two units are used in conjunction. One will power the heating element in the HLT and have its temp sensor in the HLT. The other will power the pump that circulates wort through the HERMS in the HLT to heat the mash and of course will have the probe in the MT...

...Another variable that could be added is MASH TIME. The 45 in my listed program could then be changed to MASH TIME -15. And that would only be set on the MT control of course.

Step mashes could also be added and variables setup for them. Programming (for the brewer) would be super simple as the only entries that would need to be made are the variables.

To do all that would require a rewrite of the code and additional wiring, etc.
To be honest the time, effort and money you spend trying to get 2 STCs to work as you want them to is going to be much much more than if you were to just start with an Arduino and build it from the ground up. You need the arduino anyway to flash the STCs and all the element power control will be by SSRs so the only real items you are getting out of the STC are a couple of 8 segment displays, buttons and possibly some 10A relays. You could pic up a Text/graphical LCD display, rotary encoder and relay board for less than the 2 STCs from Ebay / Aliexpress (aka Asia)
 
so I soldered a usb to uart bridge (CP2102) to a mini and I am a little confused. Got the drivers for the 2102 loaded but that is all that is showing up in my device manager. Not the mini. I guess that is ok? Seems like the sketch uploaded to the mini (or to somewhere). I will take a chance and try to program the STC now....
 
so I soldered a usb to uart bridge (CP2102) to a mini and I am a little confused. Got the drivers for the 2102 loaded but that is all that is showing up in my device manager. Not the mini. I guess that is ok? Seems like the sketch uploaded to the mini (or to somewhere). I will take a chance and try to program the STC now....

While being a bit illiterate in terms of drivers etc. that seems like what I would expect - you have the 2102 connected to the USB, what it talks to is of no importance to the PC
 
It programmed perfectly. I just want to thank you again for all your hard work on this. You are doing great work here!
 
When I download picprog.ino from work branch the file show:
Code:
...
* buffer. If you should use another software that does not have this feature you may
 * need to lower the baudrate significantly.
 *
 */

/* Define STC-1000+ version number (XYY, X=major, YY=minor) and EEROM revision */
#define STC1000PI_MAGIC_F		0x196E
#define STC1000PI_MAGIC_C		0x2691
#define STC1000PI_VERSION			100
#define STC1000PI_EEPROM_VERSION	10

But after flashing and doublepress the STC show 1.06 in display.. and the simulate html has other settings. Am I on wrong file?
 
When I download picprog.ino from work branch the file show:
Code:
...
* buffer. If you should use another software that does not have this feature you may
 * need to lower the baudrate significantly.
 *
 */

/* Define STC-1000+ version number (XYY, X=major, YY=minor) and EEROM revision */
#define STC1000PI_MAGIC_F		0x196E
#define STC1000PI_MAGIC_C		0x2691
#define STC1000PI_VERSION			100
#define STC1000PI_EEPROM_VERSION	10

But after flashing and doublepress the STC show 1.06 in display.. and the simulate html has other settings. Am I on wrong file?

Redo, and remember each required step. Download, open in Arduino IDE, check corrwct board and com port, upload to arduino, open serial monitor, press 'd' (check version of sketch) and finally flash the STC.
 
Cool!
Note, that is is in early development. But any suggestions or observations are welcome!
 
Try to set up a SEt code description

tc - Set temperature correction -5.0 to 5.0°C or -10.0 to 10.0°F
rn - Set run mode *
th - Thermostat mode? (try to hold SP, setpoint ?)
Pb - Probe select? 0=normal probe, 1=Probe 2
OH - Max PI output (should limit the maximum duty the PI will produce)
OL - Min PI output (should limit the minimum duty the PI will produce)
OP - Set output? (0-255) (26=10%,52=20%,77=30%,102=40%,127=50%,153=60%,179= 70%,204=80%,230=90%)
c1 - Integral gain. It`s the "I" in the PID. The "D" is skipped.
cP - Proportional gain. It`s the "P" in the PID. The "D" is skipped.
Pd - Period - Cycling Interval(1,2,4,8,16,32 or 64 seconds)
dh - Set current profile duration 0 to 999 hours
St - Set current profile step 0 to 8
SP - Set setpoint -40 to 140°C or -40 to 250°F
tc2 - Set temperature correction for second temp probe -5.0 to 5.0°C or -10.0 to 10.0°F


* Run Mode:
ct - Constant temperature. The PI will aim for the setpoint(SP)
cO - Constant output. In cO mode the value in OP, will be output
Pr0 - Pr5 - Program




Info from post #957 i STC-1000+ tread:
 
Yeah... It is pretty undocumented still. If nobody uses it / reports issues, I won't feel very compelled to maintain it.
But as there still is no stable release, I guess not all that many are compelled to try it out yet either, so...
I fully intend to get it to at least a usable state, since I'm going to be using it myself, but due to the family situation, I'm not really in a hurry to get it working for my own needs.

Check out this post, it is probably closest thing to documentation so far.

I'd be very happy for all and any comments, suggestions, observations et.c. That is the only way for this project to move forward at this point, as I have no time to do actual testing myself.
 
Issue.
Button scrolling work fine until enter rn, an scroll up/dn in that menu. Then it became "oversensitive" and jump two in one press.
 
It should be the same behaviour as in STC-1000+, but I can check when I get the time that the acceleration is the same.
Anyhow, this is a tradeoff that must be made between how fast the acceleration is and how short keypress result in 'double step'.
 
Is it possible to give I and P more weight? Done some testing and end up with 999 and 99 (3-4l flow, 20kg, 2500w)
 
Is it possible to give I and P more weight? Done some testing and end up with 999 and 99 (3-4l flow, 20kg, 2500w)

It is absolutely possible. I've been fiddling with these, trying to come up with a good trade off. I've put them where 'good' settings are in the lower half for my test setup, which admittedly will probably not reflect a 'real' setup in the slightest (a peltier plate, with pretty fast heating and pretty slow cooling). But it is better to err on the safe side.
By my calculations, if you use 999 / 99, the control should be pretty fast for the intent, but I'd more than willing to change this if empirical data shows otherwise :)

The 'weight' will in this case need to be a multiple of 2, so I'd need to halve it. That is no problem, to do though. I'll try to do that as soon as I can (tonight if at all possible). I'll let you know. If at all possible I'd like the full range to be usable (i.e. be able to cover as many possible setups as possible). It is better to err on the safe side though (even if your system won't react as fast as it could be).

Have you have done actual testing? That is used the hardware to control actual mash temp? In that case I'd be very interested to hear all and any experiences! Does it work for you otherwise? I'd love to see a picture of or just a description of the setup you use. All feedback could be helpful in making this firmware better :)

You say 3-4 L flow, that is per minute I assume? I does seem like a little much to me (but I really don't know), if your setup permits it (i.e. it does not compact the bed), then that might be fine.

Thank you for your interest and feedback!!!
 
Done some real test with water. My setup give overshot regardless of P and I settings. It seems that the power is 100% until set-point is passed. Someone else got that experience?
 
When uploading the newest version ta couple hours ago it seems we may have fried 2 different units. Question: when the sketch checks for the presence of the stc1000, does it know if there is a connection of all 3 pins; dat, clr, & clk? My suspicion is that we had a bad solder joint on one of these but it tried to program anyway. I only ask because the new version just got posted.
 
You haven't 'fried' the units, the program upload may have failed, but with all probability you can try again and get them working.
Now to your question, yes, it 'knows'. When it checks for presence, it reads the device ID of the chip and checks for match. For the communication to work, all pins are needed.
 
Ok, I loaded the new firmware successfully on 2 more stc's and they seem fine. I will attempt to do the same to the stc's that didn't take. They had a blank screen after attempting so I was thinking I fried them. Also, the upload said it was unsuccessful. I will let you know if I get them 'fixed'

On another note, would you advise the + version of firmware, or the pi version for use on a simple sparge water tun? I wanted to use a flashed stc so it read in fahrenheit, but I don't need the temp profiles.
 
The PI version is still in beta. And for maintaining HLT temp, I'd say stick with the regular STC-1000+ for now.
 
Ok, I thought I'd give an update on what is happening.
I've made a pretty big push the last few weeks. Had a talk with a control PhD student from my old uni, and he suggested adding the D-part back as the system response of heating liquid approaches a double integrator. So, I did that and I have also started work on a separate firmware to autotune the PID parameters.
It is still very much a work in progress, basic functionality is pretty much there, but there are still some kinks to work out and probably some fine tuning of the parameters. Also I haven't tested the fahrenheit version at all yet.
 
Nice piece of work, interested in making use of this in RIMS application and more than willing to pitch in

Having a look through the code can see in a few places where you are latching the relays low in one of the alarm conditions, can't for the life of me see where they are latched during temperature control

W
 
Just subscribing here and checking to see if any new developments. I am becoming interested in some type of electric brewing and this could be a fun adventure it looks like. I think ill start working on getting a SSR etc for some testing :)
 
Ok, I have yet to get this working. It seems to be in a cooling mode and thus sends no signal to the output relay to fire. I see that only the Celcius versions have been tested??
Or maybe I am misinterpreting the led that is coming on up by the "cool" label?
Has anyone tried the Fahrenheit mode?
 
Hi!
Yeah, this is still work in progress and unfortunately there is not much documentation, as it is not 'stable'. The cooling output is currently constant on (I thought it could be used to power a pump for example). Only heating is pid controlled.
 
Ok, I will ignore the cooling led but the heat output doesn't seem to fire. I left the configuration that I programmed it with, with the exception of Setpoint 0. I set it higher than the sensor temp by 20 degrees and waited but the heat output relay didn't fire it seems. Should I just reflash in Celcius mode and do some testing? I would love the fahrenheit option but I can convert for now.
 
I haven't even uploaded the F version, so I really don't know if it is working at all. It's been a few weeks since I did any work on this firmware, but if interest rises, I might feel inclined to continue :)
The C version I know at least works somewhat. I started work on an autotune firmware as well, but it is not completed. Autotune pretty much sucks anyway, but it may be a starting point. The PID algorithm is implemented in integer arithmetics, so it will have limitations. It won't be able to control to fast or too slow processes. Also, I need to make tradeoffs regarding the 'weight' of each of the parameters. This is stuff that still might change.
I have started to realise PID controllers are complicated beasts :) At least getting the tuning right.

Ok, I will ignore the cooling led but the heat output doesn't seem to fire. I left the configuration that I programmed it with, with the exception of Setpoint 0. I set it higher than the sensor temp by 20 degrees and waited but the heat output relay didn't fire it seems. Should I just reflash in Celcius mode and do some testing? I would love the fahrenheit option but I can convert for now.

You could absolutely give the C version a try as well. Make sure 'Set'->'rn' is 'ct' (that is constant temperature mode). Then 'Set' -> 'SP' will be your setpoint. Third, you might need to fiddle with the parameters 'cP', 'cI' and 'cd'. If you get it working in C, you might give F a try and see if you can make it work.

So, yeah... I think that at this point the PID is pretty much functional, though might need some additional tweaking of the 'weights'. Though I'm a bit in the blind here, and my control theory skills are streched to the limit...

The autotune firmware and possibly the F version need more love. And documentation of course...
 
Will be building a setup to help specifically with dev. I have an A400_P, the + firmware worked on it so I can only assume it will work on this...
 
As a temporary workaround, would it be time consuming to modify a few lines of code in the + version (fermentation control) to operate in minutes instead of hours?
As far as the PID features, RIMS/HERMS system design contributes most of the potential errors imo. For example, placing a temp prob in the center of the grainbed for control of a RIMS heater would create such a wild temp swing potential that even a PID algorythm would have trouble "figuring" it out. Sensing the wort temp imediately leaving the heater would have a much tighter swing potential and should keep the grainbed at a pretty predictable temp.
I guess I am wondering if the PID capability is worth all the trouble?

Well, if you place the sensor in the mash and not after the heater, you would be doing it wrong :) HERMS is just not all that interesting either, you could probably do that (and even better?) with thermostat action if you user tight settings.
But I totally agree that PID seems like a lot more trouble than it is worth. Just changing the stc-1000+ to minutes would definately be doable and pretty easy at that. One might want to do some additional changes (like ramping would be pretty useless and updating SP every minute to EEPROM would be unnecessary).
But we are not limited to either thermostat or PID. Me thinks that maybe a fuzzy control scheme could be both simple to understand and implement. Say for example you would specify the output at -25.6, -3.2, 0, 3.2 and 25.6 degrees difference. Then linear interpolation between the points. Lets say you set these to 50%, 30%, 10%, 2% and 0%. So, when you are right at target (0 deg difference) you'd need to know roughly how much power is required to maintain it (10%). If you're 1.6 deg below you'd be at 20% output et.c. Easy(ish) to understand. (The weird temperatures is due to that the temp*10 needs to be power of two to make calculations 'cheap', could be 12.8 or 1.6 for example also).

Will be building a setup to help specifically with dev. I have an A400_P, the + firmware worked on it so I can only assume it will work on this...

Absolutely it will! And any and all help (and of course especially development) is very welcome!!!
 
Back
Top