Вы находитесь на странице: 1из 25

Simulator for Arduino

1 / 25

Table of contents
Introduction .................................................................................................................................... 3 What's new ............................................................................................................................... 3 Free Version Differences ....................................................................................................... 3 Getting Started ............................................................................................................................. 5 System requirements .............................................................................................................. 5 Getting help .............................................................................................................................. 5 Using the IDE ................................................................................................................................ 6 Program Window .................................................................................................................... 6 Legend ................................................................................................................................ 7 BreakPoint .......................................................................................................................... 8 Program Popup Menu ....................................................................................................... 8 Variables Area ........................................................................................................................ 9 Variables Popup Menu ...................................................................................................... 9 Arduino Area ......................................................................................................................... 10 Arduino Popup Menu ....................................................................................................... 10 Bare Minimum ............................................................................................................................ 12 Loading a Sketch ....................................................................................................................... 13 Running a Sketch ....................................................................................................................... 14 Menu System .............................................................................................................................. 15 File Menu ............................................................................................................................... 15 Run Menu ............................................................................................................................... 15 View Menu ............................................................................................................................. 16 Options ................................................................................................................................... 16 Hardware ............................................................................................................................... 16 Help ........................................................................................................................................ 16 Shortcut Toolbar ......................................................................................................................... 18 Shortcut keys .............................................................................................................................. 19 Dialog Windows ......................................................................................................................... 20 Edit Window .......................................................................................................................... 20 Simulation Window ............................................................................................................... 20 Simulation Popup Menu .................................................................................................. 21 View Subroutines .................................................................................................................. 21 Error Message ...................................................................................................................... 22 Registry Settings ........................................................................................................................ 23 Version Info ................................................................................................................................. 24

2 / 25

Introduction
Simulator for Arduino is an Arduino Simulator which may be downloaded or purchased from www.arduino. com.au. The Free version has a 1minute delay on opening sketches and is code limited to 100 lines. The Pro Version has no limitations. 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 SIMFORARDUINO license for 10 users is designed for training groups with 10 students. The PROSIMSL license is for 1 user.

What's new
The latest version allows all the Arduino Examples from Basics to Strings to be run successfully. Changes include: Add Labels Improve emulation boxes - move to Simulation dialog Improve language processing add View|EEPROM data add #else and #elif Add full floating point support fix else if issues fix break improve switch Add a Stepper timer Improve Servo object Move Menu items to pop-up menus to simplify menu Add StatusBar level indicator to show the loop level Move pin labels to inside Arduino picture and value to outside Arduino board Fix most LCD issues - now will only shows 16 characters (still to fix ScrollRight/Left and vertical sizing) Many other minor issues

Free Version Differences


The Free Version is identical to the Pro Version, apart from the addition of a timer delay window and a Code Limit of 100 lines. The Free version is supplied as a demo version to allow users to trial the Simulator for Arduino program. The logic and operation of the Simulator for Arduino program is identical apart from the timer delay and code limit. In addition to the Pro version, upgrades are offered for a minimum of 1 month.

3 / 25

4 / 25

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

System requirements
The System Requirements are a PC Pentium II or later, running Windows Win2K, WinXP or Win7. The Simulator for Arduino program has not yet been tested on Vista, 98 or other operating systems but if it does run on any of these systems, please let us know by sending an email to arduinoshields@gmail.com

Getting help
For help, please email arduinoshields@gmail.com and please attach the sketch. Please also check that the sketch compiles OK in the Arduino IDE first. Thanks.

5 / 25

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 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 Selecting View|Arduino on Left. The preferred method is to have the Program Window on the left so that the work flow is input,data and output. When the Simulator for Arduino IDE is resized, the Variables window will disappear first since this is the least important window. If the main screen is made smaller, the Program window will then disappear and the Arduino Screen will always be on top. This allows for a program such as the bargraph.ino sketch (in the Display folder) to be simulated as it would appear in reality.

Program Window
The Program window area shows the program listing, and the cursor will always be in the vertical center of the screen. The Program Window allows for the program to be stepped through. When selected, the F8 key may be used to step through the program.

6 / 25

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 AutoStep time is set to less than 10ms, the Status-Bar will not update until AutoStep is stopped. The first line may be used to define the Arduino board type using the // Simulate UnoR3.jpg or // Simulate MegaR3.jpg commands. The Simulator for Arduino program will look for these commands inside the comments on the first line only. using commands inside comments allows the Arduino IDE to still compile the sketch without any changes. The UnoR3 and MegaR3 pictures are included in the Simulator for Arduino zip file.

Legend

7 / 25

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 be displayed to the left of the digital pin when the analogWrite() routine is used.

BreakPoint
A 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 AutoStep or F9 command.

Program Popup Menu

8 / 25

The Program Area Popup menu has four options: Breakpoint - right click to add a breakpoint in red Clear Breakpoint - clear all breakpoints Line Numbers - turn on the line numbers in the Program Window - this is useful for checking subroutines Ask on Line Change - if a new line is clicked in the program window, this option allows for a confirmation window before changing the line number

