S p e z i a l e l e k t r o n i k G m b H
iseg Spezialelektronik GmbH
Email: [email protected]
Phone ++ 49 351 / 26 996 - 0
Bautzner Landstr. 23
http://www.iseg-hv.com
Fax
++ 49 351 / 26 996 - 21
D - 01454 Radeberg / Rossendorf
Germany
9
7. Program example
/**********************************************************************************/
/* vhq.c
*/
/*
example program for iseg vme hv boards
*/
/* mki,
24.1.96
*/
/*
this code was compiled and run on an E6 under OS9
*/
/*
please contact iseg for the source files
*/
/**********************************************************************************/
#include <stdio.h>
#include "vhq.h"
#define base 0xFFFFDD00
int main()
{
ushort
value_s;
ushort
serial;
ushort
imaxa,imaxb,vmaxa,vmaxb;
value_s = *(ushort*) (base+MOD_ID);
/* read board id */
serial = (value_s >> 12)* 1000 + ((value_s & 0x0f00) >> 8) * 100
+ ((value_s & 0x00f0 >> 4) * 10 + (value_s & 0x000f);
printf("This board is serial no.: %d\n",serial);
value_s = *(ushort*) (base+STAT_REG1);
/* check on DAC/manual switch setting */
if ((value_s & 0x202) != 0)
{
printf("one of the two channels is in manual mode\n");
printf("program
terminating\n");
return(-1);
}
printf("both channels in DAC mode, ok.\n");
if ((value_s & 0x808) != 0)
/* check on HV ON/OFF switch setting */
{
printf("one of the two channels is OFF\n");
printf("program
terminating\n");
return(-1);
}
printf("both channels ON, ok.\n");
if ((value_s & 0x4) != 0)
/* whats the output polarity? */
printf("polarity of channel A is positive\n");
else
printf("polarity of channel A is negative\n");
if ((value_s & 0x400) != 0)
printf("polarity of channel B is positive\n");
else
printf("polarity of channel B is negative\n");
sleep(1);
value_s = *(ushort*) (base+LIMITS_A)
/* read Vmax and Imax */;
vmaxa=((value_s & 0xf0) >> 4) * 10;
imaxa=(value_s & 0x0f) * 10;
printf("Vmax(A): %4d % %, Imax(A): %4d % %\n",vmaxa,imaxa);
sleep(1);
value_s = *(ushort*) (base+LIMITS_B);
vmaxb=((value_s & 0xf0) >> 4) * 10;
imaxa=(value_s & 0x0f) * 10;
printf("Vmax(B): %4d % %, Imax(B): %4d % %\n",vmaxb,imaxb);
*(ushort*) (base+RAMP_SPEED_A) = 100;
/* set ramp speed 100 V/s */
printf("ramp A set\n");
*(ushort*) (base+RAMP_SPEED_B) = 100;
printf("ramp B set\n");
*(ushort*) (base+SET_CTRIP_A) = 100;
/* set channel A software current trip to 100 µA
*/
printf("channel A current trip set\n");
*(ushort*) (base+SET_CTRIP_B) = 0;
/* channel B without software current trip
*/
printf("channel B current trip set\n");