Some curve stepper motor steering C-programs for plotters ========================================================== and milling machines with the PCI-DIO24 digital I/O card ======================================================== Document version 1.02 First version: 2017-11-10 Latest update: 2018-01-22 By: Stefan Spännare, Lund Sweden Email: stefan.sp@outlook.com Home page: http://www.spaennare.se Project web page: http://www.spaennare.se/techproj/tmplotter.html ======================================================================= Contents: 1. Introduction 2. PCI-DIO24 I/O card installation and setup 3. Hardware setup and stepper motor drives signal connection 4. Plotter or milling machine stepper motor aspect ratio calibration 5. How to run the computer programs 6. How to compile the programs 7. Links and references 1. Introduction =============== This is only a brief users guide. At present C-programs for plotting or millig a (possibly elliptical) spiral, a Dragon curve of arbitrary order, a Cocoon curve and a Lorenz attractor curve. They have output control for stepper motors. Treadmills (se my web page) and old digital typing machines can quite easily be converted to use as plotters with these computer programs. 2. PCI-DIO24 I/O card installation and setup ============================================ It is asumed that you have a desktop computer (PC) with Windows XP (or higher) with PCI slot and a PCI-DIO24 digital I/O card. 1. Install the software and driver for the I/O card that comes on CD/DVD with the board. 2. Turn of your computer and carefully put the PCI-DIO24 I/O card into a PCI slot. 3. Turn on the computer again and run the Instacal program under Start/Programs/Measurements to activate the I/O card at Port 0. 4. Run the I/O card test with the Instacal program. If it passes the test the I/O card is now ready for use. 3. Hardware setup and stepper motor drives signal connection ============================================================ The PCI-DIO24 I/O card has three 8-bit digital I/O-ports with +5V logic. Each pin can rise or sinc around 2 mA. If your stepper motor drives has opto coupler inputs +5V driver circuits must be used in between. I use six TC428CPA MOSFET drivers for this purpose. They are fast, works perfekt at 5V, and can deliver transient currents of several 100 mA. However many other good such drivers are available and they are cheap. The stepper motor drives are connected to Port A of the PCI-DIO24 card with the following pins at the 37-pin D-SUB connector. Pin 19: Signal ground. Pin 37: Stepper motor 1 clock/step. Pin 36: Stepper motor 1 dir cw/ccw. Pin 35: Stepper motor 1 enable (active high). Pin 34: Stepper motor 2 clock/step. Pin 33: Stepper motor 2 dir cw/ccw. Pin 32: Stepper motor 2 enable (active high). 4. Plotter or milling machine stepper motor aspect ratio calibration ==================================================================== This step is very important. The computer programs are run in a console window under Windows. Right click on the map with the programs and press shift at the same time. Then choose Command prompt at the pop up menu. First run the program zeroio.exe that sets all output pins of port A in the I/O card to zero. Otherwhise the signals to the stepper motor drives can fluctuate att high frequencies. Note, don't turn on the power to the stepper motor drives before you have run this program! Then run the small program tgb.exe that runs the stepper motors 100 steps at the time manuvred from the keyboard. Follow the short instructions in the program wich keys to use. If both stepper motors moves everything is ok. The C computer programs use a short file called "stepcfg2.txt" that contains information for setting upp aspect ratio for the machine and start directions for the stepper motors. If you know that your machine moves 1.0 mm for 200 steps of the stepper motors you can simply type these two lines in the file: 200 1.0 1 200 1.0 1 or 200 1.0 0 200 1.0 0 depending on your start direction of your stepper motors. Otherwise run the program tgb.exe again and run the stepper motors so the machine moves at least 50 mm in each direction. See with the programs how many stepper motor steps this is in each direction. Of course no milling tool should be used when this is done! It can be dangerous. If you have a plotter you can simply plot a line. If for example stepper motor 1 moves 75 mm for 2800 steps and stepper motor 2 moves 56 mm for 4000 steps type the following lines into the stepcfg2.txt file. As ussual the start direction can be either 0 or 1. 2800 75.0 1 4000 56.0 1 5. How to run the computer programs. ==================================== As ususual first run the program zeroio.exe that sets all output pins of port A in the I/O card to zero. Otherwhise the signals to the stepper motor drives can fluctuate att high frequencies. Note, don't turn on the power to the stepper motor drives before you have run this program! The computer programs have quite self explonatory input and output and do not start before you ask them to do so. The programs also suggests suitable values of some input parameters. You must do the stepper motor aspect ratio calibration (see section 4) before you run the programs. The delay of the stepper motor stepping is a loop that depends on the speed of the computer. Use a small curve and a high value of the stepper motor delay the first times you run the programs. It can be wise to have the delay >= 1000 delay units. It is a good idea to start first with the "plotspiral.exe" program that plots or milles a spiral going outwards from the center. The program "plotcocoon.exe" plots a cocoon curve. It also goes outwards from the center and then inwards again. It has very narrow between the lines and is better adapted for plotting, not milling. The "plotdragon.exe" program (that plots or mills a Dragon curve) is more difficult to adjust because it doesn't start in the middle of the curve or paper. Start with a small curve for example of order 5 and c=5.0 mm. A dragon curve of order 8 and c=0.75 mm is what most fits into a A4 or letter paper and is a very detailed curve. Especially for milling machines high curve orders can not be used. The "plotlorenz.exe" program plots or mills a Lorenz attractor curve. It does not start in the middle of the curve or paper. Due to the curves chaotic beviour and sharp bendings it is quite difficult for the steppermotor control to steer. By taking several integration steps between each straight line segment it works better. 6. How to compile the programs ============================== It is assumed that you have Microsoft Visual Studio Community 2015 (or later) with C and C++ on your computer. It can be downloaded for free if you register. You compile the program with the following line at the Tools/Visual Studio Command Prompt: >cl -O2 -o program.exe program.c cbw32.lib -lm 7. Links and references ======================= https://www.visualstudio.com A place to download Microsoft Visual Studio Community C/C++ compilier and programming environment. It must be registred for free. http:/www.jor.se A place to buy the PCI-DIO24 I/O card in Sweden. To be updated. ================================================================= End of document.