hw functions for the SOLID slow control

Dependents:   S_SCTRL_e_test SPItest sscm

Committer:
wbeaumont
Date:
Fri Oct 23 11:22:52 2015 +0000
Revision:
16:6bbb6bb0678a
Parent:
15:2cf8211a3870
production version archiving

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wbeaumont 11:0416cf017b7a 1 #ifndef DEIMOS32_H
wbeaumont 11:0416cf017b7a 2 #define DEIMOS32_H
wbeaumont 11:0416cf017b7a 3
wbeaumont 14:ee02872b282b 4 /*
wbeaumont 14:ee02872b282b 5 * class related to DEIMOS specific operationt
wbeaumont 14:ee02872b282b 6
wbeaumont 14:ee02872b282b 7 * v0.10 initial development
wbeaumont 14:ee02872b282b 8 * v1.00 added class, only setHV
wbeaumont 15:2cf8211a3870 9 * v1.04 forget to assign DAC channel corrected.
wbeaumont 16:6bbb6bb0678a 10 *
wbeaumont 16:6bbb6bb0678a 11 * (C) Wim Beaumont Univeristeit Antwerpen 2014 , 2015
wbeaumont 14:ee02872b282b 12 */
wbeaumont 14:ee02872b282b 13
wbeaumont 14:ee02872b282b 14
wbeaumont 14:ee02872b282b 15 #include "AD5384.h"
wbeaumont 15:2cf8211a3870 16 #define DEIMOSHDRVER 1.06
wbeaumont 11:0416cf017b7a 17
wbeaumont 11:0416cf017b7a 18 // BIAS channel nr in the layout so have to subtract 1 to control the channel
wbeaumont 11:0416cf017b7a 19 #define DACBIASCH 39
wbeaumont 11:0416cf017b7a 20 // CAL 1 DAC CH
wbeaumont 11:0416cf017b7a 21 #define DACCAL1CH 33
wbeaumont 11:0416cf017b7a 22 #define DACCAL2CH 34
wbeaumont 11:0416cf017b7a 23 #define DACCAL3CH 35
wbeaumont 11:0416cf017b7a 24 #define DACCAL4CH 36
wbeaumont 11:0416cf017b7a 25
wbeaumont 14:ee02872b282b 26 #define HVmin 60
wbeaumont 14:ee02872b282b 27 #define DVmax 4.5 // max volt out of the DAC
wbeaumont 14:ee02872b282b 28 class Deimos32 {
wbeaumont 14:ee02872b282b 29 float HVnom;
wbeaumont 14:ee02872b282b 30 u32 serialnr;
wbeaumont 14:ee02872b282b 31 u8 con;
wbeaumont 14:ee02872b282b 32 AD5384* dac; //
wbeaumont 14:ee02872b282b 33 public:
wbeaumont 14:ee02872b282b 34 // init
wbeaumont 15:2cf8211a3870 35 // volt the max value of the HV source
wbeaumont 15:2cf8211a3870 36 // connectornr : the connector the DEIMOS is connected to
wbeaumont 14:ee02872b282b 37 // dacdev to witch DAC device the channel is connected
wbeaumont 14:ee02872b282b 38 Deimos32( float volt, u8 connectornr,AD5384* dacdev ){
wbeaumont 15:2cf8211a3870 39 serialnr=2000; con=connectornr;// real connector nr
wbeaumont 15:2cf8211a3870 40 HVnom=volt;
wbeaumont 15:2cf8211a3870 41 dac= dacdev;
wbeaumont 14:ee02872b282b 42 }
wbeaumont 14:ee02872b282b 43
wbeaumont 15:2cf8211a3870 44
wbeaumont 15:2cf8211a3870 45 float setHV(float volt ,u16& dacvalue ) {
wbeaumont 15:2cf8211a3870 46 if (HVnom < HVmin ) return -22;
wbeaumont 14:ee02872b282b 47 float dv=HVnom-volt;
wbeaumont 15:2cf8211a3870 48 if (dv > DVmax || dv < 0 ) return -23;
wbeaumont 15:2cf8211a3870 49 dacvalue=dac->set_volt(DACBIASCH , dv);
wbeaumont 14:ee02872b282b 50 return 0;
wbeaumont 14:ee02872b282b 51 }
wbeaumont 14:ee02872b282b 52 float getHv(){
wbeaumont 15:2cf8211a3870 53 if (HVnom < HVmin ) return -22;
wbeaumont 15:2cf8211a3870 54 float act_hv=HVnom - dac->get_volt(DACBIASCH);
wbeaumont 15:2cf8211a3870 55 return act_hv;
wbeaumont 14:ee02872b282b 56 }
wbeaumont 15:2cf8211a3870 57 float getHvNom(){return HVnom;}
wbeaumont 14:ee02872b282b 58 };
wbeaumont 11:0416cf017b7a 59 #endif