Hi,
I have started recently writing smuview python code for testing hardware
devices I have to prove that they can be controlled.
I saw some others asking for help on the mailing list about getting
started with python code.
Firstly - I dont fully understand how to get this to run from a command
line. I currently run this inside smuview by using the load script
command in smuview. Maybe someone could be kind enough if to explain if
the python script could be run from the command line, and if so what
changes need to occur to it.
It would be good if we could have an area where we can put basic example
scripts for each driver. Here I have attached an example of controlling
the rdtech-rd device. This is my first example, but it enabled me to
understand how to gain control of the device, then understand some of
the input and settable controls available. Then do some basic on/off and
voltage setting. I was able to learn a heap and break down the interface
into small steps. A big thanks to knarfS on assisting me so far.
I am happy for the above example scripts header to be modified so that
it can be used and shared by smuview project. The txt files are the
output showing when a device is connected and disconnected. Both are as
expected and I was able to demonstrate control of the PSU.
Next I am going to do a test file for the ZKE-EBD-USB. I am happy to
share further work if someone is happy to make a location for these. I
noticed the install location:
C:\Program Files\sigrok\SmuView\examples
Maybe this would be a good location to put these?
Regards
Stuart
# smuview test code for rdtech-rd device
#
# test code written by: Stuart Tyler
# licence: free - do what you want - no responcibility from supply side
# tested by: Stuart Tyler
# tested on device: rd6006
# Objective: Show that the power supply can be communicated with and controlled
in python
# 1. Connect to the power supply and show its capabilities
# 2. Control the psu output on and off
# 3. Show the psu output voltage
# 4. Change the psu output voltage
import smuview
import time
print("------START OF rdtech-rd TEST------")
print("------CURRENT SESSION INFORMATION------")
current_devices = Session.devices()
print(current_devices)
print("------CONNECT rdtech-rd to SESSION------")
# Connect device.
dev = Session.connect_device("rdtech-rd:conn=COM15")[0]
print (dev)
print("------SHOW CONFIGURABLES------")
conf = dev.configurables()[""]
print (conf)
# Sleep 1s to give the devices the chance to create signals.
# As per sample code from other demos
time.sleep(1)
print("------SHOW CHANNELS------")
channels = dev.channels()
print(channels)
print("------SHOW LISTABLE CONFIGS------")
listconf=conf.listable_configs()
print(listconf)
print("------SHOW SETABLE CONFIGS------")
settable=conf.setable_configs()
print(settable)
print("------ATTEMPT TO TURN PSU OUTPUT OFF------")
conf.set_config(smuview.ConfigKey.Enabled, False)
print("------ATTEMPT TO READ PSU OUTPUT VOLTAGE 10 TIMES 1 SECOND DELAY------")
for x in range(10):
# Get last sample from channel V.
sample = dev.channels()["V"].actual_signal().get_last_sample(True)
print(sample)
time.sleep(1)
print("------ATTEMPT TO TURN PSU OUTPUT ON------")
conf.set_config(smuview.ConfigKey.Enabled, True)
print("------ATTEMPT TO READ PSU OUTPUT VOLTAGE 10 TIMES 1 SECOND DELAY------")
for x in range(10):
# Get last sample from channel V.
sample = dev.channels()["V"].actual_signal().get_last_sample(True)
print(sample)
time.sleep(1)
print("------ATTEMPT TO TURN PSU OUTPUT TO 13.2V------")
conf.set_config(smuview.ConfigKey.VoltageTarget, 13.2)
print("------ATTEMPT TO READ PSU OUTPUT VOLTAGE 10 TIMES 1 SECOND DELAY------")
for x in range(10):
# Get last sample from channel V.
sample = dev.channels()["V"].actual_signal().get_last_sample(True)
print(sample)
time.sleep(1)
print("------ATTEMPT TO TURN PSU OUTPUT TO 14.4V------")
conf.set_config(smuview.ConfigKey.VoltageTarget, 14.4)
print("------ATTEMPT TO READ PSU OUTPUT VOLTAGE 10 TIMES 1 SECOND DELAY------")
for x in range(10):
# Get last sample from channel V.
sample = dev.channels()["V"].actual_signal().get_last_sample(True)
print(sample)
time.sleep(1)
print("------END OF rdtech-rd TEST------")
------START OF rdtech-rd TEST------
------CURRENT SESSION INFORMATION------
{}
------CONNECT rdtech-rd to SESSION------
IndexError: list index out of range
At:
C:/smuview_testing/python/smuview_test_rdtech-rd.py(26): <module>
------START OF rdtech-rd TEST------
------CURRENT SESSION INFORMATION------
{}
------CONNECT rdtech-rd to SESSION------
<smuview.HardwareDevice object at 0x0000000006EAB340>
------SHOW CONFIGURABLES------
<smuview.Configurable object at 0x00000000099A4B58>
------SHOW CHANNELS------
{'R': <smuview.BaseChannel object at 0x000000000997F0A0>, 'I':
<smuview.HardwareChannel object at 0x000000000997F030>, 'V':
<smuview.HardwareChannel object at 0x000000000997F0D8>, 'P':
<smuview.HardwareChannel object at 0x000000000997F068>, 'Wh':
<smuview.BaseChannel object at 0x000000000997F148>, 'Ah': <smuview.BaseChannel
object at 0x0000000009966D88>}
------SHOW LISTABLE CONFIGS------
{<ConfigKey.CurrentLimit: 32>, <ConfigKey.VoltageTarget: 30>}
------SHOW SETABLE CONFIGS------
{<ConfigKey.CurrentLimit: 32>, <ConfigKey.Enabled: 33>,
<ConfigKey.OverCurrentProtectionThreshold: 40>,
<ConfigKey.OverVoltageProtectionThreshold: 37>, <ConfigKey.VoltageTarget: 30>}
------ATTEMPT TO TURN PSU OUTPUT OFF------
------ATTEMPT TO READ PSU OUTPUT VOLTAGE 10 TIMES 1 SECOND DELAY------
(88.55900001525879, 0.0)
(89.53400015830994, 0.0)
(90.61700010299683, 0.0)
(91.4850001335144, 0.0)
(92.56299996376038, 0.0)
(93.6470000743866, 0.0)
(94.51399993896484, 0.0)
(95.59800004959106, 0.0)
(96.68200016021729, 0.0)
(97.54299998283386, 0.0)
------ATTEMPT TO TURN PSU OUTPUT ON------
------ATTEMPT TO READ PSU OUTPUT VOLTAGE 10 TIMES 1 SECOND DELAY------
(98.84400010108948, 0.0)
(99.81900000572205, 13.779999732971191)
(100.90300011634827, 13.789999961853027)
(101.76999998092651, 13.789999961853027)
(102.84899997711182, 13.789999961853027)
(103.93400001525879, 13.789999961853027)
(104.80100011825562, 13.789999961853027)
(105.88600015640259, 13.789999961853027)
(106.96399998664856, 13.789999961853027)
(107.83200001716614, 13.789999961853027)
------ATTEMPT TO TURN PSU OUTPUT TO 13.2V------
------ATTEMPT TO READ PSU OUTPUT VOLTAGE 10 TIMES 1 SECOND DELAY------
(109.1340000629425, 13.779999732971191)
(110.10899996757507, 13.170000076293945)
(111.1930000782013, 13.180000305175781)
(112.0550000667572, 13.180000305175781)
(113.14000010490417, 13.180000305175781)
(114.22500014305115, 13.180000305175781)
(115.09299993515015, 13.180000305175781)
(116.17700004577637, 13.180000305175781)
(117.25600004196167, 13.180000305175781)
(118.12400007247925, 13.180000305175781)
------ATTEMPT TO TURN PSU OUTPUT TO 14.4V------
------ATTEMPT TO READ PSU OUTPUT VOLTAGE 10 TIMES 1 SECOND DELAY------
(119.42499995231628, 13.180000305175781)
(120.40100002288818, 14.380000114440918)
(121.48600006103516, 14.380000114440918)
(122.34700012207031, 14.380000114440918)
(123.43099999427795, 14.380000114440918)
(124.51600003242493, 14.380000114440918)
(125.3840000629425, 14.380000114440918)
(126.46900010108948, 14.380000114440918)
(127.5460000038147, 14.380000114440918)
(128.41400003433228, 14.380000114440918)
------END OF rdtech-rd TEST------_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel