simulator for arduino

26
1 / 26 Simulator for Arduino

Upload: morpheys

Post on 03-Dec-2014

421 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Simulator for Arduino

1 / 26

Simulator for Arduino

Page 2: Simulator for Arduino

2 / 26

Table of contents

Introduction .................................................................................................................................... 3What's new ............................................................................................................................... 3Free Version Differences ....................................................................................................... 3

Getting Started ............................................................................................................................. 5System requirements .............................................................................................................. 5Getting help .............................................................................................................................. 5

Using the IDE ................................................................................................................................ 6Program Window .................................................................................................................... 6Variables Area ........................................................................................................................ 7Arduino Area ........................................................................................................................... 7

Bare Minimum .............................................................................................................................. 9Loading a Sketch ....................................................................................................................... 10Running a Sketch ....................................................................................................................... 11Menu System .............................................................................................................................. 12

File Menu ............................................................................................................................... 12Run Menu ............................................................................................................................... 12View Menu ............................................................................................................................. 12Options ................................................................................................................................... 13Emulation ............................................................................................................................... 13Hardware ............................................................................................................................... 14Help ........................................................................................................................................ 14

Shortcut Toolbar ......................................................................................................................... 16Emulation Toolbar ...................................................................................................................... 17Shortcut keys .............................................................................................................................. 18Program Window ....................................................................................................................... 19

Legend ................................................................................................................................... 19BreakPoint ............................................................................................................................. 19

Edit Window ............................................................................................................................... 21Analog Window .......................................................................................................................... 22View Subroutines ....................................................................................................................... 23Registry Settings ........................................................................................................................ 24Version Info ................................................................................................................................. 25

Page 3: Simulator for Arduino

3 / 26

Introduction

The benefits and features of an Arduino Simulator are:

· The ability to teach and demonstrate the inner workings of an Arduino sketch

· Test out a sketch without the hardware, or prior to purchasing hardware

· Debug a sketch

· Demonstrate a project to a potential customer

· Develop a complicated sketch faster than using the hardware

The license for 10 users is designed for training groups where there is on instructor and 10 students.

What's newThe latest version allows all the Arduino Examples from Basics to Strings to be run successfully.

Changes include:

· Add random and randomseed

· Fix Step Over on right bracket }

· Add Pause/Run or Stop button to stop a runaway program

· Add >>= and <<= operators

· Add Boolean, Float types

