Some curve stepper motor steering C-programs for plotters ========================================================= and milling machines with the Velleman K8055 I/O board ======================================================= Document version 1.02 First version: 2017-11-10 Latest update: 2018-02-06 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. Velleman K8055 USB I/O board 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. Velleman K8055 USB I/O board installation and setup ====================================================== The Velleman K8055 USB I/O board comes with an USB cable. Just plug i into your computer and it will find the driver (Windows 7 and 10). Important note! The Velleman K8055 USB I/O board is very slow compared to many other digital I/O boards of PCI type. K8055 only performs a few hundred I/O operations per second and is not useful for fast plotters or milling machines. Your stepper motors will run slow but it works. It is still instructive to use and is so easy to connect to a computer because of the USB port. Both desktop andnotebook computers can easily be used. 3. Hardware setup and stepper motor drives signal connection ============================================================ The Velleman K8055 I/O board has one 8-bit digital output port. 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. Important note! When an output LED is lit of th K8055 board it means that the output i low. The digital outputs are of open collector type and must have pull up resistors to +5 V. I use 330 Ohms resistors. The stepper motor drives are connected to the digital out port of the Velleman K8055 card according to the following: GND: Signal ground. DI 01: Stepper motor 1 clock/step. DI 02: Stepper motor 1 dir cw/ccw. DI 03: Stepper motor 1 enable (active high). DI 04: Stepper motor 2 clock/step. DI 05: Stepper motor 2 dir cw/ccw. DI 06: Stepper motor 2 enable (active high). 4. Plotter or milling machine stepper motor aspect ratio calibration ==================================================================== Very important! Because these C-programs are compiled with the old (but good) Borland BCC 5.5 C/C++ compiler the executables only work on computers with 32-bit Windows (7 or 10). 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 zeroio2.exe that sets all digital outputs of K8055 to zero. Note, don't turn on the power to the stepper motor drives before you have run this program! Then run the small program tgb2.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. ==================================== Very important! Because these C-programs are compiled with the old (but good) Borland BCC 5.1 C/C++ compiler the executables only work on computers with 32-bit Windows (7 or 10). As ususual first run the program zeroio2.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 stepper motor step delay is i ms (milli seconds). You can without problems set this delay to 0 ms becuse the Velleman K8055 I/O-board has so slow I/O operations. The stepper motors will not run so fast anyhow. It is a good idea to start first with the "plotspiral2.exe" program that plots or milles a spiral going outwards from the center. The program "plotcocoon2.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 "plotdragon2.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 "plotlorenz2.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 the Borland BCC 5.5 compiler mapp svaved under C:\ on your computer (with 32-bit Windows). You compile the program with the following line at a CMD (DOS) or PowerShell window. To open such a windows right click on the map with the programs and SHIFT simultaneously and choose the right type of window. >C:\BCC101\BIN bcc32c -O2 -o program.cpp K8055D.lib -lm 7. Links and references ======================= https://edn.embarcadero.com/article/20633 A place to download the very good 32-bit Bordland BCC C/C++ 5.5 compiler. I think you must register for free? https://www.velleman.eu/ Information and software for the Vellman K8055 I/O boards and many other kits. https://www.electrokit.com/ Electrokit. A place to buy the Vellman K8055 I/O board in Sweden. ================================================================= End of document.