Sunday, April 1, 2018

Stepper Motor Appliance with Visual Basic 6.0


In a previous article entitled "Range finder with a Laser and a Webcam in Visual Basic 6.0" we have shown a project for distance estimation by using a laser and a webcam. Here we have another interesting project by Dr. Todd Danko, that uses VB6.

Download from ME

Introduction

The most advanced pieces of scientific equipment are often both very rare and very expensive. This is a poor combination if your research needs dictate the use of such a device.
For example, scanning electron microscopes, depending on quality, cost millions of dollars. This high price prohibits their purchase for occasional research use. This high price also decreases the probability that there is a facility near by that has both, a scanning electron microscope, and has time to let you use it.
One solution to this scenario is to create a product that allows scanning electron microscopes and possibly other equipment to be used remotely. Such a device would utilize the internet to pass commands to the microscope, as well as return data from the microscope back to the user.

Proposed Solution

Build a prototype of an internet controlled appliance that simulates the remote operation of a scanning electron microscope.
This appliance has four main components:
  • Server Software - to interface with the mechanical device, and the internet
  • Client Software - to interface with the user, and the internet
  • Camera -to simulate output data similar to that of a microscope
  • Stepper Motor X-Y table - to allow the user to change the position of the subject under the microscope

Procedure

Parts

Internet Appliance Electro-Mechanical Parts
PartVendorPart #QuantityPrice
Stepper MotorJameco1518612$6.19
Diode (1N4003)Jameco769708$0.04
Gears (Assorted)Jameco1318011$7.99
Power DriverArrowUNC5804B2$4.22
8255 CardBoondog.com8255 Kit1$59.00
Logitech WebCamBest Buy961237-04031$49.99
BreadboardRadio Shack276-1741$13.49
Battery HolderRadio Shack270-3961$1.79
Wrapping WireRadio Shack278-5011$2.99


Electro-Mechanical

This internet appliance calls for several electro-mechanical components:
  • An X-Y table that is moved by two stepper motors.
    • The X-Y table's purpose is to move the subject of the camera up/down, left/right in the camera's field of view.
    • The X-Y table is constructed of a wood frame, with stepper motors gear mounted.
    • Rotational motions of the stepper motors are transferred into linear motion by a system of wires and pulleys.
  • An 8255 card to interface the server PC with the stepper motor control circuits.
    • The 8255 cards purpose is to provide an interface between the server PC and the stepper motor control circuits. More information on the 8255 card's construction and operation may be found at www.boondog.com.
  • Two stepper motor control circuits.
    • The 5804 chips take digital data in from the 8255 card, and convert it into the phasing of the stepper motor coils to rotate the stepper motors in the desired directions by specified amounts.
    • Below is a schematic for one stepper motor control circuit. Please note that this appliance requires two motors, so two of these circuits must be constructed. The first control circuit is connected to ports A.0 and A.1 of the 8255 card. The second control circuit is connected to ports B.0 and B.1 of the 8255 card.


  • A Camera to collect image data.
    • A camera captures pictures of the subject on the X-Y table.
    • The camera is connected to the server PC in this case through a USB cable.
    • The drivers included with the camera were used to capture image data through the USB port of the server PC.
  • Below is a picture of the overall electro-mechanical setup.
    • Note the ribbon cable coming in from the top of the scene. This attaches to the 8255 card.
    • Note the stepper motor control circuits to the left of the photo.
    • A battery pack is used to power the stepper motors.
    • Note the use of wires wrapped around posts on the X-Y table to convert the motor's motion into linear movement. The platform that the subject would be placed on has been removed to expose the X-Y table mechanism.


Software

The software to control this internet appliance is broken into two groups: Software on the server PC and software on the client PC.

Server

  • The purpose of the server is to interface the internet appliance with the internet.

  • The server has several software components:
    • Visual Basic software to communicate with the client through WinSock, and to communicate with the 8255 Card through the 8255.dll.
    • The visual basic software contains the following components and may be downloaded at the bottom of this page as stepper_control.zip:
      • stepper_control_server.frm
      • stepper_control_server.vbp
      • stepper_control_server.vbw
      • stepper_control_server.exe
    • FTP Server software to make image files written by the Visual Basic software available for retrieval by the client software. For this project, the Titan FTP Server was used.
    • ActiveX component to accept data from the camera, and save it to a file on the server PC's hard drive. For this project, WebCam OCX was used.
  • Note, ActiveX components as well as the 8255.dll must be installed on a PC in addition to the Visual Basic Executable in order for the server to properly function.

Client

  • The purpose of the client is to interface the user with the appliance through the internet.


  • The client has several software components:
    • Visual Basic software to communicate with the server through WinSock, and to communicate with the user through a GUI.
    • The visual basic software contains the following components and may be downloaded at the bottom of this page as stepper_control.zip:
      • stepper_control_client.frm
      • stepper_control_client.vbp
      • stepper_control_client.vbw
      • stepper_control_client.exe
    • ActiveX FTP Client component to allow the client to FTP image files from the server PC's FTP server. For this application, Distinct Software's ftpClient OCX was used.
  • Note, ActiveX components must be installed on a PC in addition to the Visual Basic Executable in order for the client to properly function.

Turbo C

To demonstrate the functionality of the circuit before investing time into writing the server and client software, I wrote some simple code in TurboC.
This code:
  • Prompts the user for the address of the 8255 card.
  • Prompts the user for the direction to rotate the motor.
  • Prompts the user for the number of degrees to rotate the motor.
  • Rotates the stepper motor in the desired direction by the desired amount.

You may download source and executable code at the bottom of this page below in turboc.zip:

Theory of Operation

Here is how the system works:
  • Control data is passed between the server and client using WinSock TCP/IP.
  • Image data is passed from the server to the client using FTP. The client has ftp code built into it, but the server PC must be running third party FTP server software.
  • When a command is sent from the client to the server, the server determines what direction to control the X-Y table.
  • The server then sends commands to the 8255 card by way of the 8255.dll file.
  • Once the server has completed commanding the X-Y table to move, the server saves an image of the new scene.
  • This scene is written to a file on the server PC by means of the WebCam OCX ActiveX component.
  • Upon completion of writing the image file, the server sends a message to the client to indicate that the X-Y table has reached the desired position, and that a new image file is available.
  • When the client receives this message, it opens an FTP dialog with the server PC and retrieves the latest image file.
  • The client then displays the latest image file and allows the user through the client to send more control data.

Operating Procedure

These steps must be taken in the following order to successfully run the internet appliance:
  • Start Up Procedure:

    • Connect appliance to the server PC.
    • Confirm network connectivity between server and client PCs.
    • Determine IP address of server PC.
    • Start the FTP server on the server PC.
    • Start the Stepper Control Server software on the server PC.
    • Select the camera driver when the Stepper Control Server requests it.
    • Start the Stepper Control Client software on the client PC.
    • Enter the server PC's IP address when the Stepper Control Client software requests it.
    • Utilize appliance.
  • Shut Down Procedure:

    • Close Stepper Control Client software.
    • Close Stepper Control Server software.
    • Close FTP server software on server PC.

Conclusion

Utilization of internet appliances such as an internet adapted scanning electron microscope have many advantages. When a piece of equipment is networked through the internet, two main things happen:
  • Expensive and rare pieces of equipment may be brought closer to users all over the world. This allows those who can not justify purchasing equipment to use it after an agreement is made with a host organization.
  • Organizations considering purchase of expensive equipment may be able to diffuse the cost of the equipment through renting time on the machine over the internet. The customer base for this use is of course worldwide.

Source:




1 comment: