Changeset 771 in ETALON


Ignore:
Timestamp:
May 25, 2018, 3:17:53 PM (6 years ago)
Author:
moutardier
Message:

modification des programmes afin de faire les graphiques

Location:
BPM
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • BPM/initialise_motors.py

    r766 r771  
    88from bpm_constants import *
    99from scope_function import *
     10import numpy as np
     11import matplotlib.pyplot as plt
     12
    1013
    1114VERBOSE_DEFAULT=0
     
    243246
    244247def horizontal_aquisition(begin,end,pas,fichier):
    245         for i in range(begin, end+1,pas):
    246                 move_motor_absolute(1,5000,i)
    247                 while motor_get(1, 'status') != 'READY':
    248                         time.sleep(1)
    249                 time.sleep(1)
    250                 read_scope_and_write(i, fichier)
    251         time.sleep(1)
    252         move_motor_absolute(1,5000,begin)
     248    L = [[],[],[],[],[]]
     249    for i in range(begin, end+1,pas):
     250        move_motor_absolute(1,5000,i)
    253251        while motor_get(1, 'status') != 'READY':
    254252                time.sleep(1)
    255253        time.sleep(1)
    256         motor_disable(1)
    257 
    258 
    259 
    260 
    261 
    262 
    263 
    264 
    265 
    266 
    267 
    268 
    269 
    270 
    271 
    272 
    273 
    274 
    275 
     254        l = read_scope_and_write(i, fichier)
     255        for i in range(5):
     256            L[i].append(l[i])
     257    time.sleep(1)
     258    move_motor_absolute(1,5000,begin)
     259    while motor_get(1, 'status') != 'READY':
     260        time.sleep(1)
     261    time.sleep(1)
     262    motor_disable(1)
     263    for i in range(4):
     264         plt.plot(L[0],L[i+1])
     265    plt.show()
    276266
    277267
  • BPM/motor_control.py

    r770 r771  
    44from initialise_motors import *
    55from scope_function import *
     6import numpy as np
    67import matplotlib.pyplot as plt
    78
     
    910# moteur 2 -> verticale
    1011
    11 #motor_enable(1)
     12motor_enable(1)
    1213
    1314#controller_hello()
     
    1516#time.sleep(1)
    1617#move_motor_relative(1,1000,1000)
    17 
    1818#urllib.urlretrieve('http://10.0.1.112/crt_print.png','../oscillo_17-05-2018_voltage5V_freq1MHz_signal_carre/test2.png')
    19 
    2019#if not os.path.exists(repertoire):
    2120#os.makedirs('./test')    cree repertoir
     
    2423
    2524
    26 # creation graphique
     25#                                 creation graphique
    2726
    28 A = loadtxt('donnees.dat')
     27
     28turn_on()
     29fichier = open("test.txt", "w")
     30horizontal_aquisition(0,2,1,fichier)
     31fichier.close()
     32#turn_off()
     33
     34"""
     35fichier = open("24-05-2018_aquisition_from_0_to_400000_step_of_1000.txt", "r")
     36A = fichier.read()
     37
    2938X = []
    3039Y1 = []
     
    3241Y3 = []
    3342Y4 = []
     43a = ""
     44l = 0
    3445
    35 for i in range(A):
    36     if (i%5) == 0:
    37         X.append(A[i])
    38     elif (i%5) == 1:
    39         Y1.append(A[i])
    40     elif (i%5) == 2:
    41         Y2.append(A[i])
    42     elif (i%5) == 3:
    43         Y3.append(A[i])
     46
     47for i in A:
     48    if (i == "\n") :
     49         if l == 0:
     50             X.append(a)
     51             
     52             l += 1
     53         elif l == 1:
     54             Y1.append(a)
     55             #print(a)
     56             l += 1
     57         elif l == 2:
     58             Y2.append(a)
     59             l += 1
     60         elif l == 3:
     61             Y3.append(a)
     62             l += 1
     63         else:
     64             Y4.append(a)
     65             l = 0
     66         a = ""
    4467    else:
    45         Y4.append(A[i])
     68        a += i
     69
     70def float_list(l):
     71    L = []
     72    for i in l:
     73        L.append(float(i))
     74    return(L)
     75   
     76X = float_list(X)
     77Y1 = float_list(Y1)
     78Y2 = float_list(Y2)
     79Y3 = float_list(Y3)
     80Y4 = float_list(Y4)
    4681
    4782plt.plot(X,Y1)
     83plt.plot(X,Y2)
     84plt.plot(X,Y3)
     85plt.plot(X,Y4)
    4886plt.show()
    4987
    50 
    51 """
    52 turn_on()
    53 fichier = open("24-05-2018_aquisition_from_0_to_400000_step_of_1000.txt", "w")
    54 horizontal_aquisition(0,400000,1000,fichier)
    55 fichier.close()
    56 turn_off()
     88#fichier.close()
    5789"""
    5890
  • BPM/scope_function.py

    r766 r771  
    4848
    4949def turn_on():
    50         scpi_command('CHAN1:STAT ON \nCHAN1:STAT?')
    51         scpi_command('CHAN2:STAT ON \nCHAN2:STAT?')
    52         scpi_command('CHAN3:STAT ON \nCHAN1:STAT?')
    53         scpi_command('CHAN4:STAT ON \nCHAN2:STAT?')
    54         scpi_command('CURS1:STAT ON \nCURS1:STAT?')
     50    scpi_command('CHAN1:STAT ON \nCHAN1:STAT?')
     51    scpi_command('CHAN2:STAT ON \nCHAN2:STAT?')
     52    scpi_command('CHAN3:STAT ON \nCHAN1:STAT?')
     53    scpi_command('CHAN4:STAT ON \nCHAN2:STAT?')
     54    scpi_command('CURS1:STAT ON \nCURS1:STAT?')
    5555
    5656def turn_off():
    57         scpi_command('CURS1:STAT OFF \nCURS1:STAT?')
    58         scpi_command('CHAN1:STAT OFF \nCHAN1:STAT?')
    59         scpi_command('CHAN2:STAT OFF \nCHAN2:STAT?')
    60         scpi_command('CHAN3:STAT OFF \nCHAN2:STAT?')
    61         scpi_command('CHAN4:STAT OFF \nCHAN2:STAT?')
     57    scpi_command('CURS1:STAT OFF \nCURS1:STAT?')
     58    scpi_command('CHAN1:STAT OFF \nCHAN1:STAT?')
     59    scpi_command('CHAN2:STAT OFF \nCHAN2:STAT?')
     60    scpi_command('CHAN3:STAT OFF \nCHAN2:STAT?')
     61    scpi_command('CHAN4:STAT OFF \nCHAN2:STAT?')
    6262
    63 
     63def suppress_alignea(l):
     64    L = ''
     65    for i in l:
     66        if not(i == '\n'):
     67            L += i
     68    return(L)
     69   
    6470def read_scope_and_write(position, fichier):
    65         fichier.write(str(position)+'\n')       
    66         for i in range(4):
    67                 scpi_command('CURS1:SOUR CH'+str(i+1)+' \n CURS1:SOUR?')
    68                 valeur = scpi_query('CURS1:FUNC UPE \n CURS:RES?')
    69                 fichier.write(valeur)
     71    fichier.write(str(position)+' ')
     72    L = [position]
     73    for i in range(4):
     74        scpi_command('CURS1:SOUR CH'+str(i+1)+' \n CURS1:SOUR?')
     75        valeur = scpi_query('CURS1:FUNC UPE \n CURS:RES?')
     76        valeur = suppress_alignea(valeur)
     77        L.append(float(valeur))
     78        fichier.write(valeur+' ')
     79    fichier.write('\n')
     80    return(L)
     81       
    7082
    7183
    7284
    7385
    74 
Note: See TracChangeset for help on using the changeset viewer.