Pages: 1 [2]   Go Down
Author Topic: Control Arduino with VB.Net/C#  (Read 7065 times)
0 Members and 2 Guests are viewing this topic.
the Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 42
Arduino robot on the way...someday...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I didn't use the serial class before in .net.
Usage is easy but it has some 'strange' behaviour that I had to understand.

btw a good resource is this link:
http://blogs.msdn.com/bclteam/archive/2006/10/10/Top-5-SerialPort-Tips-_5b00_Kim-Hamilton_5D00_.aspx

I think a good discussion about the 'efficiency' of code is always desirable, so all input is welcome.

When my webspace is ready I will post a compiled dll to use with some documentation.
Logged

the Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 42
Arduino robot on the way...someday...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, I finally got some webspace and copied the compiled dll and arduino sketch.
No further info on the website yet.
I want to add some documentation and perhaps some examples....
(In due time...)

link to the dll:
http://www.gyps.nl/arduino/Arduino_Net.dll

link to the arduino code:
http://www.gyps.nl/arduino/Arduino_net.pde

The rest will follow.
Logged

Oppuurs, Belgium
Offline Offline
Jr. Member
**
Karma: 0
Posts: 94
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Would you also be so kind to put the Visual Studio solution/project there in a zip file?

Greetings,
EriSan500
Logged

the Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 42
Arduino robot on the way...someday...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Although it's just work in progress I uploaded the complete VB.Net 2005 project here:

http://www.gyps.nl/arduino/Arduino_Net.zip

This project is not a finished and polished one.
There is one test application in there that I used to test the inputs and outputs. The application works and I included a small text file with the Arduino connections I used.
All the functions in the class are documented, so using the class shouldn't be difficult.

Some explanation here:

To use the digital ports, you have to set the direction of the port (input, output or pwm), enable the port and optionally set a trigger.
When the trigger is set on a digital port, the class fires an event every time the value of that port is changed.
To read a button, attach that button to a digital port, set the direction to input, enable the port and enable the trigger.
When you push the button, an event is fired from the class, saying that the value is changed to 1 and when you release the button, an event is fired saying that the value has changed to 0.
It's also possible to read the current value of a digital port. This function will not give the current value in return, instead it fires the same event as if the trigger was used. This value-read function can be used with or without the use of the trigger.
For an analog port there's only input, so no direction to set here. Just enable the analog port and read the value.
There is also a 'trigger' on the analog port called threshold. This will fire an event when the value of the analog input is changed by more than the set threshold. This will eliminate the slight changes that occur on the analog input.
Reading the value of the analog input works the same as on the digital input. Just use the GetAnalogValue command and wait for the event.

I know it would be more easy if the value reading functions would return a value but this conflict with the working of the Arduino code.
I'm working on that.

Keep in mind that this is no finished product.
There are no real checks on the input values and portnumbers.
These are all to be implemented in the .Net class.

current commands:

StartCommunication() As Boolean
SetDigitalDirection(ByVal Port As Integer, ByVal Direction As DigitalDirection)
SetDigitalValue(ByVal Port As Integer, ByVal Value As Integer)
EnableDigitalPort(ByVal Port As Integer, ByVal Enable As Boolean)
EnableAnalogPort(ByVal Port As Integer, ByVal Enable As Boolean)
EnableDigitalTrigger(ByVal Port As Integer, ByVal Enable As Boolean)
EnableAnalogTrigger(ByVal Port As Integer, ByVal Threshold As Integer)
GetDigitalValue(ByVal Port As Integer)
GetAnalogValue(ByVal Port As Integer)

current events:

DigitalDataReceived(ByVal DPortNr As Integer, ByVal Value As Integer)
AnalogDataReceived(ByVal APortNr As Integer, ByVal Value As Integer)
LogMessageReceived(ByVal Message As String, ByVal DebugLevel As Integer)
WatchdogReceived()
ConnectionLost()


comments are welcome as always.
« Last Edit: January 30, 2010, 03:21:02 am by vulture » Logged

the Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 42
Arduino robot on the way...someday...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

For anyone that's interested, I made a simple page for my code:

http://www.gyps.nl/arduino

In due time I will update this page to something decent, but for now it's just a simple page to keep track of the revisions and changes to the code.
Logged

the Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 42
Arduino robot on the way...someday...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I found out that there was a problem with the links on my website.
I fixed them for the interested people.

I'm also working on a way to add servo support into it.
I am using the Adafruit motorshield, so I'm planning to add all functionality of that to the Arduino_Net project.
Logged

Pages: 1 [2]   Go Up
Jump to: