Python Forum
Wish to write a code for an electronic load and a power supply for measuring Eff
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wish to write a code for an electronic load and a power supply for measuring Eff
#1
Hi there,
I am pretty new in python.
I need some help from your side.

Willing to run a program like this,

import pyvisa

# Initialize the resource manager and open the connection

rm = pyvisa.ResourceManager()
resource_address = "Your_VISA_Address"  # Replace with your actual VISA resource address
power_supply = rm.open_resource(resource_address)

try:
    # Identify the power supply
    print(power_supply.query("*IDN?"))

    # Set parameters (example values; replace as needed)
    voltage = 12.0  # Volts
    current = 5.0   # Amperes

    # Configure the power supply
    power_supply.write(f"VOLT {voltage}")
    power_supply.write(f"CURR {current}")

    # Enable the output
    power_supply.write("OUTP ON")

    # Measure output voltage and current
    measured_voltage = float(power_supply.query("MEAS:VOLT?"))
    measured_current = float(power_supply.query("MEAS:CURR?"))

    # Calculate power efficiency
    input_power = voltage * current  # Input power
    output_power = measured_voltage * measured_current  # Output power
    efficiency = (output_power / input_power) * 100

    print(f"Input Power: {input_power} W")
    print(f"Output Power: {output_power} W")
    print(f"Efficiency: {efficiency:.2f} %")

except Exception as e:
    print(f"An error occurred: {e}")

finally:
    # Turn off the output and close the connection
    power_supply.write("OUTP OFF")
    power_supply.close()
Send me your comments
Reply
#2
What is the question?
Does it work?
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  needing some help to write some code for a game calculator rymdaksel 2 1,623 Mar-08-2025, 03:02 AM
Last Post: bevisandrew
  cheap and low power python device kucingkembar 6 1,527 Jun-27-2024, 12:41 PM
Last Post: kucingkembar
  UART write binary code trix 3 1,621 Apr-28-2024, 04:57 PM
Last Post: deanhystad
  write code that resides in parent directory franklin97355 3 1,430 Apr-14-2024, 02:03 AM
Last Post: franklin97355
  Python Coding in Power BI Visual vjrans 0 810 Jan-31-2024, 07:54 AM
Last Post: vjrans
  Power Shells vs Compile and Run programs? RockBlok 2 1,174 Jan-13-2024, 09:08 PM
Last Post: RockBlok
Question Python and Power BI Desktop dangermaus33 1 1,918 Jan-19-2023, 06:54 AM
Last Post: GetOnData
  Model of supply and demand maeva 4 3,492 Nov-18-2021, 09:19 AM
Last Post: maeva
  Raising numbers to power ** GJG 3 3,495 Mar-23-2021, 03:43 PM
Last Post: deanhystad
  How to write a code with İF function? Aycaaxx 1 2,607 Nov-03-2020, 05:46 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020