We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Searduino - Arduino simulator and C/C++ devel environment

00:00

Formal Metadata

Title
Searduino - Arduino simulator and C/C++ devel environment
Title of Series
Number of Parts
90
Author
License
CC Attribution 2.0 Belgium:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Identifiers
Publisher
Release Date
Language

Content Metadata

Subject Area
Genre
Abstract
Programming and debugging Arduino in user space Introducing the Arduino simulator and C/C++ development environment. Searduino is made to ease and speed up development for the Arduino boards. In short, with Searduino you get C/C++ interface - use C/C++ to program your Arduino boards Makefiles - easy to use Makefiles for inclusion in your project Stand alone program - build your Arduino code to run on your local computer instead Simulator - run your Arduino code in a simulator to test it Simulation API - write your own test cases in C/C++ Python simulation API - write your tests in Python Arduino example translation (not ready yet, but really close) The authors of Searduino love developing code for Arduino. We love using Arduino and we believe that developing code for Arduino has been made significantly easier for not-so experienced developers. However, for some of us it is easier to develop code in our favorite editors and build and compile via the command line. Searduino was initially created to make it possible to automate the building of your arduino program and to do this outside of the Arduino IDE. Once we had the compilation and linking up and running we quickly noticed that it wouldn't take that much to make it possible to turn your Arduino program into a program executing on your local computer. The writes and reads on pins in your Arduino program were 'translated' in to reads and writes on stdin/stdout, which we used to create a simple simulator communicating via a pipe. We saw the potential of the simulator and decided to write a "proper" API for it instead. To make the simulator more usable for quick checks and for people preferring GUIs we started to write a simulator GUI in Python, so we added a Python extension to the simulator API. And here we are right now.... Hope you like it!
25
Thumbnail
15:46
51
54
Thumbnail
15:34
55
57
Thumbnail
1:02:09
58
Thumbnail
16:08
62
Thumbnail
13:26
65
67
Moment (mathematics)Embedded systemNP-hardWhiteboardUniverse (mathematics)Multiplication signThresholding (image processing)Java appletIntegrated development environmentComputer hardwareComputer programmingLine (geometry)Perfect groupProjective planeComputer animation
Student's t-testComputer programmingHeegaard splittingLine (geometry)Execution unitStudent's t-testMultiplication signComputer fileLecture/Conference
Hausdorff spaceWhiteboardExecution unitComputer programmingLine (geometry)Endliche ModelltheorieUnit testing
PlastikkarteWhiteboardDegree (graph theory)Software testingSoftware testingIntegrated development environmentQuicksortComputer programming1 (number)Functional (mathematics)Universe (mathematics)Lecture/ConferenceJSON
Unit testingComputer hardwareComputer programmingElectronic mailing listJava appletExecution unit1 (number)Presentation of a groupInterface (computing)Personal identification numberoutputExtension (kinesiology)WritingCodeStudent's t-testStandard deviationComputer simulationTouchscreenLecture/Conference
Computer programmingLie groupReading (process)Function (mathematics)Line (geometry)Personal identification numberSource codeXMLProgram flowchart
Vapor barrierIntegrated development environmentLecture/Conference
Function (mathematics)Personal identification numberPlotterStudent's t-testComputer simulationText editorCodeLine (geometry)Computer programmingWhiteboardNP-hardMultiplication signDreizehnMaxima and minimaDigitizingRight angleObject (grammar)System callGoodness of fitSource code
Type theoryBuffer solutionComputer fileRevision controlLibrary (computing)Lecture/Conference
Computer simulationJava appletSource code
TouchscreenRight angleGroup actionMultiplication signComputer simulationDigitizingFunctional (mathematics)FeedbackObject (grammar)outputStudent's t-testPersonal identification numberSource code
Personal identification numberFunction (mathematics)Source codeComputer animation
PRINCE2outputFunction (mathematics)Computer simulationComputer programmingDigitizingPersonal identification numberSimilarity (geometry)CodeSource code
Social classJava appletComputer simulationSocial classObject (grammar)WhiteboardProcess (computing)Computer programmingComputer architectureMultiplication signQuicksortInterface (computing)Java appletCodeJSON
Error correction modelDirection (geometry)Computer fileMultiplication signOnline helpComputer simulationImplementationComputer programmingPlug-in (computing)WebsiteWeightProjective plane
ImplementationStructural loadProjective planeLecture/Conference
Programming languageWebsiteComputer animation
Keyboard shortcutSerial portPersonal identification numberBound stateComputer simulationAnalogySerial communicationUser interfaceChemical equationSoftware testingInstance (computer science)Condition numberLecture/Conference
Transcript: English(auto-generated)
waste too much of my time. This is basically me. Let's get this over with. It's my role at the university. Oh, you want me to speak in this one. I always move around. But I get the rock star kind of feeling here. We, in one of our courses on embedded programming,
we switched and started to use Arduino. It was perfect, it was easy to get started with. The IDE lowers the threshold. When we introduce the Arduino or other hardware and show that to people who are new to programming,
they've just learned Java and all of a sudden we show them the command line, we show them scary tools, we noticed that when we introduced them to Arduino using the IDE, it was perfect, way easier. But, doing that, we faced some problems.
The problem is I usually read here, but I can't do it right now. So I'm going to show you my back. When we made a bigger project, not the example you see in the Arduino, it was a couple of hundred, couple of thousand lines long program split into many smaller files,
developed by several students at the same time, we had a problem. We tried using Git and cut, paste and blah, blah, blah, it didn't work. We missed unit testing a lot. We... It's not as if you are recommended to use malloc and calloc in embedded programming.
Still, it's good to do some unit testing every now and then to check the logic. And we noticed that it's pretty lame. You're developing this 4,000 lines long program,
you spent hours, weeks, and all of a sudden, the lead doesn't blink anymore. So you have to debug it, sometimes using, well, code review. So we had a problem with that. And we also needed to automate the tests. So we realized that we...
We had to write a sort of a fake environment. So basically, we took the Arduino API, implemented every fun... Oh, not every, but almost every function, the ones we use at the university. So we could create a program that could run by itself with no hardware.
And then we added some small standard out, standard in interface to it. So we could set, for example, input pin one to one and see what happened in the code. But after a while, when we did that, we realized that we were almost done writing a simulator.
So we finished one, we wrote one. And we got some complaints from students that didn't want to write unit tests in C.
So we wrote a Python extension to it, so they could write the unit tests in Python. And for the fun of it, I added a Java extension, because I needed to refresh my almost totally forgotten Java skills.
I want to show the classic Hello World example. It doesn't do good, because there is no screen here. So I'm going to do it using a Blinken list.
So let's see what happens here. I'm afraid of this presentation program. So here is a Blinken-led program. Also, there's some reading of one pin to another.
But if we focus on these lines here, it basically puts the output on pin 13 to one and takes it down again to zero. So it should blink. If how many have done these kind of things in front of a live audience and gotten away with it,
now it blinks. But let's try and upload this one. I'm going to show one of the most used features of the simulator. This is, by the way, the Arduino IDE, which is lovely.
It really helps people to get over the first barrier. So I'm not here to bash this IDE in any way. But let's upload it. And let's see when the LED blinks. Problem is that it doesn't blink.
And this was something we... Excuse me? Oh, damn it. Oh, no, you weren't supposed to see this. Damn, what a disaster.
I'm going home. Problem is my flight is on Monday. If I only can see my mouse again. Anyhow, plot is I'm going home. A lot of times, I'll never do that, which I just proved.
A lot of times, the students forgot to say what kind of pin 13 should be, or whatever pin you want to talk with. And if you don't set the output to 13, oh, sorry, this pin 13 to an output pin, you cannot write to it. So this code is writing to the LED, but nothing happens.
So now I'm going to show the simulator and how we develop code.
I'm using my favorite editor. Some of you may recognize it. It's Emacs. It's the only one I know. OK, so this is basically the same code. It's writing to digital pin 13, first a 1 and then a 0. Basically, that's all that happens.
So that's it. So I'm going to show you how we develop that. This is kind of hard.
The only thing I do, I write a couple of, these are all the lines that I need to write as a makefile. And I here put the board. I want the program for UNO, but since the program didn't work, we are programming for something we used to call stub.
It's not a stub anymore, but the name is still here. So what we are doing is we are basically saying that don't produce code for the actual Arduino, but produce code to be run locally on this one. How am I doing on time?
Good, but good depends on how much more I have to say. Perfect, thanks. So what the program does, or what Arduino does for me now is given the C file that you saw in my Emacs buffer and the small make file, it produces a shared object, basically dynamic library.
And somewhere in the history here, I should have had, I have an installed version here, and I do type crappy.
So I fire up the Java simulator. It's a big one today on this screen. I open up the newly freshly compiled shared object. And what we can see here is, this time it's actually
not a flaw in the simulator. You're seeing a lot of printouts here. It's warning. You're trying to write with a function digitalWrite to pin 13. Let's stop it and look at the rest.
Which is an input pin. This was great value for the students. All of a sudden, they could get feedback from the simulator saying that, oh, you're writing to pin 13, which is an input pin. So some of them ask me, what do we do now?
And yeah, simple answer was, you need to initialize it as an output pin. And this is what I do here. So if I recompile it now as a shared library
and open it up again, I can choose board here. But let's continue with.
All of a sudden, we don't have any warnings. And we can see the pin 13 going berserk. So we can actually test that it is working. Nice, fine. And if we would have made a similar mistake as before, we would still see some warnings here.
I just want to show you that we can also read the input pins. So in the program, if I click input 10 goes high, digital output pin 11 should also go high.
And in a rather slow fashion, it does. It's not due to the simulator, but the code that the simulator is running. So let's try and quick.
With this program, you develop C, C++ code that you run on the Arduino. You build it for Arduino, any board. You can run it as a standalone program. Basically, an ELF program, you run it.
Or the best way, if you want to use the simulator, produce a shared object, upload it to the simulator, and run it. This is the basic. There's a couple of other simulators. But I'm running out of time, so I'm just going to show the Java sort of architecture here.
This is the Arduino code built as a shared object. It's loaded by Serduino. We have a simulator API called CSIM. On top of that, we have a Java class that wraps all the simulator into a Java interface.
And Jerduino, we're not very good at names, is the Java simulator. That's it. We've done that. This, I'm happy that you can see.
It would be great to have some people join us to develop this program further. We need more implementation of the Arduino API. I think it would be pretty cool to have an Eclipse plug-in. Somehow, I don't know how. Make it possible to load Arduino's .ino files.
Basically, the Arduino files you get with the Arduino is C++ files, but they are called .ino. It would be pretty cool if you could load them into a simulator directly. What we've done so far is we can take an .ino file
and convert that into a C file, create some make files around it. So we're almost there, but we need some more help. We're running out of time. Given the amount of time I have given the three kids and everything else I do, we shouldn't
have an active project. But it's listed on one of the sites, ollo.net, that it's very active. So it is active, I think. We are building it every night using this tool, VMM, which is going to be, they are here. They're going to present something tomorrow.
Why the name? C, as in the programming language C. And one of my favorite book was called Deep Sea Secrets, so I thought the joke was so funny. So I wanted to have C. Well, you get the joke. I think, do we have any Swedes here?
OK, sorry. I'm from Gothenburg, and Gothenburg are known and hated by the rest of Sweden for their crappy jokes, and we always want to play around with stupid names. And this is a result, so don't kill me. Sorry. I apologize. Questions?
Nothing. OK. Yeah. Yes. Can you simulate analog conditions, like analog voltages and, for instance, spin button bounds and things like that?
What was it? Pin button? Sorry? I couldn't. Can you say it again? I mean, can you simulate analog inputs? Not analog out, because it's PVM, but yeah.
And things like button bounds, for instance, that would be useful to try? I don't know. Perhaps it is possible. I don't know. The serial interface, for example, is implemented. And that is not answering your question.
So let's talk afterwards. I just want to say a stupid mistake, because I implemented the hit, the human interface thing. So I have a Leonardo, which was stolen the other day. And you can now simulate the mouse and keyboard stuff. But it turned out that when I did that using the simulator,
it grabbed my mouse. So I couldn't stop the simulator anymore. And it kept running forever.