Digital trigger for analog output - python

I want to trigger an analog output from a digital trigger on NI PCI 6713
http://www.ni.com/pdf/manuals/371011c.pdf
According to the datasheet I can use PFI <0..9> and those pins are indeed shown in green in NI MAX with ao/StartTrigger
My code is the following:
task = nidaqmx.Task()
task.ao_channels.add_ao_voltage_chan("Dev12/ao0")
task.triggers.start_trigger.cfg_dig_edge_start_trig("Dev12/PFI0")
task.timing.cfg_samp_clk_timing(rate=1)
task.start()
task.write([1,2,3,4,5,6,7,8,9,10,0])
I recieve the following error:
DaqError: Source terminal to be routed could not be found on the device.
Make sure the terminal name is valid for the specified device. Refer to Measurement & Automation Explorer for valid terminal names.
Property: DAQmx_DigEdge_StartTrig_Src
Property: DAQmx_DigEdge_StartTrig_Edge
Source Device: Dev12
Source Terminal: Dev12/PFI0
Channel Name: Dev12/ao0
Task Name: _unnamedTask<1C>
Status Code: -89120
I use Python 3.7

When specifying names for channels, the format is device_name/channel_name.
For physical terminals, the format is /device_name/terminal.
Note the leading slash for terminals:
task.ao_channels.add_ao_voltage_chan("Dev12/ao0")
task.triggers.start_trigger.cfg_dig_edge_start_trig("/Dev12/PFI0")
^
Here

Related

Printing to a POS Thermal Printer using Python

Good day,
I'm working on a simple Python project and I need to print a receipt to an Epson TM-T82X thermal printer. I have checked the python-escpos library and it has good documentation.
Example is this one:
from escpos.printer import Usb
""" Seiko Epson Corp. Receipt Printer (EPSON TM-T88III) """
p = Usb(0x04b8, 0x0202, 0, profile="TM-T88III")
p.text("Hello World\n")
p.image("logo.gif")
p.barcode('1324354657687', 'EAN13', 64, 2, '', '')
p.cut()
My problem is where to get the two Usb parameters '0x04b8' and '0x0202'. I know that they are device and manufacturer IDs. Checking the documentation further, it said that the IDs can be acquired by checking the printer's Device Instance Path or Hardware ID. I've checked that as well and it gives something like this:
SWD\PRINTENUM\{67FDD9C0-3ADC-4191-9B80-1711BCA4B9DF}
I am running on Windows 10 and Windows 11. Please help. Thank you.

How to solve pass thorugh command ignored issue when setting a signal analyser MXA N9020A

I am trying to set up the signal analyser using a simple python script. I am able to set the center and frequency and span frequency but when i am trying to turn the average on and set it to exponential mode, it gives me a pass through command ignored. The instrument is connected successfully using LAN.
import string
import pyvisa # PyVISA package for connecting to the instrument
pyvisa.log_to_screen()
# Make connection to instrument
# Open a VISA resource manager pointing to the installation folder for the Keysight Visa libraries.
rm = pyvisa.ResourceManager()
# Device addr
addr_MXA = 'TCPIP0::A-N9020A-00060::inst0::INSTR'
addr_VSA = 'TCPIP0::CASCODA500::hislip1::INSTR'
SA_device = rm.open_resource(addr_VSA)
# Preset and wait for operation to complete
SA_device.write('*rst')
SA_device.query('*opc?')
# Resume the sweeping
SA_device.write('init:cont ON')
SA_device.write('init:res')
# Measurement variables for the MeasSetup
freq = '2.44GHz'
freq_span = '5MHz'
count = 10
avermode = 'EXP'
search_len = '832us'
SA_device.write('sens:freq:cent {}'.format(freq))
SA_device.write('sens:freq:span {}'.format(freq_span))
# Average
SA_device.write('sens:aver ON')
SA_device.write('sens:mon:aver:tcon {}'.format(avermode))
SA_device.write('sens:aver:count {}'.format(count))
The SCPI log of Keysight VSA
This happens because I was trying to use SCPI commands for MXA N9020A instrument on 89600 VSA software running on the computer. This is solved by downloading Keysight Command Expert and use the commands that are tailored for different instruments and also using SCPI reference guide here.

VIDIOC_G_STD: failed: Inappropriate ioctl doer device

I attempted the command below:
v4l2-ctl -d 0 --get-standard
But I get the error
VIDIOC_G_STD: failed: Inappropriate ioctl for device
The below command however works completely fine.
v4l2-ctl -d 0 --all
Any help would be appreciated. In my program when resetting the controls for my camera I am getting the Inappropriate ioctl for device.
v4l2-compliance
The above command fails four tests. I showed some of the failed tests below. I definitely need VIDIOC_QUERYCTRL to work.
Driver name : uvcvideo
Card type : HD Web Camera
Bus info : usb-3610000.xhci-4.1
Driver version: 4.9.140
Capabilities : 0x84200001
Video Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format
Compliance test for device /dev/video0 (not using libv4l2):
Test input 0:
Control ioctls:
fail: v4l2-test-controls.cpp(202): invalid query_ext_ctrl return code (5)
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: FAIL
fail: v4l2-test-controls.cpp(312): invalid queryctrl return code (5)
test VIDIOC_QUERYCTRL: FAIL
V4L2_CAP_TIMEPERFRAME
fail: v4l2-test-formats.cpp(1140): node->has_frmintervals && !cap->capability
test VIDIOC_G/S_PARM: FAIL
test VIDIOC_G_FMT: FAIL
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
fail: v4l2-test-buffers.cpp(574): VIDIOC_EXPBUF is supported, but the V4L2_MEMORY_MMAP support is missing, probably due to earlier failing format tests.
Test input 0:

How to get connected USB device list from windows by using python or cmd

I need to get connected USB device list from windows by using python or cmd.
for python i'm trying this.
import win32com.client
def get_usb_device():
try:
usb_list = []
wmi = win32com.client.GetObject("winmgmts:")
for usb in wmi.InstancesOf("Win32_USBHub"):
print(usb.DeviceID)
print(usb.description)
usb_list.append(usb.description)
print(usb_list)
return usb_list
except Exception as error:
print('error', error)
get_usb_device()
as a result i get this:
['USB Root Hub (USB 3.0)', 'USB Composite Device', 'USB Composite Device']
but i don't get a meaning full name.
and for cmd i'm trying this also:
wmic path CIM_LogicalDevice where "Description like 'USB%'" get /value
and again i don't get any meaning full name for connected usb devices.
when I'm connect a mouse, keyboard, pen drive or printer through the usb i want this kind of name. like 'a4tech mouse' or even if i get 'mouse' only that's also be fine. This type of name appears in the device section of the settings of windows 10. but i get 'USB Root Hub (USB 3.0)', 'USB Composite Device', which means nothing actually.
Is it possible with python?
If any one know this answer please help. Its very important for me.
Not sure if it's what you are looking for, but using Python 3 on Windows 10 with pywin32, you could use this to get all your drive letters and types:
import os
import win32api
import win32file
os.system("cls")
drive_types = {
win32file.DRIVE_UNKNOWN : "Unknown\nDrive type can't be determined.",
win32file.DRIVE_REMOVABLE : "Removable\nDrive has removable media. This includes all floppy drives and many other varieties of storage devices.",
win32file.DRIVE_FIXED : "Fixed\nDrive has fixed (nonremovable) media. This includes all hard drives, including hard drives that are removable.",
win32file.DRIVE_REMOTE : "Remote\nNetwork drives. This includes drives shared anywhere on a network.",
win32file.DRIVE_CDROM : "CDROM\nDrive is a CD-ROM. No distinction is made between read-only and read/write CD-ROM drives.",
win32file.DRIVE_RAMDISK : "RAMDisk\nDrive is a block of random access memory (RAM) on the local computer that behaves like a disk drive.",
win32file.DRIVE_NO_ROOT_DIR : "The root directory does not exist."
}
drives = win32api.GetLogicalDriveStrings().split('\x00')[:-1]
for device in drives:
type = win32file.GetDriveType(device)
print("Drive: %s" % device)
print(drive_types[type])
print("-"*72)
os.system('pause')
Your USB devices have the type win32file.DRIVE_REMOVABLE - so this is what you're looking for. Instead of printing all drives and types, you could insert an if condition to only process such removable devices.
Please note: SD-Cards and other removable storage media has the same drive type.
HTH!
Update, 13. July 2020:
To get further Inforrmations about connected Devices, have a look at the WMI Module for Python.
Check this example outputs, they list different informations about devices, including Manufacturer Descriptions, Serial Numbers and so on:
import wmi
c = wmi.WMI()
for item in c.Win32_PhysicalMedia():
print(item)
for drive in c.Win32_DiskDrive():
print(drive)
for disk in c.Win32_LogicalDisk():
print(disk)
os.system('pause')
To access a specific Information listed in this output, use the displayed Terms for direct access. Example:
for disk in c.Win32_LogicalDisk():
print(disk.Name)
when I'm connect a mouse, keyboard, pen drive or printer through the usb i want this kind of name...
It's called "Friendly Name" and you can use:
import subprocess, json
out = subprocess.getoutput("PowerShell -Command \"& {Get-PnpDevice | Select-Object Status,Class,FriendlyName,InstanceId | ConvertTo-Json}\"")
j = json.loads(out)
for dev in j:
print(dev['Status'], dev['Class'], dev['FriendlyName'], dev['InstanceId'] )
Unknown HIDClass HID-compliant system controller HID\VID_046D&PID_C52B&MI_01&COL03\9&232FD3F1&0&0002
OK DiskDrive WD My Passport 0827 USB Device USBSTOR\DISK&VEN_WD&PROD_MY_PASSPORT_0827&REV_1012\575836314142354559545058&0
...

How to make from mpts udp (a pack of programs with id's) to video-stream with one program id (spts)

I trying to get the link of stream with one channel (not a pack of channels which gives me mpt stream) to paste it string to opencv VideoCapure. Because if I paste it mpt stream link to VideoCapture it give me the random (one of this channels in pack) program.
For example I have link : udp://#255.1.1.7:1234 and it have pack of programs (nikelodion, blablatv, brazzerstv and etc.).
I can visualize necessary channel via vlc like that:
vlc -vv -d udp://#225.1.1.7:1234 --program=24919
Where --program - it's id of necessary channel.
I can make stream via vlc:
vlc --ttl 12 udp://#225.1.1.7:1234 --program=24919 --sout '#std{access=udp, mux=ts, dst=192.168.40.73:1235}'
but it's giving me errors. I can videocapture that stream via opencv. But it also random channels on it
Errors that happened when I ran the second command:
ts demux error: libdvbpsi error (EIT decoder): 'last_section_number' differs whereas no discontinuity has occured
main decoder error: buffer deadlock prevented

Categories

Resources