PacMaster 2.0(r200)
Controls digital PAC measurements and collects the results

PacUSBDev.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2008-2010 by Matthias Nagl                              *
00003  *   mnagl@uni-goettingen.de                                               *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #ifndef PACUSBDEV_H
00022 #define PACUSBDEV_H
00023 
00024 #include <QObject>
00025 #include <QByteArray>
00026 #include "iowkit.h"
00027 #include <math.h>
00028 
00034 class PacUSBDev : public QObject
00035 {
00036     Q_OBJECT
00037   public:
00038     PacUSBDev(QObject *parent = 0);
00039     ~PacUSBDev();
00040     static quint16 voltageToDACValue(const qreal voltage) {return qRound(voltage/1000.0/maxdacvoltage*(pow(2.0,dacbits)-1));};
00041     static qreal dacValueToVoltage(const quint16 dacval) {return qreal(dacval)/(pow(2.0,dacbits)-1)*maxdacvoltage*1000.0;};
00042     static qreal minHV() { return 0.0; };
00043     static qreal maxHV() { return maxdacvoltage * multiplicator; };
00044     static qreal stepSize() { return (maxHV() - minHV()) / (pow(2.0, dacbits) - 1.0); };
00045 
00046   public slots:
00050     void sendSyncSignal();
00054     void setDACOutput(const quint8 channel, const qreal voltage);
00055     void highVoltageOn(bool on = true);
00056     void highVoltageOff();
00057 
00058   private slots:
00059     void stopSyncSignal();
00060     void updateIowPins(); 
00061 
00062   private:
00066     bool iowconnect();
00070     void iowdisconnect();
00074     bool initDev();
00078     bool writeToDAC(const QByteArray data); 
00079 
00082     quint8 readI2CAck();
00083 
00084     IOWKIT_HANDLE iowarrior;
00085     bool connected;
00086     bool connecting;
00087     QByteArray iowPins; // Byte 0 = Port0, Byte1 = Port1 ...
00088     QList<quint16> dacValues; 
00089     QList<bool> dacEnabled;   
00090 
00091     static const bool syncOnRisingEdge = true;
00092     static const char dacI2CWriteAddress = 0xA8; // 0xA8 for AD5390
00093     static const quint8 dacbits = 14;
00094     static const qreal maxdacvoltage = 2.5;
00095     static const qreal multiplicator = 1000.0;
00096     static const quint8 numchannels = 8;
00097 };
00098 
00099 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines