Best language and library?

Hello -

I've bought an Arduino Mega R3 and the Ethernet Shield with the intention of using it to control a large airship. In this project, joysticks will be read, their data sent to the Arduino via an access point, and interpreted on the Arduino to preform various tasks. This is where things get tricky...if communication is lost between the computer and Arduino, the motors must be turned off, sort of like a fail safe.

I understand that the Arduino can function with many languages, such as LabView, C++ and it's own language, however which would be the best for my project? I have LabView experience, however I understand that the Arduino library will make my job extremely difficult. Which of the many languages has good libraries to get started with robotics and Arduino?

Dom

DominickC:
I understand that the Arduino library will make my job extremely difficult.

Where did you get this understanding from? Not from using them, I presume. There are many libraries, each designed to do a particular job. There are targetted at being easily used by newcomers, as well as being powerful enough for experienced people.

The Arduino is programmed in C++, an industry standard language.

Your project, conceptually, doesn’t sound much more complex than my radio-controlled car (of course the car doesn’t fly).

http://www.gammon.com.au/forum/?id=11506

One of the things I describe on that page, amongst others (like reading the Wii nunchuk as a joystick) is how to turn off the motors if you lose communications.

I understand that the Arduino can function with many languages, such as LabView, C++ and it's own language, however which would be the best for my project?

You may have misunderstood what is generally meant by that expression 'function with many languages'. What that specifically means is that when a arduino is plugged into a PC via it's USB buss, it looks to the PC as a simple serial comm port, so any PC programming language or application that can access the comm port will be able to send or receive characters from and to the Arduino. But the actual sketches you create and run and the library functions avalible to run on a arduino will all be done in the gcc C++ programming language.

That can be a subtle or major difference, depending on one's knowledge, understanding, or point of view.

That make sense?

Lefty

No, I guess I didn’t make it clear that I have had no hands-on experience with the Arduino Microprocessor in particular, sorry about that!

I am the programmer for FRC Team 23, and have asked about using the Arduino with the WPI LabView library - an FRC standard library - and was told by those with Arduino experience that doing my project using LabView on the Arduino would me much more difficult than I expect.

I’ll take a look at your link, thanks.

EDIT: I plan to use the Ethernet Shield in conjunction with the Arduino Mega and wire it to a wireless Access Point router. From there, I’ll connect to it wirelessly from a laptop.

Dom

So I’ve written a simple VI which should give me rudimentary joystick control over a PWM channel. An image is attached.

I gather that code is compiled and run off of the computer, and data is sent to the Arduino. Correct?

Capture.JPG

DominickC: So I've written a simple VI which should give me rudimentary joystick control over a PWM channel. An image is attached.

I don't understand your diagram at all. You seem to have stuff connected to "Arduino write" which is connected to "Arduino init" which itself is connected to the Mega2560.

Don't over-complicate things. You connect the sensor to the Arduino. It reads it, it controls stuff.

DominickC: I gather that code is compiled and run off of the computer, and data is sent to the Arduino. Correct?

I don't understand that either. The code is compiled on the PC/Mac/Linux. The compiled code (machine code) is sent to the Arduino. The Arduino executes the code.

This is the LabVIEW programming environment. This code is as simple as it gets. I open a reference to an Arduino Mega on the default COM port as well as a Joystick on the computer's USB ports. I then get the values of the Joystick, who's device index is 0, and wire the axis values to the Duty Cycle of the PWM Write Pin.

In a nutshell, I'm opening an Arduino and a Joystick, and I'm running a motor connected to a speed controller via a joystick hooked up to the computer.

Again, this is as simple as it gets.

No, this is as simple as it gets:

void setup () 
  { }
void loop ()
  {
  analogWrite (6, analogRead (0) / 4); // PWM to pin D6
  }

This reads an analog value from A0 (eg. a joystick) and writes a corresponding PWM value to pin D6 (one of the PWM pins).

