Personal tools
You are here: Home Comunità zopemaster's Home Programmazione GPyB peripheral_related_classes

Daniele Paganelli


alias mythsmith

  • Blog
  • Feed RSS
    Iscriviti al diario, con il feed RSS (?)
  • Emopiano
    Imporvvisazioni al pianoforte ed alla tastiera (del computer :)
  • Università
    Documenti redatti per/a/con l'Università
  • Programmazione
    La mia limitata biblioteca personale di script, principalmente in Python.
  • Macropost
    Testi molto lunghi, inadatti per il blog.
  • Segnalibri
    I miei segnalibri direttamente da Firefox... quando mi ricordo di aggiornarli!

Sinapsi

  • AGESCI zona di Modena
    (curato da me, si nota? ;-)
  • Magnatune
    Etichetta discografica online. Musica di alta qualità con licenza CreativeCommons. Anteprime gratuite e complete di qualsiasi album... Attenzione: rischi di non uscirne più fuori!!!
  • Conoscere Linux
    Il Linux User Group di Modena, cui sono associato dalla fondazione.
  • Slack.it
    Wiki di un amico...
  • Punto Informatico
    I miei inutili interventi sulla rivista online più antica d'italia...
  • Oblivion999
    Un gruppo metal
  • Fax via eMail
    Il servizio che utilizzo per inviare e ricevere fax via eMail per lavoro.



Contatti Personali:
  • Jabber: dapa@jabber.org
    Per accedere alla rete Jabber usa Gaim oppure Google Talk
  • Posta: daniele.chioccia.modena1.it
  • OpenWengo: paganoide
  • Perché evito MSN?
 
Document Actions

peripheral_related_classes

by mythsmith last modified 2007-05-18 06:40 PM

This was the first script to test the main gpyb classes, with a rudimental Keithley Model 2000 Voltmeter

'''Peripheral Dependent Classes for specific instruments.'''
from gpyb import CommonGPIB, InterfaceGPIB, PeripheralGPIB, lib, status_tags

import thread
import string
from scipy import gplt
from time import sleep, time

esr_tags={'7':('PON','Power ON. Instrument has been turned off and turned back on since the last time this register has been read'), '6':('URQ','User Request. LOCAL key on the front panel was pressed.'), '5':('CME','Command Error. (ieee syntax error, semantic error, GET inside program message)'), '4':('EXE','Execution Error.'), '3':('DDE','Device-dependent error due to some internal condition.'), '2':('QYE','Query Error. Data red from an empty output queue.'), '1':('','Not used.'), '0':('OPC','Operation Complete. Ready for new commands.')} class ScpiGPIB(PeripheralGPIB): '''Common methods for SCPI devices.''' def disp(self,msg): """Display a one-shot short message (disp max 7 digits)""" ln=len(msg)+17 lib.ibwrt(self.ud,'disp:text:stat 1',16) self.ibsta=lib.ibwrt(self.ud,'disp:text:data "'+msg[:6]+'"',ln) return self.ibsta

def displ(self,msg): """Display a long message by splitting it into <8 pieces. To be started in a new thread! Returns last writing ibsta.""" lib.ibwrt(self.ud,'disp:text:stat 1',16) smsg='' msgs=[] for lettera in msg: smsg=smsg+lettera
if len(smsg)==7: msgs=msgs+[smsg] smsg='' msgs=msgs+[smsg] for smsg in msgs: self.ibsta=lib.ibwrt(self.ud,'disp:text:data "'+smsg+'"',len(smsg)+17) if self.ibsta!=8448: print 'Error sending data to device. Breaking' break sleep(1) self.udisp() return self.ibsta

def udisp(self): '''Disable text display''' self.ibsta=lib.ibwrt(self.ud,'disp:text:stat 0',16) return self.ibsta
def report_esr(self): '''Read 'Event Status Register' from device 'dev' and reports it verbosely. Returns print 'Sending custom commands to EI' for cmd in self.eicm: if cmd!='read': self.fra.wrt(cmd) print 'Sent '+cmd+': status: '+str(self.ei.ibsta) else: red=self.ei.rd() print 'Read command performed on EI bus:\n'+str(red[0]) print 'Status: '+str(self.ei.ibsta) the binary string representation of the ESR number.''' self.esr=int(self.write_read(self,'*esr?')[0].replace('\n','')) s='' while self.esr: s = str(self.esr % 2) + s
self.esr/=2 l=len(s) if l<16: n=16-l
s='0'*n+s
print 'ESR code %s' % s

index=0 for tag in s: if tag=='1': print esr_tags[str(index)][0]+'\t'+esr_tags[str(index)][1] index+=1 if index>=7: break return s
def cycle_read(self,measure,iterations): '''This function iterates one-shot reading of the configured function 'measure' (eg: volt:dc). Returns a list of tuples ('time of reading','reading')''' data=[] self.wrt('conf:'+measure) i=0 itime=time() while i<=iterations: data=data+[(time()-itime,string.atof(self.write_read('read?')[0].replace('\n','')))] i+=1 return data

def cycle_plot(self,measure,iterations): '''As cycle_reads, but also plots the results.''' data=self.cycle_read(measure,iterations) x=[] y=[] for xy in data: x+=[xy[0]] y+=[xy[1]] gplt.plot(x,y) gplt.title('Volt vs time plot') gplt.xtitle('Time (seconds)') gplt.ytitle('Volt, DC') return data

#################################### class k2kV(ScpiGPIB): '''Keithley Model 2000 Voltmeter methods''' def cyvolt(self, iterations): '''Cycle read DC voltage and plots the result''' self.cycle_plot('volt:dc',iterations) ####################################

hosting
Iniziative che sponsorizziamo:
Scopri altri siti scout!
Sito precedente 5o sito precedente Home ScoutRing Lista dei Siti Sito Casuale Sito successivo 5o sito successivo
Informati e protesta contro il DRM!
Powered by Plone, the Open Source Content Management System