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

How does Netduino interact with a Computer


  • Please log in to reply
12 replies to this topic

#1 Silent Walarus

Silent Walarus

    Member

  • Members
  • PipPip
  • 10 posts

Posted 04 June 2013 - 02:10 AM

Hello

 

 

recently i bought a netduino plus 2, and i've run a few peices of code on it (blinking LED etc)

 

 

i have a few questions as to how the netduino works while it's running code

 

 

1: Can the commands going to the Netduino pins (the ones that control motor etc) come from sources coming from the computer?

 

is the following possible:

 

I have a program with a form open, and i type in a number (lets say, speed of a motor) into a textbox and hit enter. the program will tell the netduino to adjust the speed of the motor to that "speed" on the fly (i wont have to re-debug the code to apply the speed change)

 

2: Can you integrate Netduino code into other applications (or make it so that the 2  diffrent applications interact?)

 

3: Can i incorporate diffrent sensors plugged into my computer with the Netduino or make them work with each other so that data from the sensor can interact with the Netduino?

 

 

thanks!



#2 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 04 June 2013 - 08:41 AM

1: yes (well i honestly dont 100% understand your question, but iam sure its yes)

 

2: yes

 

3: yes (edit: well i dont know if _you_ can, but its possible)

 

 

(notice you didnt ask how todo it, so all my answers are correct :D  )



#3 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 04 June 2013 - 10:19 AM

For your 1st question, I'd like to add that, since you have a Netduino Plus, a nice way of doing that would be to use networking. That is, you would write a socket listener (or use one of the ready made webbservers available here on the forum) for performing tasks initiated by a PC application. You can also use a USB-to serial converter to communicate with one of the Netduino UARTs. It's also possible to implement a HID device on your Netduino but I think this would be the more cumbersome code wise.



#4 Silent Walarus

Silent Walarus

    Member

  • Members
  • PipPip
  • 10 posts

Posted 04 June 2013 - 03:56 PM

Thanks for responses!

 

im looking to have a WPF application that has some controls/displays (kinda like a "control pannel") controlling motors hooked up to the Netduino.

 

in that WPF application im going to also have a sensor (connected to my computer via USB) feeding a data stream to the application. The application will be manipulating / analyzing this data and sending appropriate commands to the Netduino to control motors.

 

 

any advice on where to get started with the Netduino part of it?



#5 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 04 June 2013 - 05:07 PM

You should be able to find lot's of stuff regarding motor control here on the forum.

As for the PC comm I've made a USB device called PeekyPokey that acts as a virtual COM port and HID device on the PC (talks to Netduino via serial) and has 8 gpio. It comes with an extensive library in the form of an easy to use .NET assembly.

 

Below are a couple of videos of the board that, in order of appearance, 1) shows interaction with a Netduino mini (and a 2nd board), 2) controlling servos, 3) controlling a stepper motor and 4) controlling an LCD.

 

 

 

As can be seen in the videos, the library contains controls in the form of virtual LEDs, buttons and such that can be used for controlling stuff. It also contains USB game pad (joystick) support and a web server (last video).

 

I use the board a lot with my Netduino mini's since it can program/debug the mini, interact with it and power it.



#6 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 04 June 2013 - 05:29 PM

Here's the other two videos, it seems one cannot include more than two videos in one post.

 

 

 

Oh, and sorry about the out-of-focus fuzziness and for speaking Swedish in the videos.



#7 Silent Walarus

Silent Walarus

    Member

  • Members
  • PipPip
  • 10 posts

Posted 04 June 2013 - 07:44 PM

Very impressive program!

 

so from what i understand, I need to get ahold of a USB-to-Analog-In-pins cabe (or your program) on the Netduino

(what i assume to be the only way to input data into the Netduino while its running)

 

So i have my application running on my computer, and when it wants to send a command to Netduino, It sends a signal to a pre-determined USB port,  which will transmit the signal to the Netduino, the Netduino will pick that up and preform the action (moving motors)

 

is this correct?

 

 

What I know how to do:

