New member question about Arduino - Page 1
Forum section: electronics / general

author: markhing
author_rank: Newbie
timestamp: February 06, 2016, 09:30:36 pm
content: Hi all,I'm a new member on this forum (although I've been watching the eevblog videos on YouTube for awhile) and just ordered some Arduino components on eBay -- but still waiting for them to arrive.I only started looking into Arduino 2 weeks ago so I'm a complete novice in this area. I'm also an electronics beginner. I thought an Arduino project would be a good way to teach my 10-year-old son to program and also teach him (and myself) some basic electronics skills.I'd like to use the Arduino to control a quadcopter (Hubsan X4 H107C) and I found some instructions here -->http://www.instructables.com/id/Easy-Android-controllable-PC-Interfaceable-Relati/?ALLSTEPSthat should do what I want on the copter control side.The other part is to use Lilypad components to create a shirt and gloves that can be used to send the wearer's body/arm movements to the computer via bluetooth in order to control the copter (so, for example, the user can control pitch by leaning forward/back, roll by tilting to the sides and yaw by turning around). The Lilypad stuff will send the user's body positions to the computer which will then translate these data into control data (similar to what the copter's joysticks positions would send) and this information would be sent to the copter via the a7105 board.Eventually I'd like to add FPV goggles for better immersion (so a user can see what the copter sees and control it using body movements). I'm thinking it would be neat if all this could be fit into an Iron-man chest plate, gloves and helmet (but that's something to think about once I've got the first bit working).With that background out of the way, my questions are:1) Has anyone done anything like the Lilypad piece before? If so, are there any tricks/traps I should know about or watch out for? What Lilypad boards should I be using? (Currently I've ordered some LilyPad Accelerometer ADXL335 boards, LilyPad bluetooth transceivers and various buttons and sensors.)2) Is the standard Arduino IDE the way to go or is there a better IDE available? I downloaded version 1.6.7 and started playing around with it but since I haven't received the Arduino hardware yet, I've not been able to fully test it. It seems okay to me but I read a few comments on various forums that said it had issues.3) I don't want to use the Processing language but some of the code is written in Processing. Is it easy to convert Processing code?Any answers, comments, suggestions would be appreciated.Thanks,Mark.

author: westfw
author_rank: Super Contributor
timestamp: February 07, 2016, 03:19:27 am
content: What you want to do is HARD. IMO, it will be a long time before an electronics/programming beginner to get to the point of implementing gesture-based remote control of a quadcoptor with FPV video. You'll probably learn a lot by trying, though!QuoteI don't know. You might want to look at the Intel "Curie" products (including "Arduino 101"), since they are specifically aimed at wearable/motion sensing applications, include bluetooth and "6 axis" motion sensors, and are significantly cheaper than a lilypad combo that will do the same thing. Curie modules are supposed to start selling "this quarter", and you can buy Arduino 101 boards with the module Now.QuoteThe Arduino IDE is simplistic. That makes it very easy to use, but not very "powerful." No debugging, for instance. There are many IDEs that are "more powerful." Most of them have people that love them, and people that hate them. For Arduino-class boards, the standard is Atmel Studio, which is based on Microsoft's Visual Studio. It's windows-only, huge, quite baroque, and only supports Atmel CPUs (many Arduinos, but not the Intel Curie that I mentioned, for example.) The choices for multi-vendor IDEs are more limited, and they're seem to be less popular. You can also use Ancient Tools without an IDE (your favorite editor, makefiles, gdb...)QuoteNo, you're wrong here. "Processing" is Java (a simplified IDE and libraries for creating Desktop Java programs.) Arduino programs are written in C++. People sometimes mention an "Arduino language", but they are msitaken. There is some preprocessing, and some special-purpose libraries that cause Arduino programs not to look QUITE like other C or C++ programs, and there are some C++ "common features" that aren't provided (or aren't implemented very well) but it really is C/C++. Neither "Processing" or "Arduino" implements a new programming language; they're both just simplified "environments" for would-be programmers. (actually, for people who want to accomplish computer-program-like things without having to become programmers.) Processing for desktop apps, Arduino for "Physical Computing."

author: markhing
author_rank: Newbie
timestamp: February 07, 2016, 07:04:50 am
content: Thanks for the suggestions westfw.Quote from: westfw on February 07, 2016, 03:19:27 amI'm a professional software developer and way back in the 80s I wrote 1802, 6809E and 8088 assembly programs plus did C and Pascal for years. Since then I've been mainly working with more modern OO languages but I still recall quite a bit from my C days, so I'm not too concerned with the software side of things once I get my head around the Arduino development environment and understand what's going on beneath the covers. I want to teach my son to program but he doesn't appear interested in just seeing results on the screen, so I thought a physical Arduino project might pique his interest.The hardware/electronics side is a different matter. I know very little so that part will be interesting. Based on eevblog video recommendations I picked up some older HP power supplies, some multimeters and a soldering station on eBay and tried my hand at soldering wires together. I also bought a couple of books that seemed to be recommended everywhere. I've not yet received any of the Arduino hardware so I haven't played around with anything.I'll check out your recommendations and keep an eye out for the "Curie" products (I didn't even know they existed).Perhaps the project is too ambitious for a first attempt at Arduino but, as you say, we should learn a lot. And even if it doesn't work out completely but gets my son interested in programming/electronics then I'll mark that down as a success.Quote from: westfw on February 07, 2016, 03:19:27 amSo if I understand what you're saying here, I can use something like C# or javascript (node.js) rather than Processing for the desktop or browser app and use the Arduino IDE (or something more powerful like Atmel Studio) to develop the sketches in C/C++? That clears some things up and would open up quite a few options.Thanks again for your input. I'll update this thread as the project progresses.Mark.

author: westfw
author_rank: Super Contributor
timestamp: February 07, 2016, 07:49:54 am
content: QuoteAh. That should help a lot. You can think of Arduino programs as mostly C, with some C++ things thrown in occasionally. You can get it to do more C++ things, but a lot of C++ things require or assume dynamic memory allocation from a nearly-infinite pool of memory, which an Arduino doesn't have. (it has sort-of working memory allocation from a REALLY TINY memory pool.)How's your physics? Turning 3 axis of linear acceleration and 3 axis of rotational info into useful values seems to me to be ... complicated.QuoteYes. Most communications between the desktop and an arduino happen over a virtual serial port, so you can talk to it with anything that can talk to a serial port, and there are examples for most of the popular desktop languages. This does tend to limit communications speed somewhat...

author: legacy
author_rank: Super Contributor
timestamp: February 07, 2016, 10:37:08 am
content: you'd better buy a fly-board, ARM based

author: legacy
author_rank: Super Contributor
timestamp: February 07, 2016, 10:39:47 am
content: Quote from: westfw on February 07, 2016, 07:49:54 amthey need quaternion engine, plus a lot of mathwhich makes the computation useless on Arduino1because of its hw limitsops, I had forgotten, in my personal opinion, you'd better forget things like ardupilot, arduIMU, etc, they are useful only to trash money and time

author: legacy
author_rank: Super Contributor
timestamp: February 07, 2016, 11:36:27 am
content: just my 50 cents contribute for that damn funny plan, how to Plan to Stay Fresh and cool when kids say your informatic toys get them hot and sticky, like in summer when it's just too hot and they are too bored to stay indoor following you, and they prefer other toys: Kids love robots!, so … why don't you go for a tiny robotic application ?the wicked plan to teach them something should look like the following ideas:idea1: OdometryPlaying Odometry is "cool game" (yes, you can do it with Arduino1), it's used by some robots, whether they be legged or wheeled, to estimate (not determine) their position relative to a starting location. It solves the question "where Am I (within the map)?". This method is sensitive to errors due to the integration of velocity measurements over time to give position estimates. Rapid and accurate data collection, equipment calibration, and processing are required in most cases for odometry to be used effectively. You just need a good pair of brushless motors and thier optical encoders (encourage efficiency), and you are ready to use all of these data from motion sensors to estimate change in position over time. The hardware is a bit more expensive than what you need for a fly-robot (500 euro at least for a quad rotors, 300 euro for a pair of good motors + encoders + H bridge + a robotic carrier), It comes with less complexity, and it's safer (if a fly robot crashes …. while Odometry-robots just don't fly)idea1.1: Dead-reckoningIn terms of robotics, Odometry vs dead-reckoning might the the step next: Deduced reckoning is figuring out where you are after starting from a known position, by using your speed, direction and time, and It's effectively integration of velocity, at sea you would know your direction from a compass, speed by any one of various means, and important complications like the wind speed and direction would be estimated.Dead-reckoning systems are based on estimating position relative to sensors. These sensors can be accelerometers, gyroscopes (say, you can use an IMU), whell encoders (recycling what you have already used for Odometry), infrared sensors, gps, etc. which have to placed on body of robot. So we can calculate displacement or coordinates. Odometry is a sub topic of dead-reckoning and based on wheel displacement calculations, literally it counts the "footsteps" as an estimate of your walking speed. A wheeled vehicle would instead count wheel revolutions, that's equivalent to counting footsteps, … and to tell you the Truth Odometry isn't very accurate on its own as wheel slippage, carpet "springiness" and uneven floors can affect accuracy, even if a separate heading sensor can help with accurate headings at least, though.Dead-reckoning (requires Arduino2, at least) adds more complexity, more costs, but more accuracy and funidea2: Inverse kinematicsPlaying Inverse kinematics is an other cool game, even if the math is definitively more more complex (you need Arduino2, or a faster ARM board with a lot of ram), as it refers to the use of the kinematics equations of a robot to determine the joint parameters that provide a desired position of the end-effector, while the movement of a kinematic chain (robot body) is modeled by the kinematics equations of the chain, as rigid body with degree of freedom. These equations define the configuration of the chain in terms of its joint parameters. Forward kinematics uses the joint parameters to compute the configuration of the chain, and inverse kinematics reverses this calculation to determine the joint parameters that achieves a desired configuration.It's funny because it involves two cool sub-gools:path planning, andmotion planning, both of them combined as specification of the movement of a robot so that its end-effector achieves a desired task is known as motion planning. Inverse kinematics transforms the motion plan into joint actuator trajectories for the robot.about kit, I was thinking aboutthis, which can add a few kit, which you can buy and use to immediately enjoy the fun, and then replace with your own madejust my 50 cents

author: Simon
author_rank: Unknown
timestamp: February 07, 2016, 05:04:47 pm
content: I am not certain but I think you will find there is a lot of overhead in the Arduino. You never quite know what is going on behind your little sketch. On the other hand Atmel studio 7 will now open and Arduino project directly and therefore convert it to C for you so you can see exactly what is going on.

author: zapta
author_rank: Super Contributor
timestamp: February 07, 2016, 05:25:29 pm
content: Quote from: markhing on February 06, 2016, 09:30:36 pmI don't have an experience with Lilypad but most Arduino boards are about the same, with permutations in MCU, form factor, connectivity to a host and peripheral. If the ATMEGA328P MCU is sufficient for your needs, a minimal board such as Arduino Pro Mini will give you the basic and will allow to attach arbitrary peripherals.Quote from: markhing on February 06, 2016, 09:30:36 pmIf it works for you, the Arduino IDE is the most straight forward to program Arduinos. Some don't like the minimalist UI but if this doesn't bother you (it doesn't bother me) than it's a good choice. It uses the standard AVR GCC C++ compiler which is installed as part of the IDE installation.Quote from: markhing on February 06, 2016, 09:30:36 pmProcessing is a host side thing, not required for using Arduino. If your Arduino communicates with the host using a USB/Serial channel than you can run on the host whatever you want. Same goes for the Wiring 'language' on the Arduino, it's not really a special language but a standard C++ with a set of Arduino libraries that you can choose to use or not.A good way to learn Arduino is using the book Exploring Arduino: Tools and Techniques for Engineering Wizardry by Bloom and an Arduino UNO board.

author: zapta
author_rank: Super Contributor
timestamp: February 07, 2016, 05:30:20 pm
content: Quote from: Simon on February 07, 2016, 05:04:47 pmArduino sketches are written in C++. I doubt if an automatic conversion of C++ to C makes it more readable.

author: retrolefty
author_rank: Super Contributor
timestamp: February 07, 2016, 05:32:06 pm
content: Quote from: Simon on February 07, 2016, 05:04:47 pmOh come on, all the arduino functions and libraries have their source code downloaded with the rest of the IDE. If you don't quite know what it is doing, then you simply have not looked for why. Timer0 configured and running during init is about the only thing going on besides what you create and you can turn that off if you have a need and don't require a few of the arduino timing functions.

author: alsetalokin4017
author_rank: Super Contributor
timestamp: February 07, 2016, 06:35:00 pm
content: Love it.....Let's just see if we can get the "Blink" sketch running first... before we start doing quaternion math and path modelling in 4-D.....

author: zapta
author_rank: Super Contributor
timestamp: February 07, 2016, 06:47:33 pm
content: Quote from: retrolefty on February 07, 2016, 05:32:06 pm+1There are many misconceptions about Arduino, and this is one of them. There is no problem whatsoever to program an Arduino 'close to the metal' if one chooses so. Disable the tick timer, have your own main loop and access the registers directly. You can also use mix mode, using Arduino I/O libraries for some functionalities and your own for the rest.The Arduino stack is based on common technologies, GCC/C++ as a language, AVR as MCU (typically), AVRDUDE for bootloader programming and USB/Serial to communicate with the bootloader.

author: Morgoroth
author_rank: Regular Contributor
timestamp: February 07, 2016, 07:51:15 pm
content: There is an extension for atmel visual studio for arduino, make a lot easy to put hand on libs and disable/enable stuffs, I mean, you keep the 'arduino lang' and at same time you have access to the deeper libraries, pretty handy if you really want to know how the libs works, or tweek them in site.www.visualmicro.com

author: zapta
author_rank: Super Contributor
timestamp: February 07, 2016, 08:15:19 pm
content: Quote from: Morgoroth on February 07, 2016, 07:51:15 pmSounds very interesting, if one doesn't mind using Atmel Studio.

author: markhing
author_rank: Newbie
timestamp: February 07, 2016, 09:46:52 pm
content: Well, I certainly was not expecting this level of response so thank you all for your replies. You've most definitely saved me quite a bit of time.i've looked at visualmicro (looks good because I already use VS2015) and I like the robot arm kit (but that will have to wait until after this project). For the physics stuff I imagine there are already algorithms/libraries developed by some smart people, so the plan is to stand on their shoulders rather than reinventing the wheel.I'm starting to feel more comfortable with the environment just reading the responses and looking at the tools (and I don't even have any Arduino hardware in my hands yet). Once the boards arrive I will definitely get that blink sketch running first and then just dive in and see what happens.

