PRT232F Pulse Counter/Digital interface card
User Manual

Rev A 10/2011

Introduction
Your PRT232 digital interface is a versatile module for interfacing the computer to the real world. It features 6 count inputs for reading devices such as flowmeters or turnstiles and measuring RPM of rotating mechanisms. It also monitors 12 digital inputs making it simple to read switches and pushbuttons and the eight power outputs will control relays, solenoid valves or small DC motors.

Communications

The PRT232 uses a simple text interface. Each command is terminated with a Carriage Return (ASCII 13) which is shown as '\n' in the text following. Responses are sent in plain text making for easy communication with a terminal such as Hyperterm. The text-based communication method also means that software control is simplified as there are no complex multilayer protocols to be decoded. 

Please note that it is not necessary to actually type in the "\r" and "\n" text. These are only representations of Carriage Return and Line Feed characters.

Settings	Serial settings are 19,200 bps, 8-bit word, No Parity, One Stop bit (8N1)
Flow Control is not used, so if you are using a program such as Hyperterm, be sure to disable it to prevent communication errors.

At power-on, the PRT232 sends the string "PRT232F-1.0\r\n" where '\r' is a Carriage Return (ASCII13) and '\n' is a Line Feed (ASCII 10). We suggest that your first command be a plain Line Feed (\n) as this will clear the command input buffer of any spurious characters that may have been created on the communication line from power up.

Operation:	Read channel <N> count. This returns the current value of the count.
Command	c,<N>\r	n:1-6
Return value	0 - 4,294,967,296 (32bits unsigned)

Operation:	Clear channel 'n' count. This resets the count to zero.
Command	z,<N>\r	n:1-6 if no parameter given, clear all counts. e.g., 
Return value	None

Operation:	Read digital input. Returns the state of the Switch Inputs S1-S12..
Command	s,<N>\r	n:1-12
		If no parameter 'n' is given, returns the value of all 12 inputs as a 12-bit word: 0-4095
Return value	"xxx"  where x is '1' or '0' representing the switch status in order. i.e., first x is S1, second is S2 and third is S3. A '1' indicates the switch is activated, a '0' deactivated. 

Operation:	Set output value. Activates/deactivates the digital Power Outputs at terminal J7.
Command	o<N>\r
		The argument '<N>' is a binary representation of the desired state and is calculated by
		combining the ON values for all inputs.

		Output			Value
		0			1
		1			2
		2			4
		3			8
		4			16
		5			32
		6			64
		7			128

		To turn all outputs OFF, set N to 0. 
		To turn on, e.g., outputs 1,2 & 5, set <N>= 2 + 4 + 32 (38) send the command
		o38\r	
Return value	None

Operation:	Control a single output. Activates/deactivates the digital Power Outputs at terminal J7.
Command	a,<C>,<S>\r
		<C>: output 1-8, <S>: 1 or 0
		e.g., to turn on output 4, send the command a,4,1 To turn it back off, send a,4,0
Return value	None

Operation:	Set watchdog timeout to <N>seconds where <N> is 0-999. When the watchdog is set to a non-zero value it is enabled. This means that if any of the outputs are active and a k or c command has not been received within the timeout period, the outputs will be turned off.
Command	w<N>\r
Return value	None

Operation:	Set maximum pulse limit of channel <C> to <N> where <N> is 0-9999 pulses  . When the pulse limit is set to a non-zero value, pulse limiting is enabled. This means that if any of the outputs are active and the specified number of pulses have been received, the corresponding output will automatically turn off. Setting pulse limit to zero disables this feature..
Command	m,<C>,<N>\r
Return value	None

Operation:	Set pulse timeout to <N> where <N> is 0-999 seconds. When the pulse timeout is set to a non-zero value, pulse timeout is enabled. This means that if any of the outputs are active and the specified number of seconds have passed since the last pulse was detected, the outputs will automatically turn off. Setting pulse timeout to zero disables this feature..
Command	v<N>\r
Return value	None

Operation:	Kick watchdog. When the watchdog is enabled (w command with non-zero value), if a k or c  command is not received within the timeout value, all outputs will be turned off.
Command	k\r
Return value	None

Watchdog, pulse limit and pulse timeout features are disabled at power on. Reading the count has the effect of kicking the watchdog, so if you are reading the count faster than the watchdog timeout, there is no need to use the 'k' command