Exemplo n.º 1
0
    def _set_vout(self, target_vout):
        if not isinstance(target_vout, Voltage):
            target_vout = Voltage(target_vout)

        rfb1_dev = self.get_elem_by_idx('RFB1').data['device']
        rfb1_fp = self.get_elem_by_idx('RFB1').data['footprint']
        rfb2_dev = self.get_elem_by_idx('RFB2').data['device']
        rfb2_fp = self.get_elem_by_idx('RFB2').data['footprint']
        if rfb1_fp[0:3] == "MY-":
            rfb1_fp = rfb1_fp[3:]
        if rfb2_fp[0:3] == "MY-":
            rfb2_fp = rfb2_fp[3:]

        allowed_rfb1_vals = iec60063.gen_vals(self._configdict['Rseries'],
                                              iec60063.res_ostrs,
                                              start='8.2K',
                                              end='10K')

        allowed_rfb2_vals = iec60063.gen_vals(self._configdict['Rseries'],
                                              iec60063.res_ostrs,
                                              self._configdict['Rmin'],
                                              self._configdict['Rmax'])

        allowed_rfb1_vals = [x for x in allowed_rfb1_vals]
        allowed_rfb2_vals = [x for x in allowed_rfb2_vals]
        best_match = None

        for pair in itertools.product(allowed_rfb1_vals, allowed_rfb2_vals):
            vout = self._get_Vout(*pair)
            error = abs(vout - target_vout)
            if best_match is None or error < best_match[1]:
                best_match = (vout, error, pair[0], pair[1])

        rfb1_value = gsymlib.find_resistor(best_match[2], rfb1_fp, rfb1_dev)
        self.get_elem_by_idx('RFB1').data['value'] = rfb1_value

        rfb2_value = gsymlib.find_resistor(best_match[3], rfb2_fp, rfb2_dev)
        self.get_elem_by_idx('RFB2').data['value'] = rfb2_value
Exemplo n.º 2
0
    def _autoset_ilim(self):
        rlim_dev = self.get_elem_by_idx('RLIM').data['device']
        rlim_fp = self.get_elem_by_idx('RLIM').data['footprint']

        icl = self.Iout * Decimal(1.2 - 0.33)

        self.target_rlim = (icl / Current('85uA')) * self.fet_Rdson

        allowed_rlim_vals = iec60063.gen_vals(self._configdict['Rseries'],
                                              iec60063.res_ostrs,
                                              self._configdict['Rmin'],
                                              self._configdict['Rmax'])

        best_match = None
        for r in allowed_rlim_vals:
            r = Resistance(r)
            if r > self.target_rlim:
                if best_match is None or r < best_match:
                    best_match = r

        rlim_value = gsymlib.find_resistor(best_match, rlim_fp, rlim_dev)
        self.get_elem_by_idx('RLIM').data['value'] = rlim_value
Exemplo n.º 3
0
    def _autoset_fsw(self):
        ron_dev = self.get_elem_by_idx('RON').data['device']
        ron_fp = self.get_elem_by_idx('RON').data['footprint']

        self.d_min = DutyCycle(
            100 * self.Vout / self.Vin_max
        )

        self.d_max = DutyCycle(
            100 * self.Vout / self.Vin_min
        )

        self.ton_min = TimeSpan(self._configdict['Ton_min'])
        self.fs_max_ontime = self.d_min / self.ton_min

        self.toff_min = TimeSpan(self._configdict['Toff_min']) + \
            TimeSpan(self._configdict['Toff_fet'])
        self.fs_max_offtime = (1 - self.d_max.value / 100) / self.toff_min

        self.fs_max = Percentage('80%') * min([self.fs_max_ontime, self.fs_max_offtime])  # noqa

        self.target_ron = Resistance(
            self.Vout.value / (Charge('100pC').value * self.fs_max.value)
        )

        allowed_ron_vals = iec60063.gen_vals(self._configdict['Rseries'],
                                             iec60063.res_ostrs,
                                             self._configdict['Rmin'],
                                             self._configdict['Rmax'])

        best_match = None
        for r in allowed_ron_vals:
            fsw = self._get_fsw(r)
            if self.fs_max > fsw:
                if best_match is None or fsw > best_match[0]:
                    best_match = (fsw, r)

        ron_value = gsymlib.find_resistor(best_match[1], ron_fp, ron_dev)
        self.get_elem_by_idx('RON').data['value'] = ron_value
Exemplo n.º 4
0
def jb_harmonize(item):
    ident = ident_transform(item.data['device'], item.data['value'],
                            item.data['footprint'])
    prefix = check_for_std_val(ident)
    if not prefix:
        return item
    else:
        if item.data['footprint'].startswith('MY-'):
            item.data['footprint'] = item.data['footprint'][3:]
        context = {
            'device': item.data['device'],
            'footprint': item.data['footprint']
        }
        if prefix == 'RES':
            params = parse_resistor(item.data['value'], context)
            from tendril.gedaif.gsymlib import find_resistor
            from tendril.gedaif.gsymlib import NoGedaSymbolException
            try:
                resistor = find_resistor(item.data['device'],
                                         item.data['footprint'],
                                         **params._asdict())
                item.data['value'] = resistor.value
            except NoGedaSymbolException:
                pass
            return item
        elif prefix == 'CAP':
            params = parse_capacitor(item.data['value'], context)
            from tendril.gedaif.gsymlib import find_capacitor
            from tendril.gedaif.gsymlib import NoGedaSymbolException
            try:
                capacitor = find_capacitor(item.data['device'],
                                           item.data['footprint'],
                                           **params._asdict())
                item.data['value'] = capacitor.value
            except NoGedaSymbolException:
                pass
            return item
        else:
            return item
Exemplo n.º 5
0
    def get_symbol(self, value, device=None, footprint=None):
        from tendril.gedaif import gsymlib

        if device is None:
            device = self._device
        if footprint is None:
            footprint = self._footprint

        if self._stype == 'resistor':
            if isinstance(value, (str, Resistance)):
                try:
                    return gsymlib.find_resistor(value, footprint, device)
                except (gsymlib.NoGedaSymbolException, InvalidOperation):
                    pass

        if self._stype == 'capacitor':
            if isinstance(value, (str, Capacitance)):
                try:
                    return gsymlib.find_capacitor(value, footprint, device)
                except (gsymlib.NoGedaSymbolException, InvalidOperation):
                    pass

        ident = electronics.ident_transform(device, value, footprint)
        return gsymlib.get_symbol(ident)
Exemplo n.º 6
0
    def get_symbol(self, value, device=None, footprint=None):
        from tendril.gedaif import gsymlib

        if device is None:
            device = self._device
        if footprint is None:
            footprint = self._footprint
        # TODO Handle other parameters such as wattage, voltage
        if self._stype == 'resistor':
            if isinstance(value, (str, Resistance)):
                try:
                    return gsymlib.find_resistor(device, footprint, value)
                except (gsymlib.NoGedaSymbolException, InvalidOperation):
                    pass

        if self._stype == 'capacitor':
            if isinstance(value, (str, Capacitance)):
                try:
                    return gsymlib.find_capacitor(device, footprint, value)
                except (gsymlib.NoGedaSymbolException, InvalidOperation):
                    pass

        ident = electronics.ident_transform(device, value, footprint)
        return gsymlib.get_symbol(ident)