Connecting to SMA100A by Rohdes&Schwarz in Python
Instrument Card
This Class Handles Rohdes And Schwarz Sma Signal Generators. Supported Model Is: -Sma100A. Signal quality, speed and flexibility these are the criteria by which signal generators are measured today. The R&S SMA100A perfectly meets these criteria, and thus is a premium-class analog generator that sets standards due to its outstanding characteristics.
Device Specification: here
Manufacturer card: ROHDES&SCHWARZ
Rohde & Schwarz GmbH & Co KG is an international electronics group specializing in the fields of electronic test equipment, broadcast & media, cybersecurity, radiomonitoring and radiolocation, and radiocommunication.
- Headquarters: Munich, Germany
- Yearly Revenue (millions, USD): 2500
- Vendor Website: here
Connect to the SMA100A in Python
Read our guide for turning Python scripts into Flojoy nodes.
PROTOCOLS > SCPI
Here is a Python script that uses Pytango to connect to a SMA100A RF Signal Generator:
import timeimport numpy as npimport PyTango as pt
def my_transfer_handler(args): total_size = args.total_size if args.total_size is not None else "unknown" print(f"Context: '{args.context}{'with opc' if args.opc_sync else ''}', " f"chunk {args.chunk_ix}, " f"transferred {args.transferred_size} bytes, " f"total size {total_size}, " f"direction {'reading' if args.reading else 'writing'}, " f"data '{args.data}'") if args.end_of_transfer: print('End of Transfer') time.sleep(0.1)
# Connect to the SMA100A RF Signal Generatorsmab = pt.DeviceProxy('sma100a/inst1')
# Reset the instrumentsmab.Reset()
pc_file = r'c:\temp\bigFile.bin'instr_file = '/var/user/bigFileInstr.bin'pc_file_back = r'c:\temp\bigFileBack.bin'
# Generate a random file of 20MB sizex1mb = 1024 * 1024with open(pc_file, 'wb') as file: for x in range(20): file.write(np.random.bytes(x1mb))
# Send the file to the instrument with eventssmab.events.on_write_handler = my_transfer_handlersmab.utilities.data_chunk_size = x1mbprint(f'Sending file to the instrument...')smab.utilities.send_file_from_pc_to_instrument(pc_file, instr_file)smab.events.on_write_handler = Noneprint(f'Receiving file from the instrument...')smab.events.on_read_handler = my_transfer_handlersmab.utilities.read_file_from_instrument_to_pc(instr_file, pc_file_back)smab.events.on_read_handler = None
# Close the connection to the instrumentsmab = None
Please note that you need to have PyTango installed in order to run this script.