hw functions for the SOLID slow control
Dependents: S_SCTRL_e_test SPItest sscm
DEIMOS32.h@14:ee02872b282b, 2014-12-07 (annotated)
- Committer:
- wbeaumont
- Date:
- Sun Dec 07 22:38:07 2014 +0000
- Revision:
- 14:ee02872b282b
- Parent:
- 11:0416cf017b7a
- Child:
- 15:2cf8211a3870
added Deimos32 class to set bias voltage
Who changed what in which revision?
User | Revision | Line number | New 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 | 14:ee02872b282b | 9 | |
wbeaumont | 14:ee02872b282b | 10 | */ |
wbeaumont | 14:ee02872b282b | 11 | |
wbeaumont | 14:ee02872b282b | 12 | |
wbeaumont | 14:ee02872b282b | 13 | #include "AD5384.h" |
wbeaumont | 11:0416cf017b7a | 14 | #define DEIMOSHDRVER 1.00 |
wbeaumont | 11:0416cf017b7a | 15 | |
wbeaumont | 11:0416cf017b7a | 16 | // BIAS channel nr in the layout so have to subtract 1 to control the channel |
wbeaumont | 11:0416cf017b7a | 17 | #define DACBIASCH 39 |
wbeaumont | 11:0416cf017b7a | 18 | // CAL 1 DAC CH |
wbeaumont | 11:0416cf017b7a | 19 | #define DACCAL1CH 33 |
wbeaumont | 11:0416cf017b7a | 20 | #define DACCAL2CH 34 |
wbeaumont | 11:0416cf017b7a | 21 | #define DACCAL3CH 35 |
wbeaumont | 11:0416cf017b7a | 22 | #define DACCAL4CH 36 |
wbeaumont | 11:0416cf017b7a | 23 | |
wbeaumont | 14:ee02872b282b | 24 | #define HVmin 60 |
wbeaumont | 14:ee02872b282b | 25 | #define DVmax 4.5 // max volt out of the DAC |
wbeaumont | 14:ee02872b282b | 26 | class Deimos32 { |
wbeaumont | 14:ee02872b282b | 27 | float HVnom; |
wbeaumont | 14:ee02872b282b | 28 | u32 serialnr; |
wbeaumont | 14:ee02872b282b | 29 | u8 con; |
wbeaumont | 14:ee02872b282b | 30 | AD5384* dac; // |
wbeaumont | 14:ee02872b282b | 31 | public: |
wbeaumont | 14:ee02872b282b | 32 | // init |
wbeaumont | 14:ee02872b282b | 33 | // volt the value of the HV source |
wbeaumont | 14:ee02872b282b | 34 | // connectornr : the connector the DEIMOS is conneted to |
wbeaumont | 14:ee02872b282b | 35 | // dacdev to witch DAC device the channel is connected |
wbeaumont | 14:ee02872b282b | 36 | Deimos32( float volt, u8 connectornr,AD5384* dacdev ){ |
wbeaumont | 14:ee02872b282b | 37 | serialnr=2000; con=connectornr; |
wbeaumont | 14:ee02872b282b | 38 | HVnom=volt; // can not be initialized now because need two parameters for the command |
wbeaumont | 14:ee02872b282b | 39 | } |
wbeaumont | 14:ee02872b282b | 40 | |
wbeaumont | 14:ee02872b282b | 41 | float setHV(float volt) { |
wbeaumont | 14:ee02872b282b | 42 | if (HVnom < HVmin ) return -2; |
wbeaumont | 14:ee02872b282b | 43 | float dv=HVnom-volt; |
wbeaumont | 14:ee02872b282b | 44 | if (dv > DVmax || dv < 0 ) return -3; |
wbeaumont | 14:ee02872b282b | 45 | dac->set_volt(DACBIASCH , dv); |
wbeaumont | 14:ee02872b282b | 46 | return 0; |
wbeaumont | 14:ee02872b282b | 47 | } |
wbeaumont | 14:ee02872b282b | 48 | float getHv(){ |
wbeaumont | 14:ee02872b282b | 49 | if (HVnom < HVmin ) return -2; |
wbeaumont | 14:ee02872b282b | 50 | return HVnom - dac->get_volt(DACBIASCH); |
wbeaumont | 14:ee02872b282b | 51 | } |
wbeaumont | 14:ee02872b282b | 52 | |
wbeaumont | 14:ee02872b282b | 53 | }; |
wbeaumont | 11:0416cf017b7a | 54 | #endif |