CAN add-on
ADwin
34
ADwin-Gold
USB / ENET, manual version 3.8, October 2005
Example:
Conversion of
Gray code
A conversion from Gray code into binary code is made with the routine below,
which you have programmed in the
ADbasic
process.
REM PAR_1 = Gray value to be converted
REM PAR_2 = Flag indicating a new Gray value
REM PAR_9 = Result of the Gray-to-binary conversion
DIM
m
,
n
AS
LONG
EVENT
:
IF
(
PAR_2
=1)
THEN
'Start of conversion
m
=0
'initialize value
PAR_9
=0
' -"-
FOR
n
=1
TO
32
'Go through all possible 32 bits
m
=(
SHIFT_RIGHT
(
PAR_1
,(32-
n
))
AND
1)
XOR
m
PAR_9
=(
SHIFT_LEFT
(
m
,(32-
n
)))
OR
PAR_9
NEXT
n
PAR_2
=0
'Enable next conversion
ENDIF
Fig. 27 – Listing: Conversion of Gray code into binary code
Programming
The functionality of the decoders is easily programmed with
ADbasic
instruc-
tions:
The instructions are in the include file
<ADWGCAN.INC>
. More information can
be found in the
ADbasic
manual and the online help.
Range
Instructions
Initialization
SSI_MODE
SSI_SET_BITS
SSI_SET_CLOCK
Receiving of data
SSI_READ
SSI_START
SSI_STATUS