Exemple #1
0
def graceful_shutdown(signal, frame):
    logger.info('Got a shutdown signal!')
    if connection:
        connection.close()

    if csv_file:
        csv_file.close()

    ads1256.stop()
    sys.exit(0)
Exemple #2
0
def ReadValues():
    rate = 25  # Frequency in Hz

    ads1256.start("1", str(rate))
    pub = rospy.Publisher('/sen_4/ResVal',
                          Float32,
                          tcp_nodelay=False,
                          queue_size=1)
    rospy.init_node('Rheostat', anonymous=True)
    rate = rospy.Rate(10)
    while not rospy.is_shutdown():
        absoluteValue = ads1256.read_channel(0)
        voltage = ((absoluteValue * 100) / 167.0) / 1000000.0
        rospy.loginfo(voltage)
        pub.publish(voltage)
        rate.sleep()
    ads1256.stop()
def PWM_Voltage_Measure(Measurement):
    gain = 1  # ADC's Gain parameter
    sps = 25  # ADC's SPS parameter
    ads1256.start(str(gain), str(sps))

    if Measurement == 'DC_Link':
        ChannelValue = ads1256.read_channel(3)
        ChannelValueVolts = ((
            (ChannelValue * 100) / 167.0) / int(gain)) / 1000000.0
        DCVolts = ChannelValueVolts
    elif Measuremnet == 'Solar':
        ChannelValue = ads1256.read_channel(3)
        ChannelValueVolts = ((
            (ChannelValue * 100) / 167.0) / int(gain)) / 1000000.0
        DCVolts = ChannelValueVolts
    else:
        UPS_Error('Error_Voltage_Measurement')
    ads1256.stop()

    return DCVolts
Exemple #4
0
ads1256.start("1", "2d5")

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((TCP_IP, TCP_PORT))
s.listen(1)

print "Wait for client..."
#Wait for a connection
conn, addr = s.accept()
print 'Connection address:', addr
while 1:
    outBin = ""

    for i in range(TCP_PACK_SIZE):
        t1 = datetime.datetime.now()
        data = ads1256.read_all_channels()
        t3 = datetime.datetime.now()

        print "%s " % (t3 - t1)

        if data[2] == 0 or data[3] == 0:
            print "ZERO %s %s" % (data[2], data[3])

        #Append data to the outgoing message
        outBin = outBin + struct.pack('!ii', data[2], data[3])

    #Send aggregated data
    conn.send(outBin)

ads1256.stop()
conn.close()
Exemple #5
0
 def __del__(self):
     ads1256.stop()
     self.stopLoop = True
     print "Destroying sensor"
Exemple #6
0
    return voltage

adc.start("1", "2d5")

signal.signal(signal.SIGINT, signal_handler)
interupted = False

dataLog = open("dcf_datalog.txt", "w")
dataLog.write("%5s %5s"%("Time", "Volts\n"))

print "DCF Survival Test"
print "Start time: ", dt.datetime.now().strftime('%Y-%m-%d - %H:%M:%S')


print "Press CTRL-C to exit safely"
count = 0
while True:
    dataLine = (dt.datetime.now().strftime('%Y-%m-%d - %H:%M:%S'), readADC_volts(channel = 7))
    dataLog.write("%s %s \n"%dataLine)
    count+=1
    sys.stdout.write("\r" + "Measurement Number: " + str(count))
    sys.stdout.flush()

    if interupted:
        print "\n Closing"
        break
    sleep(5)

dataLog.close()
adc.stop()
Exemple #7
0
def ReadValues():
    while not rospy.is_shutdown():
        Loop(ads1256.read_channel(adcChannel))
        rate.sleep()
    ads1256.stop()
Exemple #8
0
def ReadValues():
    while True:
        Loop(ads1256.read_channel(adcChannel))
        time.sleep(1 / readFrequency / 2)
    ads1256.stop()
Exemple #9
0
 def __del__(self):
     ads1256.stop()