Incorrect Analog output when using RevPiModIO

Moderator: RevPiModIO

Post Reply
in06khattab
Posts: 29
Joined: 24 Jan 2024, 19:07
Answers: 0

Incorrect Analog output when using RevPiModIO

Post by in06khattab »

I am getting different values when using piTest and RevPiModIO. The output of piTest is the correct one.
There has been some manipulations performed in Pictory:
2024-01-26_18-41.png
2024-01-26_18-41.png (6.01 KiB) Viewed 779 times
2024-01-26_18-12_1.png
2024-01-26_18-12_1.png (8.69 KiB) Viewed 779 times

Code: Select all

pi@RevPi17663:~ $ piTest -r MF1_TEMP
2 Byte-Value of MF1_TEMP: 38056 dez (=94a8 hex)
2 Byte-Value of MF1_TEMP: 37993 dez (=9469 hex)

Code: Select all

import time
import struct

rpi = revpimodio2.RevPiModIO(autorefresh=True)

value = rpi.io.MF1_TEMP.value
print(value)

This is the incorrect output of running the above code:-24208
Last edited by in06khattab on 26 Jan 2024, 19:43, edited 2 times in total.
in06khattab
Posts: 29
Joined: 24 Jan 2024, 19:07
Answers: 0

Re: Incorrect Analog output when using RevPiModIO

Post by in06khattab »

I wonder if RevPiModIO is not using the correct config.rsc file. How would I correct this?
Any changes I make to the Pictory configuration e.g. Multipliers are not making any changes to piTest.
in06khattab
Posts: 29
Joined: 24 Jan 2024, 19:07
Answers: 0

Re: Incorrect Analog output when using RevPiModIO

Post by in06khattab »

2024-01-26_18-47.png
2024-01-26_18-47.png (6.49 KiB) Viewed 778 times
It looks like there is no symbolic link. I am using Pictory 1.4.7

Does fixing this also fix these warnings?
Warning,
/usr/lib/python3/dist-packages/revpimodio2/modio.py:426: Warning: equal device name 'RevPi AIO' in pictory configuration. you can access this devices by position number .device[30|31] only!


EDIT: I have just checked the multipliers are the same in both /etc/revpi/config.rsc and /var/www/pictory/projects/_config.rsc
User avatar
nicolaiB
KUNBUS
Posts: 877
Joined: 21 Jun 2018, 10:33
Answers: 8
Location: Berlin
Contact:

Re: Incorrect Analog output when using RevPiModIO

Post by nicolaiB »

Which version of revpimodio2 are you using?

/etc/revpi/config.rsc should be a symlink to /var/www/pictory/projects/_config.rsc (on Stretch) or /var/www/revpi/pictory/projects/_config.rsc (on Buster and upwards).

NOTE: Pictory version 1.4.7 is (very) outdated, thus you must be using an outdated version of the operating system. I highly suggest to install the latest version of your Image (Bullseye) as there were several fixes and software updates since then. Also the old operating system (Stretch, was superseded by Buster, was superseded by Bullseye) does not receive security updates.

Nicolai
in06khattab
Posts: 29
Joined: 24 Jan 2024, 19:07
Answers: 0

Re: Incorrect Analog output when using RevPiModIO

Post by in06khattab »

Hi,

I am planning to upgrade to Buster, but first I need to update the image and ensure everything works including reading IO. So this is a temporary transition period. Thank you for your continued help in getting the IOs working.

Symbolic link has been fixed with: sudo ln -s /var/www/pictory/projects/_config.rsc /etc/revpi/config.rsc

EDIT: revpimodio2-2.7.1 is the version number.

I still get a different number in python vs piTest.
Python number: -29405
piTest: 36078

piTest -r MF1_TEMP

rpi = revpimodio2.RevPiModIO(autorefresh=True)
#rpi.readprocimg()

value = rpi.io.MF1_TEMP.value
in06khattab
Posts: 29
Joined: 24 Jan 2024, 19:07
Answers: 0

Re: Incorrect Analog output when using RevPiModIO

Post by in06khattab »

I have narrowed down why there is a difference between python and piTest and I think there is a bug with the library.

The issue is when there is a multiplier of 25, Divisor: 8, Offset: -12500
piTest: 36018
python: -29518

There is no issue with multiplier of 1, Divisor: 1, Offset: -12500
piTest: 3018
python: 3029

There is no issue with multiplier of 25, Divisor: 1, Offset: -12500. It looks like there is an overload as the output is incorrect.
piTest: 21834
python: 20884

There is a big issue with multiplier of 25, Divisor: 2, Offset: -12500. It looks like there is an overload as the output is incorrect.
piTest: 65465
python: -721

There is no issue with multiplier of 1, Divisor: 1, Offset: 0
piTest: 15615
python: 15641
User avatar
RevPiModIO
KUNBUS
Posts: 322
Joined: 20 Jan 2017, 08:44
Answers: 0
Contact:

Re: Incorrect Analog output when using RevPiModIO

Post by RevPiModIO »

Hi in06khattab!

The ModIO Library is set to signed integers in default on an AIO Module, piTest is unsigned.

You can get the byte-Value of the IO, using RevPiModIO via .get_value() instead of .value. The Hex value should be the same with the hex value on piTest.

If you want ModIO to treat the bytes unsigned (as piTest does) you can set .signed = False in your Python program for the input, then the .value should show the same result.

https://revpimodio.org/en/doc2/io/#signed

Gruß
Sven
python3-RevPiModIO - https://revpimodio.org/ || Der RevPi ist das Beste, was passieren konnte!
in06khattab
Posts: 29
Joined: 24 Jan 2024, 19:07
Answers: 0

Re: Incorrect Analog output when using RevPiModIO

Post by in06khattab »

Thank you very much. That has helped a lot!
Post Reply