#!/usr/bin/python # a short script to output low frequency sine wave to EPICS channels import epics import math import time import os import random a = 0 #define channel 1 & 2 amplitudes channel1 = 0 ampl1 = 1 freq1 = 0.054321 # set up channel 3 for sidebands freq3 = 0.012345 freqSB = 0.0012345 MD = 0.05 tau = math.acos(0)*4 channel2 = 0 # set up channel 4 for random numbers channel4 = 0 random.seed() rndMean = 0.0 rndSigma = 1.0 # remaining frequencies and amplitudes ampl2 = 2.54 freq5 = 0.002371 freq7 = 0.0008765 freq8 = 0.00012345 while a < 10: a = a + 0 time.sleep(0.2) # single frequency channel1 = ampl1*math.sin(tau*freq1*time.time()) channel5 = ampl1*math.sin(tau*freq5*time.time()) channel6 = ampl1*math.sin(tau*freq5*time.time()+tau/4) channel7 = ampl1*math.sin(tau*freq7*time.time()) channel8 = ampl2*math.sin(tau*freq8*time.time()) + random.normalvariate(rndMean, rndSigma) # mutliple frequencies channel2 = ampl1*math.sin(tau*freq1*time.time()) channel2 = channel2 + 10*ampl1*math.sin(tau*freq1*time.time()/10.0) channel2 = channel2 + 100*ampl1*math.sin(tau*freq1*time.time()/100.0) #channel2 = channel2 + 1000*ampl1*math.sin(tau*freq1*time.time()/1000.0) # carrier and sidebands channel3 = ampl1*math.sin(tau*freq3*time.time() + tau*MD*math.sin(tau*freqSB*time.time())) # normal distribution with a mean of 0 and a standard deviation of 1 channel4 = random.normalvariate(rndMean, rndSigma) # send the channels to the EPICS variables epics.caput("C4:TCS-PLAY_CH01", channel1) epics.caput("C4:TCS-PLAY_CH02", channel2) epics.caput("C4:TCS-PLAY_CH03", channel3) epics.caput("C4:TCS-PLAY_CH04", channel4) epics.caput("C4:TCS-PLAY_CH05", channel5) epics.caput("C4:TCS-PLAY_CH06", channel6) epics.caput("C4:TCS-PLAY_CH07", channel7) epics.caput("C4:TCS-PLAY_CH08", channel8) #output = os.system("caput C4:TCS-PLAY_CH01 " + str(channel1) + " > /home/controls/output.txt") #output = os.system("caput C4:TCS-PLAY_CH02 " + str(channel2) + " > /home/controls/output.txt") #output = os.system("caput C4:TCS-PLAY_CH03 " + str(channel3) + " > /home/controls/output.txt") #output = os.system("caput C4:TCS-PLAY_CH04 " + str(channel4) + " > /home/controls/output.txt") #output = os.system("caput C4:TCS-PLAY_CH05 " + str(channel5) + " > /home/controls/output.txt") #output = os.system("caput C4:TCS-PLAY_CH06 " + str(channel6) + " > /home/controls/output.txt") #output = os.system("caput C4:TCS-PLAY_CH07 " + str(channel7) + " > /home/controls/output.txt") #output = os.system("caput C4:TCS-PLAY_CH08 " + str(channel8) + " > /home/controls/output.txt")