· Add do while loop and for loop with { on separate line

· Add library checks

· Add EEPROM, Ethernet functionality and maybe Servo

· Show include files in gray and fix upside down format

· Add #ifdef, #endif, #ifndef

· Add Serial1,2,3 and move Input data to inside panel

· Add full LCD functionality except for CGRAM

· constant definitions after loop() should now be evaluated

· Fix for loop issue inside while

· Ability to fold/unfold arrays in Variables area

· When breakpoint is hit, run only needs to be pressed once

· Add Show Volts

Free Version DifferencesThe Free Version is identical to the Pro Version, apart from the addition of a timer delay window. The Freeversion is supplied as a demo version to allow users to trial the Simulator for Arduino program. The logic andoperation of the Simulator for Arduino program is identical apart from the timer delay. In addition to the Proversion, upgrades are offered for a minimum of 1 month.

Page 4: Simulator for Arduino

4 / 26

Page 5: Simulator for Arduino

5 / 26

Getting Started

Getting Started.

Copy the zip file to a safe place and unzip the files into this separate directory. To run the program, doubleclick the .exe file.

System requirementsThe System Requirements are a PC Pentium II or later, running Windows XP or Windows 7.

Getting helpFor help, please email [email protected]

Page 6: Simulator for Arduino

6 / 26

Using the IDE

The Simulator for Arduino IDE has several sections. These are:

· The Menu system which contains options and settings - refer to the Menu System for more info

· The Shortcut Toolbar provides single click action for commonly used operations

· The Emulation Toolbar which provides simulated data for the Serial port input, the Milliseconds and theSoftSerial input data

· The Program list box

· The Variables area

· The Arduino picture

Note that the order of the Program window, Variables are and Arduino picture may be swapped by SelectingView|Arduino on Left. The preferred method is to have the Program Window on the left so that the work flowis input,data and output.

When the Simulator for Arduino IDE is resized, the Variables window will disappear first since this is theleast important window. If the main screen is made smaller, the Program window will then disappear and theArduino Screen will always be on top. This allows for a program such as the bargraph.ino sketch (in theDisplay folder) to be simulated as it would appear in reality.

Program WindowThe Program window area shows the program listing, and the cursor will always try to stay in the verticalcenter of the screen.

The first line may be used to define the Arduino board type using the // Simulate UnoR3.jpg or // SimulateMegaR3.jpg commands. The Simulator for Arduino program will look for these commands inside thecomments on the first line only. using commands inside comments allows the Arduino IDE to still compilethe sketch without any changes. The UnoR3 and MegaR3 pictures are included in the Simulator for Arduinozip file.

Page 7: Simulator for Arduino

7 / 26

Variables AreaThe Variables area shows the status of all the variables used in program and their current value. The Valuemay be changed by clicking in the relevant cell and changing the value.

The Qualifier column typically shows if the value is a const, unsigned, static or volatile type. The qualifiernumber in a heading row (shown by the gray shading) shows how many variables of that type have beendefined.

When returning from a subroutine, the stack will be returned the the original state, and any variables definedin the subroutine or passed as arguments will be cleaned or removed.

Right Click in the Variables area to bring up the Pop-up Menu. The Arrays can be folded by selecting theFold Arrays item, and only the first element of each array will be shown.

Arduino Area

Page 8: Simulator for Arduino

8 / 26

The

The Arduino picture area allows for the digital inputs and outputs to be displayed along with the Analog inputand output values. The digital pins have only been defined up to D21 currently.

Page 9: Simulator for Arduino

9 / 26

Bare Minimum

Bare Minimum will load the bare minimum needed for a new sketch. Select Run|Edit Sketch and the pressthe rightmost button to load the Bare Minimum to start writing a sketch.

Page 10: Simulator for Arduino

10 / 26

Loading a Sketch

To load a sketch, select File|Load Sketch, press the Load Sketch button or press F4. Navigate to thecorrect folder and select the *.ino file (or *.pde for previous Arduino versions).

Page 11: Simulator for Arduino

11 / 26

Running a Sketch

After a sketch has been loaded, the first executable line of code will be highlighted. Now press the Step Inotbutton or the down arrow. Alternately, the F7 or F8 button may be pressed.

The middle section of the screen displays the variables grid, and these are organised into Bytes, Chars, Int(eger)s, Long, Strings and Defines. Any value in the grid can be changed by selecting it and typing in a newnumber.

Page 12: Simulator for Arduino

12 / 26

Menu System

The Menu system has seven sub-menus. These menus allow the Simulator to be customised.

File MenuThe File Menu Items are:

· Load Sketch (F4) - Load a Sketch into the program window

· Print Setup - open the Printer Setup Dialog Box

· Print - print a scaled picture of the program

· Open Sketch in Arduino - this opens the sketch in the Arduino IDE assuming Arduino is the defaultprogram to open sketches

· #include code - this inserts the contents of the #include file into the sketch which allows includedsubroutines to be run

· Exit - close the program

Run MenuThe Run Menu Items are:

· Reset - reset the program to the start or Setup routine

· Back - go back on step without executing any code

· Step Into - step one line through the program, and step into any subroutines

· Step Over - step one line and step over any subroutines

· Step Out of - Step out of a subroutine

· AutoStep - perform a step once every time period which is 100ms by default -see Shortcut toolbar

· Edit - open the Edit dialog box

View MenuThe View Menu Items are:

Page 13: Simulator for Arduino

13 / 26

· Analog - open or Close the Analog input window

· Emulation Tool bar - show the emulation tool bar which is useful for simulating Serial input data

· Subroutines - View the Subroutines and Line Numbers

· Arduino on Left - display the picture of the Arduino on the left and the Program window on the right

· Legend - display the digital pin legend on the top right of the Arduino picture

OptionsThe Options Menu Items are:

· Simulate Delay - Simulate delay of 1 second to 10 seconds with a Pop-up window

· Simulate Tone - Sound a tone when the tone() function is called

· Line Numbers - turn on the line numbers in the Program Window - this is useful for checkingsubroutines

· Ask on Line Change - if a new line is clicked in the program window, this option allows for a confirmationwindow before changing the line number

· Show Volts - this option allows for the analog number to be displayed as volts in the format x.xx(accurate to 0.01V)

EmulationThe Emulation Menu Items are:

· Serial - restore the Serial Output box (if undocked)

· SoftSerial - restore the SoftSerial Output box (if undocked)

· LCD - restore the LCD Output box (if undocked)

· Serial1 - restore the Serial1 Output box (if undocked)

· Serial2 - restore the Serial2 Output box (if undocked)

· Serial3 - restore the Serial3 Output box (if undocked)

· Ethernet - restore the Ethernet Output box (if undocked)

· All - Activate all the Emulation windows or turn them off

· Maximize Serial - make the Serial Emulation box larger to show long text lines

Page 14: Simulator for Arduino

14 / 26

Please note:

· the SPI port uses the Serial3 port

· the Wire or I2C/TWI port uses the Serial2 port

· SoftSerial2 uses the Serial1 port

HardwareThe Hardware Menu Items are:

· Uno - display the Arduino picture as an Arduino Uno board

· Mega - display the Arduino picture as an Arduino Mega board

· Other - open up any picture file preferably 350 pixels wide to overlay on the Arduino picture

HelpHelp Menu:

· About - Show the Program version

· Show Help - show this help - Note: this can also be activated by pressing F1

The Help | About screen shows the current software version as

Page 15: Simulator for Arduino

15 / 26

or

The F of Free version is identical to the Pro Version but has a 30 second delay window any time a newsketch is loaded or edited. The Free version has been provided as demo version to allow the Simulator forArduino program to be evaluated prior to purchase. It is recommended that after ten sketches have beentested, the Pro version be purchased since the cost of this delay is more than the purchase price. Also, it ishelps speed up the design process.

Page 16: Simulator for Arduino

16 / 26

Shortcut Toolbar

The Shortcut Toolbar provides single click actions for commonly used operations.

Button Functions:

· Load Sketch - loads a sketch from the last used folder into the Simulator

· Left up arrow - Reset

· Up Arrow - go back without executing any code

· Down Arrow - Step Over - single step jumping over any subroutines

· Left Down Arrow - Step out of subroutines excluding setup and loop

· Right Down Arrow - Single Step and Step into any subroutines

· Analog - show or close the Analog simulator window

· Run - AutoStep the program one instruction every xx ms The ms value can be edited. This time is thedelay between line execution and is not the actual speed of the program since each line may take 1-100ms to execute. If the AutoStep time period is set to faster than 10ms, the statusbar will not updateto increase speed.

· Abort - abort if the program is stuck in any loop

· Decimal, Hex and Char - change the display view of the Variables

Page 17: Simulator for Arduino

17 / 26

Emulation Toolbar

The Emulation Tool-bar allows for input data to be entered. The Emulation Tool-bar may be turned on or offby selecting View | Emulation Tool-bar. This value is saved on Exit.

For Serial ports, and Software Serial ports, the input date text boxes are now associated with the emulationboxes.The Serial data is read from left to right, so the left most character will be returned when using aSerial.read or Serial.peek command. Serial1 uses the Soft Serial data.

The Milli seconds variable is displayed in a text box. This value can be adjusted by typing in a new value.Each line of program execution takes 1us or 0.001. The commands Delay and delayMicroseconds will addthe accurate number of milliseconds or microseconds to the Millis Text box.

PulseIn provides the return data for the pulseIn() command. This value must be a number.

Page 18: Simulator for Arduino

18 / 26

Shortcut keys

Several keyboard shortcuts have been added. These are

· F2 for Reset

· F3 for Go back without executing any code

· F4 for Load a sketch

· F5 to open the Analog Window

· F6 - Edit a sketch in the Edit Window

· F7 to Step Into

· F8 to Step Over

· Shift F8 to Step out of a subroutine

· F9 to Run or AutoStep

Page 19: Simulator for Arduino

19 / 26

Program Window

The Program Window allows for the program to be stepped through. When selected, the F8 key may beused to step through the program.

A new line may be selected by click anywhere in the program window. If the Ask on Line Change option is Checked, then a Dialog will ask for confirmation that the program should jump to the new Line.

The Statusbar shows the Line number, Last Line number and the next code to be executed. If the AutoSteptime is set to less than 10ms, the Status-Bar will not update until AutoStep is stopped.

Legend

The Legend may be turned on by selecting View | Legend

The Legend shows the colours and states of the Digital output. The AnalogWrite value of a digital pin will bedisplayed to the left of the digital pin when the analogWrite() routine is used.

BreakPointA breakpoint can be set by right clicking anywhere in the program window.

The pop-up menu has two options - to add or clear the breakpoint.

If a BreakPoint is added, the breakpoint line will be shown in red. This is commonly used with the AutoStepor F9 command.

Page 20: Simulator for Arduino

20 / 26

Page 21: Simulator for Arduino

21 / 26

Edit Window

The Edit Sketch Window allows for sketches to be edited and updated or reloaded into the Program window

· Close - closes this window and resumes simulating the program

· Update Sketch - save this edited sketch back to the program window

· Save File As - save this sketch to a new .ino file

· Bare Minimum

Page 22: Simulator for Arduino

22 / 26

Analog Window

The Analog Inputs Window allows for data to be simulated for the six analog inputs. The window may beresized to be smaller, and the scrollbars and text boxes will automatically resize to suit.

The Analog Value may be changed by moving the scrollbar, or entering a new value in the white Edit box.

Page 23: Simulator for Arduino

23 / 26

View Subroutines

The View Subroutines window allows for the Subroutines to be viewed along with the number of parametersand the line number. The line numbers may be viewed in the program window by selecting Options | LineNumbers

Page 24: Simulator for Arduino

24 / 26

Registry Settings

Most settings are saved in the registry under the key SOFTWARE\Arduino Emulator 0.93

The Registry settings are shown below:

Page 25: Simulator for Arduino

25 / 26

Version Info

v0.93 6th January 2012

· Add random and randomseed

· Fix Step Over on right bracket }

