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

216.73.217.6
216.73.217.6
Info
Valid HTML 4.01 Transitional Creative Commons Lizenzvertrag
rss
เราจะทำแบบวิศวกรผู้ยิ่งใหญ่
We love the King
7. July 2026
YOUR OPINION     •••
average: 0.001,   n: 0

Rating




When using this form, your ip is stored in order to avoid multiple voting on the same website. That's it.
PyLab-Cookie-01-Ningmod-Sweep.php    5680 Bytes    04-03-2025 19:13:23


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.




 
t1 = 7299 d

t2 = 439 ms

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

Impressum