Adjustable duty cycle and temp setpoints

Describe your system and processes, and post your config file.
User avatar
Baron Ken
Posts: 99
Joined: Fri Jan 15, 2010 2:50 pm
Bot?: No

Re: Adjustable duty cycle and temp setpoints

Post by Baron Ken »

clearwaterbrewer wrote:Oh, one thing... when making changes, how long does it seem to take, and is there a period where the output is full-on? I have experienced a boilover when I went into the other room to lower the duty-cycle, the only idea I have is that something got stuck in the 'on' portion of duty-cycle that it was in for 5 seconds or so while the change was going into effect.
It 'seems' to change immediately and I do not see the power jump to 100% duty cycle. I tested it with these PID settings (output period: 10s, min pulse % 0, max pulse % 100) and at 20% duty cycle I saw 2s on, 8 s off and when I clicked the +5% button twice (now @30%), it was on 3s, off 7s (as expected). I switched back to my normal 5s output period and got expected results.

I saw no example of going to power-on for more than the duty cycle %. I would run a quick test with water if you are worried.

One thing to note. I cannot click the buttons faster than about 1s, which is the refresh rate I connect at to the BCS. So if you need to raise/lower the duty cycle or temp quickly, bear this in mind. Clicking quickly won't help. ;)
EDIT: I will probably add +/- 10% duty cycle buttons for this reason.
clearwaterbrewer
Posts: 383
Joined: Wed Feb 09, 2011 3:43 pm
Bot?: No
Location: Clearwater, FL
Contact:

Re: Adjustable duty cycle and temp setpoints

Post by clearwaterbrewer »

Baron Ken wrote: Ok, after checking out the Wiki some, I see that I2C is the bus used for expansion cards/7 seg displays. :oops:
So, I'm guessing what you are wanting is the BCS to be able to read the SV value from an adjustable PID display using the I2C bus?
yes... have a device that looks just like a PID, fits in a DIN hole just like a PID, but talks I2C... I have no idea if I2C does input though..


Sooo... looking at BuckBrewing.js, I figured that I just needed to put the last three functions in my .js to get the buttons...

Works like a charm... Now I am excited to brew again!
User avatar
Baron Ken
Posts: 99
Joined: Fri Jan 15, 2010 2:50 pm
Bot?: No

Re: Adjustable duty cycle and temp setpoints

Post by Baron Ken »

clearwaterbrewer wrote:yes... have a device that looks just like a PID, fits in a DIN hole just like a PID, but talks I2C... I have no idea if I2C does input though..
Can't help here, sorry. :(
Sooo... looking at BuckBrewing.js, I figured that I just needed to put the last three functions in my .js to get the buttons...

Works like a charm... Now I am excited to brew again!
Nice! I'm wanting to brew hopefully before too long. I haven't brewed since last Nov. and I just know my kegs are gonna blow any time now!

Also, you've probably already found it, but if you want to change the values for the buttons, they can be modified in the (overloaded) update_prop function in the js file.
ksl177
Posts: 37
Joined: Mon Feb 27, 2012 1:22 am
Bot?: No

Re: Adjustable duty cycle and temp setpoints

Post by ksl177 »

I so want this and the setpoint indicators.

If only I wasn't clueless on how/where to start with this process...
clearwaterbrewer
Posts: 383
Joined: Wed Feb 09, 2011 3:43 pm
Bot?: No
Location: Clearwater, FL
Contact:

Re: Adjustable duty cycle and temp setpoints

Post by clearwaterbrewer »

Baron Ken -

Yes, I made my duty cycles have -5,-1,+1,+5 buttons. worked sweet... now program to have the duty cycle displayed on the BK.. maybe even show KW ;-)
except that I had more issues with access locking up, I think my WiFi bridge doesn't like FL summer heat...


ksl177 -
You have to have a webserver, so I am guessing that will be your first hurdle.

Then you will point the BCS to to the webserver, particularly a file called 'external.js' that is available in the wiki:
http://www.embeddedcc.com/wiki/index.ph ... tomization

Then you tell your BCS to load that file in the 'System Settings' page
Advanced Interface Customization
Enable Path to Advanced Customization Javascript


*at this point you have not changed anything with regards to the interface, but it is an important step to be working normally here.

Now, you edit that file, copying the last three functions in BuckBrewing.js (earlier in this thread) into your js

now when a process is running that uses % or setpoint, you can monitor..

maybe ECC can let us have a .txt block that we can load this stuff to and it gets added to the internal js file?
User avatar
Baron Ken
Posts: 99
Joined: Fri Jan 15, 2010 2:50 pm
Bot?: No