· Add Pause/Run or Stop button to stop a runaway program

· Add >>= and <<= operators

· Add Boolean, Float types

· Add do while loop and for loop with { on separate line

· Add library checks

· Add EEPROM, Ethernet functionality and maybe Servo

· Show include files in gray and fix upside down format

· Add #ifdef, #endif, #ifndef

· Add Serial1,2,3 and move Input data to inside panel

· Add full LCD functionality except for CGRAM

· constant definitions after loop() should now be evaluated

· Fix for loop issue inside while

· Ability to fold/unfold arrays in Variables area

· When breakpoint is hit, run only needs to be pressed once

· Add Show Volts

v0.92 - 30 December 2011

· Add Open Sketch in Arduino function

· Allow #include to import code into main file

· The program line is always centered vertically where possible

· Add Step Over (F8) and Step Into (F7) in place of Step function

· Add a breakpoint by right clicking

· Re-organise Variables area into one list

· Remove checkboxes from digital pins

· Add Mega emulate mode

· Digital Input pins are now green

· All Arduino examples from Basics to Strings now work

· Variable values are now checked against the variable type and an error will issue if rollover occurs

· digitalWrite to an Input pin will now issue an error

· serialEvent interrupt now executes

· pulseIn implemented

· Boolean type implemented as a byte

Some items to note are:

· Display | Rowscanning double arrays are not yet implemented - pixels becomes a 1D array

v0.91 - 16 December 2011

· Serial, Softserial and LCD output windows are now dockable and can be restored using View

· Added a Legend

· Digital output pins are red while digital input pins are yellow

· Improved the screen layout areas - program, variables and Uno screen

· Improve the display swap feature

Page 26: Simulator for Arduino

26 / 26

· Improved the line numbering in Status bar - next statement displayed not previous

· Added Print option dialog

· Fixed Subroutines checking and jumping

· Added 40 more keywords

· AnalogWrite now changes the shade or red on the digital pin

· Added String types and some special string operations

· Add a dialog when the program line is changed

· Function | Edit now has a Bare Minimum button

· Function | Edit Save now saves the filename as .ino if not specified

v0.80 - v0.90 1-Dec to 16-Dec-11 first test releases (Unidentified List Box error with v0.90)