Skip to content

Commit 4d3d95e

Browse files
committed
initial commit of original AD sources
0 parents  commit 4d3d95e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+20993
-0
lines changed

05XX0405.EC3

1.85 KB
Binary file not shown.

061100A.EJL

1.84 KB
Binary file not shown.

1800ST.C

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
// DISCLAIMER
2+
//
3+
// AT KEITHLEY METRABYTE WE TAKE PRIDE IN OUR SERVICING
4+
// OUR CUSTOMERS. WE ARE PLEASED TO OFFER YOU THIS SOFTWARE
5+
// AID PROGRAM FREE OF CHARGE.
6+
//
7+
// *******BEFORE INSTALLING THIS SOFTWARE*******
8+
// *******PLEASE BE AWARE OF THE FOLLOWING******
9+
//
10+
// THIS IS NOT A STANDARD KEITHLEY METRABYTE PRODUCT.
11+
//
12+
// THIS SOFTWARE DOES NOT PROVIDE ANY WARRANTIES
13+
// AND IS NOT SUBJECT TO TECHNICAL SUPPORT.
14+
//
15+
// KEITHLEY INSTRUMENTS INC., SHALL NOT BE LIABLE
16+
// FOR ANY SPECIAL, INCIDENTAL OR CONSEQUENTIAL
17+
// DAMAGES RELATED TO THE USE OF THIS SOFTWARE.
18+
//
19+
// WE SINCERELY HOPE THAT THIS AID HELPS YOU GET THE
20+
// OPTIMAL USE OF YOUR KEITHLEY METRABYTE PRODUCT.
21+
//
22+
// DAS-1800ST Register Level Program Example
23+
24+
#include <stdio.h>
25+
#include <conio.h>
26+
#include <dos.h>
27+
28+
#define base_adr 0x320
29+
#define data_sel base_adr + 2 // Data Select Register,R/W
30+
#define dig_io base_adr + 3 // Digital I/O Register,R/W
31+
#define ctrl_a base_adr + 4 // Control Register A,R/W
32+
#define ctrl_b base_adr + 5 // Control Register B,R/W
33+
#define ctrl_c base_adr + 6 // Control Register C,R/W
34+
#define status base_adr + 7 // Status Register,R/W
35+
#define burst_length base_adr + 8 // Burst Length Register,R/W
36+
#define burst_rate base_adr + 9 // Burst Mode Conv. Rate,R/W
37+
#define qram_adr base_adr + 10 // QRAM Address Start,R/W
38+
#define counter_0 base_adr + 12 // Counter 0 Register,R/W
39+
#define counter_1 base_adr + 13 // Counter 1 Register,R/W
40+
#define counter_2 base_adr + 14 // Counter 2 Register,R/W
41+
#define ctr_ctrl base_adr + 15 // Counter Control Reg.,R/W
42+
43+
int read_dig_in(void);
44+
void scan_burst(void);
45+
void scan_paced(void);
46+
void set_chan_list(void);
47+
void set_dig_out(int);
48+
void set_pace_clk(void);
49+
void software_measure(void);
50+
51+
52+
53+
unsigned int ad_data, ad_status, choice = 0;
54+
unsigned int i;
55+
56+
void main(void)
57+
{
58+
int dig_value;
59+
float vout;
60+
clrscr();
61+
do
62+
{
63+
gotoxy(1,1);
64+
printf("\n Enter 1 for Software Measure");
65+
printf("\n Enter 2 for Scan Burst Mode");
66+
printf("\n Enter 3 for Scan Paced Mode");
67+
printf("\n Enter 4 for Set Digital Out");
68+
printf("\n Enter 5 for Read Digital In");
69+
printf("\n\n");
70+
scanf("%d",&choice);
71+
switch(choice)
72+
{
73+
case 1:
74+
software_measure();
75+
break;
76+
case 2:
77+
scan_burst();
78+
break;
79+
case 3:
80+
scan_paced();
81+
break;
82+
case 4:
83+
printf("\n Enter Digital Output ");
84+
scanf("%d",&dig_value);
85+
set_dig_out(dig_value);
86+
break;
87+
case 5:
88+
i = read_dig_in();
89+
printf("\n Dig In = %d",i);
90+
break;
91+
}
92+
93+
delay(250);
94+
}
95+
while (choice <6);
96+
printf("\n\n Done");
97+
}
98+
int read_dig_in()
99+
{
100+
return( (int)(inp(dig_io) & 0x0f));
101+
}
102+
void scan_burst()
103+
{
104+
105+
set_pace_clk();
106+
set_chan_list();
107+
// Set up the A/D
108+
outp(ctrl_c, 0x45); // Bipolar, SE, Burst, Int Clk
109+
outp(data_sel, 0x00); // data from A/D
110+
outp(burst_length, 4); // Burse length 4 chan
111+
outp(burst_rate, 9); // 100Khz
112+
outp(ctrl_a, 0x00); // soft gate,disable ctr,rst fifo
113+
outp(ctrl_a, 0x05); // soft gate,start ctr,enab fifo
114+
outp(status, 0x80); // Enable A/D conversions
115+
while (((inp(status) & 0x20) == 0) && (!kbhit() ));
116+
outp(status, 0x00); // Disable A/D conversions
117+
outp(ctrl_a, 0x01); // soft gate,disable ctr,enab fifo
118+
outp(data_sel, 0x00); // select data from A/D
119+
printf("\n");
120+
for (i=0; i<4; i++)
121+
{
122+
ad_data = inpw(base_adr)& 0xfff;// Read A/D Twos Complement
123+
ad_data ^= 0x800; // XOR to get Comp Bin Code
124+
printf("%d %x h\t",i, ad_data);
125+
}
126+
}
127+
void scan_paced()
128+
{
129+
set_pace_clk();
130+
set_chan_list();
131+
// Set up the A/D
132+
outp(ctrl_c, 0x41); // Bipolar, SE, Burst, Int Clk
133+
outp(data_sel, 0x00); // data from A/D
134+
outp(ctrl_a, 0x00); // soft gate,disable ctr,rst fifo
135+
outp(ctrl_a, 0x05); // soft gate,start ctr,enab fifo
136+
outp(status, 0x80); // Enable A/D conversions
137+
while ( ((inp(status) & 0x20) == 0) && (!kbhit() ));
138+
outp(status, 0x00); // Disable A/D conversions
139+
outp(ctrl_a, 0x01); // soft gate,disable ctr,enab fifo
140+
outp(data_sel, 0x00); // select data from A/D
141+
printf("\n");
142+
for (i=0; i<4; i++)
143+
{
144+
ad_data = inpw(base_adr)& 0xfff;// Read A/D Twos Complement
145+
ad_data ^= 0x800; // XOR to get Comp Bin Code
146+
printf("%d %x h \t",i,ad_data);
147+
}
148+
}
149+
150+
void set_chan_list()
151+
{
152+
outp(data_sel, 0x01); // select QRAM
153+
outp(qram_adr, 0x03); // # of mux channels = 4
154+
outpw(base_adr, 0x00); // chan 0, gain 1
155+
outpw(base_adr, 0x101); // chan 1, gain 2 or 10
156+
outpw(base_adr, 0x02); // chan 2, gain 1
157+
outpw(base_adr, 0x03); // chan 3, gain 1
158+
outp(qram_adr, 0x03); // reset to start addr of qram
159+
}
160+
161+
void set_dig_out(int value)
162+
{
163+
value &= 0xff;
164+
outpw(dig_io, value);
165+
}
166+
167+
void set_pace_clk()
168+
{
169+
// sample rate = 1KHz
170+
outp(ctr_ctrl, 0xb4); // Ctr 2, mode 2, lsb-msb
171+
outp(counter_2, 0x0a); // Lsb of 10 dec.
172+
outp(counter_2, 0x00); // Msb of 10 dec.
173+
outp(ctr_ctrl, 0x74); // Ctr 1, mode 2, lsb-msb
174+
outp(counter_1, 0xf4); // Lsb of 500 dec.
175+
outp(counter_1, 0x01); // Msb of 500 dec.
176+
}
177+
void software_measure()
178+
{
179+
// Set up the QRAM
180+
outp(data_sel, 0x01); // select QRAM
181+
outp(qram_adr, 0x00); // starting addr for mux chan
182+
outp(base_adr, 0x00); // chan 0, gain 1
183+
outp(qram_adr, 0x00); // reset to start addr of qram
184+
// Set up the A/D
185+
outp(ctrl_c, 0x40); // Bipolar, SE
186+
outp(ctrl_a, 0x00); // reset fifo
187+
outp(data_sel, 0x00); // data from A/D
188+
outp(ctrl_a, 0x01); // enable fifo
189+
outp(status, 0x80); // Enable A/D conversions
190+
outp(base_adr, 0x00); // start A/D
191+
while ( (inp(status) & 0x40) == 0x00); // wait for Fifo NOT Empty
192+
ad_data = inpw(base_adr)& 0xfff; // Read A/D Twos Complement
193+
outp(ctrl_a, 0x00); // disable fifo
194+
ad_data ^= 0x800; // XOR to get Comp Bin Code
195+
printf("\n A/D Data %x h",ad_data);
196+
}
197+

0 commit comments

Comments
 (0)