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

Your IP is 3.15.190.144
ec2-3-15-190-144.us-east-2.c
Info
Valid HTML 4.01 Transitional Creative Commons Lizenzvertrag
rss
เราจะทำแบบวิศวกรผู้ยิ่งใหญ่
We love the King
27. April 2024
Your valuable opinion :
0 stars

Avg. 0 from 0 votes.



PyLab-Cookie-01-Ningmod-Sweep.php    5647 Bytes    16-08-2022 18:43:46


Python Cookies : small Scripts to stay


01 .:. Sweep the Frequency of Ningmod





✈ Short Description




This is a script of my personal archive of useful, educational scripts to link our Arduino based Projects to a Computer using Pyhon (Spyder IDE 5.1.5).

This script lets you sweep the Ningmod from a Start Frequency to a Stop Frequency with a given Pausing Time between the Steps. Minimum Step Size is 1.0 kHz = 0.001 MHz. No warranty for anything. It did work on my machine.




✈ The Code




# -*- coding: utf-8 -*-
"""
Created on Tue Aug 16 11:28:15 2022

Simple Sketch to Sweep from F1 to F2

@author: Changpuak, using elements from r_57 
"""

import serial
import time
 
 
# PLEASE DON'T FORGET TO CHANGE THE NUMBER OF THE COM PORT
Ning = serial.Serial(port='COM89', baudrate=115200, timeout=.9)

time.sleep(5)           # Arduinos reset, wait to start up

FREQ_START = 10.698     # MHz
FREQ_STOP = 10.702      # MHz
FREQ_DELTA = 0.001      # MHz
WAIT = 5                # sec

FREQ = FREQ_START
x = []


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


def EMPTY_NINGMOD(x):
    time.sleep(1)
    x = b'avanti'
    while x != b'':
        x = Ning.readline()
        # print(x)


try:
    print("STARTING SWEEP ...")
    CHAT_NINGMOD('SETA:-20\n')
    EMPTY_NINGMOD(x)
    while FREQ <= FREQ_STOP:
        CHAT_NINGMOD('SETF:'+str(FREQ)+'\n')
        EMPTY_NINGMOD(x)
        print("{:.3f}".format(FREQ)+" MHz")
        time.sleep(WAIT)
        FREQ += FREQ_DELTA


finally:
    Ning.close()
    print("CONNECTION CLOSED.")




✈ 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 = 6498 d

t2 = 582 ms

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

Impressum