Home

TFX-11 MANUAL

image

Contents

1. array memory bank 1 of the 128K static RAM UEEPROM 128 bytes User EEPROM inside the HC11 e 1MB TFX 11 or 2MB TFX 11v2 Serial flash EEPROM SFLASH Refer to the TFBASIC memory map on page 189 for a graphical representation of the descriptions that follow Program and Variables memory bank 0 of the 128K static RAM This is the default RAM bank that contains the running TFBASIC program token interpreter and variable storage space It is TFBASIC s prime operating area User storage in this area is accessed directly through TFBASIC variables The total area available for storage is reduced by the overhead used by the token interpreter and the storage used by the user s program tokens This memory is battery backed and retains its information as long as the backup battery is not removed This memory is not accessible directly via the parallel port Any data stored here must be transferred to the SFLASH before off load or transferred directly out the UART via a running TFBASIC program array memory bank 1 of the 128K static RAM This area of RAM is set aside for random access data storage It is predefined as a single array containing 15232 elements called the array Each element of this array is a standard 4 byte variable This section of RAM is easily accessible any assignment to or from an amp array variable transfers the data automatically performing the bank switching This area is NOT automatically initialized on
2. Chapter 5 TFBASIC Assembly Language Reference 167 other variables Important Addresses in TFBASIC These system variables may be accessed in your assembly routines or with PEEK and POKE Be warned be sure you know what you are doing or you may have unintended side effects time variables variable tick array array array array array array eon VV Vd n Vy Oey ORF Ox OD OD OR OD Ao we WN EF c array addresses 60H 63H 64H 65H 68H 69H 6CH 6DH 70H 71H 74H 75H 78H 79H 7CH 7DH 80H notes seconds since 1 1 80 0 01 seconds second minute hour day month year 0 01 ticks Each variable must be accessed by the address given not by its name Count of CTRL Cs pending See CBREAK CTRL C enable zero 7 ignore CTRL C When set to non zero to trace execution Flag that signals SLEEP detected oversleep Count of RS232 break conditions since last call to FLUSHI or power on reset Bits are set to indicate certain errors when program is launched according to the following e CCOUNT 9BH e CENAB 9CH TRACE 9DH e OVRSLP 9EH e BRKCNT 9FH e LNCHSTAT AOH Bit 0 Bit 1 Bit 2 Bit 3 Set if there was a checksum error of code stored in SFLASH Set if there was an error getting clock time from PIC In this case the clock will be set to zero midnight January 1 1980 Set if there was an error getting the datafile pointer DF pointer from the PIC I
3. Compiler Sets startup options for tokenizer and program upload options options Compiler Options nlt Create list file Create binary file Create symbol table file Case insensitive symbol names Maximum symbols 000 Maximum ASM lines 1000 OK Cancel Embed line numbers Inserts line numbers relating to the text file in the listing file This helps relate tokens to actual code Create List File Stores an annotated listing of the program in the text file the next time the tokenizer runs whether through the Run Launch or Syntax check command The file will have the extension LST Create binary file Creates a compiled file without source code for distribution to customors Create symbol table file Creates a text file that lists labels and variables along with their location in memory for debugging Case insensitive symbol names NOT IMPLEMENTED YET Maximum symbols Sets the amount of memory allocated by TFTools for its symbol tables Maximum ASM lines Determines the amount of memory allocated for compiling assembler instructions If you do not have any assembly code you may reduce this number to allow more memory for symbols TFX 11 User 5 Guide COMMPORT CommPort Serial port Hex display Alt Capture to file Alt Z Parallel port Terminal options Serial Port Allows you to set the COM port parameters These values are saved in the
4. Terminal Status Bar Editor Window Insert Status bar TFTools is an IDE designed for the Windows operating system and includes the familiar navigation tools such as a title bar menu bar and a status bar at the bottom The key elements however are the following two windows you will be working with in TFTools 18 TFX 11 User 5 Guide Understanding the TFTools Integrated Development Environment Terminal window The terminal window which displays the TFTools integrated terminal program used for communicating with the TFX 11 and has an integrated compiler for generating tokenized TFBASIC code The editor window which is a multi window programming editor for writing and debugging TFBasic code There is only one terminal window and it is always open Although the terminal window can be resized or hidden by an editor window it cannot be minimized or closed The terminal program communicates with the TFX 11 through an Onset supplied cable connected to a PC serial COM port Program upload and data off load use a standard PC parallel LPT port connected by an Onset supplied cable there is also a two step process that allows you to upload via serial port see Editor window on page 20 As soon as a powered TFX 11 is properly connected to the PC via the serial cable the terminal window displays any characters that are received by the host PC serial port Keyboard characters go out the host PC serial port to
5. Tabs Timing UEEPROM lt gt not equal to A lt gt B gt lt not equal to A gt lt B equal to A B This is the main non volatile storage area It is a Serial Electrically Erasable Programmable Read Only Memory To help protect the user from data loss due to program errors the SFLASH interface is designed to only be read out and erased when the TFX 11 is connected to the parallel or serial port The SFLASH will retain the data for up to ten years with no power applied See Variables TFBASIC supports string operations and includes the functions MID and LEN See TFBASIC Language Reference for the TFX 11 on page 50 for details on string functions Tabs are just fine in TFBASIC and are used to increase readability In standard BASIC dialects there is little need to pace a program the sooner it s over the happier you are In a logging control application however program timing is critical Timing functions in the TFX 11 are handled by the SLEEP and HYB commands SLEEP puts the logger in a low power mode for an integral number of 10 ms steps from the wake up of the previous SLEEP command This not only provides the necessary timing but also ensures that the logger is in a low power mode during the interval HYB puts the TFX 11 in an ultra low power dormant mode with wakeup at a fixed time in the future or at regular intervals HYB is especially appropriate where the application has long periods of quiescence with
6. You can now use the character A as a synonym for amp H41 There can be up to four characters enclosed in single quotes The type of the character constant is a four byte integer Characters are shifted into the least significant byte of the integer as they are read with unused bytes set to zero For instance A is a character constant equivalent to value 41 H AB is equivalent to 4142 H ABC is equivalent to 414243 H ABCD is equivalent to 41424344 H Character constants can be used anywhere an integer value is used These are especially useful when checking if a character from the UART is equal to one or more characters For instance if you got a character from the UART in variable ch if ch Y ch y print Yes else if ch N ch n print No endif endif 186 TFX 11 User 5 Guide Characters and Strings in TFBASIC Other string operations Embedding special characters Special characters can be embedded in a character constant by preceding a pattern with the escape character V See the full explanation under Other String Operations that follows String Input You may input a string to a variable using the INPUT command as in Input Enter astring String output storing to datafile PRINT and STORE Special instructions for STORE the string is stored with the length byte first followed by the string String assignment String assignment from other string vari
7. endif sleep 0 arm SLEEP counter Sleep 200 allow 2 seconds for Ctrl C exit hyb 10 HYB exits 10 sec after last HYB goto loop In order to make use of the low power HYB state you must provide termination for all of the unused lines To make the most of the low power capabilities of the HYB command all I O and peripherals should be configured to their lowest power states Unused I O lines may be set to outputs or set to inputs if pull ups or pull downs are attached Any power Switched device should be powered off Timekeeping When the HC11 is in HYB its clock is shut down when it awakens from a HYB it automatically reads the PIC time value into the variable Finding what woke the HYB Care must be taken when setting a driven input to an output If you are sure the state will not change for example if it is connected to a pullup or pulldown resistor during the HYB duration this is what may be done Read the state of the input using PIN Depending on the state of the pin read use PSET or PCLR to set the output to the correct state HALT SLEEP STOP PICINT INTSTATE read only variable TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 IF Syntax Alternate form all on one line no ENDIF required Description Examples indentation for clarity only Output trial 1 Output trial 2 branch on result of comparison IF expression cCommand
8. ground 5V to positive supply 30uV typical p V microvolt a millionth of a volt 0 25nA max nA nanoamp a milli micro amp Dual amplifier from Texas Instruments at ti com 800 232 3200 Note the superb input offset current specifications Current drain e Supply voltage Max output swing Input voltage range Input offset voltage Input offset current 15yA typical for each amplifier 1 4V minimum ground to positive supply 1 Volt ground 0 2V to positive supply 1 Volt 160pV typical 0 1pA max pA picoamp a micro micro amp Single dual and quad amplifier from Advanced Linear Devices at aldinc com 408 747 1155 This part drives line to line Current drain e Supply voltage Max output swing Input voltage range Input offset voltage Input offset current 120pA typical for each amplifier 2 0V minimum ground to positive supply 1 Volt ground 0 2V to positive supply 1 Volt 2mV for the premium version 25pA max pA picoamp a micro micro amp NOTE If you need the specifications for gain bandwidth product noise characteristics stability offset drift temperature coefficients or output drive characteristics refer to the data sheets from the manufacturer We do not supply them in this manual These and other parameters are important in some applications but we don t have the space to cover everything Chapter 7 TFX 11 Interfacing 205
9. 2 and 4 are used to specify whether the data is to be read as one two or four bytes 1 specifies that the next 8 bits one byte be read 2 specifies that the next 16 bits two bytes be read and 4 specifies that 32 bits four bytes be read The pointer variable x is updated after all the data bytes have been read The default format of GET will read a single byte so that the 1 can be omitted in byte read commands X DFPNT save current write location in datafile FOR index 1 to 15 put some data in the datafile STORE 1 129 index NEXT index FOR A 1 TO 5 FOR B 1 TO 3 PRINT 4 GET X 1 NEXT B PRINT NEXT A The following will be displayed when you run it in TFTools 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 The STORE command uses the read only variable DFPNT to point to the next spot where data will be written DFPNT is not affected by GET or GETS Performing a GET from a location greater than DFPNT will not generate an error GETS 76 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 GETS Syntax Description Examples Output Remarks Cautions See Also Get string from datafile GET x Return string from datafile at address pointed to by variable x Argument X is either a constant or a variable that produces an address in the datafile from which the data is read When a constant is used the string is
10. Description Example of 17 Bits being Shifted shift register input value SDI bits or value SDI x SDI is designed to bring in a serial data stream from a shift register and return with a value formed from this data stream SDI first applies a negative going pulse to I O line 5 This pulse is used to latch data into the shift registers SDI then shifts in the number of bits of data specified by the value in parentheses using I O line 8 as the data input line and I O line 4 as a clock The returned value is made from the binary data received msb first Clocking occurs on the positive edge This works nicely with a 74HC 165 or 74HC166 shift register The command A SDI N will cause N bits of data to be clocked in to form an N bit two s complement number If less than 32 bits are shifted in the unspecified MSB s are zeros The last bit shifted in has a weight of 1 with the preceding bits given weights of 2 4 8 16 etc If 32 bits are shifted in the first bit will be the sign bit of the resulting number The figure below shows 17 bits shifted in to form the number 134EDH which is 79085 decimal OTTO T0071 1101101 1 54bEDH AMIS vs LJ L_ xp th if DATA No 5 CLOCK I O 4 ES ooo Chapter 4 TFBASIC Language Reference 119 This sequence works well with both 74HC165 and 74HC166 shift registers The figure below uses two 74HC165s to shift in 16 inputs By
11. Instrumentation Amplifiers What if your sensor provides two outputs like a bridge circuit An operational amplifier has both an inverting and a non inverting input but one is needed to set the gain of the circuit You can build an instrumentation amplifier from two operational amplifiers and a small pile of precision resistors using the circuit below input input output R1 R2 R1 R2 This circuit has a gain G R1 R2 R1 and works over a range of input voltages that go from ground to Max positive output R2 R1 R2 LT1101 Linear Technology s LT1101 packages this all in one 8 pin part and can instrumentation be set to a gain of 10 or 100 with no external parts amplifier Current drain 75yA typical e Supply voltage 2V minimum Max output swing ground 4mV to positive supply 1V Input voltage range ground 70mV to positive supply 2V Input offset voltage 50yV typical Input offset current 8nA max 206 TFX 11 User 5 Guide CHAPTER 8 TFX II Hardware Reference TFX 11 User 5 Guide Overview of I O Selecting digital O pins AID input choices Attaching devices to the bus TFX 11 reference schematic TFX 11 Hardware Notes The TFX 11 provides up to 19 A D converter input and up to 24 I O pins Eight I O pins are shared between digital input functions and 8 bit A D functions Therefore if all the 8 bit A D pins are used for digital input then only the eleven 12 bit A D i
12. Remarks Cautions See Also stop in lowest power mode HALT This command puts the Tattletale into its lowest power mode where it has a typical power drain of 100 pA It is up to the user to configure all I O and external devices into their lowest power states The only exits from this mode are disconnecting and re connecting the main battery or interrupting the process by commanding a LAUNCH restart from the HOST via the parallel port HALT None Before going into the dormant mode using HALT all of the unused I O lines need to be converted to inputs and asserted according to their pull down or pull up resistor configuration Any hardware attached should drop into its minimum power drain state when the lines are so asserted In order to make use of the low power HALT state you must provide termination for all of the unused input lines or set them to outputs HYB SLEEP STOP BBPWR read only variable 80 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 HYB Syntax Description Example 1 Example 2 very low power mode with wakeup HYB x This command puts the Tattletale into its lowest power mode where it has a typical power drain of 100 HA The parameter is the number of seconds to remain in this state before being awakened by the supervisory alarm in the PIC The only other exits from this mode are disconnecting and re connecting the main battery commanding a restart from
13. STORE 5 1F OutsideTemp C InsideTemp C IF PIN 1 lt gt 0 STORE 4 OPEN ELSE STORE 4 CLSD ENDIF HYB 10 goto loop This program stores two temperatures and a string OPEN or CLSD which records whether a vent is opened or closed Note the use of the semicolon at the end of the STORE statement which prevents the newline from being printed and keeps the strings to follow on the same line Note too the space after the C in the C strings embedded in the STORE formatting This puts spaces between the values in case they overflow the 5 2 formatting In the IF statement the STORE command uses the format command If this were not present a byte with the binary value 4 representing the length of the string would be inserted into the datafile just before the string This character is out of the range of normal ASCII characters and could cause problems in some applications As a result of all the formatting all three values are written on one line and when read out and viewed in a word processing program will look something like the following 25 4C 28 6C OPEN 25 5C 27 9C OPEN 25 4C 27 6C OPEN 25 4C 27 1C OPEN 25 4C 26 8C OPEN 25 5C 26 4C CLSD 25 4C 26 1C CLSD Chapter 10 TFX 11 General Hardware Reference 243 Functional overview of the TFX 11 TFX 11 in operation TFX 11 High Level Hardware Description The TFX 11 contains two processors 128K static RAM 472k
14. can appear anywhere on a line and cause the rest of the line to be ignored In assembly code a semicolon is used to separate comments from code Comments are stripped before the tokenizing pass and therefore do not affect execution code size TFBASIC supports string integer and floating point constants Integer constants are signed decimal numbers in the range 2147483648 to 2147483647 or unsigned hexadecimal numbers in the range amp HO to amp HFFFFFFFF Floating point constants must include a decimal point and or the power of ten specifier E All floating point constants are single precision with a range of 1 175494E 38 to 3 402823E 38 and 0 0 See the TFBASIC Floating Point on page 179 for details There are no short integer constants and no octal constants Character constants of up to four characters in single quotes are allowed The character on the right is placed as the least significant byte in the four byte constant String constants must be bracketed by double quote characters String constants can be used with the PRINT INPUT and STORE commands The TFX 11 has a special non volatile data storage area called the datafile which can only be written from the TFBASIC program Datafile commands are STORE for writing and OFFLD for reading An OFFLD command is not available from the TFBASIC program but is a menu command in TF Tools The datafile contains a read only pointer that points to the next empty datafile byte a
15. 2Mb flash EEPROM SFLASH and a parallel port and an RS232 serial port for development communications interface This section provides a general overview of the relationships responsibilities and interactions of the major subsystems The architecture of the TFX 11 includes an HC11 with 128K of RAM 64K of which is used for the TFBASIC token engine the users program and user variable storage The TFBASIC program is stored complete in flash as an executable image This image is created using TFTools on the host computer It is up to the TFTools host software to put together the image that will be loaded by the HC11 from the flash into its RAM for execution The initial step is for the host computer to load this image directly into the SFLASH via the parallel port connection The SFLASH provides permanent until deliberately erased and rewritten storage of the program and prepares the way for the next step which is having the HC11 copy the image into RAM Once loaded into the RAM the PIC controls the start of the program because it controls the HC11 s RESET line The PIC s timing functions can include a delayed start or periodic wakeup and shutdown of the HC11 providing the very lowest power modes when the HC11 is shutdown Fundamental to the design of the TFX 11 is its clean slate 64K RAM at RESET Resident on the host computer TFTOOLS formats compiles assembles both the user s code and a copy of the token engine into an image that is
16. 66 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 COUNT Syntax Description Examples Write this program in TFTools Output Write this program in TFTools Output count positive edges at I O line 0 cycles COUNT x count function or COUNT lt v gt count command There are two versions of COUNT The count function counts the number of square wave cycles positive edge is counted appearing at I O line 0 during a specified time Specify the duration lt x gt in hundredths of seconds between 1 and 65535 The count command works in the background incrementing variable lt v gt at every positive edge on I O line 0 COUNT lt v gt starts the background counter and COUNT with no arguments disables the count interrupt The COUNT and PERIOD functions may not be used while the COUNT command is running for N 2000 to 6000 step 2000 print set p for N Hz hrt X oOf 5 input A input to dummy var to wait print reads count 100 Hz next N Set up for 2000 Hz hit cr reads 1998 Hz Set up for 4000 Hz hit cr reads 4000 Hz Set up for 6000 Hz hit cr reads 6003 Hz count backCount start background count store in backCount SLEEP 0 SLEEP 2 A backCount save current count counting continues SLEEP 100 B backCount PRINT B A get second count show difference count stop the background coun
17. B BB A17 AO B PICHSHK PA2 A20 0 B A1 PAI B10 B PPMISO PA4 A22 B A21 PAS 811 G GND PA6 A24 amp A23 PAS B12 LED AD8 0 4A26 8 63 425 PA7 B13 B R87 AD8 1 28 6 A27 ADB 4 B14 RBS AD8 2 ASO B 2 A2 AD8 S BiS RBS AD8 3 A32 M GJ A31 AD8 6 B16 B RB4 VRL A34 g 6 A33 AD8 7 817 B R83 AD12 0 A3 6 G amp A35 VRH Bis RB2 AD12 2 A38 A37 AD12 1 B19 G RB AD12 4 A40 B B AS AD12 3 820 RBO ADi2 6 A42 J A41 AD12 5 B21 MRESET AD12 8 A44 amp A45 AD12 7 B22 B vec AD12 10 A46 R 9 A45 ADI2 823 CND REF A48 89 A47 REF B24 LITH ADVCC AS0I 9 A4 ADGND B25 B VBAT 216 TFX 11 User 5 Guide Explanation of Connector Pin Functions Overview Important note for those who want to design their own interface board UDO UDI TxD RxD HOSTREQ PPMOSI PICACK PPSCLK Explanation of Connector Pin Functions This section explains in detail the functions associated with the pins brought out to the PR 11 prototype board There are connections made on the protoboard that are required for proper operation of the TFX 11 s 8 bit A D converter If you design your own board you should include these connections or a suitable alternative to assure proper operation even if you don t use the 8 bit A D If these pins are left unconnected the internal 8 bit A D will definitely not operate properly and may cause other anomalies Onset will supply drawings
18. BAUDGET Get the baud rate of the main UART Syntax value BAUDGET Description Baudget returns the value of the current baud rate of the main UART The function returns an integer Value is one of the following bauds 300 600 1200 2400 4800 9600 19200 or 38400 Remarks The default baud rate on reset is always initialized to 19200 Cautions None See Also BAUDSET 60 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 CALL Syntax Description Cautions Remarks See Also Call an assembly language subroutine CALL addr or asm label regs var CALL lt x1 gt lt x2 gt lt v gt CALL executes a user loaded assembly language subroutine The A B and X registers are loaded with the value in the regs expression on entry to the subroutine and on exit the optionally specified variable returns with the register contents The packed format for register passing is shown below TxBASIC Variable Expression X register A register When you call an assembly language program you are leaving the warmth and safety of the TFBASIC programming environment Obviously the power to access all of the registers ports and memory also affords a path to catastrophic program crashes which may be very difficult to diagnose The ASM label needs to be defined in the program before being used with CALL ASM command and the TFBASIC Assembly Language section of the manual Chapter
19. FLOAT e Tp S ERR convert integer to float 72 FO Meester tonc UN for nextloop 73 FVAL iint RT RHET convert string to floating point value 75 GE ip err ded teud Get n byte value from datafile 76 GETS mu ee Get string from datafile 77 GOSUB VS ere go to subroutine saving return address 78 GOTO A go to label 79 HALT wmm un stop in lowest power mode 80 HYB very low power mode with wakeup 81 Iste E tede tu eme ete tea branch on result of comparison 83 INPUT DUCERE get value from console buffered 85 INSTR returns a substring s position in a string 88 Au NUI EE convert float to integer 89 IVAL T convert numeric string to integer value 90 LEN molas in dn n return length of string variable 91 URL DPI ede natural logarithm 92 LO LOGI 0 EE A common logarithm 93 xiv TFX 11 User 5 Guide MID Return a substring of a string 94 ONERR SEES go to label on error 95 PCLR ar QNS set I O pin low 97 PEEK tuos eE read memory byte 98 PERIOD ES measure period of signal 99 PICINT seeded bhava external interrupt for wakeup 100 PI sie e REM ERES ERE NAE read input state of I O pin 102 POKE gps place byte into RAM 103 PRINT e eT ets print to console 104 PSET ae set I O line high 107 PTOG toggle I O line to opposite state 108 EE EA Change sleep interval 109 RAT READRTC NER load PIC RTC time to local variable 111 REPEAT E sadist execute loop until expression tr
20. For example RUN GetData will cause the program starting at label GetData to run in the background Presumably the routine starting at label GetData has a SLEEP or STOP somewhere to pass control back to the foreground NOTE The second task is NOT a GOSUB statement do NOT use RETURN to end the background task 144 TFX 11 User 5 Guide General Guidelines for Background Tasks When a background task is started with RUN it doesn t start immediately A flag is set in TFBASIC that shows it is available to start It waits in suspended mode until the next clock interrupt occurs every 10mS or the rate chosen with the RATE command which truly starts the background task The following is an example of a working dual tasking program waitl print wait2 print Foreground prints character print background prints message sleep 0 reset the SLEEP count flags A 0 B 0 print Foreground starts background 1 run firstBG start first background task for I 0 to 50 print sleep 20 print symbols for 10 seconds next I ApS I signal to background task to stop wait for background to acknowledge if A lt gt 0 goto waitl print Foreground stops 1 starts 2 run secondBG start second background task for I 0 to 50 print sleep 20 print symbols for 10 seconds next I Be xa signal second task to stop wait for background to ack if B 0 goto wait2
21. PRINT Chapter 4 TFBASIC Language Reference 87 INSTR Syntax Description Examples Remarks See Also returns a substring s position in a string INSTR x str1 str2 Return the position in str at which the substring str2 is first found Optionally start the search at position x in str1 If the substring is not found then the function returns 0 astring This is a needle in a haystack search needle Offset instr astring search if offset lt gt 0 print mid astring offset len search endif if offset 0 print String not found endif This function does not return a string It returns an integer offset to the first character of the substring that can be used on string STR1 MID LEN 88 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 INT Syntax Description Example Build this program with your editor Output Cautions See Also convert float to integer value INT lt x gt INT returns the next integer value less than the argument The value is returned as an integer The argument must be a float If it is an integer it will be converted to float first inp 5 32987 print int of 8 5F inp 41D int inp print int of 8 5F inp 41D int inp int of 5 32987 5 int of 5 32987 6 Arguments outside the range of Tattletale integers 2147483648 to 2147483647 will result in a run time
22. RMB 164 Assembly Language Subroutines 165 Important Addresses in TFBASIC 168 Interrupt Vector Table 169 CHAPTER 6 77 TFBASIC Internals TFBASIC Structure 172 TFBASIC Integers 176 TFBASIC Floating Point 179 Characters and Strings in TFBASIC 186 TFBASIC Memory Map 189 If you are coming to TFBASIC from TxBASIC 192 CHAPTER 7 795 TFX 11 Interfacing Interfacing to Real World Signals 196 Digital Input Protection 197 Digital Output Protection 198 xvi TFX 11 User s Guide Using the Onboard A D Converters 199 Convert a Bipolar Signal Input to Unipolar 200 Operational Amplifiers 202 Instrumentation Amplifiers 206 CHAPTER 8 207 TFX 11 Hardware Reference TFX 11 Hardware Notes 208 TFX 11 Hardware Reference 209 TFX 11 Board Dimensions 210 The PR 11 Prototype Board 212 Explanation of Connector Pin Functions 217 CHAPTER 9 223 TFX 11v2 Hardware Reference TFX 11v2 Board Pinout and Dimensions 224 TFX 11v2 Board Pinout and Dimensions 225 The PR 11v2 Prototype Board 226 Explanation of Connector Pin Functions 229 CHAPTER 10 235 TFX 11 General Hardware Reference TFX Timekeeping 236 TFX 11 Data Storage Options 239 Guidelines for Storing Data to the Datafile 242 TFX 11 High Level Hardware Description 244 CHAPTER 11 249 Glossary of Terms b TFBASIC Terms and Definitions 250 INDEX 2 TFX 11 User 5 Guide xvii xviii TFX 11 User 5 Guide CHAPTER 1 Getting Started TFX 11 User 5 Guide Componen
23. Reference TFX 11 User 5 Guide Imensitons TFX 11v2 Board Pinout and D t 2 3 5 6 7 vi PiGyee 9 8304MHz Not Placed R25 o ai s ce Vy JY a2KHZ ep ANM Laer 10uF 0 1uF RB7 GND pj s ono LED nae t ua voc He 1510 RBS pa Pe Sigo a E 1 boa E Te 2 22 E t AB HC1iVoo 2 NC Pas Fe 16 spout as He zl mH ex AB Xs i ne Zinc W7 Pa FS as LZ v Gnd 22 E LED RBI VDD uiii cane zB L PAN 21 uc s Hz _Gnd HOSTREO z ABO He eo NC AT ET J RESET N C RAN REF PiCVcc o ouF Ter Ne vss H2 I N C 9 uc PB7ADOR15 Z2 TLC2543 470K M 4N5817 VRH rs Np PB amp ADDR 14 PICAGK A 3 PBS ADDR 13 JA 9 ADB 0 es PeyaboRi2 L2 E pasaooan FS PIC16F873 ADe r8 gt PB2ADDR10 FL PB1 ADDRS FS foo ape 39 ym PBOMADDRS ig Tris PGo EOC Aga ADe 3 17 38 peorano prevappre PL dria CS102 2 PEVADI PFS ADDRS HE TT CS Y AD amp 4 rz PEZ AD2 PFA ADDR4 ra th Gnd 227K 1 Anes ii 1e PEaaDa praabore LS ee EI T 2L pesans pruapoRi HS iw RAV i ADe 6 76 gt 2 amp resape _Provapono PL Tes AO Gnd QNDE Lis ENA i BT PED PO7DATA7 AD8 7 13 vi PCDATAG
24. Syntax VARPTR variable Description This function returns the address of the variable named in parentheses Since variables are defined when they are first used in a program the variable can be used here before being defined elsewhere Also the variable can be an array but it cannot include the index value Be aware that VARPTR returns the address of the most significant byte of the variable The least significant byte VARPTR data 3 Examples print varptr data address of beginning of data array indentation for MSB clarity only print varptr data 3 address of beginning of data array LSB start prog print square of values from 0 to 9 for a 0 to 9 b a a print 5 a b next a print last b value bytes print 02H peek varptr b peek varptr b 1 print 02H peek varptr b 2 peek varptr b 3 end prog See Also PEEK POKE Chapter 4 TFBASIC Language Reference 137 VGET Syntax Description Example Remarks Cautions See Also get variable from user EEPROM value VGET lt expr gt VGET returns the corresponding variable value from the User EEPROM UEEPROM Although there are 128 bytes available in the UEEPROM they can only be assigned to in 4 byte blocks These correspond to locations 0 31 Store and retrieve two bytes and a word in a single loca tion CalValA 124 CalValB 37 CalValC 1027 VSTORE 0 CalValA CalV
25. The format statement in PRINT and STORE commands for fixed point is fw dF where w is the minimum field width of the number including the sign integer part decimal point and fractional part and d is the number of decimal places in the fractional part of the number For instance the number 15 302 would be specified as 7 3F The format for scientific notation is very similar to fixed point w ds but here the minimum field width w must also include the exponent specifier For instance 2 1345E 3 would be specified as 9 4S The w 182 TFX 11 User 5 Guide TFBASIC Floating Point Floating point errors specifier is optional it defaults to a minimum field width of zero and the d specifier is optional it defaults to six decimals places but if d is specified it MUST be preceded by the decimal point Here are some examples of valid formats and what they produce Format for v v 12 345 v 0 987654 10 2F 12 34 0 99 7 28 1 23E1 9 88E 1 6 3F 12 345 0 988 5F 12 34500 0 98765 0F 12 345000 0 987654 0S 1 234500E1 9 876540E 1 Errors in floating point operations do not stop program execution Instead a bit is set in the read only variable FPERR These bits remain set until you access FPERR by copying it to a variable printing it or storing it Then FPERR is cleared to zero If you perform a number of floating point operations that produce different errors FPERR will have more than one b
26. The minimum value this can be is 5 7V Higher threshold values are settable by adding a resistor between the power source and and the LOWBATT input pin See the reference to LOWBATT in Chapter 9 Explanation of Connector Pin Functions In the TFX 11 this variable returns a value that indicates whether the power source is from the main supply or battery backup A value of 0 indicates the main power supply is active and a non zero value means the power source has switched to the backup battery This value has no hidden affect on operation it is provided for you to poll and it is up to you to determine the course of action in the program if this variable returns a non zero value This is a read only variable that can be used anywhere in the program to see if the PIC interrupt is enabled O disabled 1 enabled This variable is set when TFBASIC successfully completes the PICINT command and is reset when XIRQ completes processing of the related interrupt See the PICINT command for more information and example code Chapter 4 TFBASIC Language Reference 43 Program Commands Datafile Storage Commands Functions TFBASIC Quick Reference grouped by function e ASM end e ASM lt addr gt end e CALL x1 x2 v e CBREAK label e CBREAK COUNT v COUNT DIM label size size Assemble HC11 code inline Assemble HC11 code at lt addr gt Call x1 with registers 7 x2 returning in v Go to label if CT
27. cascading two more shift registers 32 inputs can be read at once 74HC165 and 74HC166 Shift sce tci ees Registers rere 0 00 ob yma C 224242424222 Ze ug y F ee geh THC155 SSIPL CK2 GND Yee Mo T4HC163 SSIPL_CK2 GND Yee I O 4 0 5 Remarks O lines 4 5 and 8 will normally be connected to a shift register such as a 74HC165 or 74HC166 as shown above Since the most significant bit of the shift register attached to I O line 8 is always available an initial clock is not needed Thus if you request N bits there will be N 1 clock pulses on I O line 4 Cautions Run time errors will occur if the value in the parentheses is not in the range 1 to 32 See Also SDO 120 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 SDO Syntax Description shift register output SDO value bits SDO lt x1 gt lt x2 gt or SDO lt string gt Form 1 SDO is designed to send a serial data stream made up of the least significant bits of the value The bits are sent out I O line 7 using the positive edge of I O line 4 as aclock After the last shift pulse I O line 6 is used as a positive going latch pulse This works nicely with a 74HC595 shift register pes ee bd espe Do crock qo ALILTLILTETETETL TETTE TEIL ILTL LATCH I O 6 Form 2 The second form of SDO sends characters out the serial line eight bits and then latch Timing Lines used by the SDO Command The fi
28. e PIN x1 x2 e PSET x1 x2 e PTOG x1 x2 PICINT x1 x2 x3 e SDI x e SDO lt string gt e SDO x1 x2 e TONE x1 x2 e HALT HYB x e RATE e READRTC v e RTIME v e SLEEP x e SETRTC V e STIME V Clear specified I O pins to low state Value formed from specified input pins Set specified I O pin to high state Toggle state of specified I O pin Set up external PIC interrupt Shift in x bits Shift out string expression Shift out x1 value using x2 bits Send x2 cycles of square wave of period x1 continuous if x2 0 Stop in lowest power mode Dormant mode Change SLEEP interval timing Transfer hardware RTC time from PIC to local RTC Translate from softtware RTC or variable time in seconds to array Sleep till x 10 ms from last SLEEP Set the hardware RTC time in the PIC Write array data to software RTC or variable 46 TFX 11 User 5 Guide TFBASIC Quick Reference alphabetical TFBASIC Quick Reference alphabetical e ABS x AINT x e ASC str e ASFLT x e ASM end e ASM lt addr gt end e ATN x e BAUDSET x BAUDGET e CALL x1 x2 v e CBREAK label CBREAK e CHAN x e CHR x COS x e COUNT lt v gt COUNT COUNT x DIM label size size Absolute value of x round float down to integer Returns the ASCII value of the first character of the string Interpret x as float Assemble HC11 code inline A
29. enclosure plastic 213 227 END 162 EQU 163 Erase datafile 33 Error Messages TFBASIC 142 escape sequence 187 escape sequences mnemonic 188 numeric 188 Exit 26 EXP 70 182 F FCB 160 FCC 160 FDB 160 Find Again 30 Find 29 FIX 71 182 FLOAT 72 182 Float 44 47 52 263 Floating Point Errors 183 Floating Point Functions 181 FLUSHI 165 FLUSHO 165 FOR 14 73 FPERR 43 183 Functions 44 FVAL 75 G GETBSR 165 GND 218 219 230 231 GOSUB 78 GOTO 79 H HALT 80 Hex display 37 Host Computer Requirements viii HOSTREQ 217 230 HOW error 43 HOW errors 142 HYB 81 l IDE 173 IEEE 754 floating point 126 179 IF 83 INPUT 13 85 Input Protection 197 INSTR 88 Instrumentation amplifier 202 206 INT 89 int 182 Integers 176 interrupt vectors 169 Inverting op amp 202 IRQ 219 232 IVAL 90 J jacks optional 215 228 L Labels assembler 150 LAUNCH 175 Launch 34 174 LED 218 230 LEN 91 LITH 218 Little endian 176 LNCHSTAT 168 Load OS Only 35 258 TFX 11 User 5 Guide LOG 92 182 LOGIO 93 182 Loss of Precision 185 Low Power and Time Commands 46 LT1077 1078 1079 204 M Memory Map 189 MID 94 MODEL 43 monitor 172 173 MRESET 218 230 N NaN 92 93 New 26 NEXT 14 Next 39 Non inverting op amp 203 Not a Number 92 93 184 O Offload Parallel offload 34 XMODEM Offload 33 ONERR 13 95 143 Onset contacting iii Op amp limitation
30. initial final and inc are integer expressions The variable var will first be initialized to the value of the expression initial and then the section of code between the FOR statement and the NEXT statement will be repeated until var is greater than the value of the expression final After each pass var will be increased by the value of the expression inc If STEP and inc are omitted a step value of one is assumed The limit final and step inc are evaluated and stored each time the loop is tested for continuation prints out the sequence 7 14 21 28 35 42 49 X 7 FOR A X TO X X STEP X PRINT 4 A NEXT A 7 14 21 28 35 42 49 This example demonstrates the use of for next loops for formatted print outs FOR A 1 TO 3 FOR B 1 TO 5 PRINT 5 B NEXT B PRINT NEXT A 1 2 3 4 5 i 2 3 4 5 1 2 3 4 5 Chapter 4 TFBASIC Language Reference 73 Remarks Cautions See Also The test for continuation occurs at the beginning of the loop and the STEP and LIMIT expressions are evaluated each time this test is done This allows you to use a GOTO to exit the loop Also because this structure stores nothing on the stack you can nest these loops as deeply as you like and a GOTO can be used to exit any number of FOR loops Use of GOTO to exit a loop while useful in certain circumstances is NOT generally considered good programming practice If you feel the need to use a
31. the PIC is sleeping J3 13 to J3 20 Highest numbered block of the 24 digital I O pins RB0 z1 O16 RB7 I O23 These are on the PIC processor and since they require HC11 to PIC communications rather than direct HC11 port access they are not suitable for high speed toggling used in tone generation for example Use PAO PA7 instead J3 12 Taking this LOW will perform a power on reset of the TFX 11v2 230 TFX 11 User 5 Guide Explanation of Connector Pin Functions vcc GND VBAT GND D0 D7 CSIO1 J4 9 J4 10 5VDC coming from the main LT1521 linear regulator A maximum of 150mA is available from this regulator but the amount available for your project will vary depending on the activity of the HC11 and its peripherals The TFX 11v2 should draw typically 3 5mA at idle to a peak of about 25mA when making conversions allowing about 125 mA for your projects This regulator has short circuit protection reverse battery protection and thermal shutdown Take care not to exceed the power dissipation specification which changes with ambient temperature and battery voltage or the TFX 11v2 will go into thermal shutdown temporarily halting operations until it recovers For more detailed information refer to the L T1521 data sheet supplied in Adobe Acrobat PDF format on the TFTools TFBASIC software distribution disk J4 11 J4 12 System digital ground J4 13 J4 14 Main power input to the TFX 11v2 This input can
32. variables grow downward from the location BFFFh TFBASIC This is dedicated to the TFBASIC token engine Interrupt translate table The interrupts vectors in the HC11 s EEPROM point here Since this area is located in RAM these vectors may be modified for those who might like to write their own ISRs Not for the beginner or the faint of heart EEPROM System Info Area This area contains configuration information stored at time of manufacture for use by ONSET and TFBASIC EEPROM User Area SEEPROM This area contains128 bytes accessed as an array by the VSTORE and VGET commands They have been set aside for user parameter storage The are read and written as four byte variables indexed from 0 31 Bootloader This is the code that loads the program from flash to RAM and starts it executing Interrupt Vectors These are the primary interrupt vectors that point to the interrupt table in RAM Chapter 6 TFBASIC Internals 191 variable Storing to the datafile GETBYT IF and IFF Multiple commands Removed commands String functions PRINT x y removed If you are coming to TFBASIC from TxBASIC The variable now keeps time in seconds You can use this value with no worry of wraparound after 200 days If you need to time events to resolutions of 0 01 seconds use the new stop watch functions listed in the Assembly Language Routines section of the manual The STORE command no longer uses a variable to p
33. 10 from B reg SUBB 256 extended subtract byte at address 256 from B CMPA 255 direct compare A reg with byte at addr 255 LDAA 7 128 extended load A reg with byte at address 896 Chapter 5 TFBASIC Assembly Language Reference 155 Relative Immediate Data test and bit manipulation The branch instructions form a displacement from the address of the byte immediately following the branch instruction to the address that is to be branched to In the form used by the assembler the address is specified not the displacement The assembler will then calculate the displacement You can use either a label or an absolute number to specify the address Examples BNE _NoMore branch if not equal to label NoMore BRA 74COH branch always to address 74COH Relative branches must be within 127 and 128 of the start of the next instruction If the displacement does not fall within this range a tokenizer error will result An immediate instruction deals with a value instead of an address The form of the immediate instruction is shown below MNEMONIC lt expr gt There must be white space tabs or spaces between the MNEMONIC and the There can be white space between the and the lt expr gt The assembler checks lt expr gt and makes sure it is in range 0 to 255 for some commands 0 to 65535 for others Examples LDAA amp H23 load A reg with 35 23H LDD amp H1234 load A B registers with 4660 123
34. 1980 TO 2040 5 input THE MONTH IS 1 TO 12 4 input THE DAY IS 1 TO 31 3 input THE HOUR IS 0 TO 23 2 input THE MINUTE IS 0 TO 59 1 input THE SECOND IS 0 TO 59 0 STOP YEAR IS 0 TO 99 1996 E MONTH IS 1 TO 12 5 E DAY IS 1 TO 31 7 E HOUR IS 0 TO 23 15 MINUTE IS 0 TO 59 23 SECOND IS 0 TO 59 45 mom om om om om STIME lt v gt translates the array to the variable v Time is counted in seconds starting at New Years Day 1980 In both cases dates beyond 2047 are out of range Leap years are handled properly The array is predefined Do not initialize it with DIM RTIME SETRTC READRTC and the section TEX Timekeeping Chapter 4 TFBASIC Language Reference 127 STOP Syntax Description Examples Build this program with your editor indentation for clarity only Output Remarks See Also stop program execution STOP This command stops TFBASIC execution A STOP command is not needed at the end of the program gosub psub Stop psub print A very dull sample program return A very dull sample program A program can have any number of STOP lines HALT RUN 128 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 STORE Syntax Description Example build this program Program s Output Cautions Remarks See Also store to datafile STORE
35. 4 TFBASIC Language Reference 61 CBREAK go to label on CTRL C Syntax CBREAK label Description This command allows you to redirect the flow of your program when it receives a Ctrl C character Normally the program terminates and returns to the monitor If you use the CBREAK command followed by a label name at the beginning of your program it will vector to the label when it receives a Ctrl C character To return to the normal Ctrl C action use CBREAK with no argument Example CBREAK getdata goto getdata when Ctrl C indentation for hit clarity only sleep 0 savedata for icount 1 to 2000 collect 2000 data pts store 2 chan 1 sleep 5 next icount goto savedata reset datafile pointer to start getdata print ready to off load stop This code fragment shows one use for CBREAK When a Ctrl C character is received the program will vector to the code at label getdata and be at the prompt awaiting the command for an XMODEM off load Remarks The Ctrl C handler may be changed any number of times by executing CBREAK with different arguments As with ONERR CBREAK must be executed to be effective For this reason you should put CBREAK near the beginning of the program Disable CTRL C breaks by writing a zero byte to address 9C hex POKE H 9C 0 Beware Some other way of stopping program should be considered or the parallel port connection is the only way to stop it Re enable breaks by writing a
36. GOTO to exit chances are the whole construct could be more effectively coded using a WHILE or REPEAT STEP may be positive or negative but do not use STEP O0 At this time only integer variables and expressions can be used in the FOR loop specification WHILE REPEAT GOTO 74 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 FVAL Syntax Description Examples Output Remarks See Also convert string to floating point value FVAL str FVAL takes a string representing a floating point value and converts it to its numeric floating point variable equivalent astr 1 234e1 aflt FVAL astr print 45 2f aflt 12 34 Valid characters are 0 9 E and e If the number contains other characters it will terminate the conversion at the unrecognized character In the case of 12 3x5 the number returned will be 12 3 If the number evaluated is out of the floating point range it will generate the appropriate FPERR but will not halt the program IVAL Chapter 4 TFBASIC Language Reference 75 GET Syntax Description Example Output Remarks See Also Get n byte value from datafile GET x n GET lt variable gt returns the value of the data in the datafile pointed to by the specified pointer variable x As shown in the examples below this can be used to format readouts as well as manipulate data in the logger s memory Formats 1
37. It is also used to set the TFX 11 internal clock on launch 34 TFX 11 User 5 Guide Suspend TFX 11 Load OS Only Start operating system Syntax check Size of datafile Displays the total number of bytes available for storing data in the SFLASH after the program and other information is stored Bytes stored in datafile Displays is the total amount of data bytes stored in the SFLASH Bytes to off load Enter the number of the bytes in the datafile you wish to off load Places the TFX in its lowest power state Loads only the TFBASIC operating system this requires the parallel cable to be attached This erases any program loaded in the Tattletale so the next time it boots up it will give a sign on message followed by the prompt This returns the TFX 11 to the way it was when it was shipped Reboots the TFX 11 and stops at the prompt in the terminal window Does not start running your program waits for you do that manually Tokenizes the program in the edit buffer and reports errors but does not attempt to load the program into the Tattletale This is affected by the Compiler Options see below Upon a successful check a message displays the size in bytes of the compiled program the size of the program header this is information generated by the compiler and will be added to the front of the program and the size of the variables area used by this program Chapter 3 TFTools Menu Command Reference 35
38. O NIZXL ooran ooods JVgdA QN5 DDA S 0OA OJULSOH MHSHDId X 19Sdd JVgdA QN5 ODA G E EDOA NDVIId OSIWdd ISOWdd day AvSCI TOTSO 0 v d SSA THA 8dv c 8dv T 8qV 0 8dV 225 Chapter 9 TFX 11v2 Hardware Reference The PR 11v2 Prototype Board 11 J1 TFX11 V2 11 J2 STII TR 2 pellecan 2k2 mace SE Cg HH HHTHTHHHHTHTITIHIH HII mE 3 bs i one AM es Rev 2 o 10 22 02 TFX 11 User 5 Guide 226 The PR 11v2 Prototype Board Overview Power connections Optional power jack Communications connectors The PR 11v2 Prototype board was designed to support many different configurations and applications It carries Power Serial and Parallel jacks as well as pads to take common connectors which you may purchase separately and install yourself as necessary The PR 11v2 board outline is designed to fit inside a standard SERPAC A 279V plastic enclosure included in the deluxe development kit The case comes with the parts needed to handle the basic PR 11v2 board configuration as delivered Depending on what optional connectors you install you may have to modify the case to access them The standard configuration includes a 9V battery connector for power a 9 pin mini DIN connector to mate to the Parallel cable and a 3 5mm stereo phone jack to mate to the serial cable When the TFX 11v2 is plugged into the PR 11v2 board the PR 11v2 board provides all t
39. ONERR go to label on error on page 95 Single precision floating point math IEEE 754 is available in TFBASIC along with a number of trigonometric functions See TFBASIC Floating Point on page 179 for more information See Radix Acronym for Integrated Development Environment Standard dialects of BASIC use the keyboard and disk storage for data input In the TFX 11 these inputs are augmented by the logger s analog and digital inputs A number of new commands and functions have been designed to deal with these inputs and outputs simply and efficiently The analog command to get a value from an A D channel is CHAN X where X is the channel to be read The digital I O input read command is PIN X and the digital output commands are PSET PCLR and PTOG See the language reference for more information Labels can be used in the assembly code for flow control and to define local variables Assembler labels can be up to 32 characters long must begin with a letter or an underscore _ and may end with a colon The only valid characters in a label are upper and lower case characters numbers and underscore The label name must start in the first column of the line Assembler label names are not required to be terminated with a colon when defined 252 TFX 11 User 5 Guide Glossary of TFBASIC Terms and Definitions Labels TFBASIC Line Forms Line Numbers Logical Operators Multiple Statements Octal Overflow Quo
40. OR a label terminated with a colon The Motorola reference manual places the control registers starting at location 1000H On startup the TFX 11 relocates these registers to start at location 0 When referencing the control registers in your assembly code don t forget to subtract the 1000H from the addresses given in the Motorola manual to get the correct address Assembly routines can be either executed in line with TFBASIC commands or accessed as subroutines from TFBASIC using the CALL command depending on the argument that follows ASM The assembler built in to the tokenizer assembles from the line after the ASM until it detects the END command The interpreter will switch from interpreting tokens to executing the assembly code when it reaches the 150 TFX 11 User 5 Guide TFBASIC Assembly Language Reference Example Example 1 ASMS statement and go back to interpreting tokens when it reaches the END statement No RTS RTI or other special ending command is needed before the END statement This example shifts each bit of a TFBASIC variable one bit to the left with the most significant bit rotated around to the least significant bit position Note how the TFBASIC variables are handled The name ToBeRotated points to the most significant byte of the variable To access the other three bytes of the variable To get this byte of variable Use this name most significant byte ToBeRotated next most significant byte To
41. Operational Amplifiers For those of you that are not familiar with the terms operational amplifier and instrumentation amplifier this very brief explanation should be enough to get you started Operational The op amp as they are commonly called is an amplifier with both an amplifiers inverting and non inverting input and a single output For our purposes we will treat it as having an infinite gain and no current flows through either input Three commonly used circuits for op amps are shown in the figure below with the designating the inverting and the designating the non inverting inputs inpu sm Vi R1 es output INVERTING put output Vi Vo R1 R2 NON INVERTING Input output Vo UNITY GAIN BUFFER The inverting op The inverting circuit has a gain of R2 R1 This makes sense since the op amp amp will do what is needed to keep the and inputs at the same configuration voltage and any current flowing into the input resistor R1 will also flow through the feedback resistor R2 An input voltage Vi will cause a current Vi R1 and cause an output voltage Vo of R2 Vi R1 Note the minus sign the current flows through R2 away from ground if the current 202 TFX 11 User 5 Guide Operational Amplifiers The non inverting op amp configuration Unity gain buffer op amp configuration through R1 is flowing toward ground An op amp is not magic and it cannot give an output that is larger than
42. Stopwatch functions 166 STORE 129 STPWCH 166 STR 130 STRBSR 165 String functions 186 String handling operations 187 Strings in TXBASIC 186 STRMEM 165 Suspend TFX 11 35 Syntax check 8 35 syntax error 172 T TAN 131 182 technical assistance ix TEMP 132 TEMP 12 Terminal Window 18 TFBASIC Assembly Language 150 TFBASIC summary 40 TFBASIC Important Addresses in 168 TFTools menu commands COMMPORT 37 EDIT 27 FILE 26 HELP 40 SEARCH 29 TATTLETALE 33 WINDOWS 39 TFTools Tutorial 4 TFTools Introduction to 18 TFX 11 Features iv TFxBASIC LANGUAGE OVERVIEW v thermistor 10 132 Tile 39 Timing 121 TLC1078 205 Token Engine 172 token interpreter 172 Tokenizer 172 TRACE 168 Transistor 197 ART 166 DI 217 229 DO 217 229 EEPROM 138 139 nderflow 184 ndo 27 nity gain buffer 203 RTGET 165 RTSND 166 RTTST 166 SEND 136 lt dCoc cocco cuc VARPTR 137 VBAT 218 231 VCC 218 219 231 VERS 43 VFET 197 VGET 138 VRH 220 232 VRL 220 232 VSTORE 139 Ww Warranty ix WHILE 140 X XMIT 44 49 141 263 XMIT 141 260 TFX 11 User s Guide Chapter 261 262 TFX 11 User 5 Guide ABS x AINT x ASFLT x ASM end ASM lt addr gt end ATN x BAUDSET BAUDGET CALL x1 x2 v CBREAK label CBREAK CHAN x COS 3 COUNT v FLOAT x X siinriisser dus TFBASIC QUICK REFERENCE Absolute value of x rou
43. TFBASIC Language Reference for the TFX 11 RATE Syntax Description Example code Change sleep interval RATE x This command assigns a new value for the sleep interval duration By default a SLEEP 1 equals 10ms so a SLEEP 100 gives a 1 second interval This is equivalent to RATE 1 Other acceptable values for RATE are Sleep interval RATE ticks sec ms 1 100 10 0 2 200 5 0 3 300 3 33 4 400 2 5 6 600 1 66 8 800 1 25 12 1200 833 16 1600 625 24 2400 4166 32 3200 3125 48 4800 20833 64 6400 15625 96 9600 104166 128 12800 078125 192 19200 0520833 for index 1 to 5 print print seconds sleep 100 sleep for one next index RATE 2 twice as many for index 1 to 10 print print seconds sleep 100 sleep for one next index RATE 1 return to default RAT count second interrupts per second count half second Fl Chapter 4 TFBASIC Language Reference 109 Remarks Cautions See Also variable timekeeping update rate is NOT affected by different RATES but is always updated 100 times a second Actual update time may be delayed slightly when using higher RATE values Using values for RATE not in the table will cause a run time error Using a high RATE may cause sleep overruns where there were none before Use this command with care SLEEP and STPWCH example program in Chapter 5 section assembly language subroutines 110
44. TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 READRTC Syntax Description Example code load PIC RTC time to local variable READRTC or READRTC lt v gt READRTC takes the 4 bytes from the PIC RTC in seconds and copies it directly into the variable or optionally into the variable provided as an argument This time is counted in seconds starting at New Year s Day 1980 Start loop input Set time Y N answer 1 if answer lt gt Y amp answer lt gt y goto start endif input year no input month 4 input day 3 input hour o t2 input minute 1 input second 0 print print out time print 02 5 4 3 print 402 2 2 TU 2 Chy 7 2 609 print stime convert array to variable SetRTC also copy this time to PIC ReadRTC get back time stored in the PIC sleep 0 rtime convert variable to real tim print 02 2 5 2 4 2 3 print 402 92 2 ly 7 200 NI3 sleep 100 goto loop Chapter 4 TFBASIC Language Reference 111 Output Set time Y N y year 99 month 12 day 2l hour 23 minute 59 second 45 99 12 31 23 59 45 1999 12 31 23 59 45 1999 12 31 23 59 46 1999 12 31 23 59 47 1999 12 31 23 59 48 1999 12 31 23 59 49 1999 12 31 23 59 50 1999 12 31 23 59 51 1999 12 31 23 59 52 1999 12 31 23 59 53 1999 12 31 23 59 54 1999 12 31 2
45. These are on the PIC processor and since they require HC11 to PIC communications rather than direct HC11 port access they are not suitable for high speed toggling used in tone generation for example Use PAO PA7 instead B21 Taking this LOW will perform a power on reset of the TFX 11 B22 5VDC coming from the main LM2936 linear regulator A maximum of 50mA is available from this regulator but the amount available for your project will vary depending on the activity of the HC11 and its peripherals The TFX 11 should draw typically 3 5mA at idle to a peak of about 25mA when making conversions allowing about 25 mA for your projects This regulator has short circuit protection reverse battery protection and thermal shutdown Take care not to exceed the power dissipation specification which changes with ambient temperature and battery voltage or the TFX 11 will go into thermal shutdown temporarily halting operations until it recovers For more detailed information refer to the LM2936 data sheet supplied in Adobe Acrobat PDF format on the TFTools TFBASIC software distribution disk B23 System digital ground B24 V side of CR2032 Lithium backup battery B25 Main power input to the TFX 11 This input can be in the range 5 5V to 18V but care must be taken so as not to exceed the maximum power dissipation that would result in thermal shutdown of the regulator See the LM2936 data sheet for more information 218 TFX 11
46. Use Cut or Copy to save text in the clipboard Removes the currently selected text without saving a copy in the Windows clipboard You can undo a Clear but not after you ve moved the cursor Inserts a text string with the current date and time according to the computer s clock into the document If the terminal window is currently selected a string with the date and time is sent out the serial port to the TFX 11 The default format of the string is 09 03 02 11 50 54 where 09 is the month 03 is the day and 02 is the year To insert a string showing the full year select Editor options and select the Paste date time 4 digit year checkbox Chapter 3 TFTools Menu Command Reference 27 Editor options Controls settings in the editor window with the following dialog lolx Tab size a Autoindent mode Paste date time 4 digit year DK Cancel Tab size This field sets the number of characters a tab uses when indenting code The default tab size is 8 Autoindent mode This controls whether code is automatically indented Paste date time 4 digit year This sets the format of the year in the date time string to all 4 digits instead of 2 28 TFX 11 User 5 Guide SEARCH Search Find Find again F3 Replace Go to line Find Searches for a string in the active editor window with this dialog Type the string you wish to search for in the Find field The la
47. a 10k resistor and a p channel FET The resistor 10k 0 196 biases the thermistor and together they form a resistor divider the center of which is tapped to obtain the temperature signal The FET acts as an ON OFF switch that is used to supply power to the thermistor whenever a temperature measurement is made 10 TFX 11 User 5 Guide Build a Data logger One Step at a Time Enter this program into the editor The Commands SLEEP PSET and PCLR sleep 0 start sleep 100 pelr 5 print temp chan 10 pset 5 goto start stop The example code above prints the temperature out on the HOST terminal display Five commands unique to TFBASIC are used SLEEP TEMP PSET PCLR and CHAN These commands are fundamental to many data logging and control applications and are explained below Be sure you have a good understanding of how they work before proceeding The SLEEP instruction combines two important features precise timing and power conservation Each count of the SLEEP argument represents 10 ms 1 100 of a second so SLEEP 100 sets the SLEEP countdown timer for one second When using the SLEEP function it should always be first initialized by a SLEEP 0 instruction This resets the SLEEP timer When a SLEEP command is invoked it checks the already running SLEEP timer from the previous SLEEP command to see if it has expired If not it waits in a low power mode until it does expire When the timer finally expires t
48. a symbol name that can be used anywhere a constant is expected The location controls allow you to set or modify the location counter the address to which code is assembled Notice that the TFBASIC command ASM is in two categories Source control ASM Start assembly source See TFBASIC Command ref END End assembly and return to TFBASIC Data declarations DATA Declare initialized data IEEE DB Define Byte Intel FCB Form Constant Byte Motorola DW Define Word Intel FDB Form Double Byte Motorola FCC Form Constant Characters Motorola Symbol EQU Assign value to symbol declarations Location control ALIGN Force location counter alignment RES Reserve uninitialized data DS Define Storage Intel RMB Reserve Memory Block Motorola Chapter 5 TFBASIC Assembly Language Reference 157 Details of the TFBASIC Assembler Directives 158 TFX 11 User 5 Guide Details of the TFBASIC Assembler Directives ALIGN Syntax label align expr comments Description The align directive forces the location counter to align to a boundary that is a multiple of the value specified by the expression in the operand field Examples align lign goopogononnvonmp Q m lign Q w ct w 2 word 4 Long 256 page 32768 huge i byte align align align align on word boundary on long boundary on page boundary on enormous
49. always read from the same location When a variable is used it is updated to ppoint to the next location after the end of the string GETS assumes that the first byte is the length of the string this is how STORE puts strings in the datafile unless the option is used in STORE GETS returns a string that can be assigned to another string variable or used as an argument to another command This assumes the string was stored in with the length byte astring This is a test string x DFPNT store astring print gets x This is a test string This function can be used anywhere a string variable or string constant would be used GETS will not work properly on strings that have been stored using the option GETS depends on the first byte of the stored string being the length byte The does not allow the length byte to be stored in the datafile If GETS is used and the target is not a string it will not generate an error it will read the first location as the number of bytes to return and then return that number of bytes as a text string If the bytes are not in the ASCII Range 32 127 it will still try to display it as text but most likely it will appear as garbage GET Chapter 4 TFBASIC Language Reference TI GOSUB Syntax Description Examples Build this program with your editor indentation for clarity only Program Output Remarks See Also GOSUB label RETURN go to subrou
50. applications we ve tested check radioshack com for current prices and ordering information at press time it was 6 49 Its electrical current is very limited so if you add external circuitry make sure it can deliver the current or the TFX 11 will not power up properly After you ve connected the serial cable and powered up the TFX 11 correctly do not plug the parallel cable in yet you should see the Tattletale sign on message in the terminal window as shown below Tattletale Model 11 00 TFBASIC Version 2 00 C 2002 Onset Computer Corp All Rights Reserved Don t worry if your TFBASIC version number is different as long as it is greater than 1 00 If the TFX 11 signed on then skip the following Troubleshooting steps and go directly to TFTools Tutorial Step by step on page 7 Otherwise continue with the following Troubleshooting section Let s go over the likely causes Make sure the parallel cable is not plugged in The parallel cable should be connected to TFX 11 only after power has been supplied If the parallel cable is attached before power is supplied the TFX 11 may not power up correctly The parallel cable connects the DB25F printer connector on the host computer to the 9 pin mini DIN connector on the PR 11 board This cable allows high speed offload of data stored to the flash as well as the ability to record your program in the flash A program stored in this manner will be copied to RAM and executed at powe
51. are on the board to allow mounting of a jack KYCON KLD 0202 A compatible with standard wall mount DC power supply modules The thru holes for this connector are used to attach the tie wrap used as a strain relief for the 9V battery connector This tie wrap must be removed to install the jack When this connector is used the 9V battery compartment will no longer fit inside the case The mating connector of the DC power supply must have a 2 1mm inside post which must be ground BE SURE THE POLARITY IS CORRECT BEFORE CONNECTING The Backup battery is not a requirement for operation of the TFX 11 but can be useful in some applications Important Note Simply inserting a battery into the PR 11 battery holder does not automatically provide battery backup The backup battery circuitry allows a separate power supply to be connected to TFX 11 It should be somewhere between 3 3V and 4 75V It cannot exceed 5V or damage to the TFX 11 may result If Chapter 8 TFX 11 Hardware Reference 213 Important design notes for those intending to use the backup battery below 4 5V the main power must be applied before the backup battery is inserted or the logger may not start up properly As long as the main power is attached the backup battery is electrically disconnected from the circuit by the ICL7673 NOTE The backup battery has a 1M resistor across it This is to allow proper operation with the battery removed The backup battery allows reten
52. assembly routine embedded in your TFBASIC program The register list is available in TFTools help For detailed information on these registers and what they control consult the Motorola MC68HC11F1 Technical Data Book and the Motorola MC68HC11 Reference Manual System Variables This is the HC11 s on board RAM It is used by TFBASIC to keep track of its operations Your code should neither read nor write within this area Reading while generally a benign activity will not give you any useful information and future revisions of the software may modify this area Therefore any code written to depend on values read from this area is risky at best Writing to this area is a sure recipe for disaster I O memory Can be mapped for CSIO1 and CSIO2 chip select addressing Refer to the Motorola MC68HC11F1 technical manual for details If not used with chip selects it is available as a general purpose RAM System Buffers This area contains the UART buffers and other similar TFBASIC structures Keep out 190 TFX 11 User 5 Guide TFBASIC Memory Map 1200h 12FFh 1300h 13FFh 1400h BFFFh C000h FDCOh FDC1h FDFFh FEOOh FE5Fh FE60h FEDFh FEEOh FFD5h FFD7h FFFFh Hardware Stack Do not touch Parameter Stack Keep out User Program code and Variable area The lowest part of this area contains the TFBASIC tokens and other code to be executed by the TFBASIC token engine It grows up from the low address The user
53. be adversely affected by the background task The foreground task is defined as starting with the first line of the program The background task can only be launched from the foreground task using the RUN command as described in the command reference Once the background task begins it only returns control to the foreground if it executes a STOP or a SLEEP a If the background task executes a STOP only the foreground task can start it again b If the background task executes a SLEEP the foreground runs again but is interrupted every 10mS or the rate chosen with the RATE command to check if it s time to end the background SLEEP Once the background SLEEP expires the background task has full control When a background task is running the SLEEP timing for the foreground is no longer rigorous it s easy to oversleep So the print is disabled for the foreground task only while a background task is running To distinguish between SLEEP commands the background task prints a tilde if it oversleeps instead of All TFBASIC variables are global That is they are available to both the foreground and background They can be used to pass messages or flags between the two tasks The example below shows how the foreground can signal the background to stop itself when the time is ready Use the RUN command to launch a background task Follow the RUN with the label of the routine you want to execute in the background
54. be in the range 5 5V to 18V but care must be taken so as not to exceed the maximum power dissipation that would result in thermal shutdown of the regulator See the LT1521 data sheet for more information J2 11 J2 12 System digital ground J3 1 to J3 8 HC11 External Data Bus signals When TFBASIC is running the HC11 is in expanded operating mode Therefore these lines default function is as the external data bus These lines may be used with signals CSIO1 CSIO2 AO R W and E to add memory mapped external devices 41 14 Indicates direction of transfers on external data bus 1 13 This is the E clock output It is crystal frequency divided by 4 When the E clock is low the HC11 is processing When high there is a data access taking place J1 17 First user available chip select that is mapped to range 400h 7FFh when enabled Default for the TFX 11v2 is disabled Requires understanding of the HC11 and assembly language programming to access See the MC68HC11F1 technical reference for more information NOTE Be aware this line may be used in the future by ONSET to attach memory expansion devices to the TFX 11v2 Chapter 9 TFX 11v2 Hardware Reference 231 IRQ PGO EOC CSIO2 AO PAO PA7 AD8 0 AD8 7 VRL VRH J1 20 Falling edge sensitive maskable interrupt to the HC11 CPU Set to edge sensitive at reset May be used for early wakeup from HYB Sensitivity may not be changed by user Not used by
55. by a programming logic accidental restart or other error The SFLASH holds both the program and the data Therefore the amount of data storage is impacted slightly by the size of the program Given the largest program there will be a minimum of 405k for data Use the DFMAX read only variable from inside your program to report the exact amount available This storage is best suited to holding data that does not need to be referenced once written This storage is non volatile The information written into it will remain intact even if all power including the battery backup power is removed Even if the other components are not functioning it may still be possible to read out the data from the SFLASH Chapter 10 TFX 11 General Hardware Reference 241 Data Storage Issues STORE Command Trade offs Recommendations Guidelines for Storing Data to the Datafile The ultimate task of a datalogger is retrieval of the data accurate and complete The TFX 11 has been designed to support these goals and at the same time to be simple yet flexible in the operations of storing data to and retrieving data from the datafile The integral non volatile memory offers a safeguard against accidental data loss due to power loss The STORE command offers several options for formatting your data for storage The two fundamental format choices for a datum value are text ASCII and binary String format is another way of saying text forma
56. in the non volatile flash memory along with the TFBASIC operating system To write the program to flash first connect the parallel cable and then select Launch from the Tattletale menu instead of Run This will load the program and start its execution Once loaded the user program will execute from the beginning at power up or when you select Relaunch from the Tattletale menu To erase the program and get the prompt back select Load OS only from the Tattletale menu Chapter 1 Getting Started 15 16 TFX 11 User 5 Guide CHAPTER 2 The TF Tools IDE TFX 11 User 5 Guide Understanding the TFTools Integrated Development Environment Introduction to For latest release information please be sure to read the README files TFTools on the distribution disks TFTools for Windows provides a complete interactive programming environment for developing and maintaining programs for the TFX 11 TFTools includes a programming editor for writing and debugging TFBASIC and a terminal program for uploading and downloading data and programs between the host PC and the TFX 11 This chapter explains the basics of working with the primary components of the TFTools IDE For details on specific menu commands refer to Chapter 3 TFTools Interface Title bar Menu bar E TFTools for Windows ee File Edit Search Tattletale CommPort Window Help Terminal Window 19200 Comi CaptoffA Hexoff Scrollott 1479
57. is a parse error TFTools x parse error OK n2 18200 Com2 CaptoftA Hexoff Scioloff 3090 TFX 11 User 5 Guide A Short TFTools Tutorial Parse error Fix that error This error was introduced intentionally to demonstrate how the integrated parser detects syntax errors in your programs The parser does a syntax check that detects common syntax errors such as misspelled keywords or missing arguments but it does NOT detect programming logic errors Press Enter or click OK to close the parse error message The cursor is placed in the line but not necessarily the exact spot with the error In this example program the cursor forx has the syntax error it s missing a space Add a space between for and x Press ALT Y to perform another syntax check or from the Tattletale menu select Syntax check again If your correction was successful a No Errors message should be displayed 3 TFTools for Windows File Edit Search Taltletale CommPot Window Help gt C WINDOWS Desktop TFT ools DebugMe tib for x 1 to 18 print Hello next x Information for Tokenized Program Program size 43 Program header 14 Variables size 4 cJ 18200 Com2 Captott Hex oft Scrofloft 3090 The No Errors message signals that the parser did not find any errors The Syntax Check command tokenizes the program in the edit buffer and reports any errors but d
58. its positive supply or lower than its negative supply The TFX 11 has a regulated 5V but its negative supply is ground so most applications will supply the op amp with ground and 5V This makes it impossible to use the inverting circuit as drawn unless the input is a negative voltage Advantages R1 protects input from external voltage Disadvantages To get a large gain R1 must be small loading the input Requires the input signal be negative for the positive signal needed by the TFX 11 Following the same analysis we did for the inverting configuration we find that the gain of the circuit is R1 R2 R1 for the non inverting circuit In this case we are limited to positive inputs since the TFX 11 has no negative supply Advantages High input impedance will not load down your signal Source Disadvantages Takes a positive input only To handle a negative input in a Tattletale TFX 11 application would require adding a negative supply to the Tattletale TFX 11 The analysis for this configuration is simple Since one of the fundamental operational rules of op amps states that the output will do all it can to make the and inputs equal to each other we can see that the input will follow the output Since the signal is directly into the input the impedance is essentially infinite and the output impedance is zero theoretically of course Again we are limited to positive inputs since the TFX 11 has no negative supply Real o
59. mistake CALL and the TFBASIC Assembly Language manual section Chapter 4 TFBASIC Language Reference 57 ATN Syntax Description Example Output Remarks Cautions See Also arctangent value ATN lt x gt ATN returns the angle in degrees of the expression in the parenthesis The function takes a floating point argument and returns a floating point value An integer argument will be converted to float first tangnt 1 0 degrees 0 0 degrees atn tangnt print The arctangent of 7 1F tangnt is 6 3F degrees The arctangent of 1 0 is 45 000 If the argument is inf the result is 90 0 If the argument is inf the result is 90 0 DON T FORGET The result is in degrees not radians COS SIN TAN S8 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 BAUDSET Syntax Description Remarks Cautions See Also Set the baud rate of the main UART Baudset x Sets the send and receive baud rate of the main UART to the selected baud where x baud Baud is one of these 300 600 1200 2400 4800 9600 19200 or 38400 The default baud rate on reset is always initialized to19200 DON T FORGET Changing the baud rate on the TFX 11 will NOT automatically change the baud rate of TFTools If the baud is set incorrectly CTRL C will no longer work to break the program BAUDGET Chapter 4 TFBASIC Language Reference 59
60. more commands ELSE cCommand block 2 ENDIF IF expression statement ELSE statement IF allows you conditional control of your program If the expression is true does not evaluate to 0 command block 1 is executed Otherwise if the ELSE block exists command block 2 is executed The ELSE block is optional but the ENDIF is not If one of the operands of the comparison is a floating point value the integer is treated like a float and the operands are compared as floating point values input Value if Value 100 execute block 1 if Value 100 print The value Value is 100 not allowed Value 100 end of command block 1 else otherwise execute command block 2 print The value is NOT greater than 100 OK endif end of command block 2 print Value Value 27 The value 27 is NOT greater than 100 OK Value 27 127 The value 127 is 100 not allowed Value 100 Chapter 4 TFBASIC Language Reference 83 Alternate Form if i gt 10 amp i lt 20 print Value between 10 and 20 Examples if i 100 print Value 100 else print Value 100 if char A gosub Acommand if char B goto Bcommand if value gt 100 flag 1 else flag 0 Remarks The result of a comparison using one of the relational operators is O for false and 1 for true Do not write programs depending on this however See Also Relational Operators 84 TFX 11 User 5 Gu
61. need to connect external sensors and devices to its different I O ports Understanding of the capabilities and limitations of the different I O options available is critical to completing an instrument or device that works reliably and repeatably The following sections review general issues associated with interfacing your Tattletale TFX 11 to the outside world We hope this will give you some background and ideas that will help you make the best choices for your design Admittedly this section is brief for more detail we recommend you read some of the books listed as references especially the Motorola HC11 manuals and The Art of Electronics by Horowitz and Hill 196 TFX 11 User 5 Guide Digital Input Protection 1 Digital Input Digital Input uH a Digital Input V neme Digital Input Digital Input Digital Input Protection Digital inputs must be protected from signals that exceed the TFX 11 s internal bus supply levels The diagrams below show five techniques that protect the inputs from large current spikes which may cause latch up Resistor The resistor protects the input from surges by limiting the amount of current that can be injected A typical value might be 100K R C Adding a capacitor helps protect inputs from high voltage spikes caused by electrostatic discharge The combination of resistor and capacitor here forms a low pass filter which changes the response to high speed signals whic
62. of high quality easy to use data logger controller engines with the latest in compact low power high performance components and technology The Onset supplied development software features the TFTools Integrated Development Environment IDE for Windows greatly simplifying program development with Onset s TFBASIC programming language TFBASIC is a tokenized version of BASIC with language extensions added by Onset to greatly simplify common data logging and control functions The TFX 11 hardware combines large non volatile data storage capacity and microampere range low power modes with extremely small size The resulting developer s package is well suited to rapid development of intelligent instruments from a simple temperature logger to a complicated long term remote logging and control device Note There are two versions of the TFX TFX 11 and TFX 11v2 When the term TFX 11 is used in this manual it refers to both TFX versions unless otherwise specified e Ultra low power mode Less than 100UA HYB mode 50pA typical Wide input voltage range for power supply 5 5 18 VDC with thermal shutdown protection 128k battery backed RAM for R W datafile and program Development communication and SFLASH program data upload and off load via standard PC parallel port e 11 channel 12 bit A D converter 8 channel 8 bit A D converter each channel may be optionally configured as a digital input 16 TTL Digital I O pins t
63. pins are handled in sequence as three blocks First the pins in the block 0 7 then the pins in the block 8 15 and finally the pins 16 23 On the original TFX 11 I O pins 8 15 do not correspond sequentially to their proto board pin numbers PSET PCLR PTOG 102 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 POKE place byte into RAM Syntax POKE lt addr gt lt value gt POKE lt expr1 gt lt expr2 gt Description This command stores the least significant byte of the value of the expression lt expr2 gt at the address that results from the evaluation of the expression lt expr1 gt Examples poke amp H74C0 123 b 123456789 write 123456789 to locations for a amp H74C3 to amp H74CO step 1 112H 115H msb first poke a b 256 b b 256 next a Remarks This modifies memory directly and should be used with care Its use is restricted to the 64K bank of program memory See Also PEEK VARPTR refer to list of interesting memory addresses Chapter 4 TFBASIC Language Reference 103 PRINT String examples Value examples Syntax Description Strings Values Using PRINT with Formatting Example print to console PRINT string Zformat value A ascii val PRINT lt s gt n lt x gt lt x gt any order or mix PRINT can be used to write values strings individual characters and blocks of the datafile to the hardware
64. print print All background activity done stop stop foreground after b g stopped firstBG sleep 0 Start of Background Task 1 Chapter 4 TFBASIC Language Reference 145 foreground sets A to 1 to stop loopl if A lt gt 0 goto exitl print Executing task 1 sleep 200 message every two seconds goto loopl exitl A 0 acknowledge receipt of message stop end background task 1 secondBG sleep 0 Start of Background Task 2 foreground sets B 1 to stop loop2 if B lt gt 0 goto exit2 print Executing task 2 sleep 100 this messag very second goto loop2 exit2 B 0 acknowledge receipt of message stop end background task 2 The program has two possible background programs One labeled firstBG and the other labeled secondBG The foreground program starts the background task works for 10 seconds and then sends a signal to the background to stop itself This is important There is no way for the foreground to stop the background directly This allows the background to clean up before it stops Otherwise it could be in the middle of an operation when a foreground task brought it to a halt with some operation only partially done Notice that the SLEEP command can be used in the foreground and background simultaneously Separate SLEEP counters are reserved for each task The background takes precedence though so foreground SLEEP timing is not rigorous if a background task is running The overslee
65. problems we support by reading the following paragraphs Onset provides support for its software only and does not provide instruction in how to program It is expected that you have some familiarity with programming principles and language constructs We provide an introduction to data logging computing and code examples in the text of this user s manual and on disk to help you make the transition from software only to software dependent hardware control and data logging Onset provides support for its hardware only when it does not appear to meet our published specifications or otherwise perform as advertised Onset does not provide instruction in electronics and electronic instrument design other than what is included in this manual and related application notes Also as it says in the disclaimer Onset does not guarantee its code to be free from errors It is again assumed you have some familiarity with electronic principles and practices or have access to someone who does We try to provide an introduction to data logging fundamental concepts and techniques and simple demonstration code examples in this user s manual with the source code to most examples reproduced on the disk Hardware will be repaired or replaced at Onset s discretion if found to be defective in materials or workmanship for a period of one 1 year Software will be replaced only if the disk supplied is found to be defective All the programs and other files are
66. raised to 0 125 is 1 133 To raise the value X to the power Y use the equation value exp Y log X For this to work correctly X must be greater than 0 and Y log X must fall into the valid range for exp arguments see Cautions below Beware that these numbers lose accuracy as X or Y approach their limits The range of input arguments is 87 33654 to 88 72283 Arguments greater than 88 72283 will result in a floating point Overflow error FPERR 2 with the result equal to INF Arguments less than 87 33654 will result in a floating point Underflow error FPERR 1 with the result equal to 0 0 In both cases execution is not stopped LOG 70 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 FIX Syntax Description Example Output Remarks Cautions See Also convert a float to an integer value FIX lt x gt FIX returns the next integer value closer to zero than the argument The function takes a floating point argument and returns an integer value An integer argument will be converted to float first and then converted back to integer build this program with your editor finp 5 329 result fix finp print fix of 8 3f finp 5 1D result result fix finp print fix of 48 3f finp 1D result fix of 5 329 5 fix of 5 329 5 None Arguments outside the range of Tattletale integers will generate a runtime error halting
67. registry Port Settings Com Port Baud Rate C 300 C 4800 C 600 C 9600 C 1200 19200 C 2400 C 38400 COMI Release Comm Part if TFT ools inactive Cancel All available COM ports are listed and the baud rate default is set to 19200 Check the Release Comm Port if TF Tools inactive box if you want to open the COM port any time TFTools is not being used only necessary if you are sharing the COM port with another device Hex display Toggles the terminal window into and out of hexadecimal display mode In this mode any incoming characters are displayed in hexadecimal form in rows of 16 characters on the left side of the screen The ASCII printable equivalent is displayed in 16 character rows on the right side of the screen Toggling this mode always forces output to start on a new line Chapter 3 TFTools Menu Command Reference 37 Capture to file Saves the characters in the terminal window to a file which is useful for debugging or direct recording and storing of data The first time you select this command in a session you are prompted for a file name to save the characters Either accept the default name capture txt and directory or specify your own name and or directory Once the file is open and active you can toggle the capture mode on and off press Alt Z or click the CAPT box in the terminal window s Status line Capture to file does not remain on when you exit TFTo
68. root value SQR lt x gt SQR returns the square root of the expression in parentheses This function takes a floating point argument and returns a floating point result If the argument is an integer it will be converted to float first Start input SOR argument print F sqr argument dgoto start SQOR 1 1 000000 SOR 2 1 414214 SQR 4 2 000000 SQR 100 10 000000 SQR 1000 31 622778 SQR 1000000 1000 000000 SQR 123 4 11 108556 SOR 1 NaN Not a Number because sqr 1 is imaginary SOR 16 4 000000 Note the NaN error didn t stop program Taking the square root of a negative number returns a value of Not a Number specified by the IEEE 754 floating point specification This will not stop program execution It sets the Not a Number bit in the floating point error variable FPERR EXP 126 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 STIME Syntax Description Examples build this program with your editor Output Remarks Cautions See Also set local software real time clock STIME or STIME v STIME translates the seven element array to the variable Time is counted in 1 100ths of a second starting at New Year s Day 1980 This command with RTIME allows setting and reading the Tattletale s real time clock The seventh element 6 is read only input THE YEAR IS
69. running counter called the interval counter that is incremented every 1 100 of a second When a match is found it clears the interval counter and completes the instruction In this manner the SLEEP command actually sets intervals between SLEEP commands and accordingly is independent of other timing delays If the comparison shows that the interval counter has a larger value than the tics value specified by the command the warning will be printed to the primary UART At the same time the Isb of the OVRSLP system variable is set You may check this flag by using the command PEEK amp H9E and using POKE amp H9E 0 will clear it If tics 0 no check is made but the interval counter is reset to zero The maximum value of the parameter tics is 32767 m i 1 5 6 7 8 9 97 98 99 00 COUNTER INTERRUPT GU IHTEFHAL 10 miS The figure above shows the timing for a SLEEP 100 command that was separated from the previous SLEEP command by commands that took about 65 mS to execute If the intervening commands had taken more than a second the current drain would not have dropped the interval counter would have been reset to zero and a would have been sent out the hardware UART HYB RATE RUN Chapter 4 TFBASIC Language Reference 125 SQR Syntax Description Examples build this program with your editor indentation for clarity only run it in TFTools Remarks See Also square
70. shown above Note You may want to add your own sign on message using the PRINT command TFBASIC programs no matter how launched will break with a CTRL C unless a CBREAK command has been used to specify a line number to restart to when a CTRL C is encountered You can disable CTRL C breaks by writing a zero byte to address 9C hex A count of CTRL C characters will continue to be updated at address 9B hex Clear this before you re enable break outs See CBREAK On power up TFBASIC copies the program and operating system to RAM and launches that program Remember that the program will always 174 TFX 11 User 5 Guide TFBASIC Structure break out upon finding a CTRL C unless a CBREAK command has been used to specify a label to vector to when a CTRL C is encountered Making your Using the LAUNCH command will erase the contents of the datafile and program reset the datafile pointer to O It then replaces previously the stored permanent program if any with a fresh copy of the TFBASIC token interpreter engine and your compiled program tokens Chapter 6 TFBASIC Internals 175 Internal representation Assigning A D conversion values to a TFBASIC variable Big endian vs Little endian TFBASIC Integers Integers are represented as a signed sequence of 32 bits arranged as four bytes The format is as follows MSB byte 2 byte 3 LSB SBBBBBBB BBBBBBBB BBBBBBBB BBBBBBBB where S is the sign bit and B repres
71. space character or tab in front of them on the line or a label terminated with a colon The single byte instructions like NOP and RTS can be preceded and or followed by an arbitrary number of spaces and tabs These instructions use the X register as a pointer They have the form MNEMONIC lt expr gt X where lt expr gt is a positive offset and must evaluate to a number in the range of 0 to 255 and the X upper or lower case must follow the comma without any intervening space Examples LDAA 0 X load A reg with byte pointed to by X STAA 7 8 4 X store A reg at address contained in X 52 Extended instructions may address within the full 64K memory space They have the form MNEMONIC lt expr gt If lt expr gt evaluates to a number outside the range of 0 to 65535 the assembler in the tokenizer will print an error message Examples LSR H 74CO0 logical shift right of the byte at 74COH ROL 118H rotate byte at 118H left through carry Many instructions have shortened versions called direct by Motorola for addressing page zero memory address 256 as well as full length versions for addressing all of memory The direct version of the instructions takes two bytes instead of three The assembler first evaluates the lt expr gt If the result is in the range 0 to 255 the assembler uses the direct form otherwise the assembler uses the extended form Examples SUBB 10 direct subtract byte at addr
72. the TFX 11v2 operating system Requires understanding of the HC11 and some assembly language programming to access See the MC68HC11F 1 technical reference for complete information J1 16 Used to read the 12 bit A D converter end of conversion signal J1 18 Second user available chip select that is mapped to range 800h FFFh when enabled Default for the TFX 11v2 is disabled Requires understanding of the HC11 and assembly language programming to access See the MC68HC11F1 technical reference for more information NOTE Be aware this line may be used in the future by ONSET to attach memory expansion devices to the TFX 11v2 41 15 Lowest external address line Used to qualify reads and writes for some peripherals attached to the data bus J2 11 to J2 18 Digital I O pins corresponding to pins l OO I O7 J1 1 to J1 8 8 bit A D converter inputs These pins also act as digital inputs when used with the PIN command The corresponding PIN parameters are I O 8 to I O 15 and the corresponding CHAN parameters are 11 18 Note that AD8 1 thru AD8 6 do not necessarily match connector pins A27 A32 in sequence Refer to the connector reference for the PR 11v2 or TFX 11v2 boards for the correct sequence J1 11 Provides the LO reference voltage for the HCII on board 8 bit A D converter This pin is connected to Vss through a 0 Ohm resistor R23 The resistor may be removed if you want to connect it to another reference Bypass capacitors m
73. the Tattletale s main UART Tattletale replies sent out via the TFX 11 main UART appear in this terminal window Press the key any time you want to make sure the terminal program is communicating with the TFX 11 It is also good practice to use the PRINT command to print a message with the name and version number of your program to the terminal window This can be helpful for future troubleshooting and a visual cue that you are connected to the correct board The terminal window has a 16 000 character circular buffer which holds about 8 pages of packed text When the buffer fills the oldest characters are discarded Characters in this window cannot be saved using cut and paste but they can be captured to a text file From the CommPort menu select Capture to File and type the file name where you d like to save these characters Only characters received after Capture to File has been activated will be saved The number of characters saved is limited only by disk space By default Capture to File is turned off every time you open TFTools If you choose to use the existing file when you turn it back on you will be prompted to either append the new text to the file or overwrite it Chapter 2 The TFTools IDE 19 Terminal status bar Editor window 19200 Com1 CaptonA Hexoff Scrolon 1584 The status bar at the bottom of the terminal window displays the current settings in use by the terminal program and it provides a
74. the beginning For instance the INPUT command defaults to storing a carriage return at the end of a typed string We could STORE this string without a length byte using the option see explanation above and then read it back with GET and CHR input Enter a string string savedfp dfpnt store 4 string newstring x savedfp loop i get x 1 if i amp hOD goto done newstring newstring chr i goto loop done print newstring Will echo back the string that you originally entered ASC MID INSTR LEN Chapter 4 TFBASIC Language Reference 65 COS Syntax Description Example Output Remarks Cautions See Also cosine value COS lt x gt COS returns the cosine of the expression in the parenthesis The argument must be in degrees The function takes a floating point argument and returns a floating point value An integer argument will be converted to float first degrees 0 0 init arg notice means it s a float result 0 0 just to force result to be a float for i 1 to 6 result cos degrees print The cosine of 5 1F degrees is 6 3F result degrees degrees 72 0 next i The cosine of 0 0 is 1 000 The cosine of 72 0 is 0 309 The cosine of 144 0 is 0 809 The cosine of 216 0 is 0 809 The cosine of 288 0 is 0 309 The cosine of 360 0 is 1 000 DON T FORGET The argument is in degrees not radians SIN TAN ATN
75. uploaded to the TFX 11 for execution The PIC controls RESET and at power on or Launch instructs the HC11 to load this program in the flash and then RESETs the HC11 to start to execute this code Both the HC11 and the Host PC may become the master of operations but not simultaneously The following discusses each as master separately as well as the supervisory role of the PIC Host computer in charge Under the control of the host computer the devices active are the PIC and the SFLASH Through the signal HOSTREQ the PIC will detect that the TFX is 244 TFX 11 User 5 Guide TFX 11 High Level Hardware Description PIC processor in charge connected to the host interface and wants service At this point the PIC commands an orderly shutdown of the HC11 When this process has been completed the PIC is slave to the host computer along with the SFLASH and the A D When the PIC has completed configuring itself as slave it asserts the SFLASH CS and responds to HOSTREQ with a PICACK The PIC has now given control to the HOST and set up the bus so that the default communication from the HOST is with the SFLASH The host is not required to communicate to the PIC for any SFLASH related activities READ WRITE or ERASE If the HOST wants to talk directly to the PIC or the A D it must grab the attention of the PIC by toggling the HOSTREQ line The PIC continually polls the state of the HOSTREQ line which acts as a PIC CS If it changes s
76. was declared as a floating point array This MUST be done in the DIM statement because this is the first place an array is used Chapter 6 TFBASIC Internals 179 Constants Examples Arithmetic operators Relational operators If an integer value is assigned to a floating point variable the value will automatically be converted to float before the assignment Floating point numbers can be entered by following this rule The entered number must contain at least one digit with 1 a decimal point and or 2 the power of ten operator E followed by the power of ten value 250 2 5E2 2500 0E 1 and 25E1 are all valid representations of 250 0 250 2 5E2 0 E5 and E5 are all INVALID floating point constants If a floating point constant is assigned to an integer variable the constant will first be converted to integer using the FIX function and then assigned to the variable All but one of the normal TFBASIC arithmetic operators are available for floating point math The exception is the modulo operator The tokenizer checks the two operands of each arithmetic operation If one is a float and the other an integer the integer is first converted to float and then the operation is performed The result is considered as type float in the rest of the expression For example in this equation Integer Float N 7 floatValue 5 2 3 7 9 a Te Float 5 and 2 are multiplied as integers and
77. y to UEEPROM address x Execute command block while x is true Enable disable console output
78. 0 10 88 62 87 15 85 68 84 40 83 13 81 85 80 58 79 48 78 38 77 28 76 18 75 18 74 18 73 18 72 18 71 31 70 43 69 56 68 68 67 86 67 03 66 21 65 38 64 61 63 83 63 06 62 28 61 58 60 88 60 18 59 48 58 83 58 18 57 53 56 89 56 26 55 64 55 01 54 39 53 8 93 24 52 66 52 09 51 51 50 94 50 36 49 79 49 26 48 74 48 2 47 69 47 16 46 64 46 11 45 59 45 09 44 59 44 09 43 59 43 42 64 42 16 41 69 41 24 40 79 40 34 39 89 39 44 38 99 38 54 38 09 37 64 37 19 36 74 36 29 35 86 35 44 35 01 34 59 34 16 33 74 33 31 32 89 32 49 32 09 31 69 31 29 30 89 30 49 30 09 29 69 29 29 28 89 28 49 28 09 27 69 27 29 26 89 26 49 26 25 74 25 36 24 99 24 59 24 19 23 79 23 39 23 01 22 64 22 26 21 89 21 49 21 09 20 69 20 29 19 91 19 54 19 16 18 79 18 4 18 04 17 66 17 29 16 91 16 54 16 16 15 79 15 39 14 99 14 59 14 19 13 81 13 44 13 06 12 69 12 29 11 89 11 49 11 09 10 7 10 34 9 96 959 9 419 8 79 8 39 1499 dub 21 9 6 79 6 39 5 96 5 54 5 11 4 69 4 26 3 84 3 41 24 99 24056 2 14 1 71 1 29 0 86 0 44 0 01 0 41 0 89 1 36 E1584 224 31 52 19 3 26 3 74 4 21 4 69 5 16 5 64 6 11 6 64 7 16 7 69 8 21 8 76 9 31 9 86 10 41 10 99 11 56 12 14 12 71 13 34 13 96 14 59 15 22 15 87 16 52 17 17 17 82 18 57 19 32 20 07 20 82 21 62 22 42 23 22 24 02 24 97 25 92 26 87 27 82 28 90 29 97 31 05 32 13 33 48 34 83 36 18 37 53 39 36 41 18 43 01 44 85 47 65 50 45 53 25 56 00 56 00 56 00 56 00 No attempt has been made to resolve temperatures greater than 1
79. 2 PICINT x Ly z PIN x1 X2 POKE addr value PRINT s zn Lx XqE PSET x1 X2 e REPEAT UNTIL x RETURN RTIME v SETRTC M SIN X SLEEP x SQR x STIME v STOP STORE fn x STR s L n LxIL x eTAN X aoaaa TONE x1 x2 VSTORE x y WHILE x WEND XMIT XMIT Time for x1 cycles of signal to pass with x2 as timeout Set up external PIC interrupt Value formed from specified input pins Store byte value at address addr any mix Set specified I O pin to high state Toggle state of specified I O pin Change SLEEP interval timing Transfer hardware RTC time from PIC to local RTC Repeat command block until x is true Return from subroutine Translate from softtware RTC or variable time in seconds to array Set the hardware RTC time in the PIC Sine of x Sleep till x 10 ms from last SLEEP Square root of x Write array data to software RTC or variable Shift in x bits Shift out string expression Shift out x1 value using x2 bits End program execution Store x to EEPROM using n bytes Create string Tangent of x Send x2 cycles of square wave of period x1 continuous if x2 0 Store data from software UART to string Send string data out software UART Thermistor conversion degrees Cx100 Address of variable v Return value of UEEPROM at address X Store
80. 2 13 18 B18 J3 15 3 A21 J2 14 19 B17 J3 16 4 A22 J2 15 20 B16 J3 17 5 A23 J2 16 21 B15 J3 18 6 A24 J2 17 22 B14 J3 19 7 A25 J2 18 23 B13 J3 20 use two ways to clear I O lines FOR A 0 TO 5 PCLR A NEXT A PCLR 0 1 2 3 4 5 In TFBASIC when multiple pins are specified in a single command the changes may not take place simultaneously if the pins selected are from different ports Maximum current TFX inputs can stand Pins 8 15 are INPUTS ONLY PTOG PSET and PCLR will generate a HOW error when used with these pins PSET PTOG PIN Chapter 4 TFBASIC Language Reference 97 PEEK Syntax Description Example indentation for clarity only Remarks See Also read memory byte PEEK addr PEEK lt expr gt This function returns the value of the byte located at the address lt a gt in parentheses The lt a gt can be any expression that evaluates to a valid address in BANK 0 print peek H74C0 A peek amp H112 startprog print square of values from 0 to 9 for a 0 to 9 b ax a print 5 a b next a print last b value bytes print 02H peek varptr b print 02H peek varptr b 1 print 02H peek varptr b 2 print 02H peek varptr b 3 print program starts at print 04H labptr start prog print program ends at 04H labptr end prog endprog This function can return the value of any a
81. 2 port at TTL levels The signal is inverted compared to the RS 232 TX2 input J2 3 The output of the secondary RS232 port at RS 232 levels The signal is inverted compared to the TTL RX2OUT output J2 4 The input to the secondary RS232 port at RS 232 levels The signal is inverted compared to the TTL TX2IN input Chapter 9 TFX 11v2 Hardware Reference 229 SHDN EN HOSTREQ PPMOSI PICACK PPSCLK PICHSHK PPMISO GND LED RB7 RBO RESET J2 1 Pulled HI with a 1M pullup When brought LO turns the RS 232 converter charge pump off see MAX3223 datasheet for details J2 2 Pulled LO with a 1M pulldown When brought HI turns the RS 232 converter off see MAX3223 datasheet for details 24 6 Driven LOW by the Host PC when requesting attention Bringing this line low will halt a running TFBASIC program Not meant as a user function J4 3 Communications line from Host PC to TFX 11v2 Not meant as a user function 44 5 TFX 11v2 signal that it has recognized the HOSTREQ Not meant as a user function J4 2 Host to TFX 11v2 communication clock Not meant as a user function 44 4 TFX 11v2 signal to host that it is ready for new command Not meant as a user function J4 3 Communications line to Host PC from TFX 11v2 Not meant as a user function J2 11 J2 12 System digital ground J3 10 Output from external activity LED When oscillating the PIC is active when not
82. 3359599 1999712731 23359356 1999 12 31 23 59 51 1999 12 31 23359558 1999 12 31 23 59 59 2000 01 01 00 00 00 2000 01 01 00 00 01 2000 01 01 00 00 02 2000 01 01 00 00 03 2000 01 01 00 00 04 C Remarks Cautions See Also RTIME STIME SETRTC and section TEX Timekeeping 112 TEX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 REPEAT Syntax Description Examples indentation for clarity only execute loop until expression true REPEAT cCommands to be executed UNTIL expression REPEAT loops provide one of four methods of looping available in TFBASIC The code between the REPEAT and UNTIL commands will be executed until expression becomes true Unlike the FOR and WHILE loops the testing of expression takes place after the loop has executed so a REPEAT loop will always run at least once Because this structure stores nothing on the stack these loops can nest as deeply as you like GOTO will exit any number of nested REPEAT loops and will not cause stack problems example 1 force input to be 0 or 1 and count mistakes begin tries 0 print Input 0 to exit or 1 to continue repeat input Continue goAgain tries tries 1 until goAgain 0 goAgain 1 remove comment slashes to modify behavior print that took you tries tries if goAgain 0 print Program terminating gosub CleanUp stop else goto begin endif Chapter 4 TFBA
83. 4 amp 50 250 253 50 250 50 250 50 250 13 251 50 250 255 gt 50 250 254 255 gt 50 250 254 253 252 50 250 A A D converter 208 A D input choices 208 AO 220 232 About Box 40 ABS 43 182 AD12 0 AD12 10 220 233 AD8 0 AD8 7 220 232 ADGND 221 233 ADVCC 221 233 AINT 44 47 52 263 ALIGN 159 Arithmetic Operators 180 ASFLT 54 182 ASM 55 mnemonics 155 two forms of 150 Assembler Opcodes 150 Assembly Language Subroutines 165 ATN 58 182 ATOD12 165 ATODS 165 B Backup Battery 213 Baud rate 135 baud rate 60 BAUDGET 43 60 BAUDSET 59 Big endian 176 Bipolar mode 200 Blank line 13 BRKCNT 168 C CALL 152 Capture to File 38 Cascade 39 CBREAK 62 CCOUNT 168 CENAB 168 CHAN 12 64 Character codes 105 Character constants 186 CHIBUF 165 chip selects 208 Circuit for Converting Bipolar to Unipolar 200 Clear 27 Clock Resolution 236 Communications Connectors 215 227 Contacting Onset xi Copy 27 COS 66 182 Could not Compare 185 COUNT 67 Crystals 236 CSIOI 219 231 CSIO2 219 232 TFX 11 User 5 Guide CTRL C 12 62 174 250 CTRL E 173 CTRL H 173 CTRL L 173 CTRL O 173 CTRL R 173 custom interface board 215 228 Cut 27 D D0 D7 219 231 DATA 160 Datafile Storage Commands 44 development kit 2 DFERASED 43 DFMAX 43 DFPNT 43 129 Digital I O Control 46 Digital I O pins 208 DIM 69 Disclaimers ix x DS 164 DW 160 E E 219 231 editor 11
84. 456 100 00 100 00 This function does not convert the data it only tells TFBASIC how to interpret it correctly assuming it was stored as a floating point value None VGET 54 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 ASM Syntax Description Labels Opcodes Inline assembly code ASM assemble to memory ASM or ASM address code END Assembly language can be written directly using ASM HC 11 instructions with some limitations see the TFBASIC Assembly Language reference for details are supported in all addressing modes Assembly starts when it encounters the ASM command and stops when it encounters the END command This assembler allows the use of named labels and it can access TFBASIC variables by name If the optional address is included the code is assembled starting at the specified address If address is replaced with the character assembly is done in line and automatically called when reached Labels can be used in the assembly code for flow control and to define local variables Labels MUST start in the first column Labels can be up to 32 characters long and must begin with a letter or an underscore _ The only valid characters in a label are upper and lower case characters the numbers and underscore The label name can be terminated with a colon when the label is defined but this is not necessary in the assembler These labels will
85. 4H SUBD 7 16 amp H4000 subtract 16496 4070H from A B reg These instructions read the addressed memory the first operand and modify this value using the second operand The modified value is then written back to the target address BSET Flags H 80 Set MSB in location Flags BCLR Flags H 80 Clear MSB in location Flags note the bit cleared is set in the operand mask These instructions perform a read modify write on their target locations Caution must be used when read modify write instructions such as BSET and BCLR are used with I O and control registers because the physical location read is not always the same as the location written See the Motorola documentation for more information 156 TFX 11 User 5 Guide Summary of TFBASIC Assembler Directives Summary of TFBASIC Assembler Directives The assembler makes some directives and pseudo ops available Here is a brief listing of the directives in the TFBASIC assembler The second section goes into more detail and provides examples of how the directives are used The TFBASIC assembler directives are grouped into four categories source control data declaration symbol declaration and location control The source control directives tell the assembler where its source code starts and ends The data declarations allow you to initialize an area of memory from an expression or string The symbol declaration directive allows you to assign a numeric value to
86. 5 Used to read the 12 bit A D converter end of conversion signal A16 Second user available chip select that is mapped to range 800h FFFh when enabled Default for the TFX 11 is disabled Requires understanding of the HC11 and assembly language programming to access See the MC68HC11F1 technical reference for more information NOTE Be aware this line may be used in the future by ONSET to attach memory expansion devices to the TFX 11 Chapter 8 TFX 11 Hardware Reference 219 AO PAO PA7 AD8 0 AD8 7 VRL VRH AD12 0 AD12 10 REF REF A17 Lowest external address line Used to qualify reads and writes for some peripherals attached to the data bus A18 A25 Digital I O pins corresponding to pins I O0 I O7 A26 A33 8 bit A D converter inputs These pins also act as digital inputs when used with the PIN command The corresponding PIN parameters are I O 8 to I O 15 and the corresponding CHAN parameters are 11 through 18 Note that AD8 1 through AD8 6 do not necessarily match connector pins A27 A32 in sequence Refer to the connector reference for the PR 11 or TFX 11 boards for the correct sequence A34 Provides the LO reference voltage for the HCIl on board 8 bit A D converter This pin is NOT connected unless plugged into the PR 11 breadboard The PR 11 has a jumper that normally connects this signal to ground The jumper may be cut if you want to connect it to another reference Bypass capacitors may b
87. 54321 Type a floating point value gt 134 55 Type an integer value 9999999999 lt too large an integer 999999999 9351 000 54321 1 345500E2 999999999 Entering a carriage return alone in response to an input command assigns zero to the variable A trailing semicolon after the variable specifier causes the input command to inhibit echoing the terminating carriage return Entering a Control C during an input leaves the variable unchanged The expression entered from the terminal is evaluated after each prompt If an integer value outside the range 2147483647 to 2147483647 is input a is displayed to request corrected input 86 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 See Also A floating point input between 1 175494E 38 and 1 175494E 38 assigns zero to the variable and if the input is not exactly zero sets the FPERR variable to indicate an underflow error A value of Infinity is assigned to the variable if the input is greater than 3 402823E 38 A value of Infinity is assigned to the variable if the input is less than 3 402823E 38 The value of FPERR will be updated to show an overflow occurred for either infinite result f a floating point input cannot be evaluated a is displayed to request corrected input Leading spaces and trailing spaces for integer or floating point values will cause the INPUT command to fail It will display a to request corrected input
88. 66 C or less than 56C Using the 12 bit converter gives about 0 03C resolution for temperatures between about OC and 35C The Getting Started section shows the schematic for the circuit and describes how to connect the thermistor to take temperature readings 132 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 TONE Syntax Description Example 1 Example 2 send square wave out TONE period count TONE lt x1 gt lt x2 gt TONE allows you to produce a square wave of predetermined period and duration output on I O line 3 The expression period gives the square wave period which is measured in multiples of 0 8138uSec The range of period is 70 about 17554Hz to 65535 about19Hz The expression count gives the number of cycles to be output which can be as few as one or as many as 32767 cycles This output can be used to drive a speaker and produce notes covering a large portion of the audio spectrum TONE sets I O line 3 to an output and leaves I O line 3 low at the end of a command A special form of TONE is available to produce a continuous square wave Use a value of 0 for the count argument and the square wave will continue at the period you select until you execute a TONE with a zero value for both the period and count arguments You can change the period of this continuous signal on the fly by using TONE with the new period argument and a zero count argument The square wave per
89. ASE DO NOT RETURN THE TFX 11 WITHOUT FIRST OBTAINING A RETURN MATERIALS AUTHORIZATION RMA Attempting a return without an RMA will delay processing The following procedures show you how to start the TFTools program load a test program debug it and save the debugged version At this point the serial communications cable should be properly connected between the TFX 11 and the computer and the TFX 11 should be connected to a power supply or battery the parallel cable is not necessary for this tutorial The Tattletale start up message should be displayed in the terminal window and the prompt should appear below it Press the ENTER key The prompt should display again This verifies that the serial interface is operating correctly From the File menu select Open Select the file DebugMe tfb in the directory where TFTools was installed DO NOT make any edits yet Chapter 1 Getting Started 7 Checking a TFBASIC program from the text editor Perform a syntax check Check the syntax of the TFBASIC program The loaded program should appear exactly as shown below gt TFTools for Windows File Edi Search Tattletale CommPort Window Help 3 _C WINDOWS Desktop TFT ools DebugMe tib forx 1 to 16 print Hello next x 18200 Com2 CaptottA Hexoff Scioto 3090 From the Tattletale menu select Syntax check you can also type ALT Y A message appears indicating there
90. BASIC 142 TFX 11 User 5 Guide TFBASIC Error Messages e 27 28 29 e 30 31 e 32 33 34 e 35 e 36 e 37 38 39 40 41 42 43 e 44 45 46 e 47 48 49 e 50 51 052 e 53 TONE parameter out of range not used in TFBASIC date time input to STIME out of range integer input to RTIME out of range HYB interval overflow SDO requested lt 1 or gt 32 bits CALL address gt 65535 not used in TFBASIC not used in TFBASIC VSTORE VGET index out of range gt 31 UGET timeout 65535 STIME out of range not used in TFBASIC not used in TFBASIC PRINT field width gt 255 FIX INT result overflow OFFLD x y where x gt y bad argument to BAUDSET flash EEPROM command failed time out accessing Analog to Digital converter array index out of bounds attempt to run a second background task illegal RATE argument not used in TFBASIC stack running low PIC command failure not used in TFBASIC For applications where these responses are undesirable they can be replaced by a goto on error response using the ONERR command Chapter 4 TFBASIC Language Reference 143 General Guidelines for Background Tasks e Shouldn t use HYB INPUT TONE COUNT with timeout or PERIOD in the background task Must use Sleep or Stop to allow foreground to execute e Some commands will be affected USEND and UGET in foreground will
91. BeRotatedtl third most significant byte ToBeRotatedt2 least significant byte ToBeRotatedt3 input Value to rotate ToBeRotated input Number of bits to rotate NumberShifts print value before rotation ToBeRotated asm nothing else on above line not even comments ldab NumberShiftst 3 get number of shifts in B register loop beq leave if number of shifts is zero exit rol ToBeRotated 3 ls byte ms bit to carry garbage into ls bit rol ToBeRotated 42 carry into ls bit ms bit into carry rol ToBeRotated t1l rol ToBeRotated done except ls bit of 1s byte is garbage bcc no carry branch if carry 0 ldaa ToBeRotatedt 3 get here if carry bit set oraa 1 so set the ls bit bra endloop no carry ldaa ToBeRotated 3 carry bit from ms bit 2 ce Oso anda amp HFE clear the ls bit endloop staa ToBeRotated 43 restore the ls byte Chapter 5 TFBASIC Assembly Language Reference 151 Assembly to an address ASM CA lt address gt The TFBASIC LL command syntax decb count shift completed bra loop leave end on the above line leave is an assembler label and end end is a TFBASIC command print value after rotation ToBeRotated stop MS LS 31 0 The figure above shows the operation of the assembly routine for one pass around the loop Each TFBASIC variable is 32 bits wide The figure shows the four most significant and four least significant
92. CINT x Ly z This instruction sets up I O line 16 as an edge sensitive interrupt This interrupt originates in the PIC This instruction sets I O 16 to input sets the edge clears any pending interrupts and then sets the PIC s INTE bit When an interrupt is received it will awaken the PIC if asleep which in turn will signal the HC11 via the XIRQ line The PIC will clear the interrupt flag and the interrupt enable flag so the interrupt will remain disabled until the PIC receives another enable instruction From TFBASIC this may be used as an asynchronous awakening from HYB If connected to the UDI pin it will awaken the TFX 11 from sleep on receipt of a serial character arguments ex If 0 interrupt will be disabled If 1 interrupt is enabled ey If 0 interrupt is on falling edge default If 1 on rising edge ez Address of assembly routine called when interrupt is detected intcount 0 savecount 0 cbreak clean print Count interrupts on I O Pin 16 print Hit Ctrl C to exit asm amp hb000 ldd intcount 2 increment the counter addd 1 std intcount 2 rts notice RTS code internal to i TFBASIC handles RTI end picint 1 0 amp hb000 enable PIC ints on negative going edge print INTSTATE show that PIC interrupt is enabled Should be 1 sleep 0 loop if intcount lt gt savecount print intcount intcount savecount intcount 100 TFX 11 User 5 Guide TFBASIC Language Reference
93. GET command alt system clock HYB routine Used by Bootloader Chapter 5 TFBASIC Assembly Language Reference 169 170 TFX 11 User 5 Guide CHAPTER 6 TFBASIC Internals TFX 11 User 5 Guide Overview The Host program Editor Tokenizer program loader Details of the TFX 11 program Token Engine TFBASIC Structure TFBASIC adds a tokenizing pass between editing the program and sending it to the TFX 11 This pass is transparent in that it is part of the routine that sends the program to the TFX 11 It s fast too especially when using the parallel port cable Before a program is sent to the TFX 11 it is tokenized by the host computer running TFTools The tokenizer in TFTools reads each command line and splits it into discrete basic operations and converts all expressions to their Reverse Polish equivalents Each operation is defined by a token or label and a set of parameters When tokenized the program is sent to the TFX 11 where it can be run Tokenize program Launch or Run Command Write program in TFTools editor Send program to Tattletale If a syntax error is found during tokenizing the program is not loaded and the offending line is flagged in the editor so you can correct the error The TFBASIC program runs on the TFX 11 and has two distinct parts the program s tokens which are generated from your source code and the token interpreter engine which executes
94. HYB timing is dependent on the PIC s clock crystal Wakeup from HYB timing is calculated as relative time as seconds from the current value in the HC11 clock to the requested wakeup time This value is transferred to the PIC and added to the current PIC time to calculate the alarm wakeup time The HC11 stores locally this offset count as well as the time it entered HYB When the PIC wakes it up TFBASIC gets the current time from the PIC Assuming no drift between the two crystals this technique will wake it up at the exact time requested with the variable containing the correct time for TFBASIC even if the times on the PIC and HC11 differ Since the Chapter 10 TFX 11 General Hardware Reference 237 Clock drift HC11 has been stopped during HYB the only valid time available is the PIC time in seconds Any drift error during an HYB period depends on the PIC s crystal oscillator Any drift error during TFBASIC operation is dependent on the HC11 crystal The PIC crystal drifts at a rate of 0 04 PPM PC 238 TFX 11 User 5 Guide TFX 11 Data Storage Options TFX 11 Data Storage Options The TFX 11 offers some different data storage options each designed to suit a particular purpose best Different methods of write and read access define appropriateness for using each of these different storage areas The major on board memory areas are listed below Program and Variables memory bank 0 of the 128K static RAM
95. LF that is normally sent at the end of a print statement print this is these two lines produce print a test identical output print this is a test to this one line To send a CR without a LF at the end of a line use V3 to send the carriage return and a semicolon to suppress the normal CR LF This is useful for updating a value on the display without generating a new line It will continuously write over the value on the same line The PRINT command s output is buffered All print format declarations require a numeric value between the sign and the type specifiers STORE 106 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 PSET Syntax Description Example Code Remarks Cautions See Also set I O line high PSET pin pin pin PSET x1 lt x2 gt This command sets the data direction register for the specified pins to outputs and then sets the pins to a logic high 5 volts example 1 FOR A 0 TO 7 PSET A NEXT A example 2 PSET 0 1 2 3 4 5 6 7 Either one of these will set all of the output lines high This is useful in an application where the I O lines that are not used do not have pull ups or pull downs Setting them to outputs keeps them from being floating inputs that can draw extra current needlessly See PCLR for I O pin mapping In TFBASIC when multiple pins are specified in a single command the pins are handled indivi
96. Lgs 07 ADGND POST REG Tee HOSTREQ pospatas LE L 3 De PICAR zm Jes Picack VAL pus Poapatas PS r alele 26 W PCODATAG 16 Ta PPMOSI ies POM TAT LOWBATT Huga 3 2 PPSCLK vss Qui PCVDATAT Lise ag PCODATAO it Zo paz lepmiso PAG MODA Z2 Pas MODE M pp LOWBATT PRG l ER pas RESET 1 E l zs OMG Tone i Pay 238 T Par PDS SS id PAO Pae QE fosse 5 Protection network is D3MOSI 1 AME duplicated on all six port pins l PAS E36 gt Poamisa 124M cal I PA4 4215 gt 4XOUT MAX917 Gnd I PAS eu gt 4 245 REF L f PA2 i3 gt 1B GND i Pai gum POITO VBAT wise RIS Pao ET gt Pei Not Placed MC68L1 1F1 TOFP MAXa222E C 9 AW 28 HCtiVcc us TTLICMOS Levels THN 9 i RIOUT Eira OUT VIN our 327 RS 232 levels a TCSS AP a C21 PDO RxD T2IN GND SENSE ADJ FZ o OiuF gro DEN RaoUT cz 9 N g cia eour 8 m H Gnd TFX 11 User 5 Guide 224 TFX 11v2 Board Pinout and Dimensions TFX 11v2 Board Pinout and Dimensions ooo 9990099 TOP VIEW oot clqv ooc clqv oos clqv oolclay oo6 clqv Oo oou O 020AQV oo d3u O O SSAQV o05u 00 9vd 00 vvd 007d 00 0vd OOcXL O
97. NEXT I loop back TRYTHIS B TEMP 1000000 another possible error source STOP won t get here second err causes exit TROUBLE PRINT Error E 65536 found PRINT at token address 4H E 65536 H IF E 65536 7 PRINT Multiply out of range GOTO TRYTHIS ENDIF IF E 65536 14 PRINT TEMP argument out of range STOP Error 47 found at token address 28H ultiply out of range Error 414 found at token address 35H TEMP argument out of range As with CBREAK ONERR must be executed to be effective For this reason you should put ONERR at or near the beginning of the program The error handler may be changed any number of times by executing ONERR with different arguments Do not vector ONERR to a label inside a subroutine When a error is detected the program will act as if you did a GOTO into the subroutine It will not have a proper return address on the stack and will probably crash 96 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 PCLR Syntax Description Examples Remarks Cautions See Also set I O pin low PCLR pin pin PCLR x1 lt x2 gt PCLR first converts the specified pins to outputs and then clears these pins to a logic low 0 volts The following table maps the argument value to the I O pin Uo TFX11 v2 Lo TFX11 v2 PIN PIN I O PIN PIN PIN I O PIN 0 A18 J2 11 16 B20 J3 13 1 A19 J2 12 17 B19 J3 14 2 A20 J
98. ONNECTOR A 025 SQ PINS ON 0 1 CENTERS 4 HOLES 0 152 D CONNECTOR B 025 SQ PINS ON 0 1 CENTERS Cp TFX 11 User 5 Guide 210 TFX 11 Board Dimensions Pinouts as viewed from the top pins pointing toward you of the TFX 11 UDO GND A2 vce UDI Di A4 DO S00 D3 Ae D2 SDI D5 A8 D4 HOSTREQ 07 A10 D PPMOSI R W A12 E PICACK CS101 A14 IRO PPSCK PGO EOC A16 CS102 PICHSHK AO A18 PAO PPMISO PAL A20 PA2 GND PAS A22 PA4 LED PAS A24 PAS RB7 PA7 A26 AD8 0 RBS AD8 4 A28 AD8 1 RBS AD8 5 A30 AD8 2 RB4 AD8 6 A32 AD8 3 RBS AD8 7 A34 VRL RB2 VRH A36 ADI2 0 RB1 AD12 1 A38 AD12 2 RBO AD12 3 A40 ADi2 4 MRESET AD12 5 A42 AD12 6 vcc AD12 7 A44 AD12 8 CND AD12 9 A46 AD12 10 LITH REF A48 REF VBAT ADGND ASO ADVCC The TFX 11 pins come out the top of the board When the TFX is connected to the PR 11 prototype board the components on this top surface are inaccessible Note that the two boards mate face to face therefore the pinouts of the TFX 11 and the PR 11 are mirror images when viewed from each board s top Chapter 8 TFX 11 Hardware Reference 211 The PR 11 Prototype Board Connector Serial Cable Parallel Cable Connector 2 5mm Jack uncommitted 9V Battery Connector HHBIHHBIHHHHBEHBHI we wth ath atk fe e ae e 25 ee are ee ae e uncommitted 2 0 QS SE Oo oe aM YAN Optional power connector Backup Battery CR 2032 h
99. Program Code Parameter Stack Hardware Stack System Buffers This memory for I O 928 byte on chip RAM System Variables 68HC11 Registers FFD6 H FEEO H FE60 H FEO00 H FDC1H C000 H No fixed dividing line 0400 H 0060 H 0000 H Chapter 6 TFBASIC Internals 189 RAM memory overview The TFX 11 has 128K of RAM which is split into two 64K banks Bank 0 contains the executing code as well as the HC11 internal memory registers and EEPROM which includes the UEEPROM Bank 1 is the upper 64K of RAM and is devoted to data storage only Access to this storage requires using the array Because of hardware addressing schemes in the HC11 not all of the 64K bytes of RAM in Bank 1are available The area that is available starts at 1000h and ends at FDFFh or 60928 bytes Access to this area requires bank switching which slows operation slightly You do not need to be concerned with bank switching or addressing since TFBASIC takes care of all that when you make an assignment statement The data in memory is referenced by the array s index value which is zero based Each array variable is four bytes the typical TFBASIC variable size There are 15321 4 byte variables thus the indices range from 0 15320 Memory map details by address 0000h 0060h 0060h 03FFh 0400h 0FFFh 1000h 11FFh HC11 Hardware Registers These are the registers of the processor These may be read and written directly from an
100. RL C character detected Return CTRL C handling to default Start counting transitions on I O 0 and store in variable Stop counting transitions Dimension variable label to size e FOR v x1 to x2 STEP x3 NEXT v Initiate iterative for loop e GOSUB label e RETURN e GOTO label e IF x ELSE ENDIF e INPUT s vLx Lx 1T e ONERR label v e ONERR e POKE addr value PRINT s Zn x x e REPEAT UNTIL x e RUN e STOP e UGET x1 x2 v x3 e USEND baud lt string gt e VSTORE addr value e WHILE x WEND e XMIT XMIT e STORE n x ABS x AINT x Execute subroutine at label Return from subroutine Go to label Execute 1st command block if x is true else 2nd block Prompt with s load variable v see full description for complete arg list Go to label if error error in v Return error handling to default behavior Store byte value at address addr Print string to console Repeat command block until x is true Start a background process End program execution Store data from software UART to string Send string data out software UART Store value to UEEPROM address addr Execute command block while x is true Enable disable console output Store x to EEPROM using n bytes Absolute value of x Round float down to integer 44 TFX 11 User 5 Guide TFBASIC Quick Reference grouped by function e ASC str ASFLT x e ATN x BAUDSET x CHR
101. SIC Language Reference 113 example 2 force input between 0 and 100 quit on 99 give_up Remarks None count number out of range and quit after 10 repeat tries 0 repeat input newNumber tries tries 1 if tries gt 10 goto give_up until newNumber lt 100 amp newNumber gt 0 until newNumber 99 print 99 was input Time to stop stop print Ten numbers out of range you are finished stop See Also FOR GOTO WHILE 114 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 RETURN return from subroutine Syntax RETURN Description RETURN is used with GOSUB to signal that it is time to go back to the calling routine Cautions GOSUB stores the return address on the stack and RETURN uses it to know where to jump back to If no GOSUB has placed a valid return address on the stack then executing a RETURN without a corresponding GOSUB will take whatever is on the stack and use it as the return address most likely sending the program off into space BE SURE that there is no path to a RETURN that is not deliberate This type of error is usually associated with indiscriminate use of GOTOs See Also GOSUB GOTO Chapter 4 TFBASIC Language Reference 115 RTIME Syntax Description Example code Build this program with your editor indentation for clarity only Output Remarks Cautions See Also Read local software real time cloc
102. TFX 11 Remote Data Logger Controller Engine User s Guide TFX 11 Hardware TFBASIC Programming TFTools IDE D 2469 C 10 02 Credits TFX 11 User Guide Project Director Tom Mignone Writers Tom Mignone Lon Hocker Jim Dodd Editors Tom Mignone Jim Dodd Mark McPike Lisa Capozzi Layout and Design Tom Mignone Lisa Capozzi Cover Design and Graphics Tom Mignone 2000 2002 Onset Computer Corporation all rights reserved Printed in the USA Onset and Tattletale are registered trademarks of Onset Computer Corporation Microsoft and Windows are registered trademarks of Microsoft Corporation All other trademarks are the property of their respective companies ii TFX 11 User 5 Guide INTRODUCTION Onset Computer Corporation Mailing Address P O Box 3450 Pocasset MA 02559 3450 Physical Address 470 MacArthur Boulevard Bourne MA 02532 Technical Support Customer Service tech support onsetcomp com Tel 508 759 9500 Fax 508 759 9100 www onsetcomp com Sales Tel 1 800 LOGGERS 1 800 564 4377 sales onsetcomp com www onsetcomp com ONSET document D 2469 C TFX 11 User 5 Guide iii TFX 11 common features Introducing your TFX Your new Onset TFX 11 Tattletale Flash eXpress 11 is a state of the art data logger controller the most recent in Onset s line of Tattletale data logger controller engines The TFX 11 combines Onset s years of experience in design and manufacture
103. TIL x e RETURN e RTIME v RUN e SETRTC v SIN x e SLEEP x e SQR x e STIME V Execute 1st command block if x is true else execute 2nd block Prompt with s load variable v see full description for complete arg list returns a substrings position in a string Returns the next more negative integer part of x as integer String to integer Return length of string Natural log of x Common log of x return substring of str Go to label if error error in v Clear specified I O pins to low state Byte at address addr Time for x1 cycles of signal to pass with x2 as timeout Set up external PIC interrupt Value formed from specified input pins Store byte value at address addr any mix Set specified I O pin to high state Toggle state of specified I O pin Change SLEEP interval timing Transfer hardware RTC time from PIC to local RTC Repeat command block until x is true Return from subroutine Translate from software RTC or variable time in seconds to array Start a background process Set the hardware RTC time in the PIC Sine of x Sleep till x 10 ms from last SLEEP Square root of x Write array data to software RTC or variable TFX 11 User 5 Guide TFBASIC Quick Reference alphabetical e SDI x e SDO lt string gt e SDO x1 x2 e STOP e STORE n x STR s L n LxIL x TAN x TONE x1 x2 UGET x1 x2 v x3 e USEND baud lt string gt e TEMP x e VARPTR
104. UART The formats strings values characters and datafile blocks must be separated with commas A trailing semicolon will suppress the trailing carriage return line feed that is normally sent at the end of a PRINT A string is a set of characters bracketed by either single or double quotes Strings can have any length including zero print HELLO print This is a test Values are expressions that are evaluated at the time of the execution of the PRINT statement The default format for expressions is one character All the digits of a number will be printed even if the format specifies too small a space print A A print At5 A 5 Formats are a followed by a numeric value optionally followed by a type specifier D H Q B F S The numeric value specifies the minimum number of spaces a value is allowed to take when printed Values that take less than the specified number of spaces will be filled out to the left of the value with spaces unless the first character following the 7f is a 0 in which case the fill character is a zero All digits of the value will be printed regardless of the format Decimal is assumed unless one of the type suffixes D decimal the default for integers H hexadecimal Q octal B binary F fixed point float S scientific float the default for floating point is specified For default decimal integers the format may be a variable that doesn t inc
105. User 5 Guide Explanation of Connector Pin Functions GND vcc D0 D7 CSIO1 IRQ PGO EOC CSIO2 A1 System digital ground A2 See VCC B22 above A3 A10 See PR 11 drawing for exact pin to signal correspondence When TFBASIC is running the HC11 is in expanded operating mode Therefore these lines default function is as the external data bus These lines may be used with signals CSIO1 CSIO2 AO R W and E to add memory mapped external devices A11 Indicates direction of transfers on external data bus A12 This is the E clock output It is crystal frequency divided by 4 When the E clock is low the HC11 is processing When high there is a data access taking place A13 First user available chip select that is mapped to range 400h 7FFh when enabled Default for the TFX 11 is disabled Requires understanding of the HC11 and assembly language programming to access See the MC68HC11F1 technical reference for more information NOTE Be aware this line may be used in the future by ONSET to attach memory expansion devices to the TFX 11 A14 Falling edge sensitive maskable interrupt to the HC11 CPU Set to edge sensitive at reset May be used for early wakeup from HYB Sensitivity may not be changed by user Not used by the TFX 11 operating system Requires understanding of the HC11 and some assembly language programming to access See the MC68HC11F 1 technical reference for complete information A1
106. Zsize expr STORE n lt x gt STORE 2 lt v gt STORE places bytes words double words or strings into the next free location of the SFLASH datafile Formats 1 2 and 4 are used to specify whether the data is to be stored as one two or four bytes 1 specifies that the least significant 8 bits be stored 2 specifies that the least significant 16 bits be stored and 4 specifies that all 32 bits be stored The pointer variable is updated after the data has been stored it is accessible from TFBASIC as the read only variable DFPNT The default format of store is in bytes so that the 1 can be omitted in byte storage commands Format stores strings without the length byte Channl 10 assign your particular channel FOR A 1 TO 5 store five temp measurements T TEMP CHAN Chann1 PRINT 4 T 100 02 T 100 print them too STORE 2 T NEXT A 21 14 21 14 21 14 21 14 21 14 The size specifier is ignored for floating point and string variables Floats always store as four bytes Strings store length byte first followed by that number of characters that make up the string Data stored as binary values often takes less space but requires a program most likely custom written to parse the data and create a readable file Data stored only as strings can be easily read directly in a text editor after offloading If this is your preference use the format specifier to prevent
107. a list of TFBASIC commands and keywords in alphabetical summary order 40 TFX 11 User 5 Guide CHAPTER 4 IFBASIC Language Reference TFX 11 User 5 Guide Legend e str ex ev em e Xx label ec string expression variable format 8 bit character given by x Inline assembly code line reference the commands enclosed within these brackets are optional a single character 42 TFX 11 User 5 Guide Predefined Read only variables in TFBASIC BAUDGET DFERASED DFMAX DFPNT MODEL VERS FPERR BBPWR INTSTATE Predefined Read only variables in TFBASIC These variables allow you to access certain useful internal values in TFBASIC If you try to assign a value to these variables it will have no effect In the future it may generate either a syntax or HOW error Returns the value of the main UART s current baud rate Returns 1 if the SFLASH datafile is empty Maximum datafile address size of datafile 1 Points to the datafile location that will receive the next data byte Contains model number of TFX Version of TFBASIC 100 Floating point errors Each of the five errors has a bit assigned to it FPERR is cleared any time it is accessed so it should always be assigned to a user variable first before checking it In the TFX 11v2 this variable returns a value that indicates whether the power source Voltage has fallen below a specific user settable threshold
108. a slave to the HC11 Chapter 10 TFX 11 General Hardware Reference 245 HC11 in charge The PIC as RTC and low power controller Low power operation When the HC11 is up and running it is the main processor with all its program information in RAM In this mode it is running almost exactly like any of the previous Tattletales with the PIC acting primarily as the RTC and wakeup alarm With the HC11 in charge the PIC still has the power to take back control in response to external events i e the interface attached or as necessary to control low power mode requests from the HC11 The HC11 can command the PIC via the SPI bus to set an alarm wakeup time and then the HC11 can put itself into STOP mode When the PIC alarm times out it uses the XIRQ line to interrupt the HC11 to wake it up and after a brief handshake with the PIC over the SPI the HC11 resumes processing from where it left off If the handshake does not take place the PIC will assume an operational problem with the HC11 and place it in reset This can be initiated by the TFBASIC program requesting a HYB interval The PIC sets its alarm timer to the wakeup time one second resolution and when the PIC timer times out the PIC will use XIRQ to awaken the HC11 While in HYB only the PIC is active HALT will put the TFX 11 in this same low power state but it does not provide an automatic wakeup 246 TFX 11 User 5 Guide TFX 11 High Level Har
109. abel defines the start of the background task Background tasks are stopped by STOP or a reset Only one background task can be enabled at a time Most all commands are available to the background task that are available to the foreground task see General Guidelines for Background Tasks at the end of this chapter When a background task is running the SLEEP timing for the foreground is no longer rigorous it s easy to oversleep So the print is disabled for the foreground task ONLY WHILE A BACKGROUND TASK IS RUNNING To distinguish between SLEEP commands the background task prints a tilde if it oversleeps instead of All variables are available to both the foreground and background tasks Use the RUN command to launch a background task Follow the RUN with the line number or label of the routine you want to execute in the background For example RUN back1 will cause the program starting at the label back1 to run in the background The program starting at label back1 must have a SLEEP or STOP somewhere to pass control back to the foreground or the foreground task will never have a chance to run When a background task is started with RUN it doesn t start immediately A flag is set internally in TFBASIC that shows it is available to start It waits in suspended mode until the next clock interrupt occurs every 10msec or the rate chosen with the RATE command which truly starts the background task print print Self terminating
110. ables and from string constants is performed like any other assignment as in astring Test Line String concatenation String concatenation is performed using the operator Example astring abc defg hij print astring output abcdefghij Special characters can be embedded within a string constant or a character constant by including an escape sequence Each escape sequence determines the code value for a single character Escape sequences are used to represent characters that cannot be otherwise represented There are two forms of escape sequences numeric and mnemonic Both forms start with a backslash Numeric escape sequences allow you to represent a single character using a numeric code Mnemonic escape sequences represent the character code with a single character related to its function such as a X to represent the TAB character code Mnemonic and numeric forms may be used interchangeably The mnemonic form for a the tab character is t and the numeric equivalent is x09 Both these sequences generate a single byte code of 09h The Chapter 6 TFBASIC Internals 187 surrounding double quotes are necessary as all escape sequences are strings Example To embed a double quote TFBASIC code print He said I m not sure Output He said I m not sure The following code is equivalent to the example code above print He said x221 m not sure x22 a
111. above then the TFX 11 will operate as if running off main power The system will draw the same current from the backup battery as it did from the main battery and the backup battery will drain at the same rate as the main battery The system will most likely not operate as intended note that when the power supplies switch over Vcc must be below 5 volts In theory the system can operate down to 3 3V but unless your design reconfigured the A Ds with a separate reference or they are running ratiometrically the readings will not be accurate during the fall from 5V to 3 3V Also RS 232 communications may fail at low voltages but will return as soon as the voltage is restored 214 TFX 11 User 5 Guide The PR 11 Prototype Board Communications connectors Optional 2 5mm stereo phone jacks Tutorial area Designing a custom interface board for the TFX 11 A 9 pin mini din LZR Electronics MDJ9PS and a 3 5mm stereo phone jack Shogyo International SJ 0375 3RT are mounted for connecting to the host PC using the Onset cables Along one side of the PR 11 board are seven sets of pads designed to accept either 2 5mm stereo Shogyo SJ 0252 3RT or mono LZR Electronics Inc LZR RL254 phone jacks All seven are uncommitted that is the connections to the jack s internal contacts are brought out and terminate next to the connector It is up to you to determine what jumpers get installed based on the application and the choice of co
112. al error action use ONERR with no argument When the ONERR branch is made the program loses all information about previous GOSUBs ONERR MID X 1 LOOP1 X X 2 GOTO LOOP1 find something too big MID A X ONERR LOOP2 LOOP2 A A 2 IF A 0 PRINT MAX INTEGER X STOP X X A GOTO LOOP2 MAX INTEGER 2147483647 In addition to the form shown above TFBASIC allows an optional variable to be specified that will receive the error code number and the address of the token that failed This value can be examined in the error handling routine to decide what action to take Be aware that all information on previous GOSUB return addresses is lost In addition TFBASIC resets the token parameter stack The token address for the error is stored in the least significant two bytes of the variable and the HOW error number in the most significant two bytes Use the divide and mod operators to separate out these parts The token address can be used to look into the LST file to get an idea of where the error occurred Chapter 4 TFBASIC Language Reference 95 Example build this program with your editor indentation for clarity only Program s Output Remarks Cautions See Also ONERR TROUBLE E goto TROUBLE if error error in E A 2 initialize variable FOR I 0 TO 99 execute loop up to 100 times A A 2 make A larger possible error source
113. alB 256 CalValB 65536 amp amp HO00000FF 0 256 amp amp HOOO0000FF 0 65536 amp amp HOOOO0FFFF CalValA VGET 0 CalValB VGET CalValC VGET n n p EI VGET VGET can be used to retrieve unique user calibration parameters stored in the UEEPROM by VSTORE This permits instruments to have identical TFBASIC programs while allowing for variations in sensors calibrations All values stored in the UEEPROM are assumed to be integer ASFLT can be used to recover a floating point value stored in the UEEPROM FLPTV 80 86 VSTORE 20 FLPTV FLPTV ASFLT VGET 20 The UEEPROM is only readable and writable from TFBASIC Any values stored will not be off loaded with the main flash off load unless deliberately stored into the main flash by your TFBASIC program VSTORE ASFLT 138 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 VSTORE Syntax Description Example Remarks Cautions See Also store variable to user EEPROM VSTORE lt address gt lt expr gt VSTORE stores the 32 bit value of expr at the UEEPROM address There are 128 bytes available in the UEEPROM but they can only be assigned to in 4 byte blocks Valid addresses are 0 31 TempCalVal 5 PressCalVal 1 05 HumidCalVal 0 24 VSTORE 0 TempCalVal store an integer value VSTORE 1 PressCalVal store a floating point value VSTORE 2 Humi
114. and to enter comments The semicolon is still the only way to enter comments in assembly language code in TFBASIC The PIN command returns weighted values for the various digital I O pins when they are high The PCLR PSET and PTOG commands only work with digital I O pins 0 7 and digital I O pins 16 23 Digital I O pins 8 15 are input only pins and work only with the PIN command The HYB command does not awake once every 10 seconds to check for an RS 232 BREAK condition at the input to the main UART You can use the PIC Interrupt or the IRQ line to awake from HYB early Chapter 6 TFBASIC Internals 193 Timekeeping UGET USEND RTIME and STIME do not access the hardware real time clock They make conversions between the TFBASIC software clock clock the variable and the array To access the RTC in the PIC use SETRTC and READRTC UGET and USEND no longer use the datafile for storage Instead thay use a string variable In addition USEND can now use a string constant or a string variable The UGET and USEND baud rate limit has been increased to 19200 194 TFX 11 User 5 Guide CHAPTER 7 TFX 1I Interfacing TFX 11 User 5 Guide Interfacing to Real World Signals The TFX 11 as delivered is extremely versatile and has many capabilities but it is far from a complete instrument This is where you come in In order to make the Tattletale TFX 11 into the device you envision you will most likely
115. arenthesis The function takes a floating point argument and returns a floating point value An integer argument will be converted to float first build this program with your editor arg 0 125 result log arg print Natural Log of 3F arg is 6 3F result Natural Log of 0 125 is 2 079 Arguments less than or equal to zero will generate a Not a Number NaN floating point error FPERR 4 but execution is not stopped EXP LOG10 92 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 LOGI10 Syntax Description Example output Remarks See Also common logarithm value LOG10 lt x gt LOG10 returns the common logarithm of the expression in the parenthesis The function takes a floating point argument and returns a floating point value An integer argument will be converted to float first build this program with your editor arg 0 125 result logl0 arg print Common Log of 3F arg v is 6 3F result Common Log of 0 125 is 0 903 Arguments less than or equal to zero will generate a Not a Number NaN floating point error FPERR 4 but execution is not stopped LOG EXP Chapter 4 TFBASIC Language Reference 93 MID Syntax Description Example 1 output Example 2 output Remarks Cautions See Also Return a substring of a string substr MID str x1 x2 MID returns a substring of th
116. ariable consists of 4 bytes and increments every second The array The array is a separate structure of seven 4 byte integer variables with e 0 holding seconds 0 59 e 1 holding minutes 0 59 e 2 holding hours 0 23 e 3 holding days 0 31 e 4 holding months 1 12 e 5 holding years 1980 2040 wewewwow wm The array is only updated by invoking the RTIME command or by directly modifying it with an assignment to one or more of the elements 6 contains the current ticks count 0 99 Ticks occur a the rate of 100 per second and cannot be changed Using these predefined structures simplifies date and timekeeping and time based math calculations Note that the 5 the year array element contains all four significant digits of the year not just the last two to allow simpler and error free date calculations Because the PIC and HC11 use separate clock crystals it is possible that the time kept in one processor will drift from the other Therefore a clear understanding of how the two interact is necessary to ensure critical timing sequences are not compromised The PIC keeps time in one second increments TFBASIC on the HC11 keeps time to 1 100 second Because of the HYB overhead it is recommended that all intervals below 5 seconds 236 TFX 11 User 5 Guide TFX Timekeeping PIC as primary RTC Timing dependencies only be handled by SLEEP and intervals longer than 5 secon
117. arted Getting Started 2 Quick Start Tutorial 3 A Short TFTools Tutorial 4 Build a Data logger One Step ata Time 10 CHAPTER2 77 The TFTools IDE Understanding the TFTools Integrated Development Environment 18 Navigating the IDE without a Mouse 22 CHAPTER3 2 TFTools Menu Command Reference TATTLETALE 333 COMMPORT 37 WINDOW 39 HELP 40 CHAPTER 4 41 TFBASIC Language Reference Legend 42 Predefined Read only variables in TFBASIC 43 TFBASIC Quick Reference grouped by function 44 TFBASIC Quick Reference alphabetical 47 TFX 11 User 5 Guide xiii TFBASIC Bs Reference for the TFX 11 50 AS elo ie ints absolute value 51 AINT Moteur mtra round float down to integer 52 INS e teh tal istis Returns the ASCII value of the first character of the string 53 ASFLT West Ble eee interpret argument as float 54 ASM duod o assemble to memory 55 ATN Seed seeebet exse e edes eee uvae arctangent 58 BAUD SET Ens creeds Set the baud rate of the main UART 59 BAUD GET Get the baud rate of the main UART 60 CAL Call an assembly language subroutine 61 CBREAK ET go to label on CTRL C 62 CHAN P get result of A D conversion 64 CHR e eere Returns a one character string ofthe ASCII value ofan integer 65 Minis aam e eee cosine 66 COUNT count positive edges at I O line 0 67 IM Spese ame Rot Ae bas dimension array 69 EXP T ES raise e toa power 70 IX dNfaste stica EEEE convert a float to an integer 71
118. ay be required to minimize noise that will affect A D accuracy J1 12 Provides the HI reference voltage for the HCII on board 8 bit A D converter This pin is connected to Vcc through a zero Ohm resistor R24 The PR 11v2 has a jumper that normally connects this signal to VCC The resistor may be removed if you want to connect it to another reference Bypass capacitors may be required to minimize noise that will affect A D accuracy 232 TFX 11 User 5 Guide Explanation of Connector Pin Functions AD12 0 AD12 10 REF REF ADVSS ADVCC 32 kHz LOWBATT 1 245V REF J5 10 to J5 20 12 bit A D converter inputs The corresponding CHAN parameters are 0 10 J5 1 J5 2 Provides the LO reference voltage for the 12 bit A D converter This pin is connected to ADGND through a zero Ohm resistor R26 on the TFX 11v2 main board The resistor may be removed if you want to use another A D reference voltage J5 5 J5 6 Provides the HI reference voltage for the 12 bit A D converter This pin is connected to ADVCC through a zero Ohm resistor R27on the TFX 11v2 main board ADVCC is the regulator that is the dedicated supply for the 12 bit A D converter The resistor may be removed if you want to use another A D reference voltage J5 3 J5 4 Analog ground connection for the 12 bit A D converter input signals To avoid introducing noise in the A D conversions DO NOT attach any other grounds to this point J5 7 J5 8 Anal
119. b Define Byte and dw Define Word are available for programmers preferring Intel mnemonics With the exception of the fcc directive all of the data directives accept any combination of strings and expressions Strings used with these directives must be enclosed inside double quotes Use two consecutive double quotes to generate one double quote character in the output data The fcc directive generates data from string expressions bracketed by the first character encountered in the operand field Use two consecutive occurrences of the delimiting character to generate one instance of the character in the output data data data sample string data Several different strings data several 0 terminated 0 strings 0 data sample string with quote character data string with byte expression 10 160 TFX 11 User 5 Guide Details of the TFBASIC Assembler Directives data data data data data db db fcb fcb db fcb dw dw dw fdb fdb fcc toc fco fcc Qrezo string string Cab 0 1p 27S Ua string string string with with with with with e e t yields 00 01 02 03 yields 00 01 02 03 yields 00 00 00 01 00 02 00 03 yields 00 00 00 00 00 00 00 01 yields 00 00 00 00 00 00 00 00 nding bit 7 hig h h 80 mbedded quote should just be h 61 the single quote character yields olon ilde fo
120. before the flashing cursor In overwrite mode the cursor changes to a block and each new character typed will overwrite the one under the cursor The editor also has a limited undo capability From the Edit menu select Undo or press Ctrl Z to undo the most recent action As soon as you move the cursor the Undo buffer is cleared and the previous operation cannot be undone As you write your code use the syntax checker to compile and debug the program from the Tattletale menu select Syntax check or press Alt Y When the syntax checker finds an error it informs you of the nature of the error and places the cursor on the line where the error was found This allows rapid corrections of simple mistakes decreasing the time it normally would take to find and correct the error To quickly find a specific string or jump to a particular line number use the options in the Search menu After the program compiles successfully press ALT R or from the Tattletale menu select Run to load and run your program Then to copy it to the flash memory via serial cable select Copy program to flash from the Tattletale menu Alternatively you can select Launch from the Tattletale menu to load the program via a parallel cable Tip To add a bookmark to text in the editor window go to the line where you want to place the bookmark and press Ctrl Shift 0 Chapter 2 The TFTools IDE 21 Navigating the IDE without a Mouse If you prefer the keyboa
121. bits of variable ToBeRotated The value in variable NumberShifts tells how many times to do this operation In the assembly section everything after a semicolon and up to the end of the line is considered a comment The assembler does not recognize TFBASIC comments This first form of the ASM command provides no way to initialize the A B or X registers before entering the assembly code The second form of ASM described below does This form of embedding assembly code differs from the above in that when the token interpreter reaches this point in the program it does not execute the assembly code Instead it copies the assembly code to the address specified in the argument following the ASM command After placing the code at the specified address the token interpreter continues execution with the tokens following the assembly code To actually execute the assembly routine you must use the CALL command Also with this form an RTS instruction is automatically appended to any code you write This is fine if you re writing normal assembly subroutines but you cannot use this method to write data to a RAM address Use the POKE command instead CALL x15 x2 lt v gt x1 the address of the assembly routine this is the memory address or a predefined label following the ASM command 152 TFX 11 User 5 Guide TFBASIC Assembly Language Reference Example 2 x2 the state of the X A and B registers to be upon entering
122. boundary back to byte boundary Remarks Values in the align expression must not contain any forward references Chapter 5 TFBASIC Assembly Language Reference 159 DATA DB FCB DW FDB FCC Syntax Size Specifiers for data directive only Description Examples label data size expr string expr string comments 1abel db expr string expr string comments label fcb expr string expr string comments label dw expr string expr string comments label fdb expr string expr string comments label fcc lt delim gt string lt delim gt comments b B Byte S aS Short 2 Bytes w W Word 2 Bytes Je E Long 4 Bytes q Q Quad 8 Bytes The various data declaration directives instruct the assembler to generate initialized data from expressions and strings The size of the data generated for each expression is determined either explicitly with dot size suffixing as in the data directive or implicitly by the directive name Expression values are truncated to fit into objects of the specified size The data directive and the dot size suffixes shown in the table conform to the guidelines of the IEEE 694 standard for microprocessor assembly language The fcb Form Constant Byte fdb Form Double Byte and fcc Form Constant Characters are provided as a convenience to programmers more comfortable with Motorola pseudo ops while the d
123. click OK The cursor will move to the line you entered Go to line OK Cancel 32 TFX 11 User 5 Guide TATTLETALE Tattletale Run Alt R XMODEM off load Erase datafile Copy program to Flash Launch Alt L Relaunch Parallel off load Alt O Suspend TFX 11 Load OS only Start operating system Syntax check Compiler options XMODEM Off load Erase datafile Alt Y If selected while the terminal window is active Sends a Run command to the TFX 11 to execute the program currently in RAM If selected while an editor window is active this checks the program in the editor to see if it has been modified If it has been modified TFTOOLS then compiles it and uploads it to the Tattletale Then the focus switches to the terminal window and TFTOOLS sends a RUN command to the TFX 11 starting execution of the loaded program If power is totally removed from the TFX 11 the program will be lost Initiates an XMODEM off load of the flash datafile on the TFX 11 Since this is done serially it will be substantially slower than using the parallel version This option is designed for small files or remote applications that only have a serial connection Otherwise the parallel version is recommended Erases the flash datafile over the serial port This does not erase the program To access this with a serial only link you must be able to break the TFBASIC program and return to the
124. dCalVal CurrTemp CHAN 6 VGET 0 CurrPress float CHAN 1 ASFLT VGET 1 CurrHumid float CHAN 3 ASFLT VGET 2 Both integer and float variables take four bytes and thus either will neatly fit into one location A simple VGET will return the proper integer value but ASFLT is necessary to recover a floating point value stored in the UEEPROM No special commands are necessary to store a floating point value The UEEPROM is only readable and writable from TFBASIC Any values stored will not be off loaded with the main flash off load unless deliberately stored into the main flash by your TFBASIC program The UEEPROM has a finite number of write cycles so avoid frequent rewriting of locations such as might happen if the VSTORE command appears in a loop VGET ASFLT Chapter 4 TFBASIC Language Reference 139 WHILE loop while expression true Syntax WHILE expression commands to be executed WEND Description WHILE loops provide one of four methods of looping available in TFBASIC The code between the WHILE and WEND commands will be executed as long as expression is true Like the FOR loop and unlike the REPEAT loop the testing of expression takes place before the loop is executed Because this structure stores nothing on the stack you can nest these loops as deeply as you like A GOTO can be used to exit any number of nested WHILE loops Example collect data as
125. ddress in the first 64K address space including the processor registers POKE Refer to list of interesting memory addresses 98 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 PERIOD Syntax Description Example indentation for clarity only Output Cautions Remarks See Also measure period of signal PERIOD count timeout PERIOD lt x1 gt lt x2 gt PERIOD measures the amount of time it takes for count cycles of a signal to pass The input signal must be connected to I O line 0 and is measured in units of 1 2 4576uSec about 0 40690u Sec If timeout 0 01 seconds passes before the prescribed number of cycles transpires the returned value will be zero This keeps the Tattletale from locking up forever if no signal is at the input Period may return incorrect values for input frequencies higher than 30KHz start print COUNT gives count 100 Hz X PERIOD 100 100 if X 0 print PERIOD gives 0 Hz else print PERIOD gives 245760000 X Hz endif finish stop COUNT gives 4997 Hz PERIOD gives 4996 Hz Be careful when dividing anything by PERIOD since PERIOD can return a zero which would cause a HOW error The maximum value for the count and timeout arguments is 65535 Argument maximum is 65535 COUNT Chapter 4 TFBASIC Language Reference 99 PICINT Syntax Description Examples external interrupt for wakeup PI
126. ds be handled by HYB Use SLEEP where interval timing must be precise within a sub second Since the PIC clock crystal is always running even in HYB mode the PIC processor is considered the principal RTC on the TFX 11 At Program Launch the Host PC copies its current system clock time in seconds to the PIC When the PIC starts the HC11 by removing it from RESET the PIC time is copied to the TFBASIC variable by the TFBASIC startup code with tenths of seconds being initialized to O After this initialization there is nothing explicitly built into the TFX 11 to keep the two clocks synchronized but since the commands available between the PIC and TFBASIC use calculations based on relative time there is no problem When an RTIME or STIME command is executed in TFBASIC it only acts locally that is it does not affect and is not affected by the time in the PIC After TFBASIC initialization all timekeeping data is kept locally on the HC11 and it is updated locally unless otherwise commanded from the TFBASIC program SLEEP commands All SLEEP clock timing is relative to the TFBASIC periodic timer interrupt on the HC11 TFBASIC keeps a separate SLEEP timer which while clocked from the same HC11 periodic interrupt does not share count values with the variable and therefore is not affected by the RTIME or STIME commands It can only be modified by a SLEEP x command HYB commands Since the HC11 s clock is stopped during HYB absolute
127. dual tasking program bgflag 1 use as signal from background that it will stop run bgtask sleep 0 while bgflag 1 while background running print FG show foreground presence sleep 50 wend print Done stop stop foreground Chapter 4 TFBASIC Language Reference 117 bgtask sleep print sleep print sleep print bgflag stop 0 Ready 100 Set 100 Go 0 the background task signal to foreground stop background Cautions Background and foreground operations can interact since the background task has priority The following lists the commands you should not use when running a background operation and why Command USEND UGET TONE PERIOD COUNT HYB INPUT Failure Both use software timing which is interfered with by a background task interrupting them Timing can be incorrect or input edges can be missed Keeps the other task either foreground or background from executing while HYB is active Hangs up foreground task while waiting for characters Do not use RETURN to end the background as it will cause a stack failure crashing the program Background and foreground operations can interact since the background task has priority See also STOP SLEEP and section on General Guidelines for Background Tasks at the end of thi s chapter 118 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 SDI Syntax
128. dually and in sequence as three blocks First the pins in the block 0 7 then the pins in the block 8 15 and finally the pins in the block 16 and above 1 6mA maximum output current ofr I O Pins 0 7 Pins 16 23 can source and sink up to 25mA subject to the limitations of maximum current See the PIC data sheet for more information Pins 8 15 are INPUTS ONLY PTOG PSET and PCLR will generate a HOW error when used with these pins PCLR PTOG PIN Chapter 4 TFBASIC Language Reference 107 PTOG Example code Syntax Description Remarks Cautions See Also toggle I O line to opposite state PTOG pin pin pin PTOG x1 lt x2 gt The PTOG command sets the data direction register for the specified pins to outputs and then changes the pins to the opposite state they held before this command was executed FOR A 0 TO 13 PTOG 1 NEXT A This example will cause pin D1 to change state 14 times ending up in its original state In TFBASIC when multiple pins are specified in a single command the pins are handled individually and in sequence as three blocks First the pins in the block 0 7 then the pins in the block 8 15 and finally the pins in the block 16 and above Maximum source current 1 6mA and maximum sine current Pins 8 15 are INPUTS ONLY PTOG PSET and PCLR will generate a HOW error when used with these pins PCLR PSET PIN 108 TFX 11 User 5 Guide
129. dware Description Serial Cable Pinout GND RXD TXD RING TIP ry PIN 5 PIN 1 Tattletale PIN 9 PIN 6 NC RXD 2 RING TXD STP DTR GND 448 W GND DSR RTS CTS NC RUE Parallel cable Pinout PIN 1 PIN 13 Cotten e eccccccoccce PIN7 PIN 14 PIN 25 9 PIN TFX 11 CONNECTOR MINI DIN PIN STRIP 2 MOSI 8 B6 9 SCLK B 7 B8 ola UNUSED IN 6 MISO 9 11 Hag Da PICACK 1 Bm i5 ie PICHNDSHK 3 S i6 UNUSED OUT gt 5 BS 17 OE 2 18 25 i p 4 B11 Chapter 10 TFX 11 General Hardware Reference 247 248 TFX 11 User 5 Guide CHAPTER 11 Glossary of Terms TFX 11 User 5 Guide Abbreviations Arrays Arithmetic Operators Assembly Language Break Case Comments Glossary of TFBASIC Terms and Definitions There are no abbreviations allowed for any TFBASIC commands The number of arrays in TFBASIC is limited only by the size of the variable storage area The five arithmetic operators have the highest priority of all of the TFBASIC operators Note that TFBASIC does not have a separate high priority unary minus operator but instead treats the negation of a constant or variable as zero minus the value of the variable or constant These ar
130. e memory RAM e Input 5 5 18VDC input at 0 5 W max dissipation 50 mA max Power Consumption typical Running 14 mA Sleep 4 mA HYB lt 100 pA Operating Temperature RangeO to 70 degrees C Relative Humidity 0 to 9596 non condensing e Hardware UART Baud Rates 300 600 1200 2400 4800 9600 19200 38400 Max Sampling Rate 800 samples sec from TFBASIC 3200 using assembly language A D accuracy 12 bit 1 5 LSB A D accuracy 8 bit 1 5 LSB Board Dimensions 3 2 L x 2 4 W x 0 5 H Weight 1 ounce Data 1MB less Program 43k Operating system 21k 128k Battery backed 123k available vi TFX 11 User 5 Guide Introducing your TFX TFX 11v2 Specifications Electrical e nput 5 5 18VDC input at 0 5 W max dissipation 150 mA max Power Consumption typical Running 14 mA Sleep 4 mA HYB 100 pA Environmental e Operating Temperature Range 40 to 85 degrees C Relative Humidity 0 to 9596 non condensing Performance e Hardware UART Baud Rates 300 600 1200 2400 4800 9600 19200 38400 Max Sampling Rate 800 samples sec from TFBASIC 3200 using assembly language A D accuracy 12 bit 1 5 LSB A D accuracy 8 bit 1 5 LSB Dimensional e Board Dimension 1 2 L x 2 75 W x 0 5 H Weight 0 6 ounce Non volatile Data 2MB less Program 43k Operating system 21k memory RAM 128k 123k available TFX 11 User 5 Guide vii Host Computer Re
131. e number of new files started in the current TFTools session When you save the program you will be prompted to save it as a new name Opens an existing program file Navigate to the directory containing the tfb file you wish to open select the file and then click Open Closes the currently active progam file Saves the currently active program file without prompting for a new name Saves the currently open program file with a new name Type the name navigate to the directory where you want to save the file if necessary and click Save Saves all currently open files You will be prompted to save the file as a new name for any untitled open files Prints the active editor window Closes the TFTools application You will be prompted to save any files if necessary 26 TFX 11 User 5 Guide EDIT Edit Undo Ctrl Z Cut Ctrl X Copy Ctrl C Paste Ctrl Clear Ctrl Del Paste Date time Alt D Undo Cut Copy Paste Clear Paste Date time Editor options Undoes the most recent edit in the editor window Once you select Undo all information related to the Undo is lost there is no redo feature Removes the currently selected text and saves it in the Windows clipboard for later pasting Saves a copy of the currently selected text in the Windows clipboard for later pasting Unlike Cut this does not remove the selected text Inserts whatever is in the clipboard at the cursor
132. e required to minimize noise that will affect A D accuracy A35 Provides the HI reference voltage for the HCIl on board 8 bit A D converter This pin is NOT connected unless plugged into the PR 11 breadboard The PR 11 has a jumper that normally connects this signal to VCC The jumper may be cut if you want to connect it to another reference Bypass capacitors may be required to minimize noise that will affect A D accuracy A36 A46 12 bit A D converter inputs The corresponding CHAN parameters are 0 through 10 A47 Provides the LO reference voltage for the 12 bit A D converter This pin is connected to ADGND via a jumper on the TFX 11 main board The jumper may be cut if you want to connect another reference A48 Provides the HI reference voltage for the 12 bit A D converter This pin is connected to ADVCC via a jumper on the TFX 11 main board ADVCC is the regulator that is the dedicated supply for the 12 bit A D converter The jumper may be cut if you want to connect an absolute reference 220 TFX 11 User 5 Guide Explanation of Connector Pin Functions ADGND A49 Analog ground connection for the 12 bit A D converter input signals To avoid introducing noise in the A D conversions DO NOT attach any other grounds to this point ADVCC A50 Analog reference for the 12 bit A D converter input signals Chapter 8 TFX 11 Hardware Reference 221 222 TFX 11 User 5 Guide CHAPTER 9 TFX I1v2 Hardware
133. e string argument passed to it where x1 is the offset to the start character and x2 is the number of chracters to read within the string argument SubStr MainStr this is a test print MainStr SubStr mid MainStr 3 6 print SubStr print SubStr really stop this is a test is is is is really MyStr 12345 for index 1 to len MyStr 1 print mid MyStr index 3 next index stop 123 234 345 45 5 The first character in a string is referenced as 1 not O If you use O it will be converted to one Negative numbers for x1 cause MID to terminate If the number of charaters requested goes past the end of the string then the string returned will automatically terminate at the end None LEN INSTR 94 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 ONERR Syntax Description Example build this program with your editor indentation for clarity only Program s Output What amp Where go to label on error ONERR label var ONERR directs the Tattletale to jump to the specified label if a run time error occurs instead of printing an error message Errors are normally flagged as they occur with a HOW comment If an ONERR line is encountered during execution the error printout will be skipped and execution will continue at the label This allows emergency shutdown or recovery from a program error encountered in the field To return to the norm
134. e the TFBASIC arithmetic operators in order of precedence all operators on the same level are evaluated left to right highest 96 Multiplication Division Modulo Addition Subtraction gt lt gt gt lt gt Relational operators amp Logical bitwise AND lowest Logical bitwise OR See TFBASIC Floating Point on page 179 for details about arithmetic operations involving floats The TFBASIC tokenizer has a built in assembler Code can be assembled in line with the program or into a separate area as desired See TFBASIC Assembly Language Reference on page 150 for details A CTRL C sent via the primary serial port can break a running TFBASIC program A special command CBREAK followed by a label can be used to specify the address to restart to when a CTRL C is received You can disable CTRL C breaks by writing a zero byte to address 9C hex A count of CTRL C characters will continue to be updated at address 9B hex Clear this before re enabling break outs See the section CBREAK go to label on CTRL C on page 62 Labels and variable names are case sensitive commands and keywords are case insensitive TFBASIC provides two ways to include comments in your code one for TFBASIC code the other for assembly code In TFBASIC a pair of 250 TFX 11 User 5 Guide Glossary of TFBASIC Terms and Definitions Constants Datafile Storage and Retrieval Data Types Decimal Division by Zero forward slashes
135. egrees The function takes a floating point argument and returns a floating point value An integer argument will be converted to float first degrees 0 0 init arg notice means it s a float result 0 0 just to force result to be a float for i 0 to 6 result tan degrees print The tangent of 5 1F degrees is 6 3F result degrees degrees 72 0 next i The tangent of 0 0 is 0 000 The tangent of 72 0 is 3 078 The tangent of 144 0 is 0 726 The tangent of 216 0 is 0 726 The tangent of 288 0 is 3 078 The tangent of 360 0 is 0 000 DON T FORGET The argument is in degrees not radians SIN COS ATN Chapter 4 TFBASIC Language Reference 131 TEMP Syntax Description Examples Build this program with your editor Program s Output Cautions Remarks See Also convert number to temperature value TEMP lt x gt TEMP converts the 0 65535 value x to a temperature assuming that x results from a measurement of one of the A D channels that is connected to a thermistor voltage divider circuit The temperature conversion is given in hundredths of degrees C for A 0 to 65520 step 256 tempVal temp A print 4 tempVal 100 02 abs tempVal 100 if A 256 10 9 print next A 166 00 166 00 166 00 166 00 165 88 158 48 151 08 143 68 136 33 132 00 127 68 123 35 119 05 116 12 113 20 110 27 107 36 105 16 102 96 100 76 98 57 96 82 295 07 93 32 91 57 9
136. ence 141 TFBASIC Error Messages There are two different kinds of errors recognized by TFBASIC The first type is caught in the tokenizer These are usually editing or syntax errors The second type of error is caught at run time These are usually mathematical bounds errors When an error is encountered in an executing program execution is halted and the word HOW and the error number are displayed followed by the address of offending token The token address can be found in the Token List file created by the AIt T command in TFTools The error numbers with causes are listed below HOW errors 1 not used in TFBASIC 2 array variable index out of range e 3 not used in TFBASIC 4 STORE out of range of the datafile e 5 GET or GETS out of range of the datafile 6 integer divide by zero e 7 integer multiply overflow e 8 not used in TFBASIC 9 integer add or subtract overflow 10 ABS argument 2147483648 e 11 A D channel not supported e 12 I O pin not supported e 13 attempt to set input only pin to output e 14 input to TEMP out of range e 15 not used in TFBASIC 16 SDI requested lt 1 or gt 32 bits 17 COUNT timeout 65535 18 PERIOD argument out of range e 19 not used in TFBASIC 20 not used in TFBASIC e 21 not used in TFBASIC e 22 not used in TFBASIC e 23 not used in TFBASIC e 24 SLEEP interval gt 32767 e 25 UGET USEND baud rate out of range 26 not used in TF
137. entire manual before using his or her TFX 11 this section presents some simple instructions and examples to get you up and running Do you have some familiarity with electronics and programming If you are reasonably familiar with BASIC and have a fundamental understanding of analog and digital circuits continue with this tutorial If not you can wing it but should probably consider reading an introductory text or finding a mentor For a good all around electronics reference we recommend Horowitz and Hill The Art of Electronics Remember it s all CMOS and thus static sensitive Normal care in handling CMOS devices is all you must observe to prevent damage to the TFX 11 You must take extra precautions if you are in a very dry climate and get a shock every time you touch something metallic if you like wearing wool sweaters or if you work on a wool rug It is always good CMOS practice to touch the negative battery lead first when picking up the TFX 11 Even better is to use a grounded wrist strap and table mat when handling Be warned static damage is easily identified and is NOT covered under warranty Put the CD in the drive and wait for the splash screen with installation options to appear If the Install screen does not automatically appear then Follow the installation instructions The serial cable has a DB9F connector to connect to the host computer and a mini stereo phone plug to connect to the TFX breadboard PC se
138. ents the remaining 31 individual bits in descending order The range of Tattletale integers is 232 which with the sign bit gives a range of 2147483648 to 2147483647 Any attempt to create a number outside this range will result in a run time error The A D converters return two bytes left justified so that all conversions no matter the resolution span a range of 0 65520 for the 12 bit A D and 0 65280 for the eight bit The TFX supports only unipolar operation of the A D so the assignment of the type A D Value CHAN 12 will always produce the correct value and sign In the early days of microprocessors Intel and Motorola independently devised equal but opposite storage sequences for the order of significance in multi byte data items In Intel s little endian world the Least Significant Byte LSB is stored first in the lowest address and the Most Significant Byte MSB in the highest address Motorola s order big endian is just the reverse The Motorola processor in the TFX 11 uses the Motorola sequence but when the data is off loaded directly from the datafile to an Intel based PC the order for multiple byte data items is now reversed If you try to access a four byte integer stored as binary from a BASIC or C program this byte reversal will cause incorrect results This reversal has been a cause of much confusion partly because it always works correctly for single bytes 176 TFX 11 User 5 Guide TFBASIC Intege
139. error FIX FLOAT Chapter 4 TFBASIC Language Reference 89 IVAL Syntax Description Examples Output Remarks See Also convert numeric string to integer value IVAL str IVAL takes a string representing an integer value and converts it to its numeric integer variable equivalent astr 1234 anint IVAL astr print 4 anint 1234 Valid characters are 0 9 If the number contains other characters it will terminate the conversion at the unrecognized character In the case of 123x567 the number returned will be 123 FVAL 90 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 LEN Syntax Description Examples Output Remarks Cautions See Also return length of string variable LEN str LEN takes the string argument and returns an integer value representing the number of characters including terminating characters The Maximum length is 255 characters TestString This is string one print Length of string one is len TestString print Length of string 2 is len this is string 2 Length of string one is 18 Length of string 2 is 16 none none MID INSTR Chapter 4 TFBASIC Language Reference 91 LOG Syntax Description Example output Remarks See Also natural logarithm value LOG lt x gt LOG returns the natural logarithm of the expression in the p
140. et if there was a checksum error of code stored in the SFLASH Bit 1 will be set if there was an error getting clock from PIC In this case the clock will be set to zero January 1 1980 at midnight Bit 2 will be set if there was an error getting DF pointer from PIC In this case the datafile pointer will be set to zero Bit 3 will be set if there was an error accessing the SFLASH NOTE If all is OK the value in this location will be O To develop TFBASIC applications in a PC environment you will need the TFTools Integrated Development Environment IDE The IDE provides Chapter 6 TFBASIC Internals 173 TFBASIC power up program launch CTRL C Power up for TFBASIC the tools to edit load and run programs as well as off load the stored data and view activity on the serial port File Edit Search Tattletale CommPort Window Help TerminalForm 19200 Comi CaptoffA Hexoff Scrofloft 14 79 i NONAMEO 4 n Insert When you first fired up your Tattletale it printed a sign on message Tattletale Model 11 00 TFBASIC Version 2 00 C 2002 Onset Computer Corp All Rights Reserved The Tattletale is running a program written in TFBASIC that was stored in SFLASH at the time of manufacture This program ends with a STOP command so that the prompt will appear This section shows you how to make your program launch on power up instead of the one that prints the message
141. f the terminating character is present in the input stream it will terminate input before the total count is reached Set time out If present sets a non zero time out in increments of 0 01 seconds If the time between incoming characters exceeds this value then input is terminated and the program proceeds whether or not there are terminating characters or a terminating character count set IMPORTANT NOTE If the value 0 zero is specified for the time out then INPUT checks the buffer to see if a character is available if there is a character it returns with it otherwise it returns immediately Similar to the INKEY function in other BASICs c E_ Force echoing characters Chapter 4 TFBASIC Language Reference 85 Example Example Program Output typed responses in bold face Remarks Cautions C N Force not echoing characters c T Dontinclude terminating character No CR lt LF gt on termination of input By default INPUT sends out a CR lt LF gt to the terminal when it exits even if terminating on a byte count or timeout check if a key was hit without waiting for one input hit a key to stop key 1 0 if key stop endif enter a floating point number input floatVar input intVar input Type a floating point value gt test input Type an integer value gt number print print 10 3F floatVar 10D intVar 12 6S test 10D number floatVar 9 351e3 intVar
142. for the TFX 11 See Also picint 1 0 amp hb000 re enable PIC interrupt endif sleep 10 goto loop stop clean picint 0 disable PIC interrupt print PIC interrupts disabled stop INTSTATE read only variable HYB Chapter 4 TFBASIC Language Reference 101 PIN Syntax Description Comments Remarks Cautions See Also read input state of I O pin value PIN pin pin value PIN lt x1 gt lt x2 gt For each pin that is specified by the PIN instruction the data direction control bit for that pin is set to input The value that is formed from the states of the specified pins is then returned If the voltage at a particular pin is above 2 0 volts the PIN instruction interprets the input as a 1 if it is below 0 7 volts it is interpreted as a O Intermediate values will return unpredictable indeterminate results This command returns a value of all listed pins in a set order not depending on the order they are listed in the command arguments VO WEIGHT VO WEIGHT VO WEIGHT 0 1 8 256 16 65536 1 2 9 512 17 131072 p 4 10 1024 18 262144 3 8 11 2048 19 524288 4 16 12 4096 20 1048576 5 32 13 8192 21 2097152 6 64 14 16384 22 4194304 7 128 15 32768 23 8388608 If a pin is not listed in the command s argument list its corresponding value is always returned as 0 whether or not it is set In TFBASIC when multiple pins are specified in a single command the
143. format used is based on the IEEE 754 single precision floating point standard The range of representable values is 1 175494E 38 to 3 402823E 38 and zero Also infinity and not a number NaN are represented Single precision floating point numbers are represented in four bytes The format is as follows MSB byte 2 byte 3 LSB SEEEEEEE EMMMMMMM MMMMMMMM MMMMMMMM S sign bit 0 positive 1 negative E binary exponent with bias of 128 M mantissa with 23 explicit bits and an implied 1 bit as the most significant bit In the Tattletales the most significant byte is at the lowest address of the four bytes This is important if binary data is transferred directly to a computer that interprets numbers in the opposite order as all computers with Intel microprocessors do See the previous section on TFBASIC integers for further explanation When using a floating point variable for the first time append an exclamation point after the last character of the name It allows the tokenizer to check that the correct types are being used for arguments It also allows the tokenizer to automatically convert data to the correct representation sineValue sin 90 0 sineSquared sineValue sineValue dim sineList 100 Although the type identifier only needs to be used the first time a variable is declared for clarity it is recommended that it also be used with every instance of the same variable Notice how the variable
144. gure above shows the timing of the three lines used in the SDO command The circuit below shows one use of SDO Here two 74HC595 shift registers are cascaded to form 16 outputs By adding two more 74HC595 s a total of 32 output lines can be changed with a single SDO command NOTE These format specifiers D H B F S or Q are considered ambiguous Do D or H signify the radix decimal or hexidecimal or a variable field width You can use variables for field width but not with those 12 names upper or lower case To get the radix form use 1D 1H etc Chapter 4 TFBASIC Language Reference 121 SDO Command Timing Lines 0 4 I O 6 Remarks O lines 4 6 and 7 will normally be connected to a shift register such as a 74HC595 as shown above Since the bit on I O line 7 is always available to be stored in the least significant bit of the shift register a final clock is not needed Thus if you request N bits there will be N 1 clock pulses on I O line 4 Cautions n form 1 the bit s value must be in the range 1 to 32 See also SDI and STR 122 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 SETRTC Syntax Description Example code See Also transfer local time in seconds to PIC RTC SETRTC or SETRTC v SETRTC takes the four byte variable time in seconds and uses it to set the time in the PIC or optionally takes the time in seconds from the variab
145. gyo SJ 0252 3RT or mono LZR Electronics Inc LZR RL254 phone jacks Both are uncommitted that is the connections to the jack s internal contacts are brought out and terminate next to the connector It is up to you to determine what jumpers get installed and to what I O they are connected based on the application and the choice of connector used Included on the PR 11v2 breadboard are pads already laid out and ready to accept a thermistor resistor and transistor FET that form a simple but accurate temperature measurement circuit Some of you may want to design your own mating circuit board in place of the PR 11v2 The required terminations for the 8 bit A D subsystem as well as specific connector pin assignments are summarized in the table below PR 11v2 TFX 11v2 Pin Termination Comments J4 5 MINI DIN pin E2 Parallel Port connector HOSTREQ J4 1 MINI DIN pin E8 Parallel Port connector PPMOSI J4 5 MINI DIN pin El Parallel Port connector PICACK J4 2 MINI DIN pin E7 Parallel Port connector PPSCK J4 4 MINI DIN pin E3 Parallel Port connector PICSHK J4 3 MINI DIN pin E9 Parallel Port connector PPMISO J2 11 MINI DIN pin E4 Parallel Port connector GND J2 3 3 5mm jack RS232 Primary output J2 4 3 5mm jack RS232 Primary input J2 9 3 5mm jack RS232 Secondary output J2 10 3 5mm jack RS232 Secondary input J2 13 14 9V battery Battery power input 228 TFX 11 User 5 Guide Explanation of Connector Pi
146. h include the voltage spikes Transistor This solution isolates the TFX 11 s inputs completely from the source placing the transistor at hazard the transistor is a lot easier and cheaper to replace than the processor that the inputs are connected to This design can also perform some level shifting VFET Same as the transistor but takes much less current VFETS are generally harder to obtain cost a little more and are more easily damaged by static but are the best solution for low power drain and minimal loading of the signal source Opto isolation This solution has the advantage of total isolation of both the supply and the ground of the source from that of the microprocessor However it comes at the expense of substantial current drain size and expense Chapter 7 TFX 11 Interfacing 197 1 Digital Output Load or pullup Ty Digital Output opto isolator Digital Output Digital Output E Digital Output Protection Digital outputs are just as vulnerable as inputs and they cannot be driven even transiently with a signal larger than the V supply or lower than ground They also have relatively low drive capability and should be buffered if they are expected to drive substantial loads Some examples of output buffering are given in the figure below 100K resistor The resistor in this first example will provide protection but very little drive current It is suitable for connecting to CMOS inputs d
147. h itself or INF with itself NOTE You can compare INF with INF Infinity is greater than Infinity Chapter 6 TFBASIC Internals 185 Overview String functions in TFBASIC Character constants Characters and Strings in TFBASIC String variables are denoted by adding a suffix to the name of the variable When a string variable is declared 256 bytes are reserved for it The first byte is the length of the string so a string cannot contain more than 255 characters 256 bytes are always reserved for the string whether used or not Like the integer and floating point variables TFBASIC does not initialize its string variables If the programmer does not initialize each string variable it may contain from 0 to 255 characters of any type when it is accessed in the program String constants must be enclosed in double quotes This is different from earlier versions where single or double quotes could be used String constants can be up to 255 characters in length although the editor only handles lines 256 characters long String constants can be used as arguments to commands and functions and can be assigned to string variables String functions can be used just as any other function All other functions can be used as a variable or argument in another expression Of course functions returning a string can only be used where a string is expected Functions returning an integer can only be used when an integer is expected
148. he necessary connections to fully operate the TFX 11v2 Typically 9V batteries have a rating of 500 mA Hour although some are rated at up to 1 Amp Hour Main power is connected through a 9V battery connector The fully assembled case has a 9V battery compartment to house the battery if so desired Another set of pads are on the board to allow mounting of a jack KYCON KLD 0202 A compatible with standard wall mount DC power supply modules The thru holes for this connector are used to attach the tie wrap used as a strain relief for the 9V battery connector This tie wrap must be removed to install the jack When this connector is used the 9V battery compartment will no longer fit inside the case The mating connector of the DC power supply must have a 2 1mm inside post which must be ground BE SURE THE POLARITY IS CORRECT BEFORE CONNECTING A 9 pin mini din LZR Electronics MDJ9PS and a 3 5mm stereo phone jack Shogyo International SJ 0375 3RT are mounted for connecting to the host PC using the Onset cables There is a position for a second 3 5mm stereo phone jack that can be used to connect to the second RS 232 levels channel or any other pins you would like to use Chapter 9 TFX 11v2 Hardware Reference 227 Optional 2 5mm stereo phone jacks Tutorial area Designing a custom interface board for the TFX 11v2 Along one side of the PR 11v2 board are two sets of pads designed to accept either 2 5mm stereo Sho
149. he SLEEP timer is updated with the new value from the current command and the program proceeds to execute the instruction statements that follow until the program reaches the next SLEEP statement At this point it again checks the sleep timer and again waits until it expires before updating the counter and allowing the program to proceed NOTE SLEEP commands to be effective must allow sufficient time for the intervening statements to execute If the command s between the two SLEEP instructions take longer than the SLEEP interval the SLEEP timer will expire before the next SLEEP command is reached This generates a non fatal error signaled by the program writing an out the serial port which identifyes the fact that precise timing has been compromised due to a timer overrun To reset the SLEEP timer use the SLEEP 0 statement otherwise the first invocation of SLEEP will generate an PSET sets the corresponding pin s to outputs and then sets them to 5V PCLR also sets the corresponding pin s to outputs but then sets them to OV Chapter 1 Getting Started 11 CHAN TEMP Run it in TFTools The function CHAN n returns a digital value proportional to the analog voltage at pin n The thermistor is in a divider circuit with a 10K resistor TFBASIC has a convenient function TEMP which converts the output of the converter to a temperature in hundredths of degrees C The command only works correctly when used with t
150. he divider circuit and components illustrated above While still in the text editor window select Run from the Tattletale menu to load and run the program When you run the program you should see the following output Press CTRL C to halt the program 2340 2340 2340 2340 2340 2340 2340 oe a CTRL C halts the program 12 TFX 11 User 5 Guide Build a Data logger One Step at a Time A slightly more complex program Double slashes Blank line INPUT ONERR The following enhanced program demonstrates a few more commands and also adds some descriptive comments that are valuable for code intelligibility and maintenance SAMPLE SIMPLE DATA LOGGING PROGRAM first set up variable parameters Start print input Enter time interval 1 100 sec tInterval print input Enter channel to read 0 10 Channel TNITIALIZATION onerr exit quit when memory overflows Sleep 0 initialize interval LOGGING KKKK getdata sleep tInterval Store 2 chan Channel goto getdata ENDING exit print Logger full stop This allows you to enter comment text The tokenizer ignores any text on the line following the double slash Comments enhance readability and maintainability and take up no space in the executing code Their frequent use is recommended Blank lines are permissible in TFBASIC Use them to separate logical blocks t
151. ide TFBASIC Language Reference for the TFX 11 INPUT Syntax Description Additional Switches x1 x2 x3 get value from console buffered INPUT prompt var INPUT lt s1 gt lt v1 gt x1 L x2 x3 c INPUT allows you to assign a value to a variable entered through the main UART from a terminal You can use a string in double quotes as a prompt A default prompt of the variable name is used if you don t include one If you don t want a prompting string use a zero length string quotes with no intervening characters Input will accept all variable types integer floating point and string Floating point input can be in either fixed point or scientific notation The default terminator is a lt CR gt and the default time out is none By default up to 255 characters can be input As explained below these defaults may be overridden by the optional parameters each of which must be INTEGER expressions except for the Ic options which are single case sensitive characters Set terminating character This byte value represents the terminating character for the input stream The special case means no terminator useful with the x2 parameter below for binary transfers of fixed length with all values possible Set byte count This expression fixes the count of characters to read as input before termination If a specific termination character is defined it takes priority over the count I
152. iod will change on the next transition of the signal X 1000000 4 44 16 Two octaves above 440 A for A 24 to 0 step 1 A X X X 106 100 next A Have half tone scale from 0 to 23 Y 500000 tone 21 Y 21 tone 23 Y 23 tone 19 Y 19 tone 5 Y 5 tone 14 Y 14 Recognize that sleep 0 for i 10 to 1 step 1 tone i 60 0 update continuous signal period sleep 10 produce this frequency for 100 mSec next i tone 0 0 stop the tone Chapter 4 TFBASIC Language Reference 133 Remarks Cautions In the example above the number of cycles is normalized by the interval to make the length of the note constant The above poorly tempered scale is actually remarkably close to a well tempered scale PRINT 10000 24 0 yields the value 2515 about 0 7 away from the right number 2500 The 1 06 ratio is good to about 1 10 of a half tone per octave Driving circuitry should expect the quiescent state to be low If the TONE command is not used for a while after power up set that line low with a PCLR 3 command to ensure that the speaker driver is in its low power state 134 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 UGET Syntax Description Example indentation for clarity only Output Remarks See Also bring character in software UART UGET baud count strvar timeout UGET x1 x25 v x3 The UGET co
153. ipliers CHAN EXAMPLE for counter 1 to 10 value chan 0 print 016B value B 04H value H 1D value next counter CHAN PIN CHAN PIN CHAN PIN CHAN PIN 0 A36 6 A42 11 A26 17 A31 1 A37 7 A43 12 A28 18 A33 2 A38 8 A44 T3 A30 3 A39 9 A45 14 A32 4 A40 10 A46 15 A27 5 A41 16 A29 All 19 channels are set to make ratiometric readings Channels 0 11 may be modified to make absolute measurements by the addition of an external precision reference See Using the onboard A D converters A D Channels 11 18 may be reconfigured to be digital inputs Specifying channels less than 0 or greater than 18 will generate a run time error Section Using the Onboard A D converters 64 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 CHR Syntax Description Example Output Remarks See Also Returns a one character string of the ASCII value of an integer CHR X This function returns a one character string comprised of the ASCII value of the argument This argument must be an integer and must be a value from 0 to 255 For instance since the ASCII values of the letters A B and C are 41 hex 42 hex and 43 hex we could execute this code string chr amp 41 chr amp h42 chr amp h43 print string and the string ABC should print This function is also useful in getting data from the datafile that you know is a string but doesn t have a length byte at
154. it set when you finally check its value The drawing to the right shows which bit is set for each of the four possible floating point errors Cannot compare v Loss of precision ty Not a Number Overflow error o Underflow error A Bits 31 5 not used 1 FPERR variable When the value of FPERR is printed each bit takes on the following values bit O 1 bit 1 2 bit 2 4 and bit 3 8 The values are then added up to produce the final value just as in any binary number For instance if Underflow Not a Number and Loss of Precision errors occur before FPERR is printed the value 13 1 4 8 will be printed Here is the explanation for each error Chapter 6 TFBASIC Internals 183 Underflow Bit 0 weight 1 is set if a number between 1 175494E 38 and zero results or a number between 1 175494E 38 and zero results This is not representable in single precision The result is set to zero Example floatValue 3 0E 28 3 1E 15 produce the error print result F floatValue print the result print error FPERR print FPERR value Printed result 0 000000 value of floatValue error 1 value of FPERR Overflow Bit 1 weight 2 is set if a number greater than 3 402823E 38 or less than 3 402823E 38 resulted This is not representable in single precision The result is set to Infinity or Infinity Example floatValue 2 0E30 1 0E20 p
155. k RTIME or RTIME v RTIME translates the variable seconds to the seven elements of the 2 array Time is counted in 1 100 ths of a second starting at New Year s Day 1980 This command with STIME allows translation between the all seconds format and the year month day hour minute second format RTIME lt v gt translates the variable v which represents seconds only no subseconds to the members of the array 0 gets the second 0 to 59 1 2 gets the hour 0 to 23 3 gets the day 1 to 31 4 gets the month 1 to 12 gets the minute 0 to 59 5 gets the year 1980 to 2047 6 gets the number of 0 01 sec ticks 0 99 sleep 0 loop rtime print THE TIME TS 22 4 2 1 ey 2 0 3 print on Ara Ae 2 63 pes 725 sleep 100 goto loop THE TIME IS 16 24 18 on 5 8 1996 THE TIME IS 16 24 19 on 5 8 1996 THE TIME IS 16 24 20 on 5 8 1996 Dates beyond 2047 are out of range Leap years are handled properly The array is predefined do not initialize with DIM STIME SETRTC READRTC and section TEX Timekeeping 116 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 RUN Syntax Description Example Start Background Process RUN label RUN launches a background task The background program is rigorously timed interrupting the foreground task as needed to perform its job l
156. le v if present Time is counted in seconds starting at New Year s Day 1980 See READRTC RTIME STIME READRTC and section TFX Timekeeping Chapter 4 TFBASIC Language Reference 123 SIN Syntax Description Example Output Cautions See Also Sine value SIN lt x gt SIN returns the sine of the expression in the parenthesis The argument must be in degrees The function takes a floating point argument and returns a floating point value An integer argument will be converted to float first degrees 0 0 init arg notice means it s a float result 0 0 just to force result to be a float for i 1 to 6 result sin degrees print The sine of 5 1F degrees is 6 3F result degrees degrees 72 0 next i The sine of 0 0 is 0 000 The sine of 72 0 is 0 951 The sine of 144 0 is 0 588 The sine of 216 0 is 0 588 The sine of 288 0 is 0 951 The sine of 360 0 is 0 000 DON T FORGET The argument is in degrees not radians COS TAN ATN 124 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 SLEEP Syntax Description See Also low power wait over a precise time interval SLEEP tics SLEEP x SLEEP places the Tattletale in a semi dormant mode until the number of 1 100 second intervals specified by the tics argument has expired It does this by comparing the specified 15 bit tics value with the 16 bit value in a free
157. lly TFBASIC assembly code accepts Q xxQ and xxO in addition to the above The Q prefix is the preferred method for designating octal numbers in assembler Binary Binary Base 2 numbers can be entered in TFBASIC by preceding the number with amp B The entered number must be unsigned and may include up to 32 binary characters It will be treated as a signed 32 bit two s complement number internally TFBASIC assembly code accepts B and xxB in addition to the above The B prefix is the preferred method for designating binary numbers in assembler Decimal Decimal Base 10 is the default radix in TFBASIC and therefore requires no identifying code The entered number must be in the range 2 147 483 647 to 2 147 483 647 It will be treated as a signed 32 bit two s complement number internally TFBASIC assembly code has decimal as its default radix but also accepts D and xxD as radix identifiers TFBASIC supports seven relational operators which are used for comparing two values Relational operations return 1 if the result of the comparison is true and 0 if the result is false See TFBASIC Floating Point on page 179 for details about comparisons involving floats The relational operators are lt less than A lt B lt less than or equal to A lt B gt greater than A gt B gt greater than or equal to A gt B 254 TFX 11 User 5 Guide Glossary of TFBASIC Terms and Definitions SFLASH Strings String Operators
158. long as I O pin 0 is low indentation for clarity only onerr HandleError errVar dfPointer 0 sleep 0 while pin 0 0 store dfPointer 2 chan 0 chan 2 sleep 100 wend print Finished logging ready to off load stop HandleError if errVar 65536 4 print Ran out of datafile Stopped logging else print Logging stopped by error errVar 65536 endif stop Remarks none See Also FOR GOTO REPEAT TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 XMIT XMIT enable disable console output Syntax Description Example Output Remarks Cautions See Also XMIT or XMIT On receiving the XMIT command the Tattletale will stop echoing characters received by the main UART XMIT remains in effect until the Tattletale receives XMIT or a power on reset Under the influence of XMIT characters sent to the hardware UART are simply thrown away xmit print You won t see this xmitt print You WILL see this print Input a number xmit input this prompt will be lost aNumber xmit print the number is aNumber you WILL see this Input a number type 123 here the number is 123 XMIT is most useful when you don t what characters entered into the Tattletale to be echoed Remember everything is suppressed by XMIT even error messages INPUT for another method of not echoing input characters Chapter 4 TFBASIC Language Refer
159. loscope to look for the signal transmitted from the TFX 11 This signal should appear on the serial connector at pin 3 Each time you power up the TFX 11 it will send its sign on message out on this pin and you will see a digital signal on this pin switching between 4 5V and 4 5V If you don t see a signal on this pin the TFX 11 may indeed have a problem You can send it back to Onset for a check out but I ll wager that you tried the wrong pin or have a dead battery Double check and check again If the TFX 11 passed the scope test this means the TFX 11 is sending but the computer is not receiving Check the connections again as described in the cable loopback test above In the terminal window press Enter The TFX 11 should respond with its prompt If this test succeeds it proves that the serial interface can send as well as receive The number sign is analogous to the C gt prompt in DOS and means the Tattletale is idle while waiting for a command Continue on to TFTools Tutorial Step by step on page 7 So nothing you tried worked If the above tests failed or you do not have the tools to properly perform the tests then you may need to return the TFX 11 to Onset Contact us at TFX 11 User 5 Guide A Short TFTools Tutorial TFTools Tutorial Step by step TFX 11 connections for serial communication the numbers in the front of this manual to obtain an RMA and shipping instructions for returns PLE
160. lude one of the letters of a format type D H Q B F or S print 104 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 Output Formatted examples Character codes Character code example For I 1 to 10 Print 1 I1 NFPT I 1 etc print 10H 1 140 1 35B 1 FFFFFFFF 37777777777 l1l11l1111111111111111111111T71111 print 010H 1 0140 1 035B 1 OOFFFFFFFF 00037777777777 OOOLTTI ATT IA Tee Sd ad ed print 10 2F 12 345 12 34 print 10F 12 345 12 340001 print 7 2S 12 345 1 23E1 print 5F 12 345 12 34500 print 40S 12 345 1 234500E1 For floating point numbers two numbers can be used to separately specify the minimum width and the number of decimal places of precision Both are optional with the default digits of precision being 6 Individual characters can be sent by preceding their ASCII value with a backslash You can also specify an expression after the backslash The least significant byte stored in the variable will be sent This example sends out a bell control character print Strike the bell second mate 7 Let us go below Next example prints letters a through z then CR LF for i 97 to 122 print Mi Chapter 4 TFBASIC Language Reference 105 Trailing semicolon Trailing semicolon example Remarks Cautions See Also next i print A trailing semicolon causes TFBASIC to omit the CR
161. mbler opcodes Referencing HC11 control registers Two forms of ASM In line assembly ASM TFBASIC Assembly Language Reference The TFBASIC tokenizer running on the host computer has a built in assembler The tokenizer switches from generating tokens to assembling when it encounters the ASM command and switches back to tokenizing when it encounters the END command This assembler allows the use of named labels and it can access TFBASIC variables by name Labels can be used in the assembly code for flow control and to define local variables Labels must start in the first column Labels can be up to 32 characters long and must begin with a letter or an underscore The only valid characters in a label are upper and lower case characters numbers and underscore The label name can be terminated with a colon when the label is defined but this is not necessary in the assembler These labels are accessible to the CALL command as long as they are defined before CALL is invoked TFBASIC labels are not accessible to the assembly code although TFBASIC variables are The TFBASIC assembler recognizes all of the opcodes defined in the Motorola manuals with some exceptions including all those using the Y register These include ABY CPY DEY INY LDY PSHY PULY STY TSY TYS XGDY CPD STOP BRCLR BRSET IDIV and FDIV Opcodes must have at least one character of whitespace space character or tab in front of them on the line
162. me Alt D Alt E D E ji Editor options Alt E E f Search Alt S Find Alt S F Find again F3 Alt S A 7 Replace Alt S R Go to line Alt S G Tattletale Alt T Run Alt R Alt T R S XMODEM off load Alt T X P i Erase datafile Alt T E Copy program to Flash i H Launch Alt L Alt T L Relaunch AIt T A 3 ji Parallel offload Alt O Alt T P i i Suspend TFX 11 Alt T U 5 Load OS only Alt T O j i Start operating system Alt T S Syntax check Alt Y Alt T Y E Compiler options Alt T C s Chapter 2 The TFTools IDE 23 Key Main Submenu items Hot Key sequence Term Edit CommPort Alt C Serial port Alt C S z s Hex display Alt X Alt C H i Capture to file Alt Z Alt C C i Parallel port Alt C P i Terminal options Alt C T Windows Alt W Tile Alt W T E Cascade Alt W C x Next F6 Alt W N ui b Previous Shft F6 Alt W P Help Alt H About Alt H A i TFBASIC summary Alt H T 24 TFX 11 User 5 Guide CHAPTER 3 TFTools Menu Command Reference TFX 11 User 5 Guide FILE File New Open Close Save Save As Save all Print Ctri S Alt P Exit Alt Q Open Close Save Save As Save all Print Exit Opens an empty text editor window in which you can create a new program The default name will be NONAME n where n is th
163. ments 1abel ds expr comments label rmb expr comments The res ds and rmb directives define a block of uninitialized data equal in length to the value of the expression in the operand field multiplied by the optional size specifier Blocks declared using the reserve directives affect only the location counter and do not generate any output data in the object file asm h 4000 resi res h 100 should be 4000 40FF res b h 100 should be 4100 41FF res s h 100 should be 4200 43FF res w h 100 should be 4400 45FF res l h 100 should be 4600 49FF res q h 100 should be 4A00 51FF Values used in reserve statements must not contain any forward references 164 TFX 11 User 5 Guide Assembly Language Subroutines ATOD12 PDAD12 ATOD8 GETBSR STRBSR STRMEM CHIBUF FLUSHI FLUSHO OUTTST URTGET Assembly Language Subroutines The following locations are the entry points into fixed assembly language routines The value at the beginning of each function s description is the address of that function this address is the argument to the CALL command FD9A Get reading from 12 bit A D converter Enter with one of the channel numbers 0 13 in B register Channels 0 10 specify one of the external A D input channels Channels 11 12 or 13 specify one of the reference channels Return with MSB value in A register LSB value in B register with value shifted left four bits FD9D Po
164. mmand treats I O line 1 as a UART input line to receive serial data The input expects CMOS levels and has the marking state high inverted from the normal RS 232 sense The baud rate is specified by the expression baud and can be any value between 100 baud and 19200 The expression count specifies the number of bytes to be received Strvar specifies the string variable to be used to store the data as it is received The data is stored directly into memory and is not echoed to the screen The expression timeout specifies the time out in 1 100ths of a second this time out aborts the receiving routine in case of an external system failure and continues execution at the beginning of the next command Time out can be set to any value between 0 01 and 655 35 seconds xg UGET 4800 10 X 800 IF LEN X 10 GOTO LT10 ENDIF PRINT RECEIVED ALL STOP LT10 PRINT RECEIVED ONLY LEN X CHARACTERS RECEIVED ONLY 0 CHARACTERS This program will try to receive 10 characters at 4800 baud storing them int the variable X and timing out if all ten are not received in eight seconds Provisions are also made to detect and deal with external System failure UGET uses I O line 1 as a UART input line Like USEND this line uses CMOS levels and has a marking high state inverted from the normal RS 232 sense The transfer format for the received characters is eight data bits
165. n Functions Overview Important note for those who want to design their own interface board UDO UDI SDO SDI RX20UT TX2IN TX2 Explanation of Connector Pin Functions The following paragraphs explain in detail the functions associated with the pins brought out to the PR 11v2 prototype board There are connections made on the protoboard that are required for proper operation of the TFX 11v2 s eight bit A D converter If you design your own board you should include these connections or a suitable alternative to assure proper operation even if you don t use the 8 bit A D If these pins are left unconnected the internal 8 bit A D will definitely not operate properly and may cause other anomalies Onset will supply drawings to assist you in designing a mating PC board Please contact Onset technical support for details J2 6 The output of the hardware UART at TTL levels The signal is inverted compared to the RS 232 SDO output J2 5 The input to the hardware UART at TTL levels The signal is inverted compared to the RS 232 SDI input J2 3 The output of the UART at RS 232 levels The signal is inverted compared to the TTL UDO output J2 4 The input to the UART at RS 232 levels The signal is inverted compared to the TTL UDI input J2 8 The output of the secondary RS232 port at TTL levels The signal is inverted compared to the RS 232 RX2 output J2 7 The input to the secondary RS23
166. n this case the datafile pointer will be set to zero Set if there was an error accessing the SFLASH 168 TFX 11 User 5 Guide Important Addresses in TFBASIC Interrupt Vector Table Overview To allow the interrupt vectors to be user modifiable the interrupt vectors in EEPROM all point to jump vectors that reside in the HC11 RAM Each RAM vector is made up of a JMP instruction followed by a two byte address To change the vector you must replace the RAM address in most cases it points to an RTI with the address of your own handler Addr FD C1 FDC4 FDC7 FDCA FDCD FDDO FDD3 FDD6 FDD9 FDDC FDDF FDE2 FDES FDE8 FDEB FDEE FDF1 FDF4 FDF7 FDFA FDFD Mnemonic SCI SPI PAIE PAO TO OCS5 IC4 TOC4 TOC3 TOC2 TOCI TIC3 TIC2 TIC1 RTI IRQ XIRQ SWI IOT COPF CMF RESET Explanation Serial Communications Interface Serial Peripheral Interface Pulse Accumulator Input edge Pulse Accumulator Overflow Timer Overflow Timer IC4 OC5 Timer Output Compare 4 Timer Output Compare 3 Timer Output Compare 2 Timer Output Compare 1 Timer Input Compare 3 Timer Input Compare 2 Timer Input Compare 1 Real time Interrupt External Interrupt Request Extra External Interrupt Request Software Interrupt Illegal Opcode Trap COP Failure Clock Monitor Failure RESET Used by TFBASIC UART routines PERIOD command TONE command system clock UGET command USEND command COUNT PERIOD commands U
167. nd float down to integer Interpret x as float Assemble HC11 code inline Assemble HC11 code at lt addr gt Arctangent of x Sets the main UART baud rate Gets the main UART baud rate Call x1 with registers X2 returning in v Go to label if CTRL C detected Return CTRL C handling to default A D conversion of channel x Cosine of x Start counting transitions on I O 0 and store in variable Stop counting transitions Return number of cycles at I O pin 0 in time x Dimension variable label to size Return e raised to the x power Integer part of x as integer closer to zero Convert integer x to float FOR v x1 to x2 STEP x3 NEXT v an iterative loop FVAL str GOSUB label IVAL str LEN str LOG X LOG10 x e MID str x1 x2 0 000008 ONERR label v Convert string to float Execute subroutine at label Go to label Stop in lowest power mode Dormant low power uA mode Execute 1st command block if x is true else execute 2nd block Prompt with s load variable v see full description for complete arg list returns a substring s position in a string Integer part of x as integer String to integer Return length of string Natural log of x Common log of x return substring of str Go to label if error L error in v POER x1 X2 eiae gath Clear specified I O pins to low state PEEK addr Byte at address addr PERIOD x1 x
168. nd this pointer automatically increments after each STORE command NOTE Once the data is stored in the SFLASH it cannot be read back or written over by the program TFBASIC supports long integers string constants and strings as well as IEEE 754 single precision floating point There are both implicit and explicit conversion operators to convert numbers between integer and floating point formats and back again See TFBASIC Floating Point on page 179 for details See Radix Integer division by zero will cause the program to stop executing and display the HOW message Refer to the Errors definition below for more information on error handling Floating point division by zero DOES Chapter 11 Glossary of Terms 251 Editing Errors Floating Point Hexadecimals IDE I O Analog Digital Labels Assembler NOT stop program execution As with other floating point errors it sets a bit in the FPERR error variable to indicate an error Division by zero returns a result of infinity See TFBASIC Floating Point on page 179 Editing is done on the host computer in the TFTools IDE The TFX 11 board is not running an interpreter and therefore has no facilities for editing A list of error statements and their causes can be found in TFBASIC Error Messages on page 142 An error will stop program execution and display a message unless an ONERR command has been executed by the program The ONERR command is detailed in the section
169. nd will give the same output although the code it is far less obvious in conveying what the programmer was up to Note also there is no space after the digits in the second example The escape sequence terminates with the last character in the sequence A space included after the sequence will show up as a space in the output mnemonic Here is a list of mnemonic escape sequences the ASCII characters they escape represent and their hex character code sequences list Na BEL alarm the bell character 07H b BS backspace character 08H N FF formfeed character OCH n NL newline the line feed character OAH ME CR carriage return character ODH t HT horizontal tab character 09H NV VT vertical tab character OBH Nx the double quote character 22H Ae the single quote character 27H the backslash character 5CH numeric escape xhh where hh is the hex value of the character to sequences list embed BOTH CHARACTERS MUST BE PRESENT NOTE Octal is not supported 188 TFX 11 User 5 Guide TFBASIC Memory Map TFBASIC Memory Map Mapping of RAM memory for the TFBASIC Memory Map 64K program space BANK 0 using 68HC11 processor and variable storage space DORIA ES Ex yte BANK 1 in the Internal 128K RAM EEPROM array variable storage 60928 bytes Interrupt Vectors User EEPROM System EEPROM Interrupt Translate Table User Program Variables User
170. nnector used Included on the PR 11 breadboard are pads already laid out and ready to accept a thermistor resistor and FET that form a simple but accurate temperature measurement circuit Some of you may want to design your own mating circuit board in place of the PR 11 The required terminations for the 8 bit A D subsystem as well as specific connector pin assignments are summarized in the table below TFX 11 Pin PR 11 Termination Comments BS MINI DIN pin E2 Parallel Port connector B6 MINI DIN pin E8 Parallel Port connector B7 MINI DIN pin E1 Parallel Port connector B8 MINI DIN pin E7 Parallel Port connector B9 MINI DIN pin E3 Parallel Port connector B10 MINI DIN pin E9 Parallel Port connector Bll MINI DIN pin E4 Parallel Port connector B3 3 5mm jack RS232 output B4 3 5mm jack RS232 input A35 5V 8 bit A D reference connection Chapter 8 TFX 11 Hardware Reference 215 Pinouts as viewed from the top of the PR 11 socket strips point toward you TFX 11 Pin PR 11 Termination Comments A34 GND 8 bit A D reference connection B24 Backup Battery Ltihium battery holder B25 9V battery Battery power input PR 11 Top View vec A2 B gy Al GND 81 B udo DO A4 3 D1 B2 UDI D2 A6 B E 5 D3 B3 amp Bispo D4 AS B 9 A7 DS 84 B sol DS A10 G 07 85 HOSTREO E A12 B A All R W B PPMOSI IRQ Al4 A13 CS101 87 BB PICACK CS102 A16 G B A15 PGO EOC 88 G PPSCK PAO A18
171. no parity with one stop bit at least The count parameter has a maximum of 255 USEND Chapter 4 TFBASIC Language Reference 135 USEND Syntax Description Example 1 indentation for clarity only input this string at the prompt followed by ENTER Output Example 2 Remarks Cautions See Also send characters out software UART USEND baud lt string gt USEND sends serial data out I O line 2 The argument can be any string expression constant variable or function The range for baud is 100 to 19200 or a runtime error will occur start input enter text istring usend 300 istring usend 300 x0D x0A send cr lf stop THIS IS A TEST THIS IS A TEST USEND 9600 seconds from power up loop X USEND 9600 str 13 8 X 100 02 X 100 GOTO loop This simple program continuously displays the time on a terminal connected to I O line 2 through a level shifter USEND uses I O line 2 as a UART output line Like UGET this line uses CMOS levels and has a marking high state inverted from the normal RS 232 sense The transfer format for the transmitted characters is eight data bits no parity with one stop bit at least There is no breakout from USEND and sending 220K bytes at 110 baud will take about 6 hours UGET STR 136 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 VARPTR get address of named variable
172. non zero byte POKE H 9C 1 A count of CTRL C characters will continue to be updated at address 9B hex To clear this before you re enable break outs use POKE H 9B 0 62 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 Do not vector CBREAK to a label inside a subroutine When a CTRL C is detected the program will act as if you did a GOTO into the subroutine It will not have a proper return address on the stack and operation will be unpredictable Cautions Chapter 4 TFBASIC Language Reference 63 CHAN Syntax Description Example Input mapping Remarks Cautions See Also get result of A D conversion value CHAN lt x gt The CHAN command returns a digital value corresponding to the ratio of the voltage at the input channel specified by lt x gt to the converter s reference voltage input The TFX has eleven 12 bit channels channels 0 thru 10 and eight 8 bit channels channels 11 thru 18 for a total of nineteen analog input channels The analog inputs are designed to handle signals that range from 0 to the converter s Vcc typically 5V The result of the conversion is left justified to produce a 16 bit result regardless of the number of bits in the converter The result of the 12 bit converter is shifted left four bits multiplied by 16 and that of the 8 bit converter is shifted left eight bits x256 To restore to their unjustified form divide by their mult
173. not be accessible to TFBASIC except through the CALL command and TFBASIC labels are not accessible to the assembly code although TFBASIC variables are The TFBASIC assembler recognizes most of the opcodes defined in the Motorola literature See the section TFBASIC Assembly Language for details Opcodes must have at least one character of whitespace space character or tab in front of them on the line OR a label terminated with a colon This version allows you to install assembly language code that will be executed in line with the TFBASIC code and has the form lt TFBASIC code Chapter 4 TFBASIC Language Reference 55 Assembly to an address ASM lt address gt ASM nothing else on this line not even comments lt assembly code gt lt assembly code gt lt assembly code gt end lt TFBASIC CODE gt In the assembly section everything after a semicolon and up to the end of the line is considered a comment The assembler does not recognize TFBASIC comments A more detailed explanation of this form of ASM is given in the TFBASIC Assembly language section in this manual Notice that the first form of the ASM command provides no way to initialize the A B or X registers before entering the assembly code section This can be done with the second form of ASM When the interpreter reaches this point in the program it DOES NOT EXECUTE THE ASSEMBLY CODE Instead it loads the code to the address specified by
174. nputs are left There are 16 pins available exclusively for digital I O Eight are located on the HC11 and eight are located on the PIC Because of their placement each set has slightly different operational characteristics Since the HC11 is the primary controller for the TFX 11 TFBASIC has direct access to the HC11 port I O pins In contrast the HC11 uses synchronous serial communications with hardware handshaking to operate on the PIC I O pins Therefore it is recommended that all high speed bit twiddling be performed using the 8 bit port on the HC11 while the PIC I O be used for slower speed operations The 8 bit A D converter is internal to the HC11 These A D input pins can also double as digital inputs The 12 bit converter is a separate device and communicates with the HC11 via the SPI bus Here the choice of which inputs to use is mainly based on resolution required The 8 bit converter does allow you to sample more quickly due to its lower resolution and its registers being internal to the HC11 Also available are some of the HC11 bus signals the data lines chip selects and other qualifying signals for attaching external memory mapped items to the HC11 The two chip selects CSIO1 and CSIO2 may be programmed to map into specific addresses simplifying the addition of memory mapped I O devices see TFBASIC Memory Map on page 189 and the HC11F1 Technical Data Book for details The simplified schematic on the following page ide
175. nt argument and returns a corresponding integer or floating point value print abs print abs print abs print abs 000000E0 7 7 7 7 000000E0 Integer arguments outside the range of Tattletale integers 2147483648 to 2147483647 will halt the program with a run time error None Chapter 4 TFBASIC Language Reference AINT Syntax Description Example Output Cautions round float down to integer value AINT lt x gt AINT returns the next integer value less than the argument The value is returned as a float The argument must be a float If itis an integer it will be converted to float first inData 23 7 result aint inData print aint of 5F inData result result aint inData print aint of 5F inData result aint of 23 70000 23 00000 aint of 23 70000 24 00000 Remember this function does not simply strip off the fractional part of the argument Negative numbers return the next lower whole number 32 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 ASC Syntax Description Example Output See Also Returns the ASCII value of the first character of the string ASC str ASC str index In the ASC str function the argument is any TFBASIC string variable ASC returns the ASCII value 0 to 255 of the first character of the string If the string is empty O is returned The ASC st
176. ntifies only the major components and external connections needed to properly interface additional hardware to the TFX 11 208 TFX 11 User 5 Guide TFX 11 Hardware Reference TFX 11 Hardware Reference 9 8304 MHz za 10M appa A50 ADVec ade REF A38 abled ag aDt21 age ADI22 A389 antz3 AS aptas A41 Api25 ade apn26 pass ani Add anes 68HC11F1 A45 8029 FLECGES A46 api210 AT REF A48 anano Minot loaded RB EH HG S B RBB8 sso EI RES RBS RBS RB RBI Reo MRESET Por i TxD 58 PPMOSI PFSCK FIGHSHK PPMISO Von D 100K mE 4 Im 1K um Bet ICLTE 3 WS VOUT A2 VEAT B25 uP B22 10 1N4148 oar ature HG 11 veo PIC vo AT pi IPF GND B23 BH Chapter 8 TFX 11 Hardware Reference 209 TFX 11 Board Dimensions EBEHESEHNERNESEBHEIEBEIUIZEIEIBBIUIBUIBSs mE m GE GUGIGESIISG UINBi OIUUUIUrIE C
177. numbered 0 to 19 DIM Arrayl 20 2 floating point elements numbered 0 and 1 DIM Array2 2 make Array3 have 10 elements numbered 0 to 9 each representing 5 elements numbered 0 to DIM Array3 10 5 os String arrays are not allowed in TFBASIC All arrays in TFBASIC are 0 based References to the members of the Array1 defined above will look like Array1 0 Array1 1 Array1 2 Array1 19 Notice that the index starts at 0 and ends at 19 giving the same number of elements as the number in parentheses The array and the are predefined and therefore automatically available DO NOT attempt to DIM these again The array dimension is 15232 Once a name has been defined as an array it cannot be used for a variable name and vice versa ONERROR RTIME STIME READRTC SETRTC also Data storage options array and TFX Timekeeping array Chapter 4 TFBASIC Language Reference 69 EXP Syntax Description Example Output Remarks Cautions See Also raise e to a power value EXP lt x gt EXP returns the base of the natural logarithms e 2 71828 raised to the power of the expression in the parentheses The function takes a floating point argument and returns a floating point value An integer argument will be converted to float first build this program with your editor arg 0 125 result exp arg print e raised to 5 3F arg is 6 3F result e
178. nversion will give solid repeatable results Otherwise you may require an external reference The 12 bit A D converters will work well with an externally applied precision reference that is 2 5 volts or greater up to Vdd The converter s accuracy depends on the reference voltage and begins to deteriorate with reference inputs less than 2 5 volts Chapter 7 TFX 11 Interfacing 199 Signals that go both positive and negative Circuit for converting bipolar to unipolar Convert a Bipolar Signal Input to Unipolar We have been asked how to interface a bipolar signal to a Tattletale Some Tattletales can be made to run in bipolar mode make sure to add a Schottky diode between V and ground others won t This note shows a simple way to convert a bipolar input to a positive only signal The simple schematic below shows an operational amplifier connected in an inverting configuration Note that this design assumes a relatively low impedance signal is driving Vin reference 5 Vset Vout Vin R1 R2 The only tricky thing we have done is to give a positive bias to the non inverting input to the amplifier Remember that op amps adjust Vout so that the inverting and non inverting inputs have the same voltage The equation for this configuration is Vset Vin Vout Vin R1 R1 R2 or rearranged a little Vout R1 R2 Vset Vin R1 R1 You can change this into two equations one for gain another for off
179. o make your program more readable This command allows you to assign values to variables as the program is executed Notice there is no punctuation between the string constant and the variable name When ONERR is used the program responds to an error instead of printing the error message How We know this example will eventually overflow the datafile and cause an error the ONERR command forces this error to cause a jump to the line labeled exit instead Chapter 1 Getting Started 13 STORE STOP FOR NEXT Retrieving stored data The Store command sends data to the non volatile serial Flash SFLASH datafile Once data is written to this datafile it cannot be read or modified by the program The datafile pointer is available as the read only variable DFPNT After each write to the datafile DFPNT is automatically updated to point to the next available location Data is retrieved after the program is completed The channel command returns the two bytes from the A D converter padded out to four bytes for compatibility with the standard TFBASIC integer variable The 2 after the Store command is a formatting command that says only store the two least significant bytes of the four bytes which in this instance are the only bytes that contain data This command ends program execution It is added here for readability since it really isn t needed The last line of the program halts execution anyway The above code emplo
180. oes not attempt to load or run the program Press Enter or click OK to close the No Errors message Remember just because No Errors is displayed doesn t mean there aren t any logic errors in the program it only means no syntax errors were detected Chapter 1 Getting Started 9 Save your program to a file Congratulations B All is well let s continue Building a temperature monitor uild this circuit onto your breadboard From the File menu select Save as Save the file with the name Debugged tfb By default the file is saved in the same directory as the TFTools program unless you specify a new directory You now have debugged a TFBASIC program While it is certainly not the most useful program ever written it does demonstrate the basic operations of the TFTools Windows IDE This completes the TFTools introductory tutorial The other TFTools commands and options are explained in detail in Chapters 2 and 3 To build a sample data logger continue to the next section Build a Data logger One Step at a Time This section illustrates how to build a simple data logger application starting with a simple temperature monitor and then extending its utility by adding other useful features VREG S vp0104N3 RR 10k 0 1 VO PIN 5 AID CH10 Thermistor TFX 11 The components to construct this circuit are in the goodie bag supplied with the development kit The parts include the thermistor
181. offered as is If you choose to use the software Onset cannot be held liable for any damages or loss of data incurred as a result of its use While we hope you find this software useful itis up to you to determine the applicability fitness and correctness for your application All returns require that you first request and obtain a Return Materials Authorization RMA number from Onset The RMA helps us track your return and speeds processing To obtain an RMA call Onset TFX 11 User 5 Guide ix Disclaimers sales support and have available the model number serial number invoice number and a brief explanation of the problem They will assign you a number to write on the outside of the package and refer to in any correspondence Returns without prior authorization may be delayed NOTE Some returns may be subject to a restocking fee Onset does not authorize or approve the use of this equipment in life support or related safety equipment and cannot be held responsible for any injury or death as a result of it being used in any related application If you choose to use the supplied software you do so at your own risk Onset cannot be held liable for any damages incurred as a result of its use While we hope you find this software useful it is up to you the user to determine the applicability fitness and correctness for your application We encourage your feedback for corrections amplifications interesting applications and o
182. og reference for the 12 bit A D converter input signals J3 9 An input that is by default an N C Using this input requires a zero Ohm resistor R25 to be placed on the TFX 11v2 board and the on board crystal Y2 to be removed After the modifications an input from a precise external 32 768 kHz oscillator can be fed in through this pin to drive the timebase in the PIC 16F873 J3 11 Input to a resistor divider network that is connected to an onboard low battery detector If this input is connected directly to VBAT when the voltage goes below 5 7 Volts the state of BBPWR changes If additional resistance is placed between VBAT and this input the Voltage threshold for detection increases With the choice of an external resistor this can be used as an adjustable low battery detection circuit See MAX917 data sheet for details J1 19 This is the reference output from the MAX917 used in the low battery detection circuit Be careful loading this output because it has little drive capability May be used as an A D reference Refer to the MAX917 data sheet for details Chapter 9 TF X 11v2 Hardware Reference 233 234 TFX 11 User 5 Guide CHAPTER 10 TFX 11 General Hardware Reference TFX 11 User 5 Guide RTC storage structures Two separate crystals Clock resolution TFX Timekeeping TFXBASIC has two structures for holding time related information the variable and the array The variable The v
183. oint into the datafile All datafile storage is sequential with the datafile pointer being kept internally The datafile pointer is zeroed at launch and can only increment The assembly language routine GETBYT that gets a byte from the UART input buffer now does not block and also returns count in B reg of characters in the buffer IF and IFF have changed The old IF syntax no longer works We now use the IFF syntax exclusively BUT we use the spelling of IF The operator which allowed you to put multiple commands on a single line is no longer available You can now have only one command on a line The following commands have been removed from TFBASIC ADLOOP BURST DTOA ITEXT LEFT OFFLD OTEXT PEEKW PEEKL POKEW POKEL REM RIGHT XSHAKE The STR command is much more flexible under TFBASIC You can create a string with all the same options available to the PRINT command But now you have a string variable that can be printed stored split into sub strings appended to other strings or compared with other strings When strings are stored they are stored with the length of the string first followed by the characters The PRINT command no longer supports the x y format 192 TFX 11 User 5 Guide If you are coming to TFBASIC from TxBASIC VAL function expanded No early wakeup from SLEEP ITEXT removed Datafile pointer variable replaced with DFPNT read only
184. older TFX 11 User 5 Guide 212 The PR 11 Prototype Board Overview Power connections Optional power jack The backup battery The PR 11 Prototype board was designed to support many different configurations and applications It carries Power Serial and Parallel jacks as well as pads to take common connectors which you may purchase separately and install yourself as necessary The PR 11 board outline is designed to fit inside a standard SERPAC A 279V plastic enclosure included in the deluxe development kit The case comes with the parts needed to handle the basic PR 11 board configuration as delivered Depending on what optional connectors you install you may have to modify the case to access them The standard configuration includes a 9V battery connector for power a 9 pin mini din connector to mate to the Parallel cable and a 3 5mm stereo phone jack to mate to the serial cable The CR2032 backup battery holder is mounted on the underside of the PR 11 board When the TFX 11 is plugged into the PR 11 board the PR 11 board provides all the necessary connections to fully operate the TFX 11 Typically 9V batteries have a rating of 500 mA Hour although some are rated at up to 1 Amp Hour and CR2032 lithium 3 2V batteries have a rating of 190 mA Hr Main power is connected through a 9V battery connector The fully assembled case has a 9V battery compartment to house the battery if so desired Another set of pads
185. ols you will need to turn it on each time you start TFTools There are two file capture modes Append and Overwrite The default mode is append If you select an existing text file when you turn Capture to file on you will be prompted to either append the new information to the existing file or to overwrite the existing file Parallel port Displays the currently selected parallel port and allows you to select a new one Parallel Port r Select Port 4 OK Cancel Terminal Options Controls the tab settings in the terminal window Terminal Options Tab size a OK Cancel 38 TFX 11 User 5 Guide WINDOW Window Tile Cascade Mext Previous F6 Shift F6 1 TerminalForm v 2 C tfEoolsiNONAMEO tFb Tile Cascade Next Previous 1 TerminalForm etc Rearranges all the open windows on the screen Brings different windows into focus in forward or backward order useful when some of the open windows are not visible Lists all open windows The terminal window is always listed first followed by all open tfb files with the complete path The active window is indicated with a checkmark Chapter 3 TFTools Menu Command Reference 39 HELP Help About TFBASIC summary About Displays the About Box which lists the version number of TFTools you are using This information is important if you need to contact technical support TFBASIC Provides
186. on of this driver To start TFTools click the Start menu and select Programs Onset Applications TFTools or double click the TFtools icon on the desktop The program opens displaying the main TFTools window and the terminal window A Short TFTools Tutorial This tutorial is recommended for those who have never used a TattleTale along with an Onset Integrated Development Environment IDE for Win dows such as TxTools for Windows or Crosscut for Windows If you have you can probably skip this section While your computer is running TFTools and the terminal window is displayed power up the TFX 11 by connecting its battery clip to a battery or power supply f you use a power supply make sure that the polarity is not reversed when you connect the power to the board or you may damage the board We strongly recommend a current limited power supply for development A 50 mA current limit will protect your TFX 11 from most common disasters It s not hard to go through a lot of 9 volt batteries when developing a program for the TFX 11 For example just leaving a TFX 11 plugged in running at full speed over a weekend can use up to half of an TFX 11 User 5 Guide A Short TFTools Tutorial Sign on message Troubleshooting if the Tattletale didn t sign on alkaline 9 volt battery The Radioshack 9 volt battery eliminator plugs into a wall outlet and the TFX 11 battery snap connector It has a long cord and works nicely in all
187. p printout is disabled from the foreground task when a background task is running The background prints a if it oversleeps to distinguish it from the foreground This example shows one simple method of signaling between background and foreground The A variable is originally set to 0 When the time comes for the background to stop the foreground sets A to 1 Since this could have been set while the background is SLEEPing the foreground must wait for an acknowledgment that the background has received the signal and is ending This is done by the background resetting A to 0 If the foreground just went on and tried to start the second background task and the first background task was still running an error HOW error 48 would be 146 TFX 11 User 5 Guide General Guidelines for Background Tasks signaled Another example of a dual tasking program This example is somewhat easier since there is only one background task Watch the square wave with a scope flag 0 rate 6 run background print A 300 Hz square wave is running on pin 2 print Type any character to stop it INPUT keyS 1 N flag 1 stop background sleep 0 loop sleep 1 pset 2 sleep 1 pclr 2 if flag 0 goto loop stop Chapter 4 TFBASIC Language Reference 147 148 TFX 11 User 5 Guide CHAPTER 5 TFBASIC Assembly Language Reference TFX 11 User 5 Guide TFBASIC assembly language Labels assembler Asse
188. p amps will have real values for input and output impedance as well as potential limitations when attempting to drive a signal near V supply or the V supply Advantages High input impedance will not load down your signal Source Makes an excellent signal buffer Low output impedance is appropriate for driving A D inputs Disadvantages Takes a positive input only To handle a negative input in a Tattletale TFX 11 application would require adding a negative supply to the Tattletale TFX 11 Signal may be distorted near the rails Chapter 7 TFX 11 Interfacing 203 The real world Op amp limitations Op amps we have used LT1077 1078 1079 As magical as they appear to be op amps are not perfect Some limitations are described below Current drain In your Tattletale TFX 11 application you won t want to use any more power than needed Check the current drain specs on the part you choose Supply voltage Not all op amps work with supply voltages of 5 and ground In some applications you may even want your circuit to work while the TFX 11 is running from 3 volts Max output swing Most op amps can only drive to within about a volt of their positive supply others to only about a volt of their negative supply Input voltage range Not all op amps are pleased with inputs close to the supply lines some will work with input voltages below ground Don t be confused by the inverting configuration described above In tha
189. periodic short bursts of logging and control activity This is a small block of 128 bytes of non volatile data storage located inside the HC 11 processor It is accessible only from TFBASIC and can be read and written at any time using VSTORE and VGET It is specifically meant for calibration or configuration parameters that are unique to the particular instrument This allows a single program to run on different TFX 11s without having to have different versions of the program that depends on sensor calibration or environmental factors This data will be retained with no power applied Chapter 11 Glossary of Terms 255 Variables White Space Integers Variable names up to 32 characters long are allowed in TFBASIC All variables not specifically typed are 4 byte integers IEEE 754 Floating Point Variables intended to be floating point variables must have a suffix Strings Variables intended to hold strings must have a suffix Arrays Arrays must be declared using the DIM statement An array may be either floating point or integer Up to two dimensions are allowed and total array size is limited to the size of available memory String arrays are not allowed in TFBASIC White space is stripped out except in strings before it is sent to the TFX 11 White space is necessary around command variable and array names 256 TFX 11 User 5 Guide INDEX Symbols 50 250 254 255 50 250 253 254 50 250 25
190. prompt Chapter 3 TFTools Menu Command Reference 33 Copy program to Flash Launch Relaunch Parallel off load Copies the program that you executed with the Run command to the TFX 11 s flash storage This enables you to permanently load a program using only the serial cable Tokenizes and loads the program in the edit buffer into the TFX 11 s flash storage through the parallel connection The datafile is erased and the datafile pointer is reset to O If there is data in the TFX 11 it saves the data before the Launch proceeds Causes a reset of the TFX 11 which will restart the currently burned in program The datafile is not erased and the datafile pointer is not reset This requires a parallel connection This command is only enabled in the terminal window and allows you to choose how to off load the TFX 11 datafile You cannot off load less than the number of bytes given in the Bytes to off load field but you may off load more up to the number specified in Size of datafile After you enter the number of bytes and click OK you can specify the name of the file to save the data to and the directory Off load Information Deployment 3 Launched on Sep 9 2002 15 09 56 Size of datafile 1011712 Bytes stored in datafile 0 Bytes to off load o Deployment number Displays the number of times the unit has been launched Launched on TDisplays the PC date and time stored when the program was launched
191. quirements Windows tools Parallel port note The TFX 11 was designed to be programmed and off loaded using an IBM compatible PC The minimum system requirements are e 133 MHz Pentium or greater running Windows 98 or higher e 32MB RAM e Hard Drive with 5MB available for program and related file storage e 1 3 5 1 4MB floppy drive 1 CD Drive 1 parallel port 1 available RS 232 serial port Microsoft or compatible mouse The TFX 11 comes complete and ready to run using only a single serial port on the host PC For access to all the features of the TFX 11 the host computer also requires at least one standard parallel printer port connection The parallel interface on the TFX 11 was designed to be compatible with all PC parallel ports including ECP and EPP when configured to run in standard mode viii TFX 11 User 5 Guide Introducing your TFX Technical Support Policy Warranty and Disclaimers Read this before you contact Onset for technical assistance Software programming problems Hardware circuit design problems Warranty Returns Onset provides technical support through a variety of channels The first and most important is this manual We have made every effort to provide you with all the information you need in an easy to read format please check through it thoroughly before calling us If you cannot find what you need in the manuals please be sure you understand the types of
192. r index form of the function allows you to get the ASCII value for any character in the string The index must be a value from 1 to the length of the string If index is larger than the size of the string the ASCII value of the last character of the string will be returned If the string is empty O is returned StrData ABC print ASC StrData print ASC StrData 2 print ASC StrData 3 print ASC StrData 2 print ASC StrData 1 stop A B CBA MID INSTR LEN CHR Chapter 4 TFBASIC Language Reference 53 ASFLT Syntax Description Example Output Cautions Remarks See Also interpret argument as float ASFLT lt x gt Integer and float variables both take up four bytes of storage There is nothing in the storage format that allows the two to be distinguished from each other Therefore all variables are assumed to be integer unless otherwise designated ASFLT is used to tell TFBASIC to interpret data retrieved from storage as a floating point value FltVal 100 0 create floating point value vstore 10 FltVal store it in UEEPROM 0 2 0 Fl1tVal store another value in bank switched RAM print vget 10 retrieve and print as integer default print 0 Print bank switched RAM as integer print 1F asflt vget 10 retrieve and print as float print 1F asflt 0 vetrieve and print as float stop 1120403456 1120403
193. r sleep instead of printing or setting OVRSLP Uses same routine as TFBASIC SLEEP command FD97 Stopwatch functions Values returned are four bytes with MSBs in register X and LSBs in register D Units are in ticks and will depend on the RATE command Call with a value of 0 4 in the B register for one of five functions B reg Function 0 Initialize Chains the stopwatch interrupt to the system clock and zeroes the clock Must be called before other functions are used 1 Remove stopwatch clock Calling this saves the extra time stopwatch adds to the system clock handler 2 Clear clock Clears the stopwatch to zero Stopwatch keeps running 3 Get clock Returns current stopwatch value then clears stopwatch to zero Stopwatch keeps running 4 Split clock Returns current stopwatch value but DOES NOT clear stopwatch value Stopwatch keeps running start input RATE value r lf r gt 32 goto start limit RATE to 32 for now endif rate r set to change timer resolution secPerTick 1 0 100 r print Timer resolution 4f secPerTick seconds input Hit key to start dummy 1 166 TFX 11 User 5 Guide Assembly Language Subroutines call amp hfd97 0 initialize and zero stop watch input Hit key to stop dummy 1 call amp hfd97 3 ticks get current stop watch time call amp hfd97 1 remove stop watch from system clock print 4 4f ticks secPerTick seconds goto start
194. r up of the TFX 11 Cable loopback test Recheck the port settings in TFTools From the CommPorts menu select Serial Port Make sure the selected port matches the port the cable is connected to and the baud rate is set to 19200 With the terminal window open short the tip of the phone jack to the next ring down a paper clip works well and type characters at the keyboard The characters typed should appear in the terminal window If Chapter 1 Getting Started 5 It just won t work returning the TFX 11 to Onset characters do not appear check the cable connection and try again If characters still do not appear you may have a faulty cable or COM port If there is another COM port available try moving the cable to it and repeating the above procedure If you change to another COM port don t forget to change the port number in TFTools from the CommPort menu select Serial Port If the previous test did not work try connecting to another computer If that is not possible insert a break out box between the terminal and the Tattletale serial cable and verify that your terminal is driving pin 2 Check the battery or power supply If the connections are OK perhaps the battery you are using to power the Tattletale is bad Test it under load to see if the voltage is correct for its rating Run a scope test If the battery checks out and you are convinced that the TFX 11 isn t working go back to the break out box and use an oscil
195. rd to the mouse you may use keyboard command equivalents to perform all the functions of the mouse Dialog Box Navigation Keyboard Equivalents Cancel Esc OK Enter Move withing group Up Down Arrows Toggle check box Space Toggle radio button Space Next group Tab Previous group Shift Tab Editing Control Functions Keyboard Equivalents Move cursor Arrow Keys Cursor word left Ctrl Left Arrow Cursor word right Ctrl Right Arrow Marking blocks Shift Arrow keys Select to beginning of line Shift Home Select to end of line Shift End Select to top of page Shift PgUp Select to bottom of page Shift PgDn Move cursor one page PgUp PgDn Move to beginning of line Home Move to end of line End Delete character at cursor Del Toggle insert mode Ins Delete character to left Backspace TFX 11 User 5 Guide Navigating the IDE without a Mouse Key Main Submenu items Hot Key sequence Term Edit File Alt F New Alt F N b Open Alt F O i Close Alt F C Save Ctrl S Alt F S Save as Alt F A A Save all Alt F V Print Alt P Alt F P Exit Alt Q Alt F X i Edit Alt E Undo Ctrl Z Alt E U Cut Ctrl X Alt E T E Copy Ctrl C Alt E C ij D Paste Ctrl V Alt E P i h Clear Ctrl Del Alt E L j Paste Date ti
196. rial ports are either DB9M or DB25M If you only have a DB25M COM port available you will need to get a DB25F to DB9M adapter available at your local RadioShack The latest TFTools supports COM1 thru COM16 on your host computer This connection is used to communicate with the program while it is running Be sure to remember which COM port you are connected to and that no other devices conflict with it see notes below Note 1 Older computers may share interrupts on the COM ports Typically COM1 and COM3 share one interrupt and COM2 and COM4 Chapter 1 Getting Started 3 Windows NT and the parallel port driver Start TFTools Who should use this tutorial Supplying power share another Only one device using interrupts can be active on either pair at one time Therefore if your mouse is connected to COM1 DO NOT use COM3 but restrict your choice to COM2 or COM4 If you have a mouse on COM1 and modem on COM2 then you may use COMA as long as you do not use the modem or load its drivers while TFTools is active Note 2 Most likely if you have a USB to Serial converter it should work with the TFX 11 If not contact Onset technical support for more information on USB adapters Under Windows the parallel port requires a special driver be installed Windows NT has special requirements for installation of this driver If you have Windows NT refer to the readme file on the CD for more information on the proper installati
197. riven from a separate supply where there is a possibility that the supplies won t track VFET driver The VN0104 is an N channel DMOS transistor with an on resistance of about 4 ohms when the gate is 5 volts and lots of megohms when the gate is grounded In the configuration shown it is suitable for driving small relays or opto isolators The VN0104 has a Vds of 40 volts so the solenoid can be powered directly from Vbat or any other convenient source Power switch This last example shows how to configure two VFETs one P channel and one N channel to for example turn on and off a separate voltage to switch Vbat to a separate regulator 198 TFX 11 User 5 Guide Using the Onboard A D Converters Signal conditioning of analog inputs Ratiometric A Ds External reference Using the Onboard A D Converters The analog inputs are designed to handle signals that range from 0 to the converter s Vcc typically 5V This full range ratiometric conversion is ideal for potentiometer inputs with the wiper attached to the input and the ends tied to Vsw and ground Other sensors such as strain gauges may need amplification before they can be attached to the converter input The TFX 11 has its negative reference tied to ground and its positive reference input tied to the converter s 5V positive supply This means that if you are measuring your sensor as a fraction of the reference input a potentiometer or a bridge your co
198. roduce the error print result F floatValue print the result print error FPERR print FPERR value Printed result INF value of floatValue error 2 value of FPERR Not a Number Bit 2 weight 4 is set when the floating point routine has no idea of how to represent the result One way to get this is to take the square root of a negative number which is an imaginary number The result is flagged as a not a number Example floatValue sqr 4 0 produce the error print result F floatValue print the result print error FPERR value of FPERR Printed result NaN value of floatValue 184 TFX 11 User 5 Guide TFBASIC Floating Point error 4 value of FPERR Loss of Precision Bit 3 weight 8 is set when an integer greater than 16777215 or less than 16777215 is converted to floating point This is because it takes more than 24 bits to represent such a number and single precision floating point has only 24 bits to represent the precision of a number TFBASIC will convert the value to the nearest floating point equivalent Example floatValue float 17789321 produce the error print result F floatValue print the result print error FPERR print out FPERR Printed result 17789319 000000 value of floatValue error 8 value of FPERR Could not Compare This error occurs when you attempt to compare any floating point value with NaN or if you try to compare INF wit
199. ropriate use for this limited memory is to store configuration information or sensor calibration parameters These values would be written once when the instrument is calibrated or setup and then could be read any number of times as necessary This technique allows a single program to compensate for sensor 240 TFX 11 User 5 Guide TFX 11 Data Storage Options Minimum SFLASH datafile storage or external hardware variations across otherwise identical instruments These 128 locations are divided into 32 groups of four making the integer or float the default storage unit They are accessed only by the TFBASIC commands VGET and VSTORE with valid locations being 0 31 These locations are totally non volatile they will remain even if all power is removed 472K 2Mb bytes Serial flash EEPROM SFLASH This storage is in an external serial linked flash EEPROM or SFLASH This SFLASH can be read written or erased directly by the Host computer via the parallel port but it is write only to the TFBASIC program The SFLASH is written to using the STORE command After each write to the SFLASH TFBASIC updates an internal pointer variable to point to the next location in which data can be written to The only way to erase this memory is to perform a successful OFFLOAD from the Host computer after which you will be prompted Do you really want to erase this data This is to help protect the data from accidently being corrupted or erased
200. rs Byte sequence and VARPTR x TABLE 1 memory big endian little endian address TFX PC A 0 MSB LSB Atl A 2 sis E A 3 LSB MSB NOTE The terms little endian and big endian come from Gulliver s Travels where Jonathan Swift imagined a never ending war between two Kingdoms one the Big Endians who crack open their hard boiled eggs on the big end and the other the Little Endians who crack open their hard boiled eggs on the opposite end Since integers in TFBASIC are stored MSB first the address returned by VARPTR x returns the MSB of the integer The LSB of the integer is at the address VARPTR x 3 In the following example it is assumed you want to only return the LSB of the variable and the other three bytes can be safely ignored TABLE 2 memory address A 0 MSB VARPTR x points here A 3 LSB Example X 100 put a number 255 in the LSB of X y varptr X print Value of X peek y pointing to MSB Output Value of X 0 Chapter 6 TFBASIC Internals 177 This is obviously not the correct answer The 3 added to y in the peek function of the following code corrects the problem Example X 100 y varptr X print Value of X peek y 3 now pointing to LSB Output Value of X 100 178 TFX 11 User 5 Guide TFBASIC Floating Point Internal representation Variables Example TFBASIC Floating Point The floating point
201. rward slash 00 00 00 01 00 02 00 03 should be h 6162 two single quote characters terminators terminators terminators Limits Maximum of 255 bytes generated from a single data statement Chapter 5 TFBASIC Assembly Language Reference 161 END Syntax Description Example label end comments The end directive instructs the assembler to stop reading the current source file and return control to the TFBASIC tokenizer asm ldaa 12 ldx H 86 staa 0 x end Configuration Byte set 162 TFX 11 User 5 Guide Details of the TFBASIC Assembler Directives EQU Syntax Description Examples Remarks label equ expr comments The equ directive permanently assigns a numeric value to a symbol which may be used anywhere a constant is expected Both the label and operand fields are required EBUG 1 pl W E Ei equ equ equ equ equ equ equ equ FALSI FALSE H 7F H OD H OA H 09 H 20 E ASCII delete carriage return line feed horizontal tab space character Values used in the assignment expression must not contain any forward references The TFBASIC assembler does not adapt EQU to perform text substitution on arguments which do not evaluate to a number Chapter 5 TFBASIC Assembly Language Reference 163 RES DS RMB Syntax Description Examples Remarks label res expr com
202. s 204 Open 26 operational amplifier 202 Options 36 Opto isolation 197 Output Protection 198 OUTTST 165 Overflow 184 OVRSLP 168 P PAO PA7 220 232 Parallel cable Pinout 247 Parallel Port viii Parallel Port 38 Parse Error 9 Paste 27 Paste Date time 27 PCL 11 PCLR 97 PDADI2 165 PEEK 98 168 PERIOD 99 PGO EOC 219 232 PICACK 217 230 PICHSHK 218 230 PIN 102 Pin outs TFX 11 board 211 POKE 103 168 Power Connections 213 227 PPMISO 218 230 PPMOSI 217 230 PPSCLK 217 230 PR 11 breadboard 215 217 228 229 PR 11 Prototype Board 212 226 Previous 39 PRINT 104 PRINT Formatting 104 Program Commands 44 PSET 11 107 PTOG 108 Q Quick Start 3 R R C 197 R W 219 231 Radix 57 154 RATE 109 Ratiometric 199 ratiometric 64 RB7 RBO 218 230 READRTC 111 REF 220 233 REF 220 233 Registers 119 Relational operators 180 Relaunch 34 REPEAT 113 Replace 30 RES 164 RESET 173 Resistor 197 RETURN 78 115 Returns ix RMB 164 RTC Storage Structures 236 RTIME 116 117 Run 33 S schematic 208 Schottky diode 200 Chapter 259 SDI 119 SDO 121 serial cable 3 Serial Cable Pinout 247 Serial Port 37 SETRTC 123 SFLASH v 14 35 43 129 168 172 173 174 181 239 240 241 251 255 sign bit 176 Sign on message 5 SIN 124 182 SLEEP 11 125 Special characters embedding 187 Specifications vi vii SQR 126 182 Square wave 133 STIME 127 STOP 14 128
203. saved temporarily Then 3 is converted to float and then multiplied as floating point by 7 9 Then the result of 5 2 is converted to float and this is added to the already float result of 3 7 9 and stored as a float in floatValue If instead we had assigned the result to an integer variable the only change would be that the final result would be converted to integer just before the assignment the math operations would not have changed All TFBASIC relational operators are available for floating point comparisons The precedence is exactly the same too As with the arithmetic operators the tokenizer checks the two operands of each compare operation If one is a float and the other an integer the integer is first converted to float and then the comparison is performed Unlike math operations relational operations do not carry the result or type of 180 TFX 11 User 5 Guide TFBASIC Floating Point Conversions Floating point functions comparisons along in complex expressions The result of each comparison can only be TRUE or FALSE For example in this equation Float Integer ae o 99 Bit wise AND 2 is converted to a float and then compared with 2 3 and the result TRUE is saved Then 18 is compared with 20 as integers and this result is TRUE also Finally the two TRUE results are ANDed together the amp operator This is TRUE and the print will be executed Beware of checking for equality in an IF s
204. set Gain yVout yVin R2 R1 and offset Vout for Vin 0 Offset Vset R1 R2 R1 Alternatively R2 R1 Gain 200 TFX 11 User 5 Guide Convert a Bipolar Signal Input to Unipolar Example application Example circuit for converting bipolar to unipolar Vset Offset R1 R1 R2 Suppose we had a signal that ranged from 0 5V to 0 5V and wanted to translate that to a voltage we could read with our positive signal only A D We first add a 2 5V reference to the A D and translate our input to a signal ranging from 0 to 2 5V For this we would need a gain of 2 5 and an offset of 1 25V Our circuit actually gives a negative gain so that 0 5V would translate to 2 5V and 0 5V will translate to OV From the gain and offset equations we can find the ratio R2 R1 2 5 and Vset 0 357V If we use standard 1 resistors and the op amp from Linear Technology we get the schematic shown below LT1009CZ 7X CLIE To A D Vin 100K 249K We show a 2 5V reference also from Linear Tech fed by a 3K resistor and divided down to reach the 0 357V The resistors are not the exact values that we need to give the gain and offset we wished for but come very close The LT1077 s input offset current is 0 25nA max giving an offset of about 25uV at the input This combined with the input offset voltage of 40uV max is still less than 1 LSB of a 12 bit converter Chapter 7 TFX 11 Interfacing 201
205. shortcut for changing some of these settings Click one of these two boxes to change the baud rate or COM port or select Serial port from the CommPort menu 19200 Com1 Click this box to toggle the capture the text to file setting described above or select Capture to file from the CommPort menu If you selected to append the new text to the old an A appears in the box If you selected to overwrite the existing file an O appears Capt offA Click this box to toggle the hexadecimal display mode or Hexen select Hex display from the CommPort menu When turned on incoming characters are displayed in hexadecimal form in rows of 16 characters on the left with their ASCII equivalent displayed on the right Selon Click this box to toggle the vertical scroll bar As the scroll bar is turned on or off the character number in the next box increases or decreases by two IMPORTANT Once the scroll bar is turned on the latest characters are not added to the terminal window Even if you scroll back to the bottom any communication between the TFX 11 and your computer will not appear on the screen You will need to turn the scroll bar off again to view the latest entries This is a status only box that displays the number of lines 15 in this example followed by the number of characters 84 in this example the terminal window can display as currently sized Drag the bottom or top borders of the window to adjust the n
206. ssage Refer to the Errors definition in this section for more information on error handling Single quotes are used to enclose character constants double quotes enclose character strings Using single quotes for character strings may generate an error or cause unexpected behavior The radix is the number base used to interpret numeric constants typically either decimal octal binary or hexadecimal Decimal is the default Radix and there is no way to globally change this Any number with a radix other than decimal must be specifically identified using the Chapter 11 Glossary of Terms 253 Base 16 Base 8 Base 2 Base 10 Relational Operators following techniques NOTE The identifying characters are not case sensitive Hexadecimal Hexadecimal Base 16 numbers can be entered in TFBASIC by preceding the number with amp H The entered number must be unsigned and may include up to eight hexadecimal characters It will be treated as a signed 32 bit two s complement number internally TFBASIC assembly code accepts H Oxxh in addition to the above The H prefix is preferred for designating hex numbers in assembler Octal Octal Base 8 numbers can be entered in TFBASIC by preceding the number with amp O where O is the character o not the digit zero The entered number must be unsigned and may include up to eleven octal characters It will be treated as a signed 32 bit two s complement number interna
207. ssemble HC11 code at lt addr gt Arctangent of x Sets the main UART baud rate Gets the main UART baud rate Call x1 with registers 7 x2 returning in v Go to label if CTRL C detected Return CTRL C handling to default A D conversion of channel x Returns a one character string of the ASCII value of an integer Cosine of x Start counting transitions on I O 0 and store in variable Stop counting transitions Return number of cycles at I O pin 0 in time x Dimension variable label to size e EXP x Return e raised to the x power FIX x Integer part of x as integer closer to zero FLOAT x Convert integer x to float e FOR v x1 to x2 STEP x3 NEXT v An iterative loop e FVAL str e GET x n e GETS x e GOSUB label e GOTO label e HALT e HYB x Convert string to float Return n byte value from datafile at address x Return string from datafile at address x Execute subroutine at label Go to label Stop in lowest power mode Dormant low power uA mode Chapter 4 TFBASIC Language Reference 47 IF x ELSE ENDIF e INPUT s vLx Lx x1 INSTR x str1 str2 e INT x e VAL str e LEN str e LOG x e LOG10 x MID str x1 x2 e ONERR label v e PCLR x1 x2 e PEEK addr PERIOD x1 x2 e PICINT x Ly z e PIN x1 x2 e POKE addr value PRINT s L n LX dE e PSET x1 x2 e PTOG x1 x2 e RATE READRTC v e REPEAT UN
208. st 8 strings you searched for are stored in the Find list Click the drop arrow to access this list Note Selecting Find from the menu disables the options related to Replace Find Replace Find replace Options v Start at top Whole words Selected text Case sensitive Wrap around Jv Prompt on replace Replace all Use as default Find Cancel Customize your search by using the following options Start at top Starts searching for the string at the top of the active editor window When this option is not selected the search begins where the cursor is located By default this option is enabled Chapter 3 TFTools Menu Command Reference 29 Find Again Replace Selected text Searches for the string in only the text that you ve highlighted in the editor window Whole words Searches for only complete words that match the search string instead of partial words for example if you re searching for the word stopped find will not display stop as a positive match when this is selected Case sensitive Searches for an exact match based on the uppercase and lowercase usage in the Find field Wrap around Continues the search from the beginning again if no match was found Use as default Saves the currently selected options as the default settings for all future searches Once a string has been located with Find use this option or press F3 to locate the ne
209. startup As it is battery backed it can retain its contents from one reset to another as long as the backup battery is not removed Chapter 10 TFX 11 General Hardware Reference 239 This bank of RAM is also accessible using the GETBSR and STRBSR described in the Assembly Language Subroutines section This memory is not accessible directly via the parallel port Any data stored here must be transferred to the SFLASH before off load or transferred directly out the UART via a running TFBASIC program ARRAY limitations The ARRAY is mainly meant for use as a datafile Unlike the SFLASH datafile which is write only the ARRAY may be written and read It is battery backed and can be considered non volatile as long as the backup battery is viable ARRAY variables CANNOT be used as the following FOR loop variable RTIME argument STIME argument READRTC argument e SETRTC argument CALL return variable INPUT variable e ONERR return variable This should present no problem as there is plenty of RAM available for regular variables UEEPROM 128 bytes User EEPROM inside the HC11 This is located in a section of the internal memory map of the HC11 It is read erased and written in units of four bytes the standard TFBASIC variable As with all EEPROMs any one location can only be written a limited number of times approx 10 000 before it fails This is in contrast to reads which are unlimited The most app
210. t PRINT COUNT 100 now count with function 1998 1997 Chapter 4 TFBASIC Language Reference 67 Remarks Cautions See Also Triggering off the positive edge In the same amount of time the PERIOD function will return a more accurate timing measurement COUNT has two advantages e t can be simpler to use e The number of transitions in duration can be unknown Note about 5 channel count example The maximum input frequency is about 30KHz Rates higher than that may return erroneous results Durations greater than 65535 or less than 0 will generate run time errors PERIOD 68 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 DIM Syntax Description Examples Remarks Cautions See Also dimension array DIM label size size This command is used to define an integer or floating point array in TFBASIC Any legal variable name can be used as an array name as long as its size is defined first by using this command All array members take 4 bytes just like any TFBASIC variable integer or floating point DIM allows you to dimension an array It must appear in the program before any reference to members of the array Attempts to access members outside the array s boundaries as in Array1 21 or Array1 1 in the example below result in a HOW error which will terminate program execution unless ONERROR is used make Arrayl have 20 elements
211. t as strings are made up of text characters The resultant offloaded datafile can be viewed directly in any word processing program Binary format cannot be viewed directly but requires intermediary software that transforms it to text format before it can be presented Strings and text can be stored directly as the STORE command accepts the format specifiers used by the PRINT command When using these format specifiers the data is effectively printed to the datafile While storing data as ASCII text is often results in a far less efficient use of space filling up the datafile more quickly than storing the same data in binary format the trade off is space vs the convenience of having the offloaded datafile be a readable version of the data If stored in binary format the offloaded datafile must be run through a program to parse the data and reformat for display or printing whereas a datafile properly stored in string format can be opened and viewed in any Word processing program file viewer and even printed directly immediately after offload For applications that don t worry about cramming the maximum amount of data into the datafile it is recommended that the data be stored in text format The following code is offered as an example 242 TFX 11 User 5 Guide Guidelines for Storing Data to the Datafile Example Store data in text format HYB 0 loop OutsideTemp TEMP chan 0 InsideTemp TEMP chan 1
212. t checklist What you will need to get started Additional items you will find extremely useful Getting Started The following is a list of what you should have received in your development kit This User s Guide PR 11 PR 11v2 breadboard Program and documentation CD Parallel cable DB25 to 9 pin mini DIN Serial cable DB9 to 3 5mm stereo phone jack 9 volt battery Plastic case e Combo screwdriver Assorted jacks for the PR 11 PR 11v2 breadboard Goodie bag containing 1 10k thermistor 1 10k 0 196 resistor 1 Transistor FET If anything appears to be missing please contact Onset immediately e A TFX 11 TFX 11v2 board purchased separately from the development kit An IBM compatible computer meeting the minimum system requirements as described in the ntroduction on page viii A fine point electronics soldering iron and electronics type solder A benchtop power supply 9V battery or 9V battery eliminator A voltmeter or multimeter An oscilloscope The reference book by Horowitz and Hill The Art of Electronics Second Edition Cambridge University Press ISBN 0 521 37095 7 TFX 11 User 5 Guide Quick Start Tutorial Let s try it out Do you understand BASIC OK unpack your Tattletale Install the TFTools software Connect the serial cable Important notes about COM ports Quick Start Tutorial Acknowledging that it is a rare person who wants to read the
213. t circuit the input voltage is always at ground Input offset voltage The input offset voltage can be understood as the voltage difference between the positive and negative inputs needed to make the output voltage zero Ideally this should be zero in reality many op amps have input offsets of 10mV or more This offset will appear as an error at the output equal to the input offset times the gain of the circuit Input offset current Many op amps have FET inputs that take almost no current at the input but some can have sizable currents flowing nanoamps into or out of the inputs This can lead to sizable errors if your input resistor is a large value That s not all but should be enough to give you some idea of what to look for in op amp data sheets We will show some of our biases by giving you short descriptions of three op amps we like Note that each has its own strengths Single dual and quad amplifier from Linear Technology at linear com 408 432 1900 This part has lovely current drain input voltage range and input offset voltage specs 204 TFX 11 User 5 Guide Operational Amplifiers TLC1078 ALD1704 1701 2701 4701 Current drain e Supply voltage Max output swing Input voltage range Input offset voltage Input offset current 40pA typical for each amplifier UA microamp a millionth of an amp 3 volts minimum ground 6mV to positive supply 1 Volt mV millivolt 1 1000V
214. tate it can mean only one of two things either the HOST is no longer requesting control or the HOST is requesting communication with the PIC If the HOSTREQ remains de asserted for more than 2 seconds it is understood to be a disconnect otherwise the PIC disables all CS on the bus and waits for a command from the HOST Communications to the PIC from the host include functions such as reading and setting the time setting an alarm start time or periodic sleep wake cycle time getting status information such as serial number and Model number of the board and version information for the PIC firmware The primary use of this interface is off loading of the SFLASH data and uploading new program images to the SFLASH using TFTOOLS The HC11 is completely shut down while the HOST is active When the HOST parallel interface is disconnected the PIC assumes the position of supervisory controller and holds the HC11 in RESET until the PIC finishes setting up the HC11 s environment In this state the PIC can only communicate with the HC11 via the SPI and the HC11 must be running for those communications to take place On power up the PIC s tasks include detecting if the HOST parallel interface is connected and if it isn t connected controlling the orderly power up of the HC11 When the PIC determines the HOST interface is not connected it releases the reset it holds on the HC11 so it can start running in expanded mode At this point the PIC becomes
215. tatement using floating point operands It s possible that the numbers may appear to be equal using print commands but may not truly be equal You should always test using greater than or equal or less than or equal There are two kinds of conversions implicit and explicit We have mentioned implicit conversions in the previous discussions If two operands are of different types and one is converted to the other s type this is an implicit conversion TFBASIC only makes implicit conversions from integer to float Explicit conversions are accomplished with the FLOAT INT and FIX functions You must watch out for overflow and loss of precision when making explicit conversions Overflow occurs when a floating point number with a large exponent is converted to integer For instance 1 0E15 cannot be converted to integer because the maximum integer is approximately 2 1E9 This is considered an error by TFBASIC Loss of precision occurs when an integer with too many digits is converted to floating point Integers in TFBASIC have 31 bits of precision plus a sign bit while floating point numbers only have a precision of 24 bits one bit is an implied 1 TFBASIC does not consider this an error It just rounds the floating point value to the nearest representation of the integer that it can There is an ambiguous situation This is when floating point values are stored in binary in the SFLASH datafile or in the UEEPROM Anything stored there is assumed
216. tation Marks Radix TFBASIC labels can be up to 32 characters long must begin with a letter an underscore _ or the symbol and end with a colon The only valid characters in a label are upper and lower case characters numbers underscore and TFBASIC labels DO NOT have to begin in the first column of the line Line numbers are not acceptable as labels There are almost no immediate commands and line numbers are not allowed Blank lines are permissible and are encouraged for readability Line numbers are not allowed in TFBASIC The TFX 11 supports the two logical operators AND and OR which are used for both bit wise operations and logical connectives Unlike most other BASIC dialects the operators are not spelled out but instead are represented by the symbols amp for AND and for OR TFBASIC does not support the use of colons to allow multiple statements on a single program line See Radix Overflow errors are detected during the evaluation of an expression when the intermediate value becomes greater than the maximum long integer four byte integer value of 2 147 483 647 or less than the minimum long integer value of 2 147 483 648 Overflow or underflow can occur in floating point numbers if the intermediate value is outside the range 1 175494E 38 to 3 402823E 38 See the TFBASIC Floating Point on page 179 section for details Integer overflow errors cause the program to stop executing and display the HOW me
217. ter 0DH CR call amp H0400 amp H1000A X register 1 A register 0 B register OAH LF print Finished Notice the lines sleep 0 followed by sleep 50 The PRINT command in TFBASIC sends all its output to a buffer The characters in this buffer are sent out the UART in the background as fast as the baud rate will allow but this is slow compared to the speed of the CPU When the PRINT command is completed TFBASIC continues on with the next command while characters may still be waiting in the buffer to be sent out the UART The assembly routine we wrote bypasses the UART buffer and will interfere with characters being automatically output from the buffer So we pause to let the buffer clear before using our routine Notice the new methods of defining the number base of constants You have these options IN THE ASSEMBLER ONLY For example the constant 19 decimal can be defined as Decimal is the default base amp H works the same as in TFBASIC decimal 19D or D 19 or 19 hex 13H or amp H13 or H 13 or 13 octal 230 or 23Q or Q 23 or 23 binary 10011B or B 10011 or 10011 154 TFX 11 User 5 Guide ASM mnemonics and addressing modes Single byte Inherent Indirect Indexed Extended Extended Direct ASM mnemonics and addressing modes The TFBASIC assembler uses the same opcode mnemonics that Motorola uses in its HC11 literature All assembler mnemonics must have at least one character of whitespace
218. the ASM command until it finds the end statement lt TFBASIC code ASM address nothing else on line not even comments assembly code assembly code assembly code end lt TFBASIC CODE The A B and X registers have a total of 32 bits CALL initializes these on launch using input parameters gt and returns their values at exit in the lt optional output variable gt In both cases the registers are packed the same way 31 o 0 TxBASIC Variable Expression X register A register S6 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 Radix Remarks See Also The assembler automatically appends an RTS to the end of your code If your assembly routine is launched by an interrupt you should end your code with an RTI The assembler will append an RTS to this but it will not be executed A more detailed explanation of this form of ASM is given in the TFBASIC Assembly language section earlier in the manual Assembly code allows more methods of defining the number base of constants You have these options IN THE ASSEMBLER ONLY in defining a constant 19 decimal as hexadecimal 13H or amp H13 or H 13 or 13 notice amp H works as in TFBASIC octal 230 or 23Q or Q 23 or 023 e binary 10011B or B 10011 or 9610011 e decimal 19 or 19D or D 19 decimal is the default number base Define and call functions by name Make sure in line code is not executed by
219. the HOST via the parallel port a PICINT interrupt or a high to low transition on the IRQ line The maximum value of the parameter is 65535 seconds HYB works in a similar manner to SLEEP The HYB timer runs from HYB wake up to HYB wake up For example if you exit a HYB at time O or perform a HYB 0 and then execute code that takes 3 seconds to complete and then execute another HYB with an argument of 5 you will be in the low power HYB for only 2 seconds Thus you exit the second HYB when 5 seconds have elapsed since the previous HYB As with SLEEP you must first execute a HYB 0 to initialize the HYB clock There is no printout as with the SLEEP command if the time has already gone past Check the oversleep byte with PEEK amp H9E and if MSB is set it did run out of time HYB 0 for i 1 to 12 HYB 5 print Awake from HYB with next i The following example shows how to awake early from a HYB using the PICINT It assumes a pull up resistor has been added a 100K resistor would work to connect I O Pin 16 to 5V pin B22 on the pin strip is one location for this Normally the HYB will awake every 10 seconds If you ground I O Pin 16 the HYB will awake early and the Seconds print will reflect this hyb 0 loop print Seconds print current time if intstate 0 if PICINT disabled picint 1 0 enable PICINT Chapter 4 TFBASIC Language Reference 81 Remarks Cautions See Also
220. the binary length byte from written with the strings If you are unfamiliar with data storage formats it is highly recommended you use strings and try some offlaods of test data to make sure it all works as you expect PRINT GET GETS Chapter 4 TFBASIC Language Reference 129 STR Syntax Description iin x1 x2 Examples Output Remarks Cautions See Also assign ASCH formatted output to string STR s L n x1 x2 Create a string by concatenating quoted strings converted numerical values optionally formatted string variables and character constants in any order represents a quoted string optional numeric formatting integer floating point or string expressions character constants tempc float temp chan 0 100 0 rh float chan 2 BigStr str degrees c 6 2F print BigStr store BigStr fempC RH rh degrees c 50 5 RH 64 00 This function formats output exactly like the print statement but allows assignment of the results to a string variable After the output string reaches 255 characters in length all other characters are discarded PRINT 130 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 TAN Syntax Description Example Output Cautions See Also Tangent value TAN lt x gt TAN returns the tangent of the expression in the parenthesis The argument must be in d
221. the program FLOAT INT Chapter 4 TFBASIC Language Reference 71 FLOAT Syntax Description Example Output Cautions See Also convert integer to float value FLOAT lt x gt FLOAT returns the floating point representation of the argument The argument must be an integer build this program with your editor inp 123 result float inp print float of inp 5 1F result inp 77 result float inp print float of inp 5 1F result float of 123 123 0 float of 77 77 0 Single precision floating point has a precision of 24 bits while integers have a precision of 32 bits Arguments outside the range of 16777215 to 16777215 will lose precision when converted to floating point This Loss of Precision error FPERR 8 does not stop program execution A non integer argument will cause an error in the tokenizer FIX INT 72 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 FOR Syntax Description Examples Build this program with your editor Output when run in TFTools Now build this program with your editor Output when run in TFTools for next loop FOR var initial TO final STEP inc statements NEXT var FOR v x1 TO x2 STEP lt x3 gt statements NEXT v FOR loops provide one of four methods of looping available in TFBASIC Here var can be any TFBASIC integer variable and
222. the subroutine v an optional variable name to receive the state of the X A and B registers when the subroutine returns to TFBASIC The translation of the x2 and v arguments into the microprocessors registers 81 A Eee TFBASIC Variable Expression iee Aron eee In the example below the B register is filled with the ASCII value of a character to be sent out the UART The X register is filled with the number of times to send this character beware zero in the X register will send it 65536 times do not use location 400H if using CSIO1 and CSIO2 chip selects print Start out in TFBASIC asm amp HO400 assembly routine will load at address74COH test ldaa H 2E test if transmit register empty anda H 80 test bit beq test branch back if not empty stab H 2F send character in B reg by storing in register 13H dex Count down one character bne test if not zero branch back for more end print ASM code has been loaded at 0400H sleep 0 sleep 50 must wait for PRINT output to finish call amp H0400 amp H10041 X register 1 A register 0 B register 41H A call amp H0400 amp H20042 X register 2 A register 0 B register 42H B call amp H0400 amp H30043 X register 3 A register 0 B register 43H C call amp H0400 amp H1000D Chapter 5 TFBASIC Assembly Language Reference 153 Radix X register 1 A register 0 B regis
223. the tokens The TFX 11 s interpreter engine includes a monitor that is active when the program is not running and is identified by the prompt The interpreter and monitor are loaded along with the program tokens and make up the program code that is downloaded to the TFX s Serial FLASH SFLASH The Token Engine is an interpreter that executes the TFBASIC program tokens jumping to the Monitor on an error unless redirected with the ONERR command receiving a CTRL C unless redirected by the CBREAK command or after executing a STOP or HALT Token Ctrl C HOW error STOP only if not redirected by CBREAK only if not redirected by ONERR 172 TFX 11 User 5 Guide TFBASIC Structure Monitor On launch or power up RESET TFTools TFBASIC development on aPC The monitor has a number of functions that respond to control characters CTRL R Start the interpreter on the program already in RAM CTRL L Load a tokenized program into RAM CTRL E Erase the datafile CTRL O Start XMODEM off load of the datafile CTRL H Load and execute a HEX file These characters may be entered when the terminal window is active On launch the TFX 11 always copies the operating system and program if present from SFLASH to RAM It then checks for a valid program in RAM by verifying the checksum and performing other checks as described below Bits are set in location AOH to report the following errors Bit 0 will be s
224. ther comments Application notes or suggestions supplied to us are not eligible for compensation unless details have been worked out in advance We will incorporate them when and where appropriate for the benefit of all users TFX 11 User 5 Guide Introducing your TFX Contacting Onset Preparing to contact Onset Please have handy the following information How to contact Onset If you have searched our manuals help files and other sources of assistance and still have not found an answer then you need to contact Onset Before you contact Onset please have the following information available Operating system name and version number Host computer brand name and model Number of MB of installed RAM Processor type Processor speed e TFTools version number e TFX board serial number PIC software version number Installed or attached devices modems network printers etc and their corresponding ports Please be sure to include this information in any correspondence If possible and if appropriate to the problem please try to be seated at your computer when you call You can contact us by phone fax email U S mail and the internet See the inside front cover of this manual for the current numbers Our web and FTP sites contain the latest software and example programs for the TFX TFX 11 User 5 Guide xi xii TFX 11 User 5 Guide TABLE OF CONTENTS CHAPTER1 1 Getting St
225. tine saving return address The GOSUB and RETURN commands allow you to use subroutines in TFBASIC The label specifier can be a line number or label The RETURN statement signals the end of the subroutine GOSUBs can be nested at least 20 deep GOSUB EXAMPLE SUB1 SUB2 SUB3 GOSUB SUB1 GOSUB SUB3 STOP GOSUB SUB2 RETURN RETURN RETURN 1st Subroutine 2nd Subroutine too much excitement PLEASE STOP l KKKKK PRINT lst Subroutine PRINT 2nd Subroutine PRINT too much excitement PLEASE STOP Never use GOTO to exit a subroutine called by GOSUB GOTO RETURN 78 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 GOTO Syntax Description Examples Remarks See Also go to label GOTO label GOTO causes an unconditional transfer of the program to the specified label GOTO EXAMPLE 1 simple unconditional jump GOTO SKIP PRINT you won t see this SKIP PRINT you will see this STOP GOTO can be used to exit any number of nested FOR WHILE and REPEAT loops Good programming practice avoids using GOTO Never use GOTO to exit a subroutine called by GOSUB Never use GOTO to jump to code that will execute a return statement WHILE REPEAT FOR GOOD RETURN Chapter 4 TFBASIC Language Reference 79 HALT Syntax Description Example
226. tion of the clock time and data both in the 128K RAM and internal to the HC11 and PIC when main power is removed It does this by switching to the backup power when the primary voltage falls below the backup voltage The backup power now becomes the primary power The BBPWR flag changes state but NO OTHER POWER SAVING OPERATIONS ARE PERFORMED THIS IS UP TO THE SYSTEM DESIGNER When the backup battery is switched in it powers all the circuitry that the main battery powered It is up to the system designer to have the program explicitly check the Battery Source Flag BBPWR on a regular basis When the BBPWR flag reports the system is on backup power it is recommended that the system power off any peripherals that are connected to Vcc When this is complete then the TFX 11 program should put the TFX 11 into its lowest power state HYB With everything powered down and HYB active the TFX will draw minimal current typically less than 100uA Periodic brief wakeups from HYB allow the program to check the BBPWR flag to see if main power has been restored with little impact on power consumption For example if HYB wakes every thirty seconds it can check to see if the primary battery has been replaced and if so continue from where it left off With the backup battery powering the system and the TFX 11 in HYB the primary battery can be easily swapped out and replaced with a fresh one If the program is not structured to follow this scenario as described
227. to assist you in designing a mating PC board Please contact Onset technical support for details B1 The output of the hardware UART at TTL levels The signal is inverted compared to the RS 232 SDO output B2 The input to the hardware UART at TTL levels The signal is inverted compared to the RS 232 SDI input B3 The output of the UART at RS 232 levels The signal is inverted compared to the TTL UDO output B4 The input to the UART at RS 232 levels The signal is inverted compared to the TTL UDI input B5 Driven LOW by the Host PC when requesting attention Bringing this line low will halt a running TFBASIC program Not meant as a user function B6 Communications line from Host PC to TFX 11 Not meant as a user function B7 TFX 11 signal that it has recognized the HOSTREQ Not meant as a user function B8 Host to TFX 11 communication clock Not meant as a user function Chapter 8 TFX 11 Hardware Reference 217 PICHSHK PPMISO GND LED RB7 RBO MRESET VCC GND LITH VBAT B9 TFX 11 signal to host that it is ready for new command Not meant as a user function B10 Communications line to Host PC from TFX 11 Not meant as a user function B11 System digital ground B12 Output from external activity LED When oscillating the PIC is active when not the PIC is sleeping B13 B20 Highest numbered block of the 24 digital I O pins RB0z1I O16 RB7 O23
228. to be integer In this case you must use the ASFLT function to tell TFBASIC to interpret the data as floating point See ASFLT in the TFBASIC Command Details section Here is a list of the functions available for floating point operations The functions that take a floating point argument will automatically convert an integer to float before executing the function Functions that take an Chapter 6 TFBASIC Internals 181 Print Store formats integer argument will signal an error if passed a floating point argument except for ABS which can take either type of argument TABLE 3 Name Description Argument type Return type abs absolute value float or int float or int asflt interpret value as float no integer float conversion made atn arctangent in degrees float float cos cosine of angle in degrees float float exp raise e to power float float fix float to integer closer to zero float integer float integer to float integer float int float to integer less than float integer argument log natural logarithm float float log10 common logarithm float float sin sine of angle in degrees float float sqr square root float float tan tangent of angle in degrees float float There are two floating point formats for printing or storing data as characters Fixed point notation uses only digits and the decimal point Scientific notation uses a mantissa which is really fixed point followed by an exponent in powers of ten
229. ue 113 RETURN Bless return from subroutine 115 RTIME Wetted es Read local software real time clock 116 RUN Start Background Process 117 SDI T shift register input 119 RUE shift register output 121 SETRTC M transfer local time in seconds to PIC RTC 123 lo PERPE RENE Sine 124 SLEEP low power wait over a precise time interval 125 square root 126 S ME EE set local software real time clock 127 STOP M M stop program execution 128 STORE EE store to datafile 129 STR xosbsepxe eg assign ASCII formatted output to string 130 TAN EE Tangent 131 TEMP EEE NEMUS sents convert number to temperature 132 TONE send square wave out 133 UGET qu dts bring character in software UART 135 USEND PUE send characters out software UART 136 VARPTR Pt oe cee ol get address of named variable 137 VGET usc tu Ge WU get variable from user EEPROM 138 VSTORE m store variable to user EEPROM 139 WHILE MEER loop while expression true 140 TFX 11 User 5 Guide XV XMIT XMIT enable disable console output 141 TFBASIC Error Messages 142 General Guidelines for Background Tasks 144 CHAPTER 5 149 TFBASIC Assembly Language Reference TFBASIC Assembly Language Reference 150 ASM mnemonics and addressing modes 155 Summary of TFBASIC Assembler Directives 157 Details of the TFBASIC Assembler Directives 158 159 G DATA DB FCB DW FDB FCC 160 END 102 FOU 163 S DS
230. umber of lines displayed drag the side borders of the window to adjust the number of characters displayed 1584 Use the editor window to write edit and debug TFBasic programs up to 64K bytes in size To start writing a new program open a new editor from the File menu select New To edit an existing program select Open 20 TFX 11 User 5 Guide Understanding the TFTools Integrated Development Environment from the File menu and select the tfb file you wish to open The title bar in the editor window displays the full path and file name for the tfb file For new programs NONAME is listed in the title bar until you save the file Unlike the terminal window multiple editor windows can be open at once You can cut or copy text from one window and paste it to another via the Windows clipboard You can also switch between several open windows and minimize maximize or close them as needed but only the currently selected window is active Use the Window menu to keep track of all open editor windows Although each editor window is an independent text editor there are some global settings shared by all open edit windows From the Edit menu select Editor Options to set the global tab setting autoindent mode and date time string format There are two edit modes you can switch between while entering code insert and overwrite Press the Insert key to toggle between these modes In insert mode text is added to the line
231. v e VGET x e VSTORE x y e WHILE x WEND e XMIT XMIT Shift in x bits Shift out string expression Shift out x1 value using x2 bits End program execution Store x to EEPROM using n bytes Create string Tangent of x Send x2 cycles of square wave of period x1 continuous if x2 0 Store data from software UART to string Send string data out software UART Thermistor conversion degrees Cx100 Address of variable v Return value of UEEPROM at address x Store y to UEEPROM address x Execute command block while x is true Enable disable console output Chapter 4 TFBASIC Language Reference 49 Arithmetic Relational and Logical Operators TFBASIC Language Reference for the TFX 11 These are the TFBASIC arithmetic operators in order of precedence all operators on the same level are evaluated left to right highest 9 Multiplication Division Modulo Unary Minus Logical bitwise 1 s complement Addition Subtraction lt gt gt lt gt Relational operators Logical bitwise AND Logical bitwise XOR Logical bitwise OR Assignment Il gt Qo V lowest 50 TFX 11 User 5 Guide TFBASIC Language Reference for the TFX 11 ABS Syntax Description Example Output Cautions Remarks See Also absolute value ABS lt x gt ABS returns the absolute value of the expression in the parenthesis The function takes either an integer or a floating poi
232. variable Setting the BAUD rate Entering comments in the code PIN command PCLR PSET and PTOG limitations HYB command acts differently The VAL function has been split into IVAL for integers and FVAL for floating point numbers This allows these functions to be used anywhere VAL could only be used where it was being asigned to a variable so the compiler could decide if an integer or floating point value was to be output The form of SLEEP with early wake up if D1 goes high has been removed The INPUT command covers most of the functionality of ITEXT but is more flexible because it stores to a variable Notice the addition of the DFPNT read only variable This was necessary because you don t have control of the datafile pointer as before The datafile pointer is automatically set to zero when a new program is loaded and is only changed by the STORE command This makes accidental overwriting of data impossible unless you load a new program without off loading the data first TFTools gives a warning if you attempt to do this There are two new commands to read GETBAUD and change SETBAUD the baud rate of the main UART The following baud rates are available 300 600 1200 2400 4800 9600 19200 and 38400 The only method of entering comments in a TFBASIC program is with the II operator You can no longer use the at the beginning of a line to make the rest of the line a comment Neither can you use the REM comm
233. wer down 12 bit A D converter FDAO Get reading from 8 bit A D converter internal to 68HC11 Enter with one of the channel numbers 0 7 in B register Return with value in A reg zero in B register FDA3 Read byte from Bank switched RAM Offset into bank in X register values from 0 to 60927 valid Byte returned in A register FDA6 Store byte in Bank switched RAM Byte to store in A register Offset into bank in X register values from 0 to 60927 valid FDAS Store byte in A register to next location in datafile FDAC Return next byte in UART input buffer without removing it Byte returned in A register FDAF Flush UART input buffer FDB2 Flush UART output buffer FDB5 Check for characters in UART output buffer Number of characters remaining is returned in the A register FDB8 Receive next byte from UART buffer and return in A register Returns the number of characters remaining in the buffer in the B register Waits for a byte before returning Chapter 5 TFBASIC Assembly Language Reference 165 URTSND URTTST FEESBF SLEEPF STPWCH Example showing how RATE interacts with Stopwatch function FDBB Send byte in A register out UART via buffer FDBE Return number of characters available in UART input buffer in A register FD88 Flush the SFLASH RAM buffer to EEPROM FD94 Enter with sleep argument in D register No check is made if argument 232767 Returns with Overflow flag set if ove
234. wo 8 bit ports 8 bit bus interface with chip selects for expansion Program in TFBASIC and Assembler inside full featured Windows IDE iv TFX 11 User 5 Guide Introducing your TFX TFX 11 specific features TFX 11v2 specific features TFBASIC language overview New to Onset s development environment e Dual processors Motorola 68HC11F1 and Microchip PIC16C62A Dimensions 2 4 in x 3 2 in x 0 5 in 1 RS 232 hardware UART serial port 1MB Serial FLASH SFLASH e Dual processors Motorola 68HC11F1 and Microchip PIC16F873A Dimensions 1 2 in x 2 75 in x 0 5 in 2 True RS 232 serial ports 2MB Serial FLASH SFLASH TFBASIC is a tokenized dialect of the familiar BASIC Beginners All Purpose Symbolic Instruction Code with language extensions These extensions added by Onset simplify data logging and control tasks Although the fundamental structures of the languages are similar there are many important differences This manual discusses the language with particular emphasis on this dialect s additions omissions and exceptions If you are familiar with Onset s TTBASIC or TXBASIC refer to the section What s New and Different in TFBASIC at the end of Chapter 6 If this is your first Tattletale be sure to read Chapter 1 Getting Started and complete the tutorials TFX 11 User 5 Guide v TFX 11 Specifications Electrical Environmental Performance Dimensional Non volatil
235. x COS x COUNT x CHAN x e EXP x e FIX x e FLOAT x e FVAL str e GET x n GETS x e INT x e INSTR x str1 str2 e VAL str e LEN str e LOG x e LOG10 x MID str x1 x2 e PEEK addr PERIOD x1 x2 SIN x e SQR x STR s L n LxIL x e TAN x e TEMP x e VARPTR v e VGET x Returns the ASCII value of the first character of the string Interpret x as float Arctangent of x Sets the main UART baud rate Returns a one character string of the ASCII value of an integer Cosine of x Return number of cycles at I O pin 0 in time x A D conversion of channel x Return e raised to the x power Integer part of x as integer closer to zero Convert integer x to float Convert string to float Return n byte value from datafile at address x Return string from datafile at address x Integer part of x as integer more negative returns a substring s position in a string String to integer Return length of string Natural log of x Common log of x Return substring of str Returns value of byte at address addr Time for x1 cycles of signal to pass x2 is timeout Sine of x Square root of x Create string Tangent of x Convert x to degrees C times 100 for thermistor input Address of variable v Return value of UEEPROM at address x Chapter 4 TFBASIC Language Reference 45 Digital I O Control Low Power and Time Commands e PCLR x1 x2
236. xt occurrence of the same string Searches in the editor window for one string and replaces it with another Type the string you wish to search for in the Find field and then type the new string you wish to use in the Replace field Or use the drop arrows to select a string previously entered in the Find field or the Replace field the 30 TFX 11 User 5 Guide last 8 entries are stored in both lists Be aware that leaving the Replace field empty means that the found text will be erased Find Replace Find Replace Options w Start at top Whole words Selected text Case sensitive Wrap around v Prompt on replace Replace all Use as default Find Cancel Unlike Find all options in this dialog are enabled When Prompt on replace is selected the default you will be asked to confirm that you want the string to be replaced When Prompt on replace is not selected the replacement will happen automatically Select both Prompt on replace and Replace all to automatically look for the next occurrence of the string you want to replace and confirm the replacement For details on the other options see the Find section above Goto Line Jumps to a specific line in the code By default the line the cursor is currently positioned in will be listed in the Go to line field Enter the line Chapter 3 TFTools Menu Command Reference 31 number you wish to jump to and
237. ying the ONERR command is a little fancy the following code works just as well for A 1 to dfmax Sleep tInterval Store 2 chan Channel next A Here dfmax is a predefined variable that returns the size of the datafile This command along with NEXT forms a powerful looping structure in TFBASIC The loop starts with the assignment of the first specified value 1 to A and executes all the code up to the NEXT command At the NEXT command the variable A increments and the program goes back to the FOR line The new value of the variable is then compared with the value after the TO If it is less the intervening code between the FOR and the NEXT is executed again If not execution is passed to the line following the NEXT statement Note that the current drain after executing the STOP command is as low as it would be executing SLEEP the logger is waiting for an incoming character Data can then be off loaded To retrieve the data from the SFLASH you need to be running TFTools The TFBASIC program if running must be halted and the prompt must appear in the terminal Next from the Tattletale menu select either 14 TFX 11 User 5 Guide Build a Data logger One Step at a Time Making your program boot on power up XMODEM off load or Parallel off load which will copy the data from the datafile to a file on the host PC the parallel cable must be connected for parallel off load to work The program may be stored

Download Pdf Manuals

image

Related Search

Related Contents

Digicom MAP - Swissphone  Samsung SE-S084C Manuel de l'utilisateur  取扱説明書 INSTRUCTION MANUAL  Heath Zenith SL-4180/84 User's Manual  

Copyright © All rights reserved.
Failed to retrieve file