


















Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!



















Simulator or Arduino is not an option. Simulator and Arduino or even Arduino and Simulator reads better for us. The Simulator is an add-on product to the Arduino development kit and has been designed as a training/ demo/debugging tool but not as a development or compiling tool. We fully support the Arduino project and encourage new users to buy and try a real Arduino first. For first time users, we recommend the book "Getting Started with Arduino" by Massimo Banzi. To develop code for Arduino, we recommend using the Arduino Uno together with the Arduino IDE. For larger projects, the Arduino Mega or Due may be more suitable. This Simulator has not been designed to check for syntax errors, and we recommend only using the Simulator for debugging when there is a difficult problem with an Arduino sketch. There are many Arduino clones around, and while these may be sometimes slightly cheaper, we recommend using original Arduino kits since these work better than the clones and support for the Arduino project leads to more cool new development boards.
Getting Started. Download the zip file, extract the setup.exe file. When finished, run this program to install the Simulator for Arduino program.
The System Requirements are a PC Pentium II or later. The Simulator for Arduino program will run on the following systems: WINDOWS · Windows 2000 · Windows XP · Windows 7 MAC · Windows using Parallels · Windows using VMWare VM systems LINUX · Wine on Linux (windows emulator) Untested on Windows Vista,98,ME and 95. If the Simulator does run on any of these systems, please let us know by sending an email to [email protected]
For help, please email [email protected] and please attach the sketch. Before emailing, please check that the sketch compiles in the Arduino IDE first.
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. Special Simulator hidden code may be used to setup a particular hardware configuration, and this allows the setup configuration to be saved inside the comments of the sketch. See Hidden code for more detail. 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 be displayed to the left of the digital pin when the analogWrite() routine is used. Program Popup Menu 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 · Edit Sketch - allows the sketch to be edited in the Edit Window · Syntax Colouring - show comments as light gray, #if hash commands in medium grey, definitions in green, constants in Olive and subroutines as blue · Match Braces - find the opening or closing bracket for the current line · Tabs On Top - places the tab with the filename at the top if checked or else the bottom · Find - open the Find window to find text inside the sketch BreakPoint A breakpoint can be set by right clicking anywhere in the program window. The pop-up menu has an option which can be clicked 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. The breakpoint can also be saved inside a comment using Hidden Code. the syntax // breakpoint(20) - this will set a breakpoint on line 20
· breakpoint(line,tab, condition) - will setup a breakpoint at the line on the correct Tab, (leftmost=1) with the condition. If the condition is left blank, it will not be set · SimulateLCD(x,y,width,height,pixel width,pixel space, backlight color, on color, off color) will setup a LCD area on the Arduino picture. The colors are 24bit in a BGR format where 255=Red.The pixel width should be no more than 5) · SerialIn(data) will load the Serial Port input data with the data inside the parentheses
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 second column is the watch column, and clicking in this column will show a w. The Pop-up menu can then be selected to show only Watched variables. This is useful when only a few variables are relevant amongst several hundred. The gray area in the W column may be click to show or unshow all the variables for that type. Arrays can be folded by clicking in the second or Watch column and a + sign will show that the Array has been folded. When folded, only the first element of each array will be shown. Alternately, the array may be folded at any element of the array and in this case, the elements above will be shown, but the elements below will be hidden. Click the + again to unfold the array Double Clicking in the Variable column will enable or disable the watch, and the W in the second column indicates if the Watch is on (W) or off (blank) Variables Popup Menu The Variables Area Popup menu has four options: · Watch - only display variables which have a w or + in the second column of the grid · Decimal - display Variables value in decimal
· Hex^ - display Variables value in hexadecimal · Char - display Variables value in Character format and hexadecimal · Find - open the Find window to find text inside the variables area
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 are defined up to D53 for the Mega and D13 for the Uno. The Analog Pins are defined as A0 to A5 for the Uno with A0 equal to 14. Arduino Popup Menu The Arduino Area Popup menu has four 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 · Uno - set the Arduino board to a Uno type · Mega - set the Arduino board to a Mega type · Show Volts - this option allows for the analog number to be displayed as volts in the format x.xx (accurate to 0.01V) · Minimize - turn off the Tool bar and menu to make the Arduino picture as minimal as possible. the program can be resized to then only show the Arduino picture and the Title (which shows the sketch name). · Load Sketch - load a sketch into the program window - useful in minimize mode · Input/Output - show the input/output window - useful in minimize mode
The Menu system has five sub-menus. These menus allow the Simulator to be customised. File 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 · Open the Call Stack Window The Call Stack Window is very important in debugging since it shows the origin of the current loop which may be a subroutine, while loop or any other condition. The loop level is show at the right in the Status bar. The middle area is the standard Arduino library objects, while the right area is for user define C++ onjects (which is a work in progress). Hardware · Save Hardware Settings
The Hardware Menu Items are: · Uno - display the Arduino picture as an Arduino Uno board · Due - display the Arduino picture as the ARM-based Arduino Due · Leonardo- display the Arduino picture as an Arduino Leonardo board · LilyPad - display the Arduino picture as an Arduino LilyPad board · Mega - display the Arduino picture as an Arduino Mega board · Mega (x75%) - a smaller version for laptops · Nano - display the Arduino picture as an Arduino Nano board · Other - open up any picture file preferably 350 pixels wide to overlay on the Arduino picture · Screw Terminal - Show the Shields for Arduino custom Screw Terminal board · LCD - Show the Shields for Arduino custom LCD board with a 16x2 LCD fitted · LCD 8x2 - - Show the Shields for Arduino custom LCD board with a 8x2 LCD fitted · Save Hardware Settings - save hardware settings to a .txt file which can be edited later · Save Hardware Settings - load hardware settings from a .txt file · Show All - Show all the pins, pin names and analog values for the Arduino board · Hide All - Hide all the pins, pin names and analog values for the Arduino board Help
· Font size - changes the font size of the main program window · Skins - this will change and save the skin for the whole Simulator program. The default skin is Windows. · Library Directory - set for using custom libraries · BreakPoint condition - set to break on a certain condition · Language - change between English, French, Italian and Other for titles only - also Input and output the language text · Serial InData - provides the ability to Change the Default Serial - Also available as a^ hidden code command EEPROM Window The EEPROM window allows for viewing and modifying of the EEPROM memory. Right click to bring up the popup menu which has several options: · Clear EEPROM - set all EEPROM memory to FF · Set All to 0 - all EEPROM memory to 00 · Decimal - display Variables value in decimal · Hex - display Variables value in hexadecimal · Char - display Variables value in Character format and hexadecimal · Save to Hex File - save the EEPROM memory to a hex file · Load from Hex File - load the EEPROM memory from a hex file
Call Stack The Call Stack displays the different levels of sketch loops in the left grid The middle grid shows the Arduino objects, names and Enabled status. The right grid shows classes found and objects derived from these classes. Input/Output Window The Simulation Window allows for data to be simulated for the six analog inputs for the Uno or 16 analog inputs for the Mega. 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.
Inside each port is another Popup window with three options: · Clear - clear the Port screen · Copy - copy the data to the clipboard · Open in Browser - open the Port data in the default web browser, useful for sketches using Ethernet View Subroutines The View Subroutines window allows for the Subroutines to be viewed along with the number of parameters, the line number and the tab. 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. The Email button will only be shown if the Error could be related to internal Simulator logic. If the Error message starts with Sketch Error, the Simulator has guessed that it is more likely the error is in the Sketch. If this is not the case, please email the sketch to [email protected]
The Shortcut Toolbar provides single click actions for commonly used operations. Button Functions: · Load - loads a sketch from the last used folder into the Simulator · Edit - Edit a sketch · 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 1- 100ms 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.
Several keyboard shortcuts have been added. These are · F2 for Reset · F3 for Find · 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 · F10 find (to be removed later)
Several sketches have been included for testing the Simulator. These are the Official Arduino examples in the folders 01 Basics to 19 Wire. In a typical install, the sample sketches will be found in this folder: C:\Program Files\Shields for Arduino