Categories
Statistics
Flag Counter
Since 08.08.2014
Counts only, if "DNT = disabled".

Your IP is 44.211.31.134
ec2-44-211-31-134.compute-1.
Info
Valid HTML 4.01 Transitional Creative Commons Lizenzvertrag
rss
เราจะทำแบบวิศวกรผู้ยิ่งใหญ่
We love the King
24. July 2024
Your valuable opinion :
3 stars

Avg. 3.00 from 4 votes.



PyLab-Basics.php    14618 Bytes    04-08-2022 11:58:11


Python Lab Experiments - Basics


Minimum Equipment List







✈ Software




At the time of writing these lines, Windows® Version 10 is actual. We use Python 3.9.7, Anaconda 3, Spyder 5.1.5 with the PySerial Library installed. PySerial is a Python API module which is used to read and write serial data to Arduino or any other Microcontroller. The Arduino IDE (1.8.13) should also be installed.




✈ Hardware




On the Hardware side, all devices are based on an Arduino / Genuino.
You mayst want to use a USB hub in order to connect several devices. For some experiments, a galvanic isolator for the USB connection is mandatory. You can find such gear in the bay or at Ali. Sometimes, the Amazons may also be helpful.




✈ Find the Arduino - Hello Arduino :-)




If an Arduino is connected to a Computer running Windows 10, the OS stores the information about the used COM port. If the same device is connected at a later time, the same port is used. Therefore it deems useful to create a sticker, noting this magic number on the device.

There are two easy methods in finding that number :


#1 Using the Arduino IDE
#2 Using the Windows Device Manager


RE-open the Serial Monitor to verify that the communication with the device is working. Sometimes a *IDN? command mayst be used to force an answer.





The third method uses a little Python-Script. We call it "Arduino COM-Scanner" and yes, it was strongly inspired by the I2C Scanner :-)


# -*- coding: utf-8 -*-
"""
Created on Thu Jul 21 07:11:19 2022

@author: r_57, cp-9

ETH Zürich, Quantumoptics 2022
"""


import serial
import time

minport = 0
maxport = 99
COM = 'COM'
mod = 'mod'
count = 0

def readempty(x):
        time.sleep(1)
        x = b'ava'
        while x != b'':
            x = porttest.readline()
            #print(x)
        porttest.readline()

def write_read(x):
    porttest.write(x.encode('utf-8'))
    time.sleep(0.05)
    data = []
    line = (porttest.readline())
    while len(line) > 0:
        data.append(line)
        line = porttest.readline()
        line = line.decode('utf-8')
    return data


while minport <= maxport:
    minport += 1
    try:
        porti = COM + str(minport)
        porttest = serial.Serial(port = porti, baudrate=115200, timeout=.1)  
        time.sleep(1)
        
        
        IDN = str(write_read('*IDN?'))       #who is answering
                  
        while ((IDN == '') or (IDN == '[]')):
            IDN = str(write_read('*IDN?'))
            time.sleep(0.2)
            count += 1
            
            if count >= 20:                     #ask 10 times
                IDN = 'a'                       #break while Loop
            
            count = 0
                
                
        device = int(IDN.find(mod)) + 3         #remove everything behind name
        IDN = IDN[3:device]
        
        last = IDN.rfind(' ')          #remove everithing in front of the name
        last = last + 1
        IDN = IDN[last:]
                
        
        print('Looks like there is something on ' + porti)
        
        if IDN == '':
            print('???')
        else:
            print(IDN)
        porttest.close()
        time.sleep(1)
        
    except:
        time.sleep(0.1)


The Result could look similiar to the one below :

Python COM-Scanner




✈ Additional Tools : The Resistor Box




This is a Connectorized Box containing 5 High Power (at least 5W) wirewound resistors. They are 1% in tolerance and specified for Military Use. The closest match to Student Use. They are used mainly for current limiting.


The Resistor Box


 # Component
 1 Aluminum profile housing, height 34 mm, width 65 mm, length 100 mm, (30257.1)
 1 Frontpanel, 0.5 mm, FR4. See Gerber File below
 10 Socket, nickel-plated brass, Ø 4 mm, (30101.13)
 1 HS1010RF - Wirewound Resistor 10W, 10Ω, 1%, Arcol
 1 HS1033RF - Wirewound Resistor 10W, 33Ω, 1%, Arcol
 1 RH010100R0FE05 - Wirewound Resistor 10W, 100Ω, 1%, Vishay
 1 RH005330R0FE05 - Wirewound Resistor 5W, 330Ω, 1%, Vishay
 1 RH0051K000FE05 - Wirewound Resistor 5W, 1kΩ, 1%, Vishay






✈ Additional Tools : The Test Fixture




This is a Connectorized Box containing two Toggle Clamps. This allows for a fast and reliable exchange of the components to be measured. They are pressed down on the gold plated pcb with an adjusteable force. Very repeatable.


The Test Fixture


 # Component
 1 Aluminum profile housing, height 34 mm, width 65 mm, length 100 mm, (30257.1)
 1 Frontpanel, 0.5 mm, FR4. See Gerber File below
 2 Socket, nickel-plated brass, Ø 4 mm, (30101.13)
 2 Toggle Clamp - Small Flip-down Style, from Adafruit (PRODUCT ID: 2459)






✈ Additional Tools : The Breakout Box




This is just a Connectorized Box. It shall avoid a confusing Setup. The traces on the pcb are 9 mm in width. They should be able to handle many overload conditions.


The Breakout Box


 # Component
 1 Aluminum profile housing, height 34 mm, width 65 mm, length 100 mm, (30257.1)
 1 Frontpanel, 0.5 mm, FR4. See Gerber File below
 10 Socket, nickel-plated brass, Ø 4 mm, (30101.13)






✈ Share your thoughts



The webmaster does not read these comments regularely. Urgent questions should be send via email. Ads or links to completely uncorrelated things will be removed.


Your Browser says that you allow tracking. Mayst we suggest that you check that DNT thing ?

 
t1 = 6586 d

t2 = 210 ms

★ ★ ★  Copyright © 2006 - 2024 by changpuak.ch  ★ ★ ★

Impressum