'---------------------------------------------------------------------------------------- ' Name: SHI_8081_DEMO.TIG ' Type: Tiger-BASIC(tm) Source Code ' Purpose: Demo for device driver "SHI_8081.TDD" ' C l o c k e d s e r i a l data input ' ' (C) - Copyright Wilke Technology, P.O.Box 1727, D-52018 Aachen, Germany '---------------------------------------------------------------------------------------- ' ' Thank you for using BASIC Tigers in your products. If you have questions, ideas ' or special needs, please contact your next distributor or the Tiger support team ' and visit our web site: ' ' Wilke Technology GmbH ' The Tiger Support Team ' P.O.Box 1727, D-52018 Aachen, Germany ' Krefelder Str. 147, D-52070 Aachen, Germany ' ' email: support@wilke-technology.com (english) ' email: support@wilke.de (german) ' Phone: +49 (241) 918 900 Mo to Fr, 7:00 to 16:00 (GMT) ' Fax: +49 (241) 918 9068 ' ' New information, new drivers and free downloads see: ' ' www.wilke-technology.com (english) ' www.wilke.de (german) ' ' Sincerely, ' ' Your Tiger Support Team ' '---------------------------------------------------------------------------------------- ' ' This demo was developed in this configuration: ' ' - Development software on PC: TIGER-BASIC(tm) 5.01 for Windows(tm) ' ' - The "Plug + Play Lab" equipped with a BASIC Tiger ACN-4/4 ' ' - A NipCon system to generate shift-register type output: ' . NIPS demo board (16 + 2 switches) ' . VX-16 board with 16 LEDs ' . NIP-CON Z controller ' '---------------------------------------------------------------------------------------- ' ' Driver description: ' ' The "SHI_8xYY.TDD" set of device drivers is used to input a clocked, serial ' bit stream into a BASIC Tiger. Unlike byte oriented serial data, picking ' "bytes" from a serial data stream, this driver works like a serial ' shift-register input, receiving data bit by bit sequencially. ' ' So, no explicit frameing like START- or STOP-bits are expected, though, ' these can be received and removed through a BASIC program anyway. ' ' ' The driver uses 2 input lines: ' ' - clock input ' - data input ' ' The clock line may use a TRUE or INVERTED pulse for clocking, and the ' driver either can be set to sample at FALLING or RISING edge of the ' clock line. ' ' Data is picked one bit at a trigger from the clock line and is assembled ' into the internal buffer accoring to following settings: ' ' - First bit is MSB or LSB ' ' - First incoming bit-group (e.g. a byte) is first in buffer or last ' ' - Incoming bits can be assembled into the buffer at a rate of ' 1 bit per byte to 8 bits per byte. ' ' Receiving formats of more than 8 bits per bit group (for example ' 16 data bits + 1 start + 1 stop bit = 18 bits) would be assembed ' in a 8 bits per byte scheme in the driver, and then get disassembled ' with a convert function in BASIC. ' ' Furthermore, there is no need for a "strobe" or "start" signal to initiate ' a bit stream receiving process. The driver detects the beginning and end of ' a bit stream through use of a timeout condition. ' ' When the clock signal pauses at least for the timeout period, the driver ' treats all data bits received up to this moment to be a complete set ' of received bits. These are available for the BASIC program right from ' this moment through a "GET .." instruction. After "GET .." the data buffer ' is cleared. ' ' If data is not taken from a BASIC program through a "GET ..", new data ' will overwrite previous bit recording, though a "double-buffered" mechanism ' making sure, that a data record always is complete and not the combination ' of 2 incomplete recording fractions. ' ' ' Example: ' ' CLOCK: !------- timeout -------->: ' : ' ----! !---------! !----------------------:------! !---------! !---------! !--- ' ! ! ! ! : ! ! ! ! ! ! ' !--! !--! : !--! !--! !--! ' * : * * * ' DATA: * : * * * ' * * : * * * ' * * : * * * ' ---------------! * : * !-----! * !-------------- ' * ! * : * ! ! * ! * ' * !---------------------------:-----------! !------! * ' * * : * * * ' bit=1 bit=0 : bit=0 bit=0 bit=1 ' : ' ---- previous bit recording ends here ---> : ---> next bit recording ' '---------------------------------------------------------------------------------- ' ' To run this example connect: ' ' - CLOCK signal to L80 at the BASIC Tiger ' - DATA signal to L81 at the BASIC Tiger ' ' The program directly is prepared to receive 120 bits (15 bytes) of data from ' a NIP-CON Z unit scanning up to 99 remote switches. ' ' The received data is displayed on the 4 x 20 text LCD of the "Plug + Play Lab". ' To remove the blinking of NIP-CON Z data, see comments in this program. ' ' Any other source for serial clocked data may be used instead of a NIP-CON Z ' unit if not available, you just may remove those code lines dealing with ' "blinking" suppression (Strings B$, DUMMY$ used for that). ' ' ' Further technical specifications of the SHI_"8xYY.TDD" driver: ' ' - Max clock frequency: 20 000 Hz min ' - Min clock frequency: 4 Hz (due to 255 ms max timeout setting) ' - Timeouts: 2...254 ms ' Note: A timeout setting of "2" generates a timeout of 1...2 ms ' A timeout setting of "x" generates a timeout of (x-1)...x ms ' '---------------------------------------------------------------------------------- USER_VAR_STRICT ' check for proper variable declarations TASK MAIN ' begin task MAIN STRING A$(128), B$(128), DUMMY$(128) LONG N, K INSTALL_DEVICE #1, "LCD1.TDD" ' LCD driver '---------------------------------------------------------------------------------- ' !<--- Parameter no. in INSTALL_DEVICE instruction ' ! ' ! !<--- ev. this value can be unchanged, see VALUE here for unchanged ' ! ! "-" signal: If this parameter is present, set it correctly! ' ! ! ' ! ! '------------------------------------------------------------------ ' 1. 0 ' <1> Timeout in ms (2...255) for detecting a data packet ' '------------------------------------------------------------------ ' 2. - ' <1> Receive edge: which clock edge samples DATA bits? ' ' 00 = rising edge, XX = falling edge ' '------------------------------------------------------------------ ' 3. - ' <1> Receive bit sequencing: 00 = low bit first (LSB) ' ' XX = high bit first (MSB) ' '------------------------------------------------------------------ ' 4. - ' <1> Receive byte sequencing: 00 = low byte first ' ' XX = high byte first ' '------------------------------------------------------------------ ' 5. 0 ' <1> Receive bits per byte: Receive 1..8 bits per bytes ' ' Default = 8 '---------------------------------------------------------------------------------- INSTALL_DEVICE #2,"SHI_8081.TDD",2,0,0,1,8 ' clocked shift-in, 2 ms timeout, L80/L81 USING "UH<2><2> 2.2.2.2.2" ' formatting for bytes to be shown as HEX bytes PRINT #1, "<1>"; ' clear LCD LOOP 999999999 ' many loops ... GET #2, 0, A$ ' read clocked data '---------------------------------------------------------------------------------- ' A$ <--- CUT_AND_PASTE$ ( SOURCE$ ) ' cut away SOURCE completely !! ' ' A$ <--- CUT_AND_PASTE$ ( SOURCE$, OFFSET, LEN) ' cut out some bytes only ! ' ! ! ! ' ! ! ! ' ! ! !<-- no. of bytes to CUT + PASTE: 0...nn ' ! ! ' ! !<-- offset in SOURCE string ' ! ' !<-- source string to get + cut data from '---------------------------------------------------------------------------------- B$ = A$ ' this line only for: Remove blinking of NIPS-board DUMMY$ = CUT_AND_PASTE$ (B$, 2, 2) ' this line only for: Remove blinking of NIPS-board IF B$ <> FILL$("00"%, LEN(B$)) THEN ' this line only for: Remove blinking of NIPS-board PRINT #1, "<1>" ' clear LCD FOR K = 0 TO 2 ' show up to 3 lines with up to 6 bytes on LCD FOR N = 0 TO 5 ' IF K*6+N+1 > LEN(A$) THEN ' exit if LEN of string is completely shown GOTO ABORT_FOR_LOOP ' ENDIF ' PRINT USING #1, " "; NFROMS(A$, K*6+N, 1); ' show 1 byte in HEX format NEXT ' PRINT #1, "" ' cursor on LCD to next line NEXT ' ELSE ' this line only for: Remove blinking of NIPS-board ENDIF ' this line only for: Remove blinking of NIPS-board ABORT_FOR_LOOP: ' PRINT #1, "<1BH>A<0><0><0F0H>Len ="; LEN(A$); " " ' show length of string on top line WAIT_DURATION 200 ' ENDLOOP ' END ' end of task MAIN