I need to access a controler for some motors. The controler can only be accesed via Ethernet. Unfortunatly I know very little about that kind of communications.
So I worked through the UDP-Examples LabView provides. That helped a lot, however some questions remain:
What I do not understand is, how I am supposed to open a connection to the controler. In all the LabView-examples you always had to enter the Port-Number in the Server and Reciver vi. However with the microcontroller, I can't just enter a port number. I assume, that the microcontrroller already has some sort of a port and acts similarily to the reciver.vi in te examples, however how can I find out it's port number or manipulate it?
I found a documentation for the microcontroller. It says that all commands to the microcontroller and all answers will be send in UDP-protocoll as Text coded in UTF-8. Succesfully decoded commands will be answered with an "ACK"-package and send back to the "commander".
The commands are the following:
global.exit= ends the server
global.socket=<Port.No> opens UDP-socket
global.isconnected= answers with 0 or 1 if the port can be used
global.getPort= returns the PortNumber where the server is listening
There are more of course. Some for setting Parameters of a gerneral I/O-Port, and many more for moving the motors of course. However I think the above are the ones I need in order to open a connection.
Of course there is kid of all I need. I just don't know how to use it. How am I meant to sent any of these orders to the controller without having a connection already?
Do I have to sort of send the first commands "everywhere", hope this device is the only one that answers, ask for his port and then open a connection?
I am really lost!
Thanks for your help already!
Solved! Go to Solution.
Please tell me which microcontroller you use for this task. Do you have installed the driver from this µC on your system?
If not you can find the drivers on this site: http://www.ni.com/devzone/idnet/d/
Maybe with this driver you get some functions to be able to connect to the µC.
There could be a problem with the UTF-8 data typ. Labview is not able to handle UTF-8 datas. So maybe you have to convert it into an other data type.
How you connect to the µC you should find in the manual.
thanks for your answer.
The enmtire thing is getting more and more confusing for me. What I did until now is plug the microcontroler to the universitys network/internet. And thats it. No Idea what I need from now on.
The microcontroller is an AVR32 AP7000 Processor from Atmel. The Board is an ATNGW100. At least that is what I'm guessing from the looks of it. However I didn't find it in the documentation I have, so I can't be certain.
Concernimg the driver: I havent installed anything yet. And I couldn't find a driver on the link that you gave me, nor did I find anything elsewhere. Maybe I just didn't see it although it was stuck right to my face, however I kind of get really confused. All I found was about actually programming the controller, which is not what I want to do. All I need to do is send some orders to it.
Should I be able to see the microcontroller in the Network thing in the explorer? I can't....
I am really lost, don't even know where to start! Especially as I seem to have missunderstood how the communication works. As far as I got it from the LabView examples, there should be a Reader and a Writer running on the microcontroller as soon as it has got power. Now the controller must somehow know on what ports these readers and writers are, mustn't it? And I guess this should be written in the program that is running on the controler. If this is true, pleas tell me, as I have all the source files and could check through them!
And again to the drivers: Isn't writing a driver exactly what I want to do? Or do you mean some sort of a more fundamental drver the computer needs to sense that there is something around that he could talk to?
You can see, I really got no clue and I just cant find any useful answer anywhere.
I tried a port scanner. However I don't know how I am meant to find the microcontroller from the this.
Of course I can exclude ports that say "E-Mail" or something as obvious. However there are also hundreds of ports that say some weird combinations of Letters I have never heard before.
And especially there was none saying "microcontroller" or the model number/name of the program that is written on the controller or something similar.
Is there anything special I should be looking for?
How is the microcontroller network configured? Is it a static IP address? Do you have a separate network for the microcontroller?
What I would recommend if you are not already doing so is to setup another network interface on your LabVIEW computer. If you don't already have a spare (lot's of motherboards have two) then an addin card is only about $6.00.
I am going to guess that your microcontroller has a static IP of 192.168.1.100. I doubt that is it. You will want to configure your dedicated network port to 192.168.1.1 or something. It doesn't matter as long as it is on the same subnet (192.168.1.n) and the number after the last period is not the same as that of your microcontroller or anything else on this network. There should only be two things - your LabVIEW computer and your microcontroller.
Run the port scanner on this network specifying the IP address of your microcontroller. If you are lucky it will point out any open UDP ports.
What you did was probably to port scan your Internet connection.
thanks for your answer.
I did indeed port scan my internet connection, as that was the only ethernet I had. Both the computer and the microcontroller were connected to the university network.
Now however I did as you said and baught a new netwok card. i connected it to the microcontroller with a crossover cabel.
Now from here on I have some more questions. You said that I should cofigure this new netwok adapter to an IP-Adress of 192.168.1.1. What i did was to set the value in the device manager - the network card - properties - advanced - Network Adress from "Not Present" to the Value you gave me.Is that what you meant?
Now for the port-scan I you said that I would need to specify the IP-address of my microcontroller. But how do I find out the microcontrrolles IP-address? I did of course check the 192.168.1.100. However the port scanner always only gave "IP-address not found". How do you know it is 192.168.1.xxx at all? Couldn't it be anything up to 192.168.255.xxx as well? Trying through all those addresses with all the ports seems like a task for eternity to me...
I still feel as if I should be able to somehow "see" the microcontroller on my computer. Like all the other gadgets that are on a network, e.g. printers and all the other computers. However somehow I can't. Does that mean anything?
thanks a lot for everybody who helped.
I just managed to get it to work, writing kind of an own port scanner. As the controller was programmed to send an answer to every command send to him, I wrote an UDP-Server in LabView that would send a command to the controller taht he had to answer. In the "Open UDP" I specified the IP-Address of the ethernet card of my computer, that was connected to only the microcontroller via the crossover cabel.
The Server then sent the command to a not specified IP-Address (xFFFFFFFF). First to Port 1, then to Port 2, etc... and waited for an answer. This way I don't need to know the IP-Address.
In the end the Port-Number was (of course) 1234.
Thanks again for all your Ideas and your time!
Hah! That reminds me of a quote from Spaceballs.
"That's the stupidest combination I've ever heard of in my life! That's the kinda thing an idiot would have on his luggage!"