Skip to content

Commit

Permalink
Input Voltage Limit (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
smariel committed Jan 11, 2020
1 parent feb075f commit cfa45aa
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 25 deletions.
52 changes: 33 additions & 19 deletions html/itemEditor.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,6 @@ <h3>Characteristics</h3>
<div class="col-xs-4 mintypmax"><label for="input_vout_max">V<sub>OUT MAX</sub></label><input id="input_vout_max" type="text" data-itemdata="vout_max" class="form-control input_vout input_num item-control" placeholder="max (V)" data-toggle="tooltip" data-placement="bottom" title="Maximum output voltage (V)" /></div>
</div>

<!-- OUTOUT CURRENT LIMIT -->
<div class="form-group row">
<div class="col-xs-12">
<label for="source_ilimit">Output current limit (absolute value)</label>
<input id="source_ilimit" type="text" data-itemdata="iout_limit" class="form-control input_num" placeholder="xx A (0 = no limit)" data-toggle="tooltip" data-placement="bottom" title="Output current limit (0 = no limit)"/>
</div>
</div>

<!-- DC/DC EFFICIENCY -->
<div class="form-group source_dcdc">
<label>Efficiency</label>
Expand All @@ -131,17 +123,6 @@ <h3>Characteristics</h3>
<div class="col-xs-4 mintypmax"><label>I<sub>Q TYP</sub></label><input id="input_iq_typ" type="text" data-itemdata="iq_typ" class="form-control input_iq input_num item-control" placeholder="typ (V)" data-toggle="tooltip" data-placement="bottom" title="Typical quiescent current (A)" /></div>
<div class="col-xs-4 mintypmax"><label>I<sub>Q MAX</sub></label><input id="input_iq_max" type="text" data-itemdata="iq_max" class="form-control input_iq input_num item-control" placeholder="max (V)" data-toggle="tooltip" data-placement="bottom" title="Maximum quiescent current (A)" /></div>
</div>

<!-- LDO DROPOUT -->
<div class="form-group source_ldo">
<label>Dropout voltage</label>
<div class="row">
<div class="col-xs-5 dropout"><input id="input_drop_i" type="text" class="form-control input_num" placeholder="xx A" data-toggle="tooltip" data-placement="bottom" title="Output current (A)" /></div>
<div class="col-xs-5 dropout"><input id="input_drop_v" type="text" class="form-control input_num" placeholder="xx V" data-toggle="tooltip" data-placement="bottom" title="Dropout voltage (V)" /></div>
<div class="col-xs-2 dropout"><a id="add_drop" class="btn btn-default"><span class="fa fa-plus"></span></a></div>
</div>
<canvas id="dropChart" width="200" height="108"></canvas>
</div>
</div>

<!-- _____________________ -->
Expand Down Expand Up @@ -172,6 +153,39 @@ <h3>Feadback</h3>
<div class="col-xs-4 mintypmax"><label>V<sub>REF MAX</sub></label><input id="source_vref_max" type="text" data-itemdata="vref_max" class="form-control input_num source_adj item-control" placeholder="typ (V)" data-toggle="tooltip" data-placement="bottom" title="Maximul regulator Vref (V)" /></div>
</div>
</div>


<!-- LIMITS -->
<div class="container">
<h3>Limits</h3>

<!-- INPUT VOLTAGE LIMIT -->
<div class="form-group row">
<div class="col-xs-12">
<label for="source_vinlim">V<sub>IN</sub> limit</label>
<input id="source_vinlim" type="text" data-itemdata="vin_limit" class="form-control input_num" placeholder="xx V (0 = no limit)" data-toggle="tooltip" data-placement="bottom" title="Maximum recommended input voltage (0 = no limit)"/>
</div>
</div>

<!-- OUTPUT CURRENT LIMIT -->
<div class="form-group row">
<div class="col-xs-12">
<label for="source_ilimit">I<sub>OUT</sub> limit</label>
<input id="source_ilimit" type="text" data-itemdata="iout_limit" class="form-control input_num" placeholder="xx A (0 = no limit)" data-toggle="tooltip" data-placement="bottom" title="Maximum recommended output current (0 = no limit)"/>
</div>
</div>

<!-- LDO DROPOUT -->
<div class="form-group source_ldo">
<label>Dropout voltage</label>
<div class="row">
<div class="col-xs-5 dropout"><input id="input_drop_i" type="text" class="form-control input_num" placeholder="xx A" data-toggle="tooltip" data-placement="bottom" title="Output current (A)" /></div>
<div class="col-xs-5 dropout"><input id="input_drop_v" type="text" class="form-control input_num" placeholder="xx V" data-toggle="tooltip" data-placement="bottom" title="Dropout voltage (V)" /></div>
<div class="col-xs-2 dropout"><a id="add_drop" class="btn btn-default"><span class="fa fa-plus"></span></a></div>
</div>
<canvas id="dropChart" width="200" height="108"></canvas>
</div>
</div>
</form>


Expand Down
20 changes: 16 additions & 4 deletions js/class.Item.Source.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Source extends Item {
vout_min : '1.78',
vout_typ : '1.8',
vout_max : '1.82',
vin_limit : '0', // v1.8.0, 0=no limit
iout_limit : '0', // v1.8.0, 0=no limit
r1 : '150000',
r2 : '120000',
Expand Down Expand Up @@ -475,13 +476,24 @@ class Source extends Item {
}
}

// Check if Vin < vin_limit
let vin_limit = parseFloat(this.characs.vin_limit);
if(vin_limit !== 0) {
for(let valType of ['typ', 'max']) {
let vin = this.getInputVoltage(valType);
if((vin > 0 && vin > vin_limit) || (vin < 0 && vin < vin_limit)) {
alerts.push(`V<sub>IN ${valType.toUpperCase()}</sub> (${vin}V) exceeds the input voltage limit (${vin_limit}V).`);
}
}
}

// Check if Iout < iout_limit
let ilimit = parseFloat(this.characs.iout_limit);
if(ilimit !== 0) {
let iout_limit = parseFloat(this.characs.iout_limit);
if(iout_limit !== 0) {
for(let valType of ['typ', 'max']) {
let iout = this.getOutputCurrent(valType);
if(Math.abs(iout) > Math.abs(ilimit)) {
alerts.push(`I<sub>OUT ${valType.toUpperCase()}</sub> is higher than the output current limit (|${iout}| > |${ilimit}|).`);
if((iout > 0 && iout > iout_limit) || (iout < 0 && iout < iout_limit)) {
alerts.push(`I<sub>OUT ${valType.toUpperCase()}</sub> (${iout}A) exceeds the output current limit (${iout_limit}A).`);
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
// Electron module to send/receive message with all renderers
const ipcMain = electron.ipcMain;

// Node.js module to access File System
const fs = require('fs');
// Node.js module to work with paths
Expand Down Expand Up @@ -270,10 +271,14 @@ ipcMain.on('Item-editReq', (evt, itemStr, itemType) => {
// save the event to respond to this msg later
renderers.itemEditor.reqEvent = evt;

// Electron module to get screen informations
const screen = electron.screen;
const maxWidth = screen.getPrimaryDisplay().workAreaSize.width;

// Create the itemEditor window
renderers.itemEditor.browserWindow = new BrowserWindow({
width : ('source' == itemType) ? 1000 : 650,
height : ('source' == itemType) ? 720 : 485,
width : ('source' == itemType) ? (1300>maxWidth)?maxWidth:1300 : 650,
height : ('source' == itemType) ? 540 : 485,
parent : renderers.PTree.browserWindow,
modal : true,
resizable : false,
Expand Down

0 comments on commit cfa45aa

Please sign in to comment.