Counter Reset With RevPiModIO

Moderator: RevPiModIO

kodyaz
Posts: 16
Joined: 13 Oct 2018, 06:57
Answers: 0

Counter Reset With RevPiModIO

Post by kodyaz »

Hi, How to reset counter values with RevPiModIO.
User avatar
RevPiModIO
KUNBUS
Posts: 322
Joined: 20 Jan 2017, 08:44
Answers: 0
Contact:

Re: Counter Reset With RevPiModIO

Post by RevPiModIO »

It is not implemented yet :(

! BUT !

I did it NOW 8-) I just have to run some tests an will publish a link to the "beta" tomorrow. It would be nice if you can test the new Version (2.3.0) an report your experience!

Sven
python3-RevPiModIO - https://revpimodio.org/ || Der RevPi ist das Beste, was passieren konnte!
User avatar
RevPiModIO
KUNBUS
Posts: 322
Joined: 20 Jan 2017, 08:44
Answers: 0
Contact:

Re: Counter Reset With RevPiModIO

Post by RevPiModIO »

And here it is: http://revpimodio.org/dnl/python3-revpi ... -1_all.deb

Beta with reset of counter inputs.

You have to download and install it on you pi via:

Code: Select all

wget http://revpimodio.org/dnl/python3-revpimodio2_2.3.0-1_all.deb
sudo dpkg -i python3-revpimodio2_2.3.0-1_all.deb
You use it like the old version. So let the counters count some values and call the .reset() function of the counter inputs.

Code: Select all

import revpimodio2
rpi = revpimodio2.RevPiModIO(autorefresh=True)

# Read the counter input values
rpi.io.Counter_1.value
11
rpi.io.Counter_2.value
11

# Reset counter inputs
rpi.io.Counter_1.reset()
rpi.io.Counter_2.reset()

# Read the counter input values again
rpi.io.Counter_1.value
0
rpi.io.Counter_2.value
0

Please post your experiences!

Sven
python3-RevPiModIO - https://revpimodio.org/ || Der RevPi ist das Beste, was passieren konnte!
kodyaz
Posts: 16
Joined: 13 Oct 2018, 06:57
Answers: 0

Re: Counter Reset With RevPiModIO

Post by kodyaz »

miprotek wrote: 10 Dec 2018, 16:34 And here it is: http://revpimodio.org/dnl/python3-revpi ... -1_all.deb

Beta with reset of counter inputs.

You have to download and install it on you pi via:

Code: Select all

wget http://revpimodio.org/dnl/python3-revpimodio2_2.3.0-1_all.deb
sudo dpkg -i python3-revpimodio2_2.3.0-1_all.deb
You use it like the old version. So let the counters count some values and call the .reset() function of the counter inputs.

Code: Select all

import revpimodio2
rpi = revpimodio2.RevPiModIO(autorefresh=True)

# Read the counter input values
rpi.io.Counter_1.value
11
rpi.io.Counter_2.value
11

# Reset counter inputs
rpi.io.Counter_1.reset()
rpi.io.Counter_2.reset()

# Read the counter input values again
rpi.io.Counter_1.value
0
rpi.io.Counter_2.value
0

Please post your experiences!

Sven
Thanks Sven. This code was executed.
Thank you for your interest.

But I have one more question. Can I shut down Revolution Pi 3 with python software?
User avatar
RevPiModIO
KUNBUS
Posts: 322
Joined: 20 Jan 2017, 08:44
Answers: 0
Contact:

Re: Counter Reset With RevPiModIO

Post by RevPiModIO »

Nice to read that the counter reset works, thank you!

You can execute all system commands via python with os.system("command"). So if you like so shutdown your RevPi with Python, you can do it like this:

Code: Select all

import os
os.system("/usr/bin/sudo /sbin/poweroff")

This code will shut down your RevPi immediately.

Sven
python3-RevPiModIO - https://revpimodio.org/ || Der RevPi ist das Beste, was passieren konnte!
kodyaz
Posts: 16
Joined: 13 Oct 2018, 06:57
Answers: 0

Re: Counter Reset With RevPiModIO

Post by kodyaz »

Thank you Sven for your benevolence.
Bonze
Posts: 9
Joined: 04 Apr 2019, 10:37
Answers: 0

Re: Counter Reset With RevPiModIO

Post by Bonze »

das reseten der Counter funktioniert aber nicht bei allen Inputs!, das ist mir heute aufgefallen, dachte erst an einen Fehler meinerseits,
aber nach wechsel auf einen anderen Input hat es sofort funktioniert... vl liegt hier ein Software Bug vor. D Bei Counter6/7 funktioniert es auf jedenfall, aber bei 8/9 hat es nicht funktioniert..
User avatar
RevPiModIO
KUNBUS
Posts: 322
Joined: 20 Jan 2017, 08:44
Answers: 0
Contact:

Re: Counter Reset With RevPiModIO

Post by RevPiModIO »

Hi Bonze!

Danke für die Meldung, ich werde das umgehen prüfen und korrigieren - Ergebnisse poste ich dann an dieser Stelle.
python3-RevPiModIO - https://revpimodio.org/ || Der RevPi ist das Beste, was passieren konnte!
User avatar
RevPiModIO
KUNBUS
Posts: 322
Joined: 20 Jan 2017, 08:44
Answers: 0
Contact:

Re: Counter Reset With RevPiModIO

Post by RevPiModIO »

Alle liebe Community!

Dank Bonze konnte ich einen Fehler verbessern und der .reset() Befehl der Counter IOs läuft nun auch auf Countern 8-16.

Zu dem Fehler kam es durch den ioctl Aufruf, dessen Daten durch padding etwas anders interpretiert werden müssen :D

Version 2.3.2 Behebt dieses Problem und führt noch ein paar Debuggingwerkzeuge ein:

DE [https://revpimodio.org/version-2-3-2/]
EN [https://revpimodio.org/en/blogs/version ... imodio-en/]

Gruß, Sven
python3-RevPiModIO - https://revpimodio.org/ || Der RevPi ist das Beste, was passieren konnte!
Bonze
Posts: 9
Joined: 04 Apr 2019, 10:37
Answers: 0

Re: Counter Reset With RevPiModIO

Post by Bonze »

ich hab heute festgestellt, das wohl in der neusten Version wieder ein Bug ist, bei dem sich der Counter nicht zurücksetzen lässt. Counter7/8 funktioniert bei gleicher Konfiguration.
Counter9/10 , konfiguriert als Encoder, wirft beim zurücksetzen folgenden Fehler:

Code: Select all

plc: __init__.py started: Fri Feb 21 13:18:05 2020
/home/pi/.local/lib/python3.5/site-packages/revpimodio2/modio.py:330: RuntimeWarning: got io error during ioctl and count 1 errors now
  RuntimeWarning
Post Reply