author: westfw
author_rank: Super Contributor
timestamp: February 08, 2016, 05:04:55 am
content: QuoteYou know exactly as much (or as little) as if you used Atmel ASF libraries, STM Cube libraries, or TI's Tivaware...

author: Muxr
author_rank: Super Contributor
timestamp: February 08, 2016, 05:29:38 am
content: For something as ambitious as that I would probably look at using Raspberry Pi Zero. You have the flexibility of using any language (even scripting languages) at that point.The problem with most microcontrollers is that they don't have much RAM. So buffering a lot of visual data you need to process and make decisions on is going to be a challenge in itself. It can be done on more powerful MCUs, but it isn't going to be a walk in the park.With RPi you would be able to leverage heavier libraries, things likehttp://opencv.org/for instance.

author: legacy
author_rank: Super Contributor
timestamp: February 08, 2016, 10:23:41 am
content: Quote from: Muxr on February 08, 2016, 05:29:38 amin this case, my suggestion is: learn both, use both, and split the high level into RPI (where you can use the language of your choice, python? Lua? C? C++? Erlang? Pascal?), the low-level into MPU(C/C++), then connect the MPU to RPI over the serial lineRPI=== serial line === MPUPROs: in this case you will be able to deal real time task (@MPU, {PWM, timers, ADC, DAC, … etc }), and the management and communication (@RPI, { WIFI, LAN, WEB, SSH, ... etc } ), more conformably and with the flexibility of using any language without the need to scarify the real timeCONs: you have to buy and handle two piece of hardware with two different toolchains { barebone@MPU, linux@RPI }

