Exemplo n.º 1
0
def makePhotoFromIntensity(intensityL, intensityR, nodes):
    # linear in log-log (ohms vs lux)
    # resistance is 5K at 100 lux, slope is -0.9 (per Denny)
    x = 0
    resistors = []
    for i in (intensityL, intensityR):
        if i <= 1:
            lR = 5.5
        else:
            lI = math.log(i, 10)
            lR = 5.5 - lI * 0.9
        # print 'intensity', i, 'resistance', 10**lR
        resistors.append(cc.Resistor(10**lR, nodes[x], nodes[x + 1]))
        x += 1
    return resistors
Exemplo n.º 2
0
def makeMotor(emf, nodes):
    return [cc.Resistor(Rm, nodes[0], 'emf'),
            cc.VSrc(emf, 'emf', nodes[1])]
Exemplo n.º 3
0
def makePot(alpha, nodes, value = 5000):
    alpha = util.clip(alpha, 0.01, 0.99)
    return [cc.Resistor(value*alpha, nodes[0], nodes[1]),
            cc.Resistor(value*(1-alpha), nodes[1], nodes[2])]
Exemplo n.º 4
0
def resistorFromPins(colors, pin0, pin1):
    (x0, y0) = pin0
    (x1, y1) = pin1
    return [cc.Resistor(resistorValue(colors), nodeNameForPin(x0,y0), nodeNameForPin(x1,y1))]