Develop a computer controlled Multipurpose Machine [closed]
May be my title wording can be misleading, but this is what I'm trying to accomplish.
I have a plan to develop a multipurpose integrated machine (something like fully automatic washing machine... But does more than that)... It is going to have many moving and non moving parts which needs to be controlled by a chip / processor on the panel...
I know C# and could write the modules that takes care of the user input and controls the machine by issuing commands to it. But what should do on the machine side...
Say, suppose I want the machine to rotate Drum B for 30 Seconds... My C# code will be
Machine.Rotate(drumB, Direction.Clockwise, 30);
But How am I going to access the m开发者_JS百科otor of the machine so that It can spin for 30 seconds...
Should I know "Embedded Systems" to do it or is there something else I need to learn.
Could you please help me out... If possible with the books / online material to start learning the same.
Thanks
You should start looking at the hobby sites for the .Net Micro Framework.
They'll give you all the kit you need in, well, kit form. I'm actively developing some hardware with a FEZ Domino from Tinyclr.com
I've found TinyClr.com excellent and SparkFun.com also has tons of stuff.
First, IMHO you must learn embedded systems for this kind of project, despite the tecnologies you may use. Thinking and programming in embedded systems is a bit different than thinking and programming for desktop computers.
The most important difference is the hardware resources (example, most of the times you will have limited disk and memory capacity, and the same for the processor). Other important difference is the software fault tolerance (it can be a little anoying if the driver gets stuck inside the car on the washing machine because the software chrashed...). There are other important points that you must look for (example, software-hardware co-design), but I think this 2 are really important ones and I think you must pay attention to them from the beggining of your project.
As an introduction to embedded systems, I would recommend you "Programming Embedded Systems: With C and GNU Development Tools" form Michael Barr (more software oriented) and "Designing Embedded Hardware" by John Catsoulis (hardware oriented). Of course, you can always check Wikipedia article as a starting point.
If you really want to use .NET, you have two options:
- as has already been said, look for .NET Micro Framework. Take care that the .NET MF only works with a limited number of hardware (check this page);
- other option is to buy an industrial panel (example of one here) or industrial computer, install Windows Embedded and program under standard .NET Framework. Beside this last advantage, the hardware is industrial, which means it is, for example, shock and water resistant, and has a number of inputs (USB, CAN, Ethernet, Serial, ...) that you can use with all the advantages of Windows programming.
Another option is to try other hardwares, but in that case you must use the libraries/APIs/frameworks the manufacturer provides for that hardware.
In order to you access your the hardware, you must use the available hardware inputs/outputs. For example, if you want to comunicate with a, let's say, stepper motor, you must check how you can comunicate with it. If the only way is by sending a PWM signal, you must find a way to do so. Two hipothesis:
- if you are using a development kit with .NET MF, you must check if it can generate a PWM signal, otherwise you will probably need to write a device driver to do so;
- if you are using a host computer as human interface connected to an external hardware (it can be connected through USB, Serial, ...), the hardware must be capable to receive messages from the host and generate the PWM signal (almost certainly you will a microcontroller on your hardware for this behaviours).
For both hipothesis, you can create a high-level framework with methods like the you one you presented that abstracts all the communication with the hardware. Also, @Daniel suggestion of callbacks is a really good one because it makes your framework more flexible (as an example, you can have different behaviours defined on the callback for each of the motors after it stops or before it starts).
As a final point, you must evaluate what do you really need for your project. If your project must be cheap, probably you will use a small hardware, but in that case you may, or may not, be able to use the .NET Micro Framework; if you can spend a little bit more money, maybe you can use a little more expensive hardware running Windows and in that case you can use even the standard .NET Framework.
Sorry for the big answer, but I hope it helps you on your choice(s)!
A very straight forward approach is to use the .NET Micro framework. But at least a basic knowledge of embedded systems isn't that bad.
This isn't .NET, but maybe you can search around and get some ideas from it.
BTW, it seems to me, from the first 'intuitive thought', that most of the commands that you'll be issuing to the devices will be asynchronous, as something like:
Motor.StartTurning(90, 0.1, CallBackFunction);
The system need not be an embedded system as such, you could control your machine and acquire sensor data using a PC equipped with suitable digital and analogue I/O hardware (examples). The problem with that approach is that real-time performance may be an issue with a General Purpose Operating System (GPOS) such as Windows or Linux. You could equip the PC with a Real-time Operating System (RTOS), but then C# is unlikely to be an option, and you loose many of the benefits of PC development such as familiar development and debug environments. Physical size may also be an issue, although very small industrial PC architecture boards are available such as PC/104, but that then is essentially an embedded system that just happens to share familiar desktop hardware architecture.
It is possible to use .NET Micro on a truly embedded systems based on non-x86 hardware, but again this does not provide hard real-time performance.
Controlling a motor is not always as simple as turning it on or off, you may also need speed or position control using closed loop-feedback, and PID controllers.
精彩评论