Re: Adjustable duty cycle and temp setpoints

Post by Baron Ken »

maybe ECC can let us have a .txt block that we can load this stuff to and it gets added to the internal js file?
Is this so you don't have to worry about having an external js file stored somewhere? I'm not having any problems with having my external js stored on Dropbox! It only reloads the external js file when you switch pages, so it doesn't have to access it often (for me anyway).
ksl177
Posts: 37
Joined: Mon Feb 27, 2012 1:22 am
Bot?: No

Re: Adjustable duty cycle and temp setpoints

Post by ksl177 »

Setting up a webserver for me is pretty easy. It's the entire lack of time to learn JS and screw around with the interface part of the program that's the issue. ;)
ksl177
Posts: 37
Joined: Mon Feb 27, 2012 1:22 am
Bot?: No

Re: Adjustable duty cycle and temp setpoints

Post by ksl177 »

What would be awesome is if we could get a JS file with just the code for the Buttons and the Color changing setpoint indicators.

After that, I'm pretty sure I can hammer through it. ;)
User avatar
Baron Ken
Posts: 99
Joined: Fri Jan 15, 2010 2:50 pm
Bot?: No

Re: Adjustable duty cycle and temp setpoints

Post by Baron Ken »

ksl177 wrote:What would be awesome is if we could get a JS file with just the code for the Buttons and the Color changing setpoint indicators.

After that, I'm pretty sure I can hammer through it. ;)
NOTE: the changes below are used at your own risk!
Some of the functions are overloaded (meaning they are used instead of the firmware function of the same name) and if you want the original firmware functionality, don't use these! Also important to keep this in mind when updating the firmware.
ECC has indicated they would like to add the setpoint indicator feature to the base firmware, but until then you can use this code.
Make a copy of your external.js file before modifying it.

The functions below are added to the external.js file (and must be enabled for use on the settings page).

Here is the code for the Duty Cycle and Temp Set point buttons.
The 2 buttons for Duty Cycle change are +5% and -5% and the 4 buttons for Temp Setpoint are +1, -1, +5, -5. These values can be changed in the code. I may change it to use variables to make changes easier in the future.

Code: Select all

function update_prop() {   // This is an overloaded function!
    var b = "";
    var a, h, c, g, e = 0;
    b += '<div id="outprop"><br><h3>Current State Properties</h3>';
    b += '<table border="1" cellPadding="3px" width="600px"><tr class="s1"><td width="170">Outputs Asserted<br> in this State</td><td>Control Type</td><td width="130">Temp Probe<br>Association</td><td>Temperature <br>Setpoint ' + degrees + "</td></tr>";
    for (var f = 0; f < MAXOUTS; f++) {
        a = parseInt(ucstates[UCST_OUTSTYPE + f]);
        if (a) {
            h = (a == 1) ? "Direct " + ((ucstates[UCST_OUTSVAL + f] == 100) ? "On" : "Off") : (a == 2) ? ((ultemps[0]!=0) ? "<input type='button' value='+5%' onClick='dutycyclechg(" + f + ", cp, cs, 5);'><input type='button' value='-5%' onClick='dutycyclechg(" + f + ", cp, cs, -5);'><br>Duty Cycle " + ucstates[UCST_OUTSVAL + f] + "%" : "Duty Cycle " + ucstates[UCST_OUTSVAL + f] + "%") : (a == 3) ? "Hysteresis" : "PID";
            c = (a <= 2) ? "N/A" : ((ultemps[0]!=0) ? "<input type='button' value='+1' onClick='tempsetpointchg(" + f + ", cp, cs, 1);'><input type='button' value='-1' onClick='tempsetpointchg(" + f + ", cp, cs, -1);'><input type='button' value='+5' onClick='tempsetpointchg(" + f + ", cp, cs, 5);'><input type='button' value='-5' onClick='tempsetpointchg(" + f + ", cp, cs, -5);'><br>" + (ulstates[ULST_PIDSET + f] / 10) : (ulstates[ULST_PIDSET + f] / 10));
            g = (a <= 2) ? "N/A" : getTempAssn_alt(f);
            b += '<tr class="s2"><td>Out' + f + ": " + sysnames[SN_OUT + f] + "</td><td>" + h + "</td><td>" + g + "</td><td>" + c + "</td></tr>";
            e = 1
        }
    }
    for (var d = 0; d < 4; d++) {
        if (parseInt(ucsysios[UCIO_EXPDIGI + d])) {
            b += '<tr class="s2"><td>DigiExp' + d + " Outputs</td><td>[0:11]=" + parseInt(ulstates[ULST_EXPDIGI + d]).toString(2) + "</td><td>N/A</td><td>N/A</td></tr>";
            e = 1
        }
    }
    if (e == 0) {
        b += '<tr class="s2"><td>None</td><td>N/A</td><td>N/A</td><td>N/A</td></tr>'
    }
    b += "</table></div>";
    gid("setp").innerHTML = b
}

