Skip to content

Instantly share code, notes, and snippets.

@amarvutha
Last active December 24, 2015 02:19
Show Gist options
  • Save amarvutha/6730277 to your computer and use it in GitHub Desktop.
Save amarvutha/6730277 to your computer and use it in GitHub Desktop.
Controlling the MixNV rf generator
# Controlling the MixNV (Windfreak Technologies) rf synthesizer
# Amar Vutha
# version 1
import serial
import numpy as np
import time
usbPort = "/dev/ttyACM0"
sleepTime = 0.01
class Synth:
def __init__(self,portname):
self.usbStream = serial.Serial(portname,timeout=1)
def status(self):
#time.sleep(sleepTime)
self.usbStream.write("f?")
print "Frequency: ",self.usbStream.readline()[:-2],"MHz"
self.usbStream.write("a?")
print "Amplitude: ",self.usbStream.readline()
def frequency(self,f):
self.usbStream.write("f"+`f`)
time.sleep(sleepTime)
#self.usbStream.write("f?")
#print self.usbStream.readline()[:-2]
def amplitude(self,n):
self.usbStream.write("a"+`n`)
time.sleep(sleepTime)
#self.usbStream.write("a?")
#print self.usbStream.readline()
def scan(self,start,stop,numsteps):
try:
while True:
for f in np.linspace(start,stop,numsteps):
self.frequency(f)
time.sleep(sleepTime)
except KeyboardInterrupt: return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment