Issues controlling Analog Output

Topics about the Software of Revolution Pi
Post Reply
MattIO
Posts: 1
Joined: 22 Sep 2023, 14:47
Answers: 0

Issues controlling Analog Output

Post by MattIO »

Hi,

I'm currently performing some work for our client who has just purchased a RevPi Connect 4 and a MIO, we are currently attempting to read an input voltage (AnalogInput_1) and based on that reading, turn an output (AnalogOutput_1) either on (10v) or off (0v).

So far I am successfully able to read the input without issue and have confirmed that the reading is correct, the problem I am now having is controlling our output. When i try to set AnalogOutput_1 to 10v nothing happens, however when i set a value of 0 the voltage increases to 10v and after this I am unable to alter the voltage. I have followed the tutorial and have set the following for AnalogOutput_1:

  • AnalogOutputLogicLevel_1: 0
  • AnalogOutput_1: 10000
  • AnalogOutputMode_1: analogOutput
  • OutputLogicLevelVoltage_1: 0

My code is below:

Code: Select all


import time
import revpimodio2

def loop(cycletools):
    timestamp_milliseconds = int(round(time.time() * 1000))

    #list = revpimodio2.io.IOList()
    #print(revpimodio2.io["AnalogInput_1"])

    analog_value1 = rpi.io.AnalogInput_1.value

    #voltage stays at 0v
    #rpi.io.AnalogOutput_1.value = 10000

    #voltage goes to 10v and is stuck
    #rpi.io.AnalogOutput_1.value = 0

    #voltage goes to 10v and is stuck
    #rpi.io.AnalogOutput_1.value = 1

	#what we ideally need
    if(analog_value1 > 1000):
        #turn output to 10v
        rpi.io.AnalogOutput_1.value = 10000
    else:
        #turn output off (0v)
        rpi.io.AnalogOutput_1.value = 0


    analog_value2 = rpi.io.AnalogOutput_1.value
    print(timestamp_milliseconds, analog_value1,analog_value2)
    
# create new instance of revpimodio2 
rpi = revpimodio2.RevPiModIO(autorefresh=True)

# catch SIGINT and handle proper release of all IOs
rpi.handlesignalend()

# start cycle loop, cycle time in milliseconds
rpi.cycleloop(loop, cycletime=2000)


Once running this code I have to use the "Reset Driver" option in PiCtory to set the output back to 0v.

I'm probably doing something wrong so apologies. We are C# developers, we don't work with Python and IOT devices typically, any help would be appreciated. If you need anymore information please let me know.

Thanks
Matt.
u.biakoup
KUNBUS
Posts: 182
Joined: 14 Apr 2022, 13:04
Answers: 2

Re: Issues controlling Analog Output

Post by u.biakoup »

Hello MattIO,
let's troubleshoot this together.
First, have a look at how to commission MIO in this tutorial.
If you have followed the checklist and still haven't found a solution, feel free to contact me again.

Yours sincerely,

Ulrich Kouatang Biakoup | Technical Support
Post Reply