function dutycyclechg(curpos, curp, curs, chgval)
{
  ucstates[UCST_OUTSVAL + curpos]=parseInt(ucstates[UCST_OUTSVAL + curpos])+chgval;
  savestuff("ucstate", curp, curs, ucstates)
} 

function tempsetpointchg(curpos, curp, curs, chgval)
{  
  ulstates[ULST_PIDSET + curpos]=parseInt(ulstates[ULST_PIDSET + curpos])+chgval*10;
  savestuff("ulstate", curp, curs, ulstates)
}
Here is the code for the setpoint indicators.

Code: Select all

function drawSetpoint(c, b, g, gauge, scale)  // this is a new function to draw a setpoint indicator on the gauge
{
  var e = Math.PI / 12;
  var a = e / 10;
  var tempSetPt = ultemps[ULTMP_SETP + gauge]/10;
	var d = (tempSetPt == -409.6)? 0 : tempSetPt;
	if (d==0) {return;}
	var tempPt = ultemps[ULTMP_TMP + gauge] / 10;
	var f = (tempPt == -409.6)? 0.0 : tempPt;
  c.save();
  c.translate(90 * scale, 95 * scale);
  c.rotate(Math.PI + Math.PI / 8);
  c.rotate((2 * Math.PI - Math.PI / 4) * (d - b) / (g - b));
  c.beginPath();
  c.lineWidth = 1;
  c.strokeStyle = "#A0A0A0";
  if (Math.abs(f-d) <=5 && Math.abs(f-d) >2)  // ECC came up with adding colors!
  {
  	c.fillStyle = 'yellow';
  }
	else if (Math.abs(f-d) <=2)
	{
		c.fillStyle = 'lime';
	}
	else
	{
		c.fillStyle = 'red';
	}
  c.moveTo(0, -68 * scale);
  c.lineTo(5 * scale, -77 * scale);
  c.lineTo(-5 * scale, -77 * scale);
  c.lineTo(0, -68 * scale);
  c.fill();
  //c.stroke();
  c.closePath();
  c.beginPath();
  c.fillStyle = "#A0A0A0";
  c.moveTo(5 * scale, -77 * scale);
  c.lineTo(5 * scale, -80 * scale);
  c.lineTo(-5 * scale, -80 * scale);
  c.lineTo(-5 * scale, -77 * scale);
  c.fill();
  c.closePath();
  c.restore();
}
function draw_temp(a, h, j, b)  //overloaded this function to add drawSetpoint
{
  var d = isNaN(j) ? 0 : j;
  if (browserSupportsHTML5)
  {
  	var g = (parseInt(ucsysios[UCIO_CELC]) == 1) ? -20 : 20;
	  var l = (parseInt(ucsysios[UCIO_CELC]) == 1) ? 120 : 220;
	  var e = (parseInt(ucsysios[UCIO_CELC]) == 1) ? 5 : 10;
	  var c = (parseInt(ucsysios[UCIO_CELC]) == 1) ? 2.5 : 2;
	  var k = document.getElementById("canvas" + a).getContext("2d");
	  k.save();
	  k.clearRect(0, 0, 180 * b, 200 * b);
	  var f = k.createRadialGradient(87 * b, 90 * b, 57 * b, 90 * b, 95 * b, 75 * b);
	  f.addColorStop(0, "#fafcff");
	  f.addColorStop(0.9, "#C0C0C0");
	  k.fillStyle = f;
	  k.arc(90 * b, 95 * b, 72 * b, 0, Math.PI * 2, true);
	  k.fill();
	  k.translate(90 * b, 95 * b);
	  k.restore();
	  drawTickMarks(k, g, l, c, e, b);
	  drawLabel(k, h, a, d, b);
	  drawPointer(k, g, l, d, b);
	  centerPin(k, b);
	  drawOuterBezel(k, b);
	  drawSetpoint(k, g, l, a, b);
	}
}
ksl177
Posts: 37
Joined: Mon Feb 27, 2012 1:22 am
Bot?: No

Re: Adjustable duty cycle and temp setpoints

Post by ksl177 »

Perfect! Thanks guys.
Post Reply