Moderator: RevPiModIO
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: ts=4:sw=4:et
import time
import revpimodio2
def loop(cycletools):
timestamp_milliseconds = int(round(time.time() * 1000))
analog_value1 = rpi.io.InputValue_1.value
analog_value2 = rpi.io.InputValue_2.value
print(timestamp_milliseconds, analog_value1, analog_value2)
# create new instance of revpimodio2 in readonly (monitoring) mode
rpi = revpimodio2.RevPiModIO(autorefresh=True, monitoring=True)
# catch SIGINT and handle proper release of all IOs
rpi.handlesignalend()
# start cycle loop, cycle time in milliseconds
rpi.cycleloop(loop, cycletime=20)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: ts=4:sw=4:et
import time
import revpimodio2
def loop(cycletools):
timestamp_milliseconds = int(round(time.time() * 1000))
analog_value1 = rpi.io.InputValue_1.value
analog_value2 = rpi.io.InputValue_2.value
print(timestamp_milliseconds, analog_value1, analog_value2)
# create new instance of revpimodio2 in readonly (monitoring) mode
rpi = revpimodio2.RevPiModIO(autorefresh=True, monitoring=True)
# catch SIGINT and handle proper release of all IOs
rpi.handlesignalend()
# start cycle loop, cycle time in milliseconds
rpi.cycleloop(loop, cycletime=20)
Hi palmerpi,
I would recommend a simple Python application using the revpimodio2 library. For storage you can use a in memory database or nearly any other database which runs on Linux.
A simple application with gathers information from two analog inputs every 20 milliseconds and prints the timestamp in milliseconds with the two value could look like this:
Code: Select all#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ts=4:sw=4:et import time import revpimodio2 def loop(cycletools): timestamp_milliseconds = int(round(time.time() * 1000)) analog_value1 = rpi.io.InputValue_1.value analog_value2 = rpi.io.InputValue_2.value print(timestamp_milliseconds, analog_value1, analog_value2) # create new instance of revpimodio2 in readonly (monitoring) mode rpi = revpimodio2.RevPiModIO(autorefresh=True, monitoring=True) # catch SIGINT and handle proper release of all IOs rpi.handlesignalend() # start cycle loop, cycle time in milliseconds rpi.cycleloop(loop, cycletime=20)
Do you know if I can speed the time the actual analog refreshes? I'm not capturing the constantly changing reading on input 1.
Im using your script above with one input as an example and while the loop reads at 20ms the reading from the analog doesn't update at this rate.
e.g Time Milliamps
1636109023743 15934
1636109023764 15934
1636109023783 15934
1636109023803 15934
1636109023822 13795
1636109023843 13795
1636109023862 13795
1636109023882 13795
1636109023901 13795
1636109023922 13795
1636109023941 13795
1636109023961 13795
1636109023980 13795
1636109024001 13795
1636109024020 13795
1636109024040 13795
1636109024059 13795
1636109024080 13795
1636109024099 13795
1636109024119 13795
1636109024139 13795
1636109024159 13795
1636109024178 13795
1636109024198 13795
1636109024218 13795
1636109024238 13795
1636109024257 13795
1636109024278 13795
1636109024297 13795
1636109024317 13795
1636109024336 13795
1636109024357 13795
1636109024376 13795
1636109024396 13795
1636109024416 13795
1636109024436 13795
1636109024455 13795
1636109024476 13795
1636109024495 13795
1636109024515 13795
1636109024535 13795
1636109024555 13795
1636109024574 13795
1636109024595 13795
1636109024614 13795
1636109024634 11659
1636109024654 11659
1636109024674 11659
1636109024693 11659
1636109024713 11659
Hi palmerpi,
I would recommend a simple Python application using the revpimodio2 library. For storage you can use a in memory database or nearly any other database which runs on Linux.
A simple application with gathers information from two analog inputs every 20 milliseconds and prints the timestamp in milliseconds with the two value could look like this:
Code: Select all#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ts=4:sw=4:et import time import revpimodio2 def loop(cycletools): timestamp_milliseconds = int(round(time.time() * 1000)) analog_value1 = rpi.io.InputValue_1.value analog_value2 = rpi.io.InputValue_2.value print(timestamp_milliseconds, analog_value1, analog_value2) # create new instance of revpimodio2 in readonly (monitoring) mode rpi = revpimodio2.RevPiModIO(autorefresh=True, monitoring=True) # catch SIGINT and handle proper release of all IOs rpi.handlesignalend() # start cycle loop, cycle time in milliseconds rpi.cycleloop(loop, cycletime=20)