
'
'Hagtronics_PicDas - ActiveX Control for The PIC DAS project
'Copyright 2000 by Steven C. Hageman all commercial rights reserved
'


This is the documentation file for the ActiveX control that will control
the Hagtronics Project known as: PIC DAS


General: 

	The general operation of the control is to set the Com port that the PIC DAS 
is connected to with the Let Com_Port call, then open the com port and turn on the PIC DAS 
with a call to the Connect() method.

	In visual basic the code looks like,
	
		PicDas.Com_Port = 4   		'If the COM Port is COM 4
		error_val% = PicDas.Connect	'Turn the PIC DAS on

	All of the PIC DAS commands return a 0 if the function was sucessful or a 
negative number if an error happened.

The error codes are shown below. Also a call to the method Last_Error yields the 
string of the last error that happened, such as,

	if PicDas.Connect < 0 then
		error_string$ = PicDas.Last_Error
		print error_string$
	endif

The code above connects to the PIC DAS, if the method fails, the return code will be
a negative value and the property Last_Error will contain an error string of the error
that happened. Generally it is a good idea to check the return value from each method
call to be sure that nothing went wrong.

Once the PIC DAS is connected to, any of the other functions may be called.

To disconnect and turn off the PIC DAS the Disconnect method may be called,

	error_val% = PicDas.Disconnect

Again, the method returns a 0 if the function suceeded or a negative number
if the function failed.  


===== Listing of error codes =====
'Error codes
Const UNDESCRIBED_ERROR = -1
Const COULD_NOT_CONNECT = -2
Const COULD_NOT_DISCONNECT = -3
Const VERSION_NOT_READ_CORRECTLY = -4
Const RS232_COMMAND_NOT_SENT = -5
Const SEND_RS232_ERROR = -6
Const PARAMETER_1_OUT_OF_RANGE = -7
Const PARAMETER_2_OUT_OF_RANGE = -8
Const BITSET_NOT_READ_CORRECTLY = -9
Const BITCLEAR_NOT_READ_CORRECTLY = -10
Const DIRECTION_NOT_READ_CORRECTLY = -11
Const BITINPUT_NOT_READ_CORRECTLY = -12
Const PORTINPUT_NOT_READ_CORRECTLY = -13
Const PORTOUTPUT_NOT_READ_CORRECTLY = -14
Const PULLUPS_NOT_READ_CORRECTLY = -15
Const ANALOGIN_NOT_READ_CORRECTLY = -16
Const ANALOGOUT_NOT_READ_CORRECTLY = -17
Const PIC_DAS_NOT_CONNECTED = -18


===== Listing of properties =====

Public Property Get Com_Port() As Integer


===== Listing of methods =====

Public Function Bit_Set(ByVal bit%) As Integer
Sets Bit, bit% = 0-7, Returns 0 if OK, else error code

Public Function Bit_Clear(ByVal bit%) As Integer
Clears Bit, bit% = 0-7, Returns 0 if OK, else error code

Public Function Direction(ByVal num%) As Integer
Sets digital I/O port direction
num% = 0-255: 1=Input, 0=Output, Returns 0 if OK, else error code

Public Function Bit_Input(ByVal bit%) As Integer
Reads Bit
bit% = 0-7, Returns 0 or 1,else error code

Public Function Port_Input() As Integer
Reads entire digital I/O port
Returns 0-255 (port value), else error code

Public Function Port_Output(ByVal value%) As Integer
Sets digital I/O port to a value
value% = 0-255, Returns 0 if OK, else error code

Public Function Pullups(ByVal state%) As Integer
Sets digital I/O port pullups on or off
state% = 0 (off) or 1(on), Returns 0 if OK, else error code

Public Function Analog_In(ByVal channel%) As Integer
Reads the A/D
channel% = 0-7, Returns A/D code (0-4095) or error code

Public Function Analog_Output(ByVal channel%, ByVal dac_value%) As Integer
Sets Analog DAC Output
channel% = 0-3, dac_value% = 0-4095, Returns 0 if OK, else error code

Public Function Version() As String
Returns PIC DAS firmware version string

Public Function Connect() As Integer
Connects and turns on the PIC DAS
Returns 0 if OK, else error code

Public Function Disconnect() As Integer
Disconnects and turns off PIC DAS
returns 0 if OK, else error code

Public Property Get Last_Error() As String
Returns the last error code string that the PIC DAS set (must call immediately after error)


----- End -----