Since the analogRead returns a value in the range 0 to 1023, and the PWM expects a value on the range 0 to 255, I divide the read value by 4.

... was told by those with Arduino experience that doing my project using LabView on the Arduino would me much more difficult than I expect

Well they may be right about that bit. Why not just program on the Arduino? I mean, one line of code to control a motor is hardly very complex.

That may be as simple as it gets, if I wanted to read an analog signal and scale it to supply a PWM output, all in C. The equivalent of what you wrote is attached.

For my previous example, I’m hooking up a joystick - which reads values from 0 to 255 - to a computer, and setting the output of a PWM channel - with a speed controller hooked up to it, with a motor on the other end.

capppp.JPG

I'm confused. What is the question?

If failsafe is important to you, head over to DIY Drones (http://diydrones.com/), and look at their ArduPilot Mega based boards. They have a second processor on the board that takes over when communication is lost, and can be programmed to, for example, return to base. They also have the accelerometer and gyro on board, and can take a GPS receiver too.

How does the WPI LabView library work with the Arduino? Does the Arduino run some general purpose sketch that the LabView library sends commands to? Or does LabView actually build some code that runs on the Arduino?

Are you using the LIFA Toolkit? https://decibel.ni.com/content/groups/labview-interface-for-arduino

dxw00d: I'm confused. What is the question?

If failsafe is important to you, head over to DIY Drones (http://diydrones.com/), and look at their ArduPilot Mega based boards. They have a second processor on the board that takes over when communication is lost, and can be programmed to, for example, return to base. They also have the accelerometer and gyro on board, and can take a GPS receiver too.

I'm now looking for someone to check my understanding of the Arduino library. I just threw together a few simple and quick "sketches" which preform basic tasks.

dhunt: How does the WPI LabView library work with the Arduino? Does the Arduino run some general purpose sketch that the LabView library sends commands to? Or does LabView actually build some code that runs on the Arduino?

Are you using the LIFA Toolkit? https://decibel.ni.com/content/groups/labview-interface-for-arduino

The WPI LabView library was never intended to work on the Arduino. I took a look at it, and only some functions will work, such as calling joysticks and cameras. From what I understand, one loads a firmware to the Arduino tailored to LabView, allowing it to run LabView project files.

I am in fact using the Arduino Toolkit/library. That's the only library I used in the attached examples, no other libraries were used.

The simplest failsafe is putting some hardware in the plane that must receive a command every 'n' seconds or it turns off the motor. Then, your controller sends a minor command every n/4 seconds - it can be just repeating a current setting. Then can be anything from a small processor down to a 555 timer.

That way, you lose comms and the plane responds without further input. For an expensive plane, the 'return to home' solution is way cool but much more complex.

I like the idea of a hardware timer. I'm certainly going to look into that, as well as how I can implement the functionality thru software. I could send commands/values from joysticks to the Arduino over a TCP port, and have a timer on the Arduino side. If there are no comms for x second(s), the motors shut off.

I'm designing the software like this...There will be 2 states. Disabled and Enabled. In Disabled, the motors will not accept any input, sensors will not read back values and so on. When Enabled (A button/switch pressed on the computer), a boolean will be sent to the Arduino via a TCP port, enabling it. During Enabled, everything is functional. I could, potentially, time the receipt of each packet, and force the bot into Disabled if the current timer time is greater than 1 second.

The airship is designed to coast down to the ground, posing little risk if the failsafe is triggered.

Eventually, we'll be integrating a GPS. But for now, we're flying with a camera and a map. We might decide to integrate IR sensors which would use a PID loop to follow an IR emitter beacon held by a person on the ground...almost like a leash.

If you have some intelligence in the airship, you should have it do a slow circle when you power off the motors so it spirals down roughly over the location where it lost comms. It would be easier to track on the way down - rather than heading off in a potentially difficult direction.

That’s a great idea! We’re going to have a unique motor/fan system controlling the airship, so this will be pretty easy to accomplish.

Thanks!