-code C# programs for Computer (XNA game stuido, some WPF)

-code simple C# programs for Netduino (netduinoapps)

 

What Im learning to do:

-code netduinoapps to control small servos

-using breadboards etc...

 

What I have no clue how to do:

-link up the computer and Netduino so that the program that's running on the computer can send commands to the program running on the netudino



#8 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 04 June 2013 - 08:01 PM

Wow, hanzibal, you've been busy :) Very nice! Chris

#9 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 04 June 2013 - 08:28 PM

@Silent Walarus:

May I ask what sensor you would be getting the analogue readings from?

There aren't many USB<->analogue boards and if you find one, its likely to be much more expensive than a regular USB<->serial cable.

The Netduino is much better at dealing with analogue than a PC. Depending on your requirements, I think you'd be much better off letting your Netduino do the analogue readings. If your PC app needs the analogue readings, your Netduino could easily send them to the PC using a USB<->serial cable. From the PC app point of view, it's simply a matter of reading/writing to a COM port. You could define your own protocol for sending messages back and forth and having the Netduino perform various tasks initiated by commands sent from the PC app. Same thing on the Netduino side of things, simply read/write to a COM port.

The PeekyPokey is a PC<->Serial and PC<->GPIO combo and cannot operate without the supervision from a PC app running in the other end of the USB cable.

Here's what I think you should do next:

1. Get a USB<->UART (3V3) converter cable like this classic one:
https://www.sparkfun.com/products/9717

or a cheap board like this one:
http://www.ebay.com/...=item484bf4eb2f

2. Hook up your Netduino to your PC via the above cable/board:

Netduino ---------------------- Cable/board
UART_Tx ---------------------- Rx
UART_Rx ---------------------- Tx
GND --------------------------- GND

3. Find some code for doing serial talk from the forum (there are hundreds of posts regarding that)
http://lmgtfy.com/?q...UART Read Write

4. Using that info, write a small program to send the string "Hello world" from your Netduino to your PC

5. Implement your own serial protocol for data interchange and command execution

6. Start working on that sensor (if possible, have the Netduino do the readings)

7. Have tons of fun!

#10 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 04 June 2013 - 08:39 PM

Wow, hanzibal, you've been busy :) Very nice! Chris

Thank you, I hope you didn't mind me writing about the board here on the forum. It's not commercially available (yet) though but a first batch of 200 have been ready for some time while I've been "perfecting" the software :-) Coding is very much inspired from my experiences with .NETMF in general and Netduino in particular. In many cases, I've actually been reusing code in both directions. Would you mind if I write a separate post about the board?



#11 Silent Walarus

Silent Walarus

    Member

  • Members
  • PipPip
  • 10 posts

Posted 04 June 2013 - 09:05 PM

The Sensor I am using will (hopefully) have nothing to do directly with the Netduino..... it's data and conntections etc will be processed by a program running on my computer (one that I make)

 

The Sensor is connected to my computer, not to the Netduino, via USB. The data stream probably can't be handled by the Netduino (not to mention they probably have diffrent update times)

 

So what I will be doing is have the program analyze the data, pick out an appropriate action, and then (here's my problem) send the command to do the action down that cable to the Netduino (end problem) the Netduino will then preform that action with the motors (learning that)

 

the specific question (i think you adressed) is what to put in this logic:

 

on computer app:

if (action1 == true)

{

//code for sending command to netduino (dont know)

 action1 = false;

}

 

on netduino:

if( // something to do with incoming signals indicating action1 (dont know) )

{

  preformMotorCode1 == true;

}

 

 

I think you adessed my question with the "code for serial talk" link..... but if after reading this you think of something diffrent please do tell :D

 

im a real newbie at this so thank you so much for the info!



#12 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 04 June 2013 - 10:24 PM

http://blog.codeblac...with-RS232.aspx



#13 Silent Walarus

Silent Walarus

    Member

  • Members
  • PipPip
  • 10 posts

Posted 05 June 2013 - 12:22 AM

Thank you so much NooM and hanzibal! :D






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.