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

Two Way communication


Best Answer maxbeast, 09 March 2014 - 08:41 AM

Thanks sfugarino. I was stupid enough to don't consider that there are TWO phisical ports, one on Netduino and the other on PC. But your picture explains it very well. Now i've got it!

Go to the full post


  • Please log in to reply
4 replies to this topic

#1 maxbeast

maxbeast

    New Member

  • Members
  • Pip
  • 5 posts

Posted 02 March 2014 - 09:50 PM

I need to implement a system like this:

 

1) Netduino controls a stepper.

2) Affter some step, Netduino must notify a windows form app that the motor has finished

3) The window app do some job, and after that notify Netduino.

4) Netduino run the motor again

 

An so on.

 

the two tasks (motor stepping and the windows form app job) are very short: the motor runs for about half a second, the job consists in capturing an image from a web cam streaming and save it in a folder, so less than a second.

 

Plus, is critical that none of the two actors fail a sigle phase.

 

I tried with Netduino Plus one, 4.2.0.1 Tried with a COM 2/COM1 communication, that failed because of the USB/RS232 cable, maybe for different voltage required by the cable (5V, i think).

 

At this point i'm stuck: must i buy a couple of breakbox or a cables for my Netduino Plus 1 and implement via rs232, or buy a Netduino Plus 2 and implement the communication with the winform app via Ethernet? It is possible a two way communication? I've tried to use Socket on ND+1, but in that case, i obtained a crash when i tried to create an instance of the output ports (4) for the stepper motor. Viceversa, if the output ports are already created, i cannot create a Socket.

 

Plus i think that with the COM1/COM2 solution i have to make 2 usb ports busy, plus a thord for the webcam. Too much cables and also i don't know if the communication is enough robust.

 

Any suggestions?

thank you all.

 

 



#2 rharding64

rharding64

    New Member

  • Members
  • Pip
  • 8 posts

Posted 03 March 2014 - 03:29 AM

Max,

 

as many parent processes model well to a state machine, at first glance what you are trying to accomplish is sequential with dependencies involved. 

let's break down your system;

 

I need to implement a system like this:

 

1) Netduino controls a stepper.

>>are you using a ULN2003 device to control the stepper motor, just google uln2003 stepper motor and you will find many circuits like this. ULN2003 has built in diode projection for the CEMF build up in the 4 coils of a typical stepper motor. 

2) Affter some step, Netduino must notify a windows form app that the motor has finished

>>suggest that you install a sense line that tells you when the stepper motor is actually running then feed this as an input to your system. Now, you will be able to sense when motor is actually ON or OFF, not depending blindly on the control commands.  So use the sense line into digital input on Netduino.  the windows forms app listens for this line and fires an event handler in the windows forms application. 

3) The window app do some job, and after that notify Netduino.

>>that is just passing messages between a windows PC form application and the netduino application. 

 

i have been creating c# based tools and electronic interface design/build for various clients since 2006.  To have true system wide interaction with the device under test it is important to also provide device interaction via your SCPI programmable test equipment as well.  I am currently working on an OOP design pattern so i can create custom remote control applications for any SCPI capable test gear provided that i have the OEM gear programmer's reference guide PDF file.  

4) Netduino run the motor again

 

An so on.

 

the two tasks (motor stepping and the windows form app job) are very short: the motor runs for about half a second, the job consists in capturing an image from a web cam streaming and save it in a folder, so less than a second.

>>here, have you tried using the AutoResetEvent / ManualResetEvent?  

Also, there are things that you can do in winform applications to give additional information in the form of different colored prompts, i.e. red background with yellow font implies error message, navy blue background with white font means status, green background with yellow font means input, ect. 

 

 

Plus, is critical that none of the two actors fail a sigle phase.

 

I tried with Netduino Plus one, 4.2.0.1 Tried with a COM 2/COM1 communication, that failed because of the USB/RS232 cable, maybe for different voltage required by the cable (5V, i think).

 

At this point i'm stuck: must i buy a couple of breakbox or a cables for my Netduino Plus 1 and implement via rs232, or buy a Netduino Plus 2 and implement the communication with the winform app via Ethernet? It is possible a two way communication? I've tried to use Socket on ND+1, but in that case, i obtained a crash when i tried to create an instance of the output ports (4) for the stepper motor. Viceversa, if the output ports are already created, i cannot create a Socket.

>>here, don't waste your money!  I have been using FTDI chips in c# for years. They have an unmanaged API for years, but now they have a c# wrapper api as well. FTDI now offers up to 4 ports that can be mapped into 4 VCP, or USB based individually.(FT4232) you can also get a two port device as well, the FT2232.  A partner company DLPdesigns makes the pcb dev boards that can be mounted on breadboard. they are very easy to set up and use. since there is a pretty large user base, many good examples out there for use. so,

so offerings by dlp designs; 

 

two port model; 

http://www.dlpdesign...usb/2232h.shtml

 

4 port model;

see FTDI page on chip

http://www.ftdichip....ICs/FT4232H.htm

see evaluation board offered;

http://www.ftdichip....Mini_Module.pdf

 

So, going forward, well these items work in your application?

 

cheers

 

Ron 

Santa Clara, CA

 

 

if you want to 

 

Plus i think that with the COM1/COM2 solution i have to make 2 usb ports busy, plus a thord for the webcam. Too much cables and also i don't know if the communication is enough robust.



#3 maxbeast

maxbeast

    New Member

  • Members
  • Pip
  • 5 posts

Posted 03 March 2014 - 04:00 PM

Rharding64, thank you for your very exhaustive answer!

 

i'll try the two-ports model, before buy anything else. The thing i can't understand is this: i've seen several tutorial about two way communication via COM1/COM2, but how can the device or the windows app receive a message from the port? For example, in a situation like that, i would open the COM1 on Netduino and the COM2 on the windows app. How can Netduino receive messages on COM1, if tne windows app has the COM2  port open (and therefore sending messages and listening on this port) and not the COM1? This is the enigma for a very beginners like me!

 

For the other questions, i must thank you for the suggested sensorline, it seems to fix the bounce problem. I've already tried with a home made device like this, but i had to write lines of code to avoid the event fired continuosly. The problem is that the only place is a tiny shaft. I'll study the problem. The stepper is a Nema 17, and the program i've made is enough accurate to sop the motor exactely in the same position (I handled the drift).

 

As a programmer, i was thinking that a two way message system via ethernet was easier.

 

thank you again!



#4 sfugarino

sfugarino

    Member

  • Members
  • PipPip
  • 29 posts
  • LocationSuwanee, GA

Posted 09 March 2014 - 01:16 AM

The name of the ports doesn't matter. You need to connect the TX (transmit)t on one machine to the RX(receive) on the other. The RX on the first goes to the TX on the second. That's how the communication is bi-directional. If the voltages are different between the two machines, you need to use a logic level shifter between them. I've got my netduino talking to a beaglebone.

 

boards2.png

 

 



#5 maxbeast

maxbeast

    New Member

  • Members
  • Pip
  • 5 posts

Posted 09 March 2014 - 08:41 AM   Best Answer

Thanks sfugarino. I was stupid enough to don't consider that there are TWO phisical ports, one on Netduino and the other on PC. But your picture explains it very well. Now i've got it!






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.