author: legacy
author_rank: Super Contributor
timestamp: February 08, 2016, 10:37:11 am
content: Quote from: markhing on February 07, 2016, 09:46:52 pmcircumstances where the complexity has grown too much, like moving on ice& to survive you have to be careful about how to move your feet, step by stepis it time to move on theAVR-ICE?I am going to sell my AVRdragon (30-30 euro), in order to buy the new ICE (60-70 euro)it doesn't yet support the HV programming, AVRdragon supports it, the new AVR-ICE doesn'tprobably it will never added as feature, but it's more comfortable, fast, and powerfulthe perfect swissknife if combined with AVR/VisualStudio

author: westfw
author_rank: Super Contributor
timestamp: February 08, 2016, 10:43:39 am
content: Quotehopefully you mean the "Atmel ICE" ? It also supports the Atmel ARM chips, which is a big plus.

author: legacy
author_rank: Super Contributor
timestamp: February 08, 2016, 11:06:56 am
content: Quote from: westfw on February 08, 2016, 10:43:39 amyes, that's the good guy, I had forgotten its commercial nameQuote from: westfw on February 08, 2016, 10:43:39 amironically it's the big plus which made me to take the decision to upgrade my equipment(I am currently focused on AVR8, but I am planning to use it for ARM, too)

author: markhing
author_rank: Newbie
timestamp: February 08, 2016, 11:14:27 am
content: Quote from: Muxr on February 08, 2016, 05:29:38 amI believe I can get away with a moderately powered Arduino because the heavy lifting will be done by a full-fledged computer and the MPU-6050 breakout board.On the front-end, I'll use the LilyPad Arduino to read data from the MPU-6050 3 Axis Gyroscope/Accelerometer Sensor Module (actually 3 of them once I figure out how to connect them to one LilyPad module). This module has a built in accelerometer and gyroscope, but it also has some sort of Digital Motion Processor that processes the raw accelerometer/gyroscope data on the chip and can return results in quaternions without the Arduino having to do the math. This can then be converted to yaw-pitch-roll.Once yaw-pitch-roll data are sent to the main computer (via Bluetooth), the main computer can do the required calculations to convert yaw-pitch-roll to copter commands (analagous to joysticks positions + throttle) and then send the data via a wired serial port to the Arduino Due (which then sends the commands to the copter via the A7105 breakout board over the 2.4Ghz radio).Since the relatively underpowered Lilypad is only used for passing sensor input (i.e. no data flows back to it from the copter/Due/Computer and it doesn't do any major calculations), it should be powerful enough. When FPV is added, I don't expect this to go through either the LilyPad or the Due so, again, no worries for the Arduino boards. I suspect the diagram would look something like this...LilyPad Arduino <-- MPU-6050|vLilyPad Bluetooth Transceiver --> ... --> (bluetooth) Laptop Computer (C# program) --> Arduino Due --> A7105 breakout board (2.4Ghz transceiver) --> ... --> Copter Flight Ctrl board (2.4Ghz radio).If you see any flaws in this setup please don't hesitate to point them out.

author: FreddyVictor
author_rank: Regular Contributor
timestamp: February 08, 2016, 12:59:23 pm
content: Quote from: markhing on February 08, 2016, 11:14:27 amregarding the Digital Motion Processing (DMP) code, it is not available in source format.Invensense had a demo board which sent control commands+data and someone captured the data sent via i2c & is availableheremost multi-copter code that I have seen doesn't use it tho'....You might like to get an MP9250 BoB as well - it's cheap & is pretty much the same as MPU6050 but with the addition of a magnetometer