BNC 630 User Manual

Page 75

Advertising
background image

70

' ------------------------------- Main Loop --------------------------------
' This loop calculates each point of the arbitrary waveform.
' It then calls one of several subroutines (depending on what format you
' would like the data in) to send the data to the 630

NUMPOINTS = 80 ' Total number of points generated

Phase# = 0 ' Reset sinewave phase accumulator to 0

PhaseInc# = 2 * 3.1415926# / NUMPOINTS ' Phase goes 0 to 2*Pi

' This loop generates the points and sends them to the 630

FOR PointNumber = 1 TO NUMPOINTS

' Note: Here we call a function to generate a new point value. Basic returns
' a value from SIN() which ranges from -1.0 to +1.0. You may insert
' your own function here, but be sure that the returned value ranges
' from -1.0 to +1.0 since the subroutines below expect "PointVal"
' to range from -1.0 to +1.0.

PointVal = SIN(Phase#)

' Pick one of the following subroutines depending on desired data format:
' GOSUB SendFloat ' Send Floating Point, ex: 3.67e-2, -.586, .012e1,...
GOSUB SendHex ' Send Hexadecimal, ex: fed7,124,63c8...
' GOSUB SendInteger ' Send Integer, ex: -2047,185,2047...
' GOSUB SendBinary ' Send Binary, ie <hi byte>,<low byte>,...

Phase# = Phase# + PhaseInc# ' Advance the phase of our sinusoid

NEXT PointNumber ' Continue loop and generate more points

' All points have now been generated and sent to the 630.
' When the 630 hasn't received any chars over the serial port for a
' 1 second time-out, it assumes that all points have been sent and starts
' generating the waveform.

ArbExit:
CLOSE : SYSTEM ' Close the comm port and exit the program.

Advertising