Click here to Skip to main content
15,885,546 members
Articles / Programming Languages / C++

Control Univelop CNC 4\5 Axis Board (user mode)

Rate me:
Please Sign up or sign in to vote.
4.93/5 (5 votes)
12 Jun 2009MIT1 min read 30K   1.9K   17  
A C++ class to control Univelop CNC 4\5 Axis controller board in usermode on Linux.

Introduction

Recently, I got my hands on a Univelop CNC 4\5 Axis controller board and wanted to write Linux user mode code to interface with the board. The board has the ability to control up to 5 steppers and 6 switches (4 axis limiters \ 1 Stop \ 1 Aux). The code also uses virtual positioning to allow the implementer to move the stepper to virtual positions, say -50 to +50. The class allows for per axis stepper pulse delays since the implementer may have different speed steppers for each axis. It may be necessary to increase the delay for slower steppers. A too fast delay leads to the stepper buzzing and not rotating. The switch state functions return true if the switch is closed, and false if open. The Univelop5Axis class functions are well commented, and the Univelop user manual is attached to the top of this page. The manual shows all the pin out information needed to understand the inner workings of the code.

The attached project was done with CodeBlocks, but will also compile from command line using GCC.

Using the Code

Below is a list of the core functions of the class. The following can be in your main function:

C++
#define BASEPORT 0x378

Univelop5Axis r( BASEPORT );

// To display the states of the 6 switch's which
// can be used as limiters, emergency stop, or aux
printf( "AuxState: %d\n" , r.IsSetAux() );
printf( "StopState: %d\n" ,r.IsSetStop() );
printf( "XlimState: %d\n" ,r.IsSetXLimit() );
printf( "YlimState: %d\n" ,r.IsSetYLimit() );
printf( "ZlimState: %d\n" ,r.IsSetZLimit() );
printf( "AlimState: %d\n" ,r.IsSetALimit() );

// Moving individual steppers Clockwise (CW) or Counter Clock Wise (CCW)
printf( "Testing stepper X movement\n");
r.StepX( 500 , Univelop5Axis::CW);
r.StepX( 500 , Univelop5Axis::CCW);
printf( "Testing stepper Y movement\n");
r.StepY( 500 , Univelop5Axis::CW);
r.StepY( 500 , Univelop5Axis::CCW);
printf( "Testing stepper Z movement\n");
r.StepZ( 500 , Univelop5Axis::CW);
r.StepZ( 500 , Univelop5Axis::CCW);
printf( "Testing stepper A movement\n");
r.StepA( 500 , Univelop5Axis::CW);
r.StepA( 500 , Univelop5Axis::CCW);
printf( "Testing stepper C movement\n");
r.StepC( 500 , Univelop5Axis::CW);
r.StepC( 500 , Univelop5Axis::CCW);
 
// To move directly to a virtual position
// you can use the following functions
// The each of the sets of three will step the motors 800 times.
// (0 to 200 = 200(CW) , 200 to -200 = 400(CCW) , -200 to 0 = 200(CW)) 
r.MoveXTo( 200 ); // +200
r.MoveXTo( -200 ); // -200
r.MoveXTo( 0 ); // Goto the origin

r.MoveYTo( 200 );
r.MoveYTo( -200 );
r.MoveYTo( 0 );

r.MoveZTo( 200 );
r.MoveZTo( -200 );
r.MoveZTo( 0 );

r.MoveATo( 200 );
r.MoveATo( -200 );
r.MoveATo( 0 );

r.MoveCTo( 200 );
r.MoveCTo( -200 );
r.MoveCTo( 0 );

Univelop Board Images

This is the main board which plugs into the parallel port:

UnivelopCNC/mainboard.jpg

This is the main board with Axis controllers attached:

UnivelopCNC/total.jpg

History

  • June 12th 2009 - Initial release.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Software Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --