HP E1328A User Manual page 80

D/a converter module
Hide thumbs Also See for E1328A:
Table of Contents

Advertisement

/*********************************************************************************/
void setup_dtoa(char *base_addr, int mode, int channel, float level)
{
/* This function sets up the D/A converter to output voltages or currents */
/* on the specified channels. */
80
HP E1328A Register-Based Programming
unsigned short level_word = 0, msbyte = 0, lsbyte = 0;
/* convert voltage or current level to binary number */
if (mode == 1)
{
level_word = (unsigned short)(level * 3000) + 0x8000;
msbyte = level_word >> 8;
lsbyte = level_word & 0xFF;
}
else
{
level_word = (unsigned short)(level * 1500000) + 0x8000;
msbyte = level_word >> 8;
lsbyte = level_word & 0xFF;
}
/* wait for the D/A ready bit and the channel's settle bit = 1, */
/* and then write msbyte of voltage */
switch (channel)
{
case 1:
while(!READY);
while(!SETTLE1);
iwpoke((unsigned short *)(base_addr + 0x10),msbyte);
/* wait for D/A ready bit = 1, and then write lsbyte of voltage */
while (!READY);
iwpoke((unsigned short *)(base_addr + 0x12),lsbyte);
break;
case 2:
while(!READY);
while(!SETTLE2);
iwpoke((unsigned short *)(base_addr + 0x14),msbyte);
/* wait for D/A ready bit = 1, and then write lsbyte of voltage */
while (!READY);
iwpoke((unsigned short *)(base_addr + 0x16),lsbyte);
break;
case 3:
while(!READY);
while(!SETTLE3);
iwpoke((unsigned short *)(base_addr + 0x18),msbyte);
/* wait for D/A ready bit = 1, and then write lsbyte of voltage */
while (!READY);
iwpoke((unsigned short *)(base_addr + 0x1A),lsbyte);
break;
/* convert voltage */
/* convert current */
/* channel 1 */
/* channel 2 */
/* channel 3 */
Appendix B

Advertisement

Table of Contents
loading

Table of Contents