Example: bachelor of science

www.picaxe.com BASIC COMMANDS Section 2 1

Section 2 BASIC COMMANDS revolution (c) revolution Education : rights 10 !This PDF is designed to be used with the shortcut links (document outline) visible on the left hand these links makes it much easier to navigate through this manual! Section 2 BASIC COMMANDS revolution (c) revolution Education : rights 10 .. 5 picaxe Software .. 7 Pre-Processor and Directives .. 8 Variables - General .. 13 Variables - Storage .. 14 Variables - Scratchpad .. 15 Variables - System .. 16 Variables - Special function .. 17 Variables - Mathematics .. 25 Variables - Unary Mathematics .. 28 Input / Output Pin Naming Conventions .. 40branch .. 43calibadc (calibadc10) .. 57dec .. 62doze .. 63eeprom (data) .. 66end .. 67exit .. 71get .. 72gosub (call) .. 73goto .. 79hi2csetup - slave mode (X2 parts only).

Section 2 BASIC COMMANDS revolution (c) Revolution Education Ltd. Web: www.picaxe.com All rights reserved. Version 7.9.2 10/2015 2 2 www.picaxe.com Contents ...

Tags:

  Picaxe, Revolution

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of www.picaxe.com BASIC COMMANDS Section 2 1

1 Section 2 BASIC COMMANDS revolution (c) revolution Education : rights 10 !This PDF is designed to be used with the shortcut links (document outline) visible on the left hand these links makes it much easier to navigate through this manual! Section 2 BASIC COMMANDS revolution (c) revolution Education : rights 10 .. 5 picaxe Software .. 7 Pre-Processor and Directives .. 8 Variables - General .. 13 Variables - Storage .. 14 Variables - Scratchpad .. 15 Variables - System .. 16 Variables - Special function .. 17 Variables - Mathematics .. 25 Variables - Unary Mathematics .. 28 Input / Output Pin Naming Conventions .. 40branch .. 43calibadc (calibadc10) .. 57dec .. 62doze .. 63eeprom (data) .. 66end .. 67exit .. 71get .. 72gosub (call) .. 73goto .. 79hi2csetup - slave mode (X2 parts only).

2 79hi2csetup - master mode .. 84high .. 86high portc .. 89 Section 2 BASIC COMMANDS revolution (c) revolution Education : rights 10 94hserout .. 97hspiin (hshin) .. 99hspiout (hshout) .. \ \ else \ endif .. {goto} .. {goto}.. 109if {goto} .. 110if {goto} .. exit .. exit .. gosub .. gosub .. 112inc .. 128irout .. 134kbled (keyled) .. 136let .. 137let dirs / dirsc = .. 139let dirsA / dirsB / dirsC / dirsD = .. 140let pins / pinsc = .. 141let pinsA / pinsB / pinsC / pinsD = .. 144low .. 145low portc .. 146nap .. 158poke .. 161pop .. 170put .. 171pwm .. 172pwmduty .. 173pwmout .. 174random .. 177read .. 178readadc .. 179readadc10 .. 180readdac .. 184 Section 2 BASIC COMMANDS revolution (c) revolution Education : rights 10 .. 186readmem.

3 190readrevision .. 194readowclk .. 195resetowclk .. 203reverse .. 205rfout .. 207run .. 209select case \ case \ else \ endselect .. 216serout .. 228setfreq .. 232shiftin (spiin) .. 234shiftout (spiout).. 241srset / srreset .. 246switch on/off .. 254touch .. 256tune .. 266uniout .. 270writemem .. 272 Appendix 1 - COMMANDS .. 273 Appendix 2 - Additional (non-command) reserved words .. 274 Appendix 3 - Reserved Labels .. 275 Appendix 4 - Possible Conflicting COMMANDS .. 276 Appendix 5 - X2 Variations .. 277 Appendix 6 - M2 Variations .. 278 Manufacturer Website: .. 279 Trademark: .. 279 Acknowledgements: .. 279 Section 2 BASIC COMMANDS revolution (c) revolution Education : rights 10 picaxe manual is divided into four sections: Section 1 -Getting StartedSection 2 - BASIC CommandsSection 3 -Microcontroller interfacing circuitsSection 4 -FlowchartsThis second Section provides the syntax (with detailed examples) for all the BASIC COMMANDS supported by the picaxe system.

4 It is intended as a lookup reference guidefor each BASIC command supported by the picaxe system. As some COMMANDS onlyapply to certain size picaxe chips, a diagram beside each command indicates the sizesof picaxe that the command applies using the flowchart method of programming, only a small subset of the availablecommands are supported by the on-screen simulation. These COMMANDS are indicatedby the corresponding flowchart icon by the more general information about how to use the picaxe system, please see Section 1 Getting Started . picaxe SoftwareThe main Windows application used for programming the picaxe chips is called the picaxe Editor . This software is free of charge to picaxe see Section 1 of the manual ( Getting Started ) for installation details andtutorials. Please ensure that you are using the latest version, the software is a freedownload from Editor 6 is also a flowcharting application designed for educational use (itreplaces Logicator).

5 Programs are developed as graphical flowcharts on screen. Theseflowcharts are then automatically converted into BASIC files for download into thePICAXE is a simpler free version of the Programming Editor software for use on theLinux and Mac operating systems. It also supports all the BASIC COMMANDS in VSM is a Berkeley SPICE circuit simulator, which will simulate completeelectronic circuits using picaxe chips. The BASIC program can be stepped through lineby line whilst watching the input/output peripheral react to the latest version of the software is available on the picaxe website you have a question about any command please post a question on the very activesupport forum at this 2 BASIC COMMANDS revolution (c) revolution Education : rights 10 are used as markers throughout the program. Labels are used to mark aposition in the program to jump to from another position using a goto, gosubor other command.

6 Labels can be any word (that is not already a reservedkeyword) and may contain digits and the underscore character. Labels must startwith a letter or underscore (not digit), and are followed directly by a colon (:) atthe marker position. The colon is not required within the actual compiler is not case sensitive (lower and/or upper case may be used at anytime).Example:main:high ; switch on output 1pause 5000 ; wait 5 secondslow ; switch off output 1pause 5000 ; wait 5 secondsgoto main ; loop back to startWhitespaceWhitespace is the term used by programmers to define the white area on aprintout of the program. This involves spaces, tabs and empty lines. Any of thesefeatures can be used to space the program to make it clearer and easier to is convention to only place labels on the left hand side of the screen. All othercommands should be indented by using the tab key.

7 This convention makes theprogram much easier to read and are normally placed on separate lines. However if desired the colon(:) character can be use to separate multiple COMMANDS on a single line pin1 = 1 then : high 1 : else : low 1 : endifLine continuationLong lines can be continued onto a second line by using an underscore pin1 = 1 then gosub _label1 ; continued on second lineCode CollapsingOn long programs in Programming Editor the { and } brackets can be used tocollapse ( hide ) sections of code to make programs clearer { high 1}CommentsComments are used to add information into the program for future are completely ignored by the computer during a download. Commentsbegin with an apostrophe ( ) or semicolon (;) and continue until the end of theline. The keyword REM may also be used for a comment. Section 2 BASIC COMMANDS revolution (c) revolution Education : rights 10 lines can be commented by use of the #REM and #ENDREM :high 0 ; make output 0 highlow 0 REM make output 0 low#rem ; #rem out a number of lineshigh 0pause 2000#endremConstantsConstants are fixed numbers that are used within the program.

8 The softwaresupports word integers (any whole number between 0 and 65535).Constants can be declared in four ways: decimal, hex, binary and are typed directly without any (hex)numbers are preceded with a dollar-sign ($) or (0x).Binarynumbers are preceded by a percent-sign (%).ASCII text stringsare enclosed in quotes ( ).Examples:100 ; 100 decimal$64 ; 64 hex0x64 ; 64 hex%01100100 ; 01100100 binary A ; A ascii (65) Hello ; Hello - equivalent to H , e , l , l , o B1 = B0 ^ $AA ; xor variable B0 with AA hexSymbolsSymbols can be assigned to constant values, and can also be used as alias namesfor variables (see Variables overleaf for more details). Constant values andvariable names are assigned by following the symbol name with an equal-sign(=), followed by the variable or constant.

9 Symbols can use any word that is not areserved keyword ( switch, step, output, input, etc. cannot be used)Symbols can contain numeric characters and underscores (flash1, flash_2 etc.)but the first character cannot be numeric ( 1flash). Simple constant maths isalso available. See the symbol command entry later in this manual for moreinformation. The use of symbols does not increase program :symbol RED_LED = ; define a constant symbolsymbol COUNTER = b0 ; define a variable symbollet COUNTER = 200 ; preload variable with value 200mainloop: ; define a program address; address symbol end with colonshigh RED_LED ; switch on output COUNTER ; wait secondslow RED_LED ; switch off output COUNTER ; wait secondsgoto mainloop ; loop back to start Section 2 BASIC COMMANDS revolution (c) revolution Education : rights 10 and DirectivesThe main purposes of the picaxe Pre Processor are1) To allow BASIC programs to be split over multiple files2) To allow macros (user defined functions)3) To allow multiple word string replacement myhighC(x) = high portC xThe pre-processor takes one or more input files, combines them together,substitutes and processes any macros, and then generates a single output filewhich is then passed to the standard picaxe compiler.

10 If desired end users canview the final pre-processor output code via the File>Options>Diagnostics DirectivesDirectives have a hash/pound (#) symbol as the first non-blank character of aline, and are immediately followed by the directive are two main types of directive, those used by the pre-processor and thoseused by the compiler. The pre-processor simply ignores compiler following is a list of all the pre-processor directives.#PICAXED efine the picaxe must match the Workspace Explorer setting.#INCLUDEI nclude and merge a specified file, which generallyhas a .basinc file extension.#DEFINED efine a single line symbol#MACRO/#ENDMACROD efine a multiline symbol or macro#UNDEFU ndefine a previously defined symbol/macro#IFProcess next block if symbol/calculation is true#IFDEFP rocess next block if symbol is defined#IFNDEFP rocess next block if symbol is not defined#ELSEIFP rocess next block if symbol/calculation is true#ELSEIFDEF Process next block if symbol is defined#ELSEP rocess next block if previous blocks have not been processed.


Related search queries