Example #1
0
def main():
    global pid
    contador = 0
    nombres = ('Velocidad' , 'Posicion')
    #dato = int(prbs())
    encoder = decoder(6,13)
    header = FORMATO_ENCABEZADO%nombres
    
    if(DEBUG):print header
    if(FILE):f.write(header+"\n")

    while (contador < 100000):
    	#dato = prbs()
    	#print contador%300
        if not contador%100:
            valor_prbs = prbs()
            encoder.pid_velocidad.SetPoint(valor_prbs)
            print "Valor prbs = %s"%valor_prbs
        velocidad = encoder.velocidad
    	body = FORMATO_VALORES % (contador , velocidad , encoder.pos*0.12566370614359174)
        
    	if(DEBUG): print body
    	if(FILE): f.write(body + "\n")
    	time.sleep(0.01)
        contador += 1
    encoder.cancel()
    encoder.pid_velocidad.motor.parar()
    encoder.pi.stop()    
Example #2
0
dm2 = 2250
dpr = 3820
dcz = 6650

magnitudes = sys.argv
print magnitudes
#magnitudes = magnitudes[1:-1].split(',')
magnitudes2 = []
print magnitudes
print magnitudes[1:]
for string in magnitudes[1:]:
    magnitudes2.append(float(string))
print magnitudes2


decoder = rotary_encoder2.decoder( 6, 13,)
tr.salir()
time.sleep(0.5)

try:

    for magnitud in magnitudes2:
        print magnitud
        print "Cortando Magnitud de %s"%magnitud
        veces = m.ceil(magnitud/largo_prensa)
        print "Magnitud cortada en %s partes"%veces
        for paso in range(int(veces)):
            avance = (int((float(magnitud))/(veces))/0.12566370614359174)
            decoder.SetPoint_posicion(int(avance+decoder.pos))
            print "distancia a recorrer = %s"%(int(avance))
            print "Moviendose hacia %s "%(int(avance+decoder.pos))
Example #3
0
      self.cbA.cancel()
      self.cbB.cancel()

if __name__ == "__main__":

   import pigpio

   import rotary_encoder2

   pos = 0

   def callback(way):

      global pos

      pos += way

      print("pos={}".format(pos))

   pi = pigpio.pi()

   decoder = rotary_encoder2.decoder(pi, 6, 13,)

   time.sleep(300)

   decoder.cancel()

   pi.stop()

Example #4
0
                                    self._pulse)
        self.cbB = self.pi.callback(self.gpioB, pigpio.EITHER_EDGE,
                                    self._pulse)
        if abs(setpoint - self.pos) < 0.5:
            pass
        else:
            self.pid_posicion.SetPoint(setpoint)
            self.status = 1


if __name__ == "__main__":

    import rotary_encoder2

    decoder = rotary_encoder2.decoder(
        6,
        13,
    )
    try:

        while 1:
            sp = raw_input('ingresa comando : ')
            if sp == 'pos': print "jfsdkfjsdfklsjdf %s" % decoder.pos
            else: decoder.SetPoint_posicion(float(sp))

    except KeyboardInterrupt:

        decoder.pid_posicion.motor.parar()
        decoder.cancel()
        decoder.pi.stop()
Example #5
0
if __name__ == "__main__":

    import pigpio

    import rotary_encoder2

    pos = 0

    def callback(way):

        global pos

        pos += way

        print("pos={}".format(pos))

    pi = pigpio.pi()

    decoder = rotary_encoder2.decoder(
        pi,
        6,
        13,
    )

    time.sleep(300)

    decoder.cancel()

    pi.stop()