Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Advice on Adaptability of a Particular Arduino Project?


  • Please log in to reply
3 replies to this topic

#1 JoelJustJoel

JoelJustJoel

    New Member

  • Members
  • Pip
  • 3 posts

Posted 05 March 2011 - 04:30 AM

Okay, this is from an earlier post of mine, but I've cleverly reworded it to hopefully attract more responders.

We have not yet purchased a Netduino, but we may buy one soon to evaluate for possible use in a university freshman Introduction to Engineering course.

The overall question is, how easy is it to port Arduino projects over to the Netduino? Clearly C# is different than the Wiring-based Arduino language, but how difficult is a typical migration? There are BLOCs (bazillions of lines of code) of Arduino apps out there, so it would be really nice if they ported over easily.

In particular, can one of you experienced Netduino users possibly glance at this Arduino code for talking to a LabVIEW PC -- http://web.me.com/ik...on/LabVIEW.html -- and give me a wild guess of how easy it would be to migrate this over to a Netduino? I'm pretty comfortable in C# and C, and the Wiring/Arduino language seems quite C-like.

Thanks in advance for any advice,
Joel

#2 freds

freds

    Advanced Member

  • Members
  • PipPipPip
  • 61 posts

Posted 05 March 2011 - 05:09 AM

Hi Joel

The examples given in the link for labview are not paticullary complex
or difficult to understand. They basically just use serial communications
for reporting analog readings and switching digital ports on or off.

The biggest differences would be in the analog scaling of inputs between the Arduino and Netduino.

Also from a language standpoint you can mimic processing in C#

Running Processing Code on the .NET Micro Framework

#3 Dan Morphis

Dan Morphis

    Advanced Member

  • Members
  • PipPipPip
  • 188 posts

Posted 05 March 2011 - 05:12 AM

Okay, this is from an earlier post of mine, but I've cleverly reworded it to hopefully attract more responders.


I'm glad you asked again. When I saw your first post, I wasn't really sure what you were asking.

For me, the Netduino / .NET MicroFramework is an awesome platform. This is the first microcontroller I've been able to get working in < 5 mins. Literally, in < 5 mins I had an LED blinking on my Netduino. I have a micro controller based on the Atmel (running the Ethernut OS) which sits on my shelf because the process to get it up and running / writing code was such a pain. The IDE at the time (6-7 years ago) was so archaic compared to Visual Studio, I just gave up on it. That board ran me like $140.

Then I bought a Linux based board (TS-7200) from Technologic Systems, and flailed around on that for a while before I buggered up the boot block and had to jump through a bunch of gyrations to make it boot after that. I believe I paid $130 for it at the time.

Finally, I came upon the Netduino. My interest was piqued because of the low cost, and because its can run Net MF. Being that I write C# all day for my day job, it would be a piece of cake to write code for the board. But I didn't buy one of the Netduino boards because it didn't have ethernet. Sure, I could add an ethernet shield, but those are another $45.

So when the Netduino+ came out, I jumped as soon as I found out (late January). I scoured the net, and found one of the last few available boards in North America for sale at Cana-Kit and ordered one. Best decision I've made in a while :)

Then I placed an order for some RFID stuff, an arduino protoshield, and some relays from SparkFun. I wasn't even 100% sure I would be able to make any of this stuff work not being real familiar with how all this stuff works, but I figured it was worth a shot. It wasn't long before I had my Netduino reading in the data from the RFID reader (ID-20 if your interested).

Then I set out to figure out how to make the relays work. My first attempt was to drive the relay directly from one of the digital pins. It worked, but I'm REAL lucky I didn't burn up the pin. Then I found the arduino relay schematic hooked that up. Everything worked great!

Now, I have a circuit board milled, and I'm putting the final touches on the hardware, and I'm going to write some glue code in software to be able to open my doors via RFID. A goal I've had for almost 10 years, but I've never even come close until now.

So, if your asking if you should go with the Netduino platform, my answer is a resounding yes :)

To your question:

In particular, can one of you experienced Netduino users possibly glance at this Arduino code for talking to a LabVIEW PC -- http://web.me.com/ik...on/LabVIEW.html -- and give me a wild guess of how easy it would be to migrate this over to a Netduino? I'm pretty comfortable in C# and C, and the Wiring/Arduino language seems quite C-like.


I took a quick stab at converting your LabView 2 page from wiring to C#. Took me < 5 mins.

using System.IO.Ports;
using System.Threading;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;

public class LabView {
    private static OutputPort _d3 = new OutputPort(Pins.GPIO_PIN_D3, false);
    private static OutputPort _d4 = new OutputPort(Pins.GPIO_PIN_D4, false);
    private static OutputPort _d5 = new OutputPort(Pins.GPIO_PIN_D5, false);

    static void Main() {
        var serial = new SerialPort(SerialPorts.COM1, 9600, Parity.None, 8, StopBits.One);
        serial.DataReceived += SerialDataReceived;
        serial.Open();
            
        //turn on ho light
        var d13 = new OutputPort(Pins.GPIO_PIN_D13, true);

        Thread.Sleep(Timeout.Infinite);
    }

    private static void SerialDataReceived(object sender, SerialDataReceivedEventArgs e) {
        var buffer = new byte[1];
            
        (sender as SerialPort).Read(buffer, 0, 1);

        var data = buffer[0];
        //set up the integer serialReading to store reading
        //analogRead stores anything received via serial

        switch (data) {
            //if a ‘0’ is received, turn all LED’s off
            case 0:
                SetPins(false, false, false);
                break;
            //if a ‘1’ is received, turn the first LED on
            case 1:
                SetPins(true, false, false);
                break;
            //if a ‘2’ is received, turn the second LED on
            case 2:
                SetPins(false, true, false);
                break;
            //if a ‘3’ is received, turn the third LED on
            case 3:
                SetPins(false, false, true);
                break;
            default:
                break;
        }

        //delay for 0.01 seconds
        Thread.Sleep(10);
    }

    private static void SetPins(bool pin3, bool pin4, bool pin5)
    {
        _d3.Write(pin3);
        _d4.Write(pin4);
        _d5.Write(pin5);
    }
}

Hope this helps, btw welcome to the Netduino community :)

#4 JoelJustJoel

JoelJustJoel

    New Member

  • Members
  • Pip
  • 3 posts

Posted 05 March 2011 - 10:05 PM

Terrific! Thanks, Fred and Dan, for the great responses. That info and translation assistance is a big help.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.