Generating a
Sine Wave
HP IBASIC (RGBSINE)
C and QuickBASIC
Programs
258 HP E1340A Register-Based Programming
This program generates a 4 Vp-p, 10 kHz sine wave. The program selects
the sine wave in the waveform EPROM and places it in RAM 0. The
frequency, attenuation (amplitude), and the various mode parameters are set
in the sequence indicated in Figure C-3.
1
!RE-SAVE"RGBSINE"
2
GET "SUBS",500,3 !place subprograms at line 500, continue w/line 3
3
!Program which demonstrates how to output a sine wave using register
4
!reads and writes.
5
!
10
!Compute the E1340 base address in E1300 A16 address space
20
COM Base_addr
30
Base_addr=DVAL("1FC000",16)+(80*64) !base address
40
!
50
!Reset the AFG
60
Afg_reset
70
!Set the function and load RAM
80
Function(0,0) !sine wave in RAM 0
90
!Set the frequency (frequency register 1)
100 Frequency1(1000.) !1 kHz
110 !Set amplitude, offset, impedance, correction
120 Amplitude(2,0,50,0) !2 Vpk, 0V, 50 ohms, correction enabled
130 !Set the Aux Out level, Aux In level, clock source, Aux Out signal,
140 !RAM bank, frequency register, and output mode.
150 Mode(0,0,3,1,0,0,0) !norm,norm,internal,pulse/cycle,bank 0,reg 1,cont
160 END
170 !
The C program RGBSINE.C is in directory "CPROG", and the
QuickBASIC program RGBSINE.BAS is in directory "QBPROG" on the
example program disk HP P/N E1340-10036.
Appendix C