Pregunta

how does a computer program control a mechanical movement, what is the bridge between the object code and a certain machine part.

Let us say I have a certain paint sprayer which is directed, and I wanted that to move circularly either

1. Start at the circumference of a certain radius circle and paint circularly and stop when it reaches to the center of the circle or
2. start at the center of the circle and run around until it reaches a certain radius.

and if I represent my sprayer as noselPaint and how that progamatic noselPaint construct is linked to actual spraying tip to control its movement in a uniform manner.

¿Fue útil?

Solución

Your question is too broad, but I'll try to highlight main steps for task of this kind. Any mechanical hardware that controlled by the PC programs contains the next main parts:

  1. PC program
  2. Motor controller board (with the heart is microcontroller e.g. AVR, STM32 or any other)
  3. Power drivers (provide high electric current for mechanical part motors)
  4. Motors (usually servo-motor)

PC program read the control file and then send data to the driver motor controller board (e.g. most common case nowadays by mean of USB). After that microcontroller process data and generate signal to the motors, that rotate the shaft to appropriate angle. In processing data stage includes storing received data to the internal controller memory and recalculation (if required) from angle data to the voltage levels or to required "time". Then it pass to motors. Another words servo-motor can't rotate to an angle 63 degree (it not understand what mean "63" digit) but it can get as I wrote above voltage or PWM (it depends on which kind of the servo-motor microcontroller works).

PC program can be written on different programming language C, C++, C#, Python or others. But to negotiate with the controller board driver required. Other way is using libusb library that has bindings for different language.

Microcontroller also has program that writes to its flash-memory (this program named firmware). This program write with assembler or C language (for more complicated firmwares).

Implementation of such kind tasks required knowledge not only in PC programming but also electric and electronic circuits design, OS driver programming, standard hardware interfaces implementation. And also complicate task is design construction of your moving parts.

To getting started with your question I can recommend your to get a evaluation microcontroller board (e.g. STM32F103VB contained hardware USB interface or AVR ATMega16 or ATMega8 simpler microcontroller but has no USB interface). And as moving part is HS645mg servo-motor.

UPDATE:

  1. Simple evaluation board for STM32 microcontroller, required only one board the heart of motors controller bridge.
  2. STM32 Programmer, required to flash firmware into the microcontroller memory (only one required for development)
  3. Servo-motor, is the moving part (number of motors depend on your task and device degrees of freedom, i.e. joints)
  4. Simple and easy to use power circuit parts, required to provider high current for servo-motors.

All of these parts can be bought on ebay, but usually more swiftly approach is to look up electronic store in your region (of course not a consumer electronics shop).

Working with microcontroller (MC) is quite simple:

  1. MC tutorial
  2. MC video tutorial

Also I think you can find a lot of similar tutorial by Googling "STM32 getting started". Program for STM32 microcontroller written in C language via e.g. Coocox IDE (it is based on Eclipse IDE) and compiled by special compiler ARM GNU toolchain.

As for PC program read the control file I mean that: Control file is simple binary or text file with data represented in format that easy to read in program, for example it can be sequence of coordinate where your paint sprayer should be moved at or something like that.

PC program is the common program that written in any programming language your familiar. Most of language are suitable for this task. The main objective of program is read control file (that was described above) and send data to controller board by mean of USB.

Sending data to MC isn't much differ from working standard library. The simplest way to send data via USB is using libusb library. But as for setup USB on microcontroller is more complicated task however there are a lot of detailed manual on STM32 MC at the official web-site (e.g. STM32F103xx).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top