Variables Area
The Variables area shows the status of all the variables used in program and their current value. The Value may 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 qualifier number in a heading row (shown by the gray shading) shows how many variables of that type have been defined.

When returning from a subroutine, the stack will be returned the the original state, and any variables defined in 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 the Fold Arrays item, and only the first element of each array will be shown.

Variables Popup Menu

The Variables Area Popup menu has four options: Fold Arrays - shrink arrays so only the first element is shown - select again to expand arrays Decimal - display Variables value in decimal Hex - display Variables value in hexadecimal

9 / 25

Char - display Variables value in Character format and hexadecimal

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

Arduino Popup Menu

10 / 25

The Arduino Area Popup menu has three options: 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 Show Volts - this option allows for the analog number to be displayed as volts in the format x.xx (accurate to 0.01V)

11 / 25

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

12 / 25

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

13 / 25

Running a Sketch
After a sketch has been loaded, the first executable line of code will be highlighted. Now press the Step Into button 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 new number.

14 / 25

Menu System

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

File Menu

The 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 default program to open sketches #include code - this inserts the contents of the #include file into the sketch which allows included subroutines to be run. The file contents will be shown in gray Log Errors - alll errors will be logged to the ErrorLog.txt file Note that Errors here means program and simulator errors Exit - close the program

Run Menu

The 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 Run - perform a step once every time period which is 1000ms by default -see Shortcut toolbar

15 / 25

Edit Sketch - open the Edit dialog box

View Menu

The View Menu Items are: Simulation data - open or Close the Simulation input/output window Subroutines - View the Subroutines and Line Numbers EEPROM - View the EEPROM data

Options

The 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

Hardware

The 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

Help

The Help Menu items are : About - Show the Program version Show Help - show this help - Note: this can also be activated by pressing F1

16 / 25

The Help | About screen shows the current software version as

or

The F of Free version is identical to the Pro Version but has a delay timer window any time a new sketch is loaded or edited. The Free version has been provided as demo version to allow the Simulator for Arduino program to be evaluated prior to purchase. It is anticipated that after a week of use, it will be more economically viable to purchase the Pro Version than continue to run the Free Version. A new limitation is a Code limit of 100 lines which will be displayed on the Delay Timer screen.

17 / 25

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 Simulation - show or close the Simulation input/output window Run - AutoStep the program one instruction every xx ms The ms value can be edited. This time is the delay between line execution and is not the actual speed of the program since each line may take 1100ms to execute. If the AutoStep time period is set to faster than 10ms, the statusbar will not update to increase speed. Abort - abort if the program is stuck in any loop Millis - the run time in milliseconds. This value can be changed at any time. Each program step takes 1us which is an approximation PulseIn - this value is the result of the PulseIn function and can be changed to suit Step Into (F7) - this button allows for the program to be single stepped 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 add the 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.

18 / 25

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 Simulation 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

19 / 25

Dialog Windows
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 SaveUpdate - save the sketch under the same name and update the sketch in the program window Bare Minimum - load the bar minimum code skeleton - see here for more info

Simulation Window
The Simulation Window allows for data to be simulated for the six analog inputs. The window may be resized to be smaller, and the scrollbars and text boxes will automatically resize to suit. The Analog Value may be changed by moving the respective scrollbar, or entering a new value in the white Edit box. Input and Output data is displayed in five ports. Each port has its own line for input data and a box for output data. Each Port can be expanded or contracted to suit the display and resized. The ports are assigned as: Port1 can be Serial Port2 can be Serial1,Serial2,Serial3, SoftSerial1, Ethernet Server

20 / 25

Port3 can be SoftSerial2, Ethernet Client Port4 can be LCD, Wire, SPI Port5 can be File

Simulation Popup Menu

The Simulation Window Popup Menu has two items: Show All Ports - to view the five ports and reset the Splitter bars if needed Hide Unused Ports - close all ports except the opened ports

View Subroutines

21 / 25

The View Subroutines window allows for the Subroutines to be viewed along with the number of parameters and the line number. The line numbers may be viewed in the program window by selecting Line Numbers

Error Message

The Error message screen displays any code which the Simulator cannot process or which the Simulator decides if an illegal operation such as: the above operation, outside the setup() and loop() routines setting a digital pin which is set to input changing a const(ant) value setting a variable to a value outside its limits addressing an array element before the start or past the end of the array The File|Log Errors option allows these errors to be logged to an ErrorLog +date.txt file.

22 / 25

Registry Settings
Most settings are saved in the registry under the key SOFTWARE\Arduino Emulator 0.94 The Registry settings are shown below:

23 / 25

Version Info
v0.94 28th January 2012 Add Labels Improve emulation boxes - move to Simulation dialog Improve language processing add View|EEPROM data add #else and #elif Add full floating point support fix else if issues fix break improve switch Add a Stepper timer Improve Servo object Move Menu items to pop-up menus to simplify menu Add StatusBar level indicator to show the loop level Move pin labels to inside Arduino picture and value to outside Arduino board

Fix most LCD issues - now will only shows 16 characters (still to fix ScrollRight/Left and vertical sizing) Many other minor issues

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

24 / 25

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

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

25 / 25

Вам также может понравиться