00001 // PCI-3340蜈・蜃コ蜉帙け繝ゥ繧ケ 00002 // 2011/02/09 Yuki YOKOKURA 00003 // 00004 // Interface遉セ陬スPCI-3340縺ョ縺溘a縺ョ蜈・蜃コ蜉帶ゥ溯�ス繧呈署萓帙@縺セ縺吶�� 00005 // 00006 // Copyright (C) 2011 Yuki YOKOKURA 00007 // This program is free software; 00008 // you can redistribute it and/or modify it under the terms of the GNU General Public License 00009 // as published by the Free Software Foundation; either version 3 of the License, or any later version. 00010 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 00011 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 // See the GNU General Public License for more details <http://www.gnu.org/licenses/>. 00013 // Besides, you can negotiate about other options of licenses instead of GPL. 00014 // If you would like to get other licenses, please contact us<yuki@katsura.sd.keio.ac.jp>. 00015 00016 #ifndef PCI3340 00017 #define PCI3340 00018 00019 #include <sys/io.h> 00020 #include <unistd.h> 00021 #include <algorithm> 00022 00023 namespace ARCS { // ARCS蜷榊燕遨コ髢� 00024 class DAC3340 { 00025 private: 00026 static const unsigned int MAX_CH=8; // 繝√Ε繝阪Ν譛�螟ァ蛟、 00027 unsigned int BaseAddr0; // 蜈磯�ュ繧「繝峨Ξ繧ケ0 00028 double Imax[MAX_CH]; // 譛�螟ァ髮サ豬� 00029 double VperA[MAX_CH]; // 繧オ繝シ繝懊い繝ウ繝鈴崕蝨ァ髮サ豬∵鋤邂励ご繧、繝ウ 00030 00031 void Settings(void); // DAC縺ョ險ュ螳壹r陦後≧髢「謨ー 00032 void Output(unsigned short DACdata[MAX_CH]); // DAC縺九i謖�螳壹@縺滄崕蝨ァ繧貞�コ蜉帙☆繧矩未謨ー 00033 void Zero(void); // DAC縺ョ蜃コ蜉幃崕蝨ァ繧� 0[V] 縺ォ縺吶k髢「謨ー 00034 unsigned short IIbyteHi(unsigned short in); // 2byte繝�繝シ繧ソ縺ョ荳贋ス�1byte繧呈歓蜃コ縺励※蜃コ蜉� 00035 unsigned short IIbyteLo(unsigned short in); // 2byte繝�繝シ繧ソ縺ョ荳倶ス�1byte繧呈歓蜃コ縺励※蜃コ蜉� 00036 double CurrentLimitter(double Iref, unsigned int ch); // 髮サ豬√Μ繝溘ャ繧ソ 00037 double CurrentToVolt(double Iref, unsigned int ch); // 髮サ豬∵欠莉、蛟、[A]縺九iDAC蜃コ蜉幃崕蝨ァ[V]縺ォ螟画鋤 00038 unsigned short VoltToDacData(double Vdac); // DAC蜃コ蜉幃崕蝨ァ[V]縺九iDAC縺ョ螳滄圀縺ョ謨エ謨ー蛟、縺ォ螟画鋤縺吶k 00039 00040 public: 00041 // 繧ウ繝ウ繧ケ繝医Λ繧ッ繧ソ(DAC蛻晄悄蛹厄シ�險ュ螳�) 00042 DAC3340(unsigned int Base0, const double MaxCur[MAX_CH], const double VoltPerAmp[MAX_CH]); 00043 ~DAC3340(); // 繝�繧ケ繝医Λ繧ッ繧ソ(DAC邨ゆコ�蜃ヲ逅�) 00044 void PutCurrentCmd(volatile double Iref[MAX_CH]); // 髮サ豬∵欠莉、蛟、繧奪AC縺九i蜃コ蜉� 00045 }; 00046 } 00047 00048 #endif 00049 00050 00051