# Controlling Microcontroller using Visual C# [closed]

I'm building an ROV which I will program normally with C but I want to control the microcontroller from a PC using a program written in C#. So for the ROV, the microcontroller will be controlling it but the microcontroller will take its commands from a PC (not a joystick for example).

I'll be using Atmel AVR.

I need to figure out how to connect the PC to the microcontroller (through a USB or Serial?)

Can I just drop the whole microcontroller thing and control the ROV through the PC without any microcontrollers in between ?

## closed as not a real question by Leon Heller, Olin Lathrop, Nick Alexeev♦, Dave Tweed♦, Brian CarltonMay 23 '13 at 20:02

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

• What microcontroller are you using? We can't help you much without knowing specifics: What type of motors? What sensors are available? – apnorton May 23 '13 at 17:37
• This may be of interest to you: netmf.codeplex.com – apnorton May 23 '13 at 18:11
• Question nominated for reopening. I feel it makes a valid proposition, and one that is perfectly feasible in multiple ways, as the existing answers illustrate. – Anindo Ghosh May 24 '13 at 13:09
• @Bingo In order to (hopefully) get some reopen votes, you may want to provide context: Presumably you mention C# because that is a language you are most familiar with. Presumably you want (ideally) to be able to program both the microcontroller side, and some control program on the PC side, for that same reason. If that is not an option (it may not be with AVRs) then you want to be able to write control code on the PC side in C#, and interact through such code over the USB port to trigger specific actions on the microcontroller side. I could have edited the question thus, but prefer you do it. – Anindo Ghosh May 24 '13 at 14:12

You can use the .net micro-framework to do this. With visual C# you can even live debug the program on the micro controller as well as upload managed application code. Typically an ARM board such as Netduino. Some hardware options are also listed in the Wikipedia page.

• Will it work on the AVR as the framework requires 32-bit devices while the AVR is an 8-bit ? – Bingo May 24 '13 at 13:56
• I think the AVR doesn't meet the minimum requirements in the specification, the easiest way is to use a specific port made for specific boards such as the netduino (ardunio + .net) or ghielectronics USB. If the board meets the minimum hardware requirements, you can make your own port, but that's no small feat. – MandoMando May 24 '13 at 15:24

Usually a setup with UART at controller side and a Serial<=>USB cable works. Then you write a program for the controller that listens for incoming commands and executes them. Then write a program on your PC that writes instructions to the serial device (/dev/ttynnnn or COMn) and subsequently listens for responses.

What is practical and achievable highly depends on the microcontroller platform.

You basically have two options:

1) Use the already mentioned Serial port approach (I really don't want to know how many FT232 have been sold already); Basically you're emulating a serial port where you send data, although the connector is USB

2) Use HID: This is a USB class driver that comes with windows (or Linux or whatever) by default and also defines some method of communication. Keyboard/Mouse drivers are examples for HID drivers. There is quite a lot of example code out there, if your controller supports being an HID device I would go this route. For starters: http://embedded24.net/ (but as I said, there are many libs out there)