Home
LMMS MN1278 User's Manual
Contents
1. Mint v4 PC Programming Guide The Mint Interface Library is a common API that allows access to Mint controllers It can be used via an ActiveX control or through C source code The Mint Interface Library is suitable for use under Windows 95 98 ME NT and 2000 The ActiveX control OCX can be used with a large number of languages This document concentrates on Microsoft Visual C Microsoft Visual Basic and Borland Delphi but the principle is the same in any language The C source code can also be used directly from Visual C Communication to NextMove PCI and NextMove PC occurs over Dual Port RAM on the card Communication to all other controllers takes place over a serial port using either RS232 or RS485 The are several example programs included on the Baldor Motion Toolkit as part of the PC Developer Libraries This chapter covers general methods of communication with Mint controllers The next chapter covers the specifics of using the Mint Interface Library 2 1 NextMove PCI NextMove PCI requires a device driver under all Windows operating systems See the NextMove PCI Installation Guide for details on installing the device drivers The version number of the device driver can be found using the following method Windows 95 98 ME Locate the file NMPCIL VXD in the WINDOWS SYSTEM directory using Windows Explorer Right click the file and select Properties The Version tab of the displayed dialog gives vers
2. MintControllerl setDriveEnable 0 wbEnabled FALSE end end NINT MN1278 05 2001 33 Mint v4 PC Programming Guide 6 This code should now run To add an error handler change the first parameter to setDriveEnable to 1 to create a run time error This will raise an EOleException error To trap this error modify the code as follows procedure TForml ButtonlClick Sender TObject var wbEnabled WordBool begin Trap errors try All errors will cause program Read the current state of the drive enable MintControllerl getDriveEnable 0 wbEnabled flow to jump to the except y L Write back the toggled value MintControllerl setDriveEnable 0 wbEnabled FALSE except This is called on any function in the try block failing On E Exception do MessageBox 0 pchar E Message Mint Interface Library Call failed 0 end end To prevent Delphi from halting program execution in the event of an exception the Stop on Delphi Exceptions check box must be cleared This is found in the Debugger Options from the Tools menu Dabiu plant Bare Language Deception cr Excepicra sc Ten la Mon ooo ar WILL d ripere Y bbarr Ld Dip nf Veika lanar E mapi CORBA 3 prep Eepo DORDA hee E kapir 34 PC Based Motion Control PC Based Motion Control This chapter covers creating motion applications on the host PC Mint MN1278 05 2
3. and the Mint v4 CAN Programming Manual section 3 Getting Started with CANopen On Mint v4 serial controllers Comms now uses binary packets to transfer data but in earlier Mint versions an ASCII based packet was used All Mint v4 controllers also support the older protocol Example In this example Comms is used to pass commands to a Mint program using two Comms locations Location is used to pass the command and location 2 is used to pass data The host code is written in C but the principles are applicable to any language Host Address of NextMove PC define nmADDRESS 0x33C Node number define NODEO 0 Mint v4 PC Programming Guide COMMS location uses define CONTROL_LOCATION 1 define PARAM 1 2 Flags for control location define COMPLETED 0 0 define SPECIAL ROUTINE1 1 0 Create a handle to the controller CNextMovePC myNextMove NODEO nmADDRESS Define variables float fErrorCode float fOutput 1 0 float fControl SPECIAL ROUTINE1 Write to comms location myNextMove setComms NODEO PARAM 1 amp fOutput Write to comms location myNextMove setComms NODEO CONTROL LOCATION amp fControl Handshake to Mint program to wait for completion of function do myNextMove getComms NODEO CONTROL LOCATION amp fControl while COMPLETED fControl Read the data returned myNextMove getComms NODEO PARAM 1 amp fErrorC
4. stdafx h to be included in the precompiled header Project Settinga y Pescuros Files E perde bt Figure 3 6 Project Settings step 4 Mint MN1278 05 2001 17 Mint v4 PC Programming Guide 5 Select Precompiled Headers in the Category drop list Change stdafx h to precomp h in the Use Precompiled header option Settings 5 3 Source Files E SIRA cpp E WC Tutors cpp 3 WCTutorial re IE CTutornalDlg cpa EM Hoeder Files Resource h MERA L IN CTutedath LST Y vCTuto aiDigh ij Resource Filas E pede a Figure 3 7 Project Settings step 5 18 MN1278 05 2001 Mint Using the Library with Various Languages 6 Select Preprocessor from the Category drop list Add dot comma followed by the path to the Mint Interface Library header files in the Additional include directories field Press OK to close the dialog Project Settings 5 3 Source Files E precomp cpa Ey CTutoral cpp Ey WCTutorialre 32 WHDCAWS_AFSDLL MBCS HC B5TDAFS H E CTutornsiDlgcpa r PH Hoeder Files I Pesoureh A MER IN vCTutoralh WCTuteralDl6 h EAminfhost E Piss ounce Filas a a peded E Figure 3 8 Project Settings step 6 7 Inthe FileView pane delete stdafx cpp Right click on VCTutorialFiles and select Add Files To Project Add precomp cpp which should be in the c mint host directory Mint
5. Once the ActiveX Control has been included in the project the event handlers are accessed as ActiveX events The functions listed below are used to tell the controller that a handler exists on the host PC and events of this type should be generated installAxisIdleEventHandler installCANlEventHandler installCAN2EventHandler installCommsEventHandler installDPREventHandler M CA AL TL MN1278 05 2001 43 Mint v4 PC Programming Guide installErrorEventHandler installFastInEventHandler installInputEventHandler installMoveBufferLowEventHandler installSerialReceiveEventHandler installStopSwitchEventHandler installResetEventHandler installTimerEventHandler installUnknownEventHandler The passed parameter is a BOOLEAN parameter e TRUE indicates that a handler exists on the host PC e FALSE indicates that a handler does not exist on the host PC VisualBasic Example Create a MintController object called nmPCP in the Form_Load function add nmPCI setNextMovePCIlLink 0 O nmPCI installTimerEventHandler TRUE nmPCI setTimerEvent 1000 Double click on the MintController object and select the TimerEventHandler function add the code Dim b As Boolean nmPCI getRelay 0 b If b Then nmPCI setRelay 0 0 Else nmPCI setRelay 0 1 End If When the timer event is generated on the controller this will interrupt the host PC and create a timer event This is trapped by the ActiveX control and executes the code in the timer e
6. btLOCK_AXIS_7 9 LockIO data LOCK IOPC _____ 11515 Reet AAA DPR Status Register 0 T DPR Contents locked if 1 btLOCKED DPR contents invalid if 0 btVALID 2 15 Reserved EE Axis Mix This specifies the number and types of axes available on the NextMove variant Lo Byte Number of stepper axes Hi Byte Number of servo axes Digital 1 O Mix This specifies the number of digital inputs and outputs available on the NextMove variant Lo Byte Number of digital outputs Hi Byte Number of digital inputs Analog I O Mix This specifies the number of analog inputs and outputs available on the NextMove variant Lo Byte Number of analogue outputs Hi Byte Number of analogue inputs Mint MN1278 05 2001 57 Mint v4 PC Programming Guide MML Build ID The build identifier of the Mint Motion Library running on NextMove Each version of the Mint Interface Library can only communicate with one version of Mint To make sure the versions match each version of Mint has a build number embedded in it To return the build number call getAAABuild Timer Tick This is a free running 16bit counter that is updated by NextMove once every 2ms and can be used to synchronize data with the DPR Mint Line Number This is the currently executing Mint program line By reading this location it is possible to trace program execution without affecting program flow unlike Mints built in program tracer The Mint status flag
7. DPR Events Events can be manually generated in both directions using the function doDPRE vent and the DPREvent handler If the host PC calls doDPRE vent this will generate an interrupt to the controller that will call the DPREvent handler on the controller If the controller calls the function doDPREvent this will generate an interrupt to the host PC that will call the DPREvent handler on the host PC The function doDPREvent accepts an 8 bit code which is passed to the event handler Example The below code sample will install a DPREvent handler on the host when a DPREvent is received the code is printed prototypes void myDPREventHandler void p _ int16 nCode main program void main void 1 Create an instance of the CNextMovePCI class CNextMovePCI1 myPCI 0 0 install timer event handler myPCI installDPREventHandler myDPREventHandler DPREvent handler void myDPREventHandler void p _ int16 nCode cout lt lt DPR Event lt lt nCode lt lt endl When this application is running on the host PC calling DPREVENT from either Mint or an embedded application will generate an interrupt to the PC calling the DPREvent handler 4 2 4 Handling Events Using the ActiveX Control As the ActiveX control supports all events hence any application that can use the ActiveX control can trap and handle events from the controller This allows event handling using Visual Basic and Delphi
8. The 1ms Timer Tick is an incrementing counter that indicates that NextMove is running The counter is 32 bit The counter increments by 1 every lms 6 4 Axis Data The axis data area is divided into 12sections four for the main board axes and four for the expansion board axes The base address for each axis is listed below Address Symbolic Constant Axis 0 roAXIS_0 Axis 1 roAXIS_1 Axis 2 roAXIS_2 Axis 3 roAXIS_3 Axis 4 roAXIS_4 Axis 5 roAXIS_5 Axis 6 roAXIS_6 Axis 7 roAXIS_7 Axis 8 roAXIS_8 Axis 9 roAXIS_9 Axis 10 roAXIS_10 Axis 11 roAXIS_11 59 Mint v4 PC Programming Guide Offset Use Symbolic Constant Data Size 0x00 Measured Position roPOSITION float LEN A ES SEE 0x06 i Mode of motion rMODE_OF_MOTION int 32 0x07 Reserved 0x08 Axis error T roMOTION_ERROR T int 32 0x09 float OE Reserved i i Reserved O TT Reserved A Ss ee int 16 int 16 int 16 oat Reserved o x x10 11 13 o e o X olojo A KH RM R l l lt l l ol el Gl as o o D oo oo oo 2 a j G ti sE The layout of the section is compatible to the current layout on NextMove PC The locations used on NextMove PC for the upper 16 bits of data are unused All data is written every 2ms by NextMove except those marked These locations are only written when they change 60 MN1278 05 2001 Mint 6 5 I O Data The UO data ar
9. 744 2572 Telephone 1501 646 4711 Fax 65 747 1708 Fax 1 501 648 5792 email sales baldor com web site www baldor com Mint MN1278 05 2001 iii Mint v4 PC Programming Guide Manual Revision History Manual Revision History BOCL Comments Reference M00545 000 Raised from MN00249 003 This is a new UM for v4 allowing updates to the v3 manual to continue as MN00249 X YZ M00545 001 Added NextMove PC device driver documentation Corrected for Mint v4 new C files Win2000 WinME May 2001 M00545 002 Updates for PC Developer Libraries 1302 release Mint v4 PC Programming Guide vi Contents Introduction a da eat 1 1 1 INtOdUCION 0 A ete ook aceon 2 1 2 A aae a alate ec cttadssacacecet abe era Ea ade aeea aaia laid 2 Communicating with a Controller ooocononononononoconanenenonononos 3 2 1 NexiMove PG litis EE EA 4 2 2 NexIMove P Cia a ta 4 2 3 Dual Port RAM on NextMove PCI and PC sees eee 4 2 4 Mint Comms Array All Controlersi sese eee 5 2 5 Interfacing with MINT cise rita 7 2 5 1 Preventing Deadlock SituatiONS ooooocccnnnnnnonococoncccnnnononcncnnonnnnanancn canon 7 Using the Library with Various Languages sssssssesessssssssss seves 9 3 1 CREARA od ES 10 31 1 E AS EA iinitt rele ate eee 10 3 1 2 Pre Compiled Headers in Visual C 6 0 sees 11 3 1 3 A Visual C 6 0 Tutorial see 14 3 1 4 Compiling an ATL COM Project with Visual C eee eee 24 3 1
10. Functions There are various functions that can be used to control events generation These are detailed below The user can read which events are currently active using the function getEventActive Any currently pending events can be cleared selectively using the function setEventPending This accepts the same bit pattern as above clearing a set bit will clear the pending flag for that event Hence passing a value of zero will clear all pending interrupts Once a handler has been installed the event generation can be disabled by using the function setEventDisable This function accepts a bit pattern as above Setting a bit will disable the generation of that type of event Hence setting this to zero will enable all events which have a handler installed The function getEventDisable Will return a bit pattern of any currently disabled interrupts By default all digital inputs will generate events when they become active These digital inputs can be masked so that they do not generate events using the function set IMask This function accepts a bit pattern which represents all digital inputs it the bit is set then the digital input will generate an event when the input becomes active Then function get IMask Will return a bit pattern representing those digital inputs which will generate an event when they become active 42 MN1278 05 2001 Mint PC Based Motion Control 4 2 3 Interrupting the Host from a Mint Program
11. If multiple events occur within a 2ms tick then the above priority system will be used to decide which event to generate A higher priority event will interrupt a lower priority event Each event is processed within a separate thread by the host PC application If more than one event is active on the host PC they will execute concurrently In order for an event to be generated the the appropriate event handler must be installed The event handlers are installed with the following functions in C Axis Idle The install function for axis idle events it accepts a pointer to a function if this is a NULL pointer the handler is uninstalled typedef void TAxisIdleEventHandler void pController __int16 nAxisBitPattern __int16 installAxisIdleEventHandler TAxisIdleEventHandler pHandler CAN1 The install function for CAN events on bus 1 it accepts a pointer to a function if this is a NULL pointer the handler is uninstalled typedef void TCANEventHandler void pController __int16 installCANlEventHandler TCANEventHandler pHandler CAN2 The install function for CAN events on bus 2 it accepts a pointer to a function if this is a NULL pointer the handler is uninstalled typedef void TCANEventHandler void pController __int16 installCAN2EventHandler TCANEventHandler pHandler Comms The install function for Comms events it accepts a pointer to a function if this is a NULL pointer the handler is uninstalled typedef void TCo
12. Long integers 32 bit signed integers e Short integers 16 bit signed integers e Floats 32 bit floating point e BSTRs Visual Basic Style strings e Pointers to all the above types Some languages do not support all of these data types e g WonderWare InTouch does not support short integers or pointers For these languages a wrapper COM server may have to be written to convert to types used by the language Documentation should be provided with each language on how to perform this 24 MN1278 05 2001 Mint Using the Library with Various Languages 3 2 2 The ActiveX Control and Error Handling The ActiveX control produces COM ActiveX errors exceptions if any function fails These will be trapped by whatever exception handling method is implemented in that language error handling in Visual Basic is described in more detail in 3 3 1 The meaning of the error code can be found as follows e Mask off the top 16 bits or 17 in VB as the actual error code is only contained in the lower 16 bits e Ifthe number is 200 hex 512 or greater it is a Mint Interface Library error e If the number is less than 200 hex 512 it is a standard COM error created by the framework not the Mint Interface Library 3 2 3 The ActiveX Control and Serial Controllers One instance of part of the ActiveX control will be shared by all applications that use it This means that more than one application can access the same serial controlle
13. MN1278 05 2001 19 Mint v4 PC Programming Guide 8 Right click on precomp cpp in FileView and select Settings Select All Configurations in the Settings For drop list Select Precompiled headers in the category drop list on the C C tab Click the Create Precompiled Header radio button and enter precomp h in the text field Project Settings EH Hoeder Fies y Resoureh Sigeh H Y WCTutoralh WCTuteralDI6 h EB Pee ource Files m Bede bi Hram hender Figure 3 9 Project Settings step 8 9 Edit VCTutorial cpp and VCTutorialDlg cpp In both files replace include stdafx h with include precomp h Check the project builds 20 MN1278 05 2001 Mint Using the Library with Various Languages 10 Select ClassView Right click on CVCTutorialDlg and select Add Member Function Copy the dialog below Rill Menber Function IM E moi TR Enor lineg C Bubice pede C Piete T Static T mel Figure 3 10 Class View dialog step 10 Hit OK to edit the new function The MILError function will check the return code from all Mint Interface Library functions Edit the function as follows __int16 CVCTutorialDlg MILError __int16 nError if erSUCCESS nError TCHAR szError szMAX ERROR getErrorString szError nError MessageBox szError return nError 11 At this poin
14. TMoveBufferLowEventHandler void pController __int16 nAxisBitPattern __int16 installMoveBufferLowEventHandler TMoveBufferLowEventHandler pHandler Reset The install function for reset events it accepts a pointer to a function if this is a NULL pointer the handler is uninstalled typedef void TResetEventHandler void pController __int16 nCode __int16 installResetEventHandler TResetEventHandler pHandler Serial Recieve The install function for serial receive events it accepts a pointer to a function if this is a NULL pointer the handler is uninstalled typedef void TSerialReceiveEventHandler void pController __int16 installSerialReceiveEventHandler TSerialReceiveEventHandler pHandler 40 MN1278 05 2001 Mi LIL PC Based Motion Control Stop Switch The install function for stop switch events it accepts a pointer to a function if this is a NULL pointer the handler is uninstalled typedef void TStopSwitchEventHandler void pController __int16 installStopSwitchEventHandler TStopSwitchEventHandler pHandler Timer The install function for timer events it accepts a pointer to a function if this is a NULL pointer the handler is uninstalled The parameter passed to the event handler is always zero typedef void TTimerEventHandler void pController __int16 nTimerEvent __int16 installTimerEventHandler TTimerEventHandler pHandler Unknown The install function for unknown events it accepts a pointer to a functi
15. constant of of SERIAL_IO_BASE Mint MN1278 05 2001 63 Mint v4 PC Programming Guide 6 9 Special Functions Registers Address Symbolic Constant ICM Handshaking Data associated with events Ox3FA Data associated with events Application Code Register Functionality Code Register Scratchpad Register roSCRATCH_PAD The way in which dual port RAM is used may vary from application to application All applications should use the registers detailed in this document in the same way This will allow host resident code to determine whether it recognizes the application and the protocol used for communication There is no hardware restriction upon those locations that may be read or written from either side Both NextMove and the host have full read and write access to all locations Application Code Register 3FB This register identifies the software running on NextMove The host may use this to determine how to communicate with the software or better interpret the bits within the Functionality Code Register Each application program should have a unique identifier Of the 65536 possible codes the first half are reserved Codes 32768 to 65535 may be used to identify user programs Application programs should prime this register after all other initialization It is recommended that the host does not write to this location Description Of Program Symbolic Constant Unidentified program or no program running Loader running
16. erBBP_POLL_TIMEOUT erBBP_POLL_NO_DATA erBBP_RX_TIMEOUT erBBP_UNSUPPORTED_TRANS erBBP_INVALID_DATA_LENGTH erBBP_VALUE_OUT_OF_RANGE erBBP_VALUE_OUT_OF_BOUNDS erBBP_CONTROL_FAULT_COND erBBP_STATUS_MODE_REJECT erBBP_BLOCK_REJECTED erBBP_END_OF_BLOCK erIN_BBP_ROUTINE erAUTOTUNE_FAILED erNO_CAPTURED_DATA erSQ_INVALID_OUTPUT_FILE erSQ_INVALID_INPUT_FILE erSQ_TOO_MANY_VARIABLES erSQ_BASIC_TABLE_NOT_FOUND erSQ_MOTION_TABLE_NOT_FOUND erSQ_CONSTANT_TABLE_NOT_FOUND erSQ_INPUT_FILE_READ_ERROR erSQ_OUTPUT_FILE_WRITE_ERROR Error in ICM protocol Timeout on ICM Device driver mismatch No response from controller BBP protocol error No response to poll BBP protocol error No data ready for polling BBP protocol error Receive data timeout Invalid or unsupported transaction number Invalid data field length for transaction Data value out of range for transaction rejected Data value out of bound for transaction modified by controller Controller fault condition prevented execution Controller status mode prevented execution Block transfer value not accepted End of block reached A BBP access is blocking use of the resource Autotune function failed No captured data is available to upload Squash Could not create output file Squash Could not open file to be squashed Squash Too many variables in the program Squash Could not find the file basic XYZ Squash Could not f
17. in section 5 2 This may take the form of as in the MySimplePCI example instructing the device driver to perform the task The read should be a simple 32 bit read from the memory address the PLX chip has been mapped into Block 1 PLXWrite This function must write to the PLX chip Block 3 in section 5 2 This may take the form of as in the MySimplePCI example instructing the device driver to perform the task The write should be a simple 32 bit write to the memory address the PLX chip has been mapped into Block 1 5 3 3 Files to Include in a CSimplePCI Derived Class Project The following Mint Interface Library files must be included in the project e base cpp e mml cpp e nmbase cpp simplepci cpp Mint MN1278 05 2001 49 Mint v4 PC Programming Guide The following files may also be added e host _def cpp if the function getErrorString is being used e precomp cpp if this file is being used to construct the precompiled header 50 MN1278 05 2001 Mint Appendix 1 DPR Map Appendix 1 DPR Map Each area of the address map is described below Where an address is shown that is the DPR location Where an address offset is shown that offset is added to the base address Floating point numbers will conform to C31 format It is up to the PC interface to convert to IEEE format before passing the data to the PC application Likewise IEEE floating point numbers must be converted to C31 format before writing to the DPR
18. kkk kk kk kkk kk Toggle the state of the enable T Ae ke ke He e ke ke He ke e ke ke ke ke ke ke ke ke ke ke ke ke ke k k k k k k k k k k k k k k k kk k kk kk myController setDriveEnable 0 bState False End Sub 8 This code should now work At this stage an error handler will be added Change the getDriveEnable code to access an axis that does not exist E g myController getDriveEnable 1 bState This should create the following error when run INT MN1278 05 2001 29 Mint v4 PC Programming Guide Microsoft Visual Basic Runtime error 2147220980 S00 AXR spec filed out of range pie End Debug Hei Figure 3 13 Example Dialog Box 9 Add the following code to trap this or any other error Private Sub Command1_Click Dim bState As Boolean On Error GoTo commandl_error T e ke k ke ke ke ke ke ke ke ke ke ke ke k ke ke k k k k k k k k k k k k k k kk kkk kk kk kkk kk Read the state of the drive enable for axis 0 TAREA AAA RARA RARA AAA AAA KK AAA KA AAA AAA AAA myController getDriveEnable 1 bState VA ke ke ke ke ke ke ke ke ke ke ke ke ke k ke ke k k k ke k k k k k k k k k k k k k k k kk kk kkk kk Toggle the state of the enable Ikkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk myController setDriveEnable 0 bState False Exit Sub commandl_error Ikkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk Display the error and leave subroutine Ikkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
19. the command line Try MintBreak and then call the function again This function cannot be used under Windows NT NextMove did not respond The function was unable to create a required temporary file Check disk space Bad coding contact supplier Interface already in use by the comms protocol Interface already in use by a file download Interface already in use by a file upload Interface already in use a a Mint328 routine Serial port not opened Corruption occured Specified port not available Could not enable WM_NOTIFY The checksum failed The controller sent NAK Port could not be opened Card number out of range Axis out of range Invalid controller enumeration Comms address out of range Port already in use The user aborted the command 70 Appendix 3 Symbolic Constants erCONTROLLER_REPORTS_ERROR erUPDATING erRECEIVE_BUFFER_EMPTY erTRANSMIT_BUFFER_FULL erINVALID_RETRIES erBAD_SQUASH_FILE erUNDEFINED_SERIAL_ERROR erPSERIAL_BUFFER_CORRUPTION erFUNCTION_NOT_SUPPORTED erCANNOT_OPEN_FILE erINVALID_FORMAT erDATA_TOO_LONG erINCORRECT_ARRAY_SIZE erUNKNOWN_ERROR_CODE erCONTROLLER_NOT_RUNNING erMML_VERSION_MISMATCH erNO_DEVICE_DRIVER_SUPPORT erBAD_COM_PORT_NUMBER erBAD_BAUD_RATE erIN_GETCHARTIMEOUT erIN_PUTCHARTIMEOUT erIN_GETSTRINGTIMEOUT erIN_PUTSTRINGTIMEOUT erCAPTURING erLINE_TOO_LONG erINVALID_PLATFORM erNO_INTERRUPT_REGISTERED erINVALID_IRQ erBAD_INPUT_BUFFER erBAD_OUTPUT_BUFFER erBAD_D
20. 001 35 Mint v4 PC Programming Guide The Mint Interface Library provides all of the functionality that is available in the Mint programming language Motion applications can be written on the host PC by calling functions from the Mint Interface Library When a function is called the Mint Interface Library communicates with the controller and calls the specified function directly on the controller The Mint functionality is still being performed by the controller but it has been initiated directly by a host application The real time elements of Mint are still run on the controller but the sequencing can be controlled by the host application The following diagram shows the architecture known as Immediate Command Mode Controller ES mu TED Servo Loop Figure 4 1 Immediate Command Mode Interface Immediate Command Mode ICM is the method that allows Mint motion functions to be called from a host application bypassing Mint Calling functions from the host is particularly useful if there is a large amount of processing to do i e calculation of multi axis paths as the host can do the processing and send the commands to the controller Note that these functions can be used in conjunction with a Mint program For example a Mint program handles the I O and the host calculates the path and sends it to the controller using setVectorA The Immediate Command Mode interface can also be used for testing applications to be compiled
21. 5 Click on the Mint icon in the toolbox and draw a square on the form This will create a MintController ActiveX control which will be used to communicate with the controller Click on the control on the form And change the name from MintController1 to myController 28 MN1278 05 2001 Mint Using the Library with Various Languages 6 Inthe Form_Load module we will tell the COM server which type of controller we want to communicate with These means the code will depend on the controller you have The Consts should be editted to match your system MintDrive Private Sub Form_Load Const NodeNumber 10 Const CommPort 1 Const Baudrate 57600 myController setMintDriveLink NodeNumber CommPort Baudrate True End Sub NextMove PC Private Sub Form_Load Const NodeNumber 0 Const Address amp H23C myController setNextMovePCLink NodeNumber Address End Sub NextMove PCI Private Sub Form_Load Const NodeNumber 0 Const CardNumber 0 myController setNextMovePCI1Link NodeNumber CardNumber End Sub 7 Add a command button and place the following code behind it Private Sub Command1_Click Dim bState As Boolean VA ke ke ke ke k ke ke ke k k k k k k k k k k k k k k k k k k k kk k kk kkk kk kk kkk kk Read the state of the drive enable for axis 0 Ikkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkx k myController getDriveEnable 0 bState VA k k k k k k k k k k k k k k k k k k k k k k kk k kk kk kkk
22. 5 RS485 Networks ea r r ra aa tad rera te eae ea e ARAE ananake ARRE SEAE 24 3 2 All Other Languages The ActiveX Control OCX T eee 24 3 2 1 The ActiveX Control And The Languages It Can Be Used With 24 3 2 2 The ActiveX Control and Error Handling sees eee 25 3 2 3 The ActiveX Control and Serial Controllers sese 25 3 2 4 The ActiveX Control and RS485 Networks sese eee eee 25 3 2 5 Distributing an Executable Which Uses The ActiveX Control 25 3 2 6 Server Busy Component Request Pending Errors sss ee eee 25 3 3 Visual BASIC 6 TTT 27 3 3 1 Error number Conversion esse eee eee 27 M mx MN1278 05 2001 vii Mint v4 PC Programming Guide 3 3 2 A Visual Basic Tutorial see 27 3 4 Borland Delphi SO citrico maaa aa ARS alii lalala 31 PC Based Motion Control sss sss ss sss ss esse esse essen esen nenes 35 4 1 Limitations of PC based applications eee eee eee 37 4 2 Events and Interrupt Control on NextMove PBC sees ee eee eee 38 4 2 1 Writing and Installing an Interrupt Handler esse eee 38 4 2 2 Event Control Functions sss ee eee eee 42 4 2 3 Interrupting the Host from a Mint Program DPR Events 43 4 2 4 Handling Events Using the ActiveX Control sees eee 43 NextMove PCI and Non Microsoft Operating Systems 45 5 1 How to Recognise the NextMove BPCL eee eee 46 5 2 Host Accessible Hardware on NextMove PCL eee eee eee 46 5 3 The CSimplePCl Class
23. All library functions do this automatically e The update time on NextMove is 2ms e Where units are shown the key is as follows uu user units uu s user units second au analogue units See ADCMode keyword for explanation of ranges percentage cts encoder counts e All addresses and address offsets are in hex 6 1 NextMove PCI DPR Map Dual Port RAM on NextMove PCI has 4K of 32 bit data The DPR map is similar to NextMove PC but certain areas are designated as read only This means that if the user tries to write to these locations the data may be corrupted The Dual Port RAM on NextMove PCI is 32 bit rather than the 16 bit wide DPR on NextMove PC hence 32 bit values on will use two 16 bit DPR locations In order for the memory map of DPR to be consistent between the two controllers where 32 bit values are stored NextMove PCI will have a redundant location OxFFF Interrupt Host Interrupt NextMove OxFF Control Registers Reserved OxFEO OxFEO OxFDF OxF i 1K User Area OxBEO 0xBE OxBDF Reserved for future use Mint MN1278 05 2001 51 Mint v4 PC Programming Guide Read Only 0x43F 0x420 Axis Data Reserved Scratchpad Unused Functionality Code x3FA x3F9 Interrupt Data 0x3F9 ICM handshake Reserved Old user area Comms 99 locations Serial Transmit Buffer Serial Receive Buffer 14F Immediate Command Mode A
24. EVICE_DRIVER_CALL erSEMAPHORE_TIMEOUT erINVALID_EVENT erFUNCTION_NOT_AVAILABLE erBOOT_TEST_FAIL erBUFFER_TOO_SMALL erREQUIRES_DEV_DRIVER erICM_TX_TIMEOUT erICM_RX_TIMEOUT MN1278 05 2001 The controller detected an error Interface already in use by a firmware update The receive buffer is empty The transmit buffer is full The retries parameter failed Bad squash file parameter The serial error is unknown The pseudo serial buffers are corrupt Not supported on this platform File bad or doesn t exist file not proper COFF format Too much data in one chunk Atray size or pointer incorrect The error code was not known The controller is not running mgBUILD incorrect Device driver not set up Serial port not supported Baud rate not supported Interface already in use Interface already in use Interface already in use Interface already in use Interface already in use Mint line too long Invalid firmware for the controller No interrupt registered for this controller Invalid Interrupt Input buffer wrong size Output buffer wrong size The device driver call failed A semaphore was not available Could not register the event Function not currently available Power up self test failed Not enough memory to load prog Requires development build of device driver Timeout on ICM Timeout on ICM 71 Mint v4 PC Programming Guide erICM_RX_SIZE_ERROR erICM_PROCESS_TIMEOUT erDEV_DRV_UNKNOWN_IOCTL erBBP_ACK_TIMEOUT
25. Immediate Command Mode supported Mint for NextMove suported Mint for NextMove suported Custom Version Mint Motion Library Embedded Reserved NextMove test program running apNONE apLOADER apFRONT apNM_TEST apNM_MINT apFRONT_MINT apRPD_MINT apMML 64 Appendix 1 DPR Map Functionality Code Register 3FC This register describes the capabilities of the software running on NextMove The register may be used by a host to determine how it should communicate with the software what data is stored in dual port RAM etc The register contains a series of bits each of which indicate whether a specific feature is supported The table below describes the current list of standard application capabilities It is expected that this list will grow over time Application programs should set the relevant bits in this register after all other initialization It is recommended that the host does not write to this location Bit Description Of Feature Symbolic Constant Loader communication fc LOADER_COMMS protocol Motion Generator auto update feAUTO_UPDATE of locations 0 to 12F FRONT OUT communication feFRONT_COMMS protocol Pseudo Serial Port Buffer fcSERIAL_PORT Mint interpretation of serial feCOMMS_ON buffer communications Comms Protocol Mint running fcMINT_RUNNING Reserved ee ee Scratchpad Register 3FD This register is a general purpose register used only by the host It is only written to by th
26. Mint version 4 PC Programming Guide MN1278 Issue 1 2 Mirt MN1278 05 2001 ome INT Mint v4 PC Programming Guide Copyright BALDOR MOTORS AND DRIVES Copyright Baldor UK Ltd 2001 All rights reserved This manual is copyrighted and all rights are reserved This document or attached software may not in whole or in part be copied or reproduced in any form without the prior written consent of Baldor UK Baldor UK makes no representations or warranties with respect to the contents hereof and specifically disclaims any implied warranties of fitness for any particular purpose The information in this document is subject to change without notice Baldor UK assumes no responsibility for any errors that may appear in this document MINT is a registered trademark of Baldor UK Ltd Windows 95 Windows 98 and Windows NT are registered trademarks of the Microsoft Corporation Baldor UK Ltd Baldor ASR GmbH Mint Motion Centre Telephone 49 0 89 90508 0 6 Bristol Distribution Park Fax 49 0 89 90508 492 Hawkley Drive Bristol Baldor ASR AG BS32 OBF Telephone 41 0 52 647 4700 U K Fax 41 0 52 659 2394 Telephone 44 0 1454 850 000 Fax 44 0 1454 859 001 Australian Baldor Pty Ltd Web site www baldor co uk Telephone 61 2 9674 5455 Sales email sales Obaldor co uk Fax 61 2 9674 2495 Support email technical support baldor co uk Baldor Electric F E Pte Ltd Baldor Electric Company Telephone 65
27. ODE CARDNUMBER NextMove BX define NODE 1 define COMMPORT 2 define BAUDRATE 9600 m_pController dynamic_cast lt CController gt new CNextMoveBX NODE COMMPORT BAUDRATE TRUE 22 Using the Library with Various Languages 14 The code should now compile but not link The following files should be added to the project to make it link MintDrive amp NextMove BX base cpp baldorserial cpp host_def cpp if you have not already added it logfile cpp mme cpp mml cpp serial cpp synchronisation cpp uncompress cpp NextMove PC Base cpp Host_def cpp if you have not already added it logfile cpp mml cpp nextmove cpp nm_nt cpp nm_win32 cpp nmbase cpp nmstd cpp synchronisation cpp uncompress cpp NextMove PCI Base cpp Host_def cpp if you have not already added it logfile cpp mml cpp nm_pcil cpp nm_win32 cpp nmbase cpp synchronisation cpp uncompress cpp 15 Add a button to the dialog in the dialog editor Double click the button to edit the OnButton routine and add this code void CvCTutorialDlg OnButton1 BOOL b Display a busy cursor CWaitCursor cur Read the state of the axis 0 enable if erSUCCESS MILErr
28. a Reserved Old user area Serial Transmit Buffer Immediate Command Mode gt 54 Appendix 1 DPR Map Address Use Read Only Axis 5 Data Axis 4 Data I Axis 3 Data Axis 2 Data Axis 1 Data Mi Mi NE i Axis Data Axis 0 Data 0x010 0x010 D 0x00 1ms Timer Tick 0x00 0x00C Axis Configurations 4 7 Axis Configurations 0 3 MINT Error Line 0x009 MINT Error 0x008 MINT Status 2ms Timer Tick 0x005 BuildID a 0x004 Analog I O Mix O Z o Status Control Registers Axis Mix 0x001 DER Status Register 0x000 DPRControlRegister o do o O MN1278 05 2001 55 Mint v4 PC Programming Guide 6 3 Status and Control Registers Address Symbolic Constant Read Only 0x000 DPR Control Register roCONTROL 0x001 DPR Status Register roSTATUS 0x002 Axis Mix roAXIS_MIX Digital I O Mix Analog Axis Configurations PCI 8 11 PC 4 7 0x00D 1ms Timer Tick rol MS_TIMER Ox00F Reserved n a DPR Control Register NextMove PCI 0 Lock DPReontents ROCK 6 Lockaxis5DPR contents ___ btLOCK AXIS 5 ______ 8 Lockaxis7DPR contents ____ btLOCK AXIS 7 _____ 9 Lack axis 8 DPR contents ___ btLOCK AXIS 8 RR el 19 31 Reserved 56 Appendix 1 DPR Map DPR Control Register NextMove PC 0 T Lock DPR contents T ROCK 6 Lock axis 5 DPR contents ROCK ARR 5 8 Lockaxis7DPR contents
29. also referred to as the PLX chip It controls the hardware reset and interrupt lines 128 bytes IO This is also the PCI controller chip but mapped into IO space not 32 bytes This is currently unused Of these the two memory mapped areas blocks 1 and 3 will be used Blocks 2 and 4 are can be ignored The memory mapped addresses of blocks 1 and 3 should be read from the computers PCI controller The memory address of Block 1 must be stored for the functions PLXRead and PLXWrite and the address Block 3 is mapped into must be stored for use with the functions getLong and setLongInternal 5 3 The CSimplePCI class The CSimplePCI class splits the hardware access functions from the rest of the Mint Interface Library To use the class inherit from the CSimplePCI class and supply the virtual functions required listed below The easiest way to do this is to modify the CMySimplePCI example 46 MN1278 05 2001 Mint NextMove PCI and Non Micorsoft Operating Systems 5 3 1 The CMySimplePCI Example The CMySimplePCI example overloads CSimplePCI to create a class which can be used to communicate with NextMove PCI under Windows 9X and Windows NT using the CSimplePCI interface Itis laid out in such a way that the Windows specific code can easily be replaced with code specific to another operating system 5 3 2 Functions Required by the Overloaded Class The CMySimplePCI class declaration is as follows It shows all the function
30. ate an instance of the object and call any of the functions described later in the manual For example to download nmpci out to a NextMove PCI a CNextMovePCI1 object can be created Hint All controllers referenced in the Mint v4 PC Programming Guide are derived from the CController class defined in BASE H All functions are virtual so it is safe to pass pointers to objects as CController if the class type to be created is not known at compile time The following files should be included in your C project ite Creer Dase AA O baldorserial cpp host_defcpp aaam logfile cpp_ A mme cpp MintDrive NextMove BX ServoNode 51 All mml cpp NextMove PC nextmove c nm_nt cpp nm_peil cpp Neaye POD O K O a nm_win32 NextMove PC amp PCI Using the Library with Various Languages Controller nmbase cpp MOP i cvcssmnnsnnanninnninnnnsnn _NextMove PC prec omp Cpp serial cpp All Serial syncronisation cpp T uncompress cpp 3 1 2 Pre Compiled Headers in Visual C 6 0 In order to speed up compilation of C projects using C the Mint Interface Library files precomp cpp and precomp h can be used This has been found to reduce build times by up to 85 so although not required are worth using To use precompiled headers include precomp h at the top of each source file Then include precomp cpp in the project and set it to create the pre compiled header file The following sections go into mor
31. by a C31 compiler and run on NextMove This is described in Mint v4 Embedded Programming Guide There is a one to one correlation between Mint commands and Mint Interface Library Functions For example within a Mint program the MOVER keyword is used to create a relative positional move on an axis MOVER O 10 The Mint Interface Library function for this is setMoveR setMoveR 0 10 The keyword has been prefixed with set Almost all Mint keywords are available in the Mint Interface Library The will be prefixed with set for writes get for reads and do for commands 36 MN1278 05 2001 Mint PC Based Motion Control Functions called from the host fall into two categories Those functions that replicate Mint keywords are known as Mint Motion Library calls MML and those functions which are general communications functions are known as Mint Interface Library calls MIL Example The following code is a Visual Basic extract showing a host application set up a move on a NextMove BX The TMintController object has been added to the form and named myController Set up some data Dim axis0 1 As Integer Dim isIdle As Boolean axis0 0 Create handle to NextMove node comm port baud rate open myController setNextMoveBXLink 2 1 19200 1 Set move parameters on axis 0 myController setSpeed 0 40 myController setAccel 0 400 myController setDecel 0 400 myController doReset 0 Load the move and start it myContro
32. ccccccccceeeeeeceeneceeeeeeeeeeeeeaeeeeeeseeeseaeeeeeeeeetees 46 5 3 1 The CMySimplePCl Example eee eee 47 5 3 2 Functions Required by the Overloaded Class sse 47 5 3 3 Files to Include in a CSimplePCl Derived Class Project 49 Appendix 1 DPR Mapisicini ba 51 6 1 NextMove PCI DPR Map sss sees eee eee 51 6 2 NextMove PC DPR Map sese eee 54 6 3 Status and Control BRegisters eee eee 56 64 CAMS DAA iaa ari A A A a A 59 6 5 Ne HR in 61 5162 CGOMMSAT UT 62 6 7 Immediate Comand Mode sees 62 6 8 Pseudo Serial Interface sse eee eee 63 6 9 Special Functions Registers see eee 64 viii MN1278 05 2001 Mint Contents 6 10 Data A A tatyceturaniad 66 Appendix 2 TIMINOS i ci oconnoneoncini cacin cantada dedico seene 67 7 1 Immediate Command Mode Functions s 67 Appendix 3 Symbolic Constants csseecessssssesseeeeeneees 69 Bibliography oi id 77 Introduction Introduction The Mint y4 PC Programming Guide details how to call Mint v4 functions and how to communicate with Mint controllers from PC based host applications Mint v4 PC Programming Guide 1 1 Introduction The PC Developer Libraries allow PC based applications to be written that communicate with Mint controllers This is achieved using the Mint Interface Library which is a common API Application Program Interface for the range of Mint based motion controllers The Mint Interface Library is suitable for use under Win
33. d subtract amp H200 There is a function called VBErrorToMIL in mil bas to do this Public Function VBErrorToMIL VBError amp As Long If VBError amp 0 Then VBErrorToMIL amp erSUCCESS Else VBErrorToMIL VBError amp And amp H7FFF H200 End If End Function If the result of this function is negative the error was produced by VB not the Mint Interface Library 3 3 2 A Visual Basic Tutorial This section will guide you through creating a visual basic application The application will contain one button which will toggle the state of the enable output for axis 0 Note that the axis must already be configured as servo use the Mint WorkBench to do this 1 Open Visual Basic and create a New Standard Exe 2 Select Components from the Project menu MN1278 05 2001 27 Mint v4 PC Programming Guide i as ORAS Anke Figure 3 12 Selection of Mint Component 3 Find Baldor Motion Library XXXX for Mint Build XXXX in the list and check the box In this example the version 1107 is being used but you this will have changed by the time this manual is printed If there is a choice of several versions choose the most recent unless you want to target an older version of Mint Hit OK This should have added the icon to the toolbox 4 Select Add Module from the Project tab Click on the Existing tab and add mil bas which should be in the c nint host directory
34. dows 95 98 ME NT and 2000 via an ActiveX control or C source code Features include e Ability to upload and download Mint programs and configuration files e Ability to interrogate the Mint command line e Updating of new firmware into FLASH or RAM e Support for the Mint Comms Protocol whereby data can be transferred to an executing Mint program by means of a protected datapacket e Ability to read Dual Port RAM locations on the NextMove PCI and NextMove PC Mint v4 controllers e PC based motion control e Support for communications with controllers on a CAN network Support is provided for the following controllers e NextMove product family NextMove PCI NextMove BX and NextMove PC e MintDrive e ServoNode 51 s EuroSystem product family SmartMove SmartStep EuroSystem EuroStep EuroServo This manual does not include detail on individual Mint Interface Library functions Details can be found in the Mint v4 Function Reference Guide 1 2 Installation From the Baldor Motion Toolkit CD the PC Developer Libraries should be installed from the NextMove PCI NextMove BX v4 MintDrive and ServoNode 51 product pages This will install the ActiveX component the C source files and the examples A custom setup option is also included to allow selective install of the components Communicating with a Controller Communicating with a Controller This chapter covers general communication with Mint controllers
35. e 78 MN1278 05 2001 Mint
36. e detail on how to set up precompiled header files in the supported compilers To use pre compiled headers with a Visual C project 1 Make sure precomp cpp is included in the project 2 If the project was generated by the App Wizard it will have created a file called stdafx cpp to create the precompiled header file As precomp cpp replaces stdafx cpp delete stdafx cpp from the project If stdafx cpp was NOT deleted in the previous step proceed to step 6 Replace all instances of include stdafx h with include precomp h In the Project menu select Settings This will open the Project Settings dialog Select the C C tab In the Category drop down select General Select All Configurations in Settings For on the left In the Preprocessor definitions field add _INC_STDAFX_H_ separating it from the preceding text with a comma This causes precomp h to include the files previously included by stdafx h stdafx h can still be edited to add more files to the precompiled header as required The dialog should now look similar to the screen shot below Press OK to store these changes Now proceed to step 7 Mint MN1278 05 2001 11 Mint v4 PC Programming Guide MJZ WINDOWS _AFSTLL_OMBLS INC_STDAFX_H_ F Y Figure 3 1 Visual C 6 0 Project Settings step 5 6 Add include precomp h to the top of each source c or cpp file Note that no pre compiler directives e g include if define should be plac
37. e Loader immediately after reset when it is cleared to zero It may be used by the host to determine that a NextMove may be installed on the bus As NextMove will not write to this location the host can write codes and read them back in the knowledge that they should not have changed After use by the PC host the scratchpad should be returned to the value it originally contained It is recommended that NextMove application programs do not write to this register Mint MN1278 05 2001 65 Mint v4 PC Programming Guide 6 10 Data Synchronization It may be desirable to prevent NextMove PC and PCI from updating the DPR update area for a period to allow a snap shot of DPR to be taken The status and control registers provide a mechanism for this It is supported by the function lockDPR This function can be used to e request that DPR not be updated by Mint e inform Mint that it can now update MML Note that locking DPR can take up to two milliseconds to complete 66 MN1278 05 2001 Mint Appendix 2 Timings Appendix 2 Timings These timings show the time taken to call Immediate Command Mode ICM functions from a host The tests were performed on a 300 MHz Pentium II PC On both MintDrive and NextMove PCI the timings were the same on Windows 95 and Windows NT 7 1 Immediate Command Mode Functions Function NextMove PCI Mint NextMove PCI MintDrive Mint MintDrive WinNT4 WinNT4 Win95 Win95 0 140ms 0 254 ms 0 726ms J
38. e controller interrupts the host PC the device driver will trap the interrupt and determine what type of event has occurred Following this it will call the appropriate event handler NextMove can generate a number of events in response to certain situations e Axis idle an axis has become idle e CAN 1 CAN Open an event on CAN bus 1 e CAN2 Baldor CAN an event on CAN bus 2 e Comms the comms location 1 to 5 has been written to e DPR event the user generated a DPR event see 4 2 3 Interrupting the Host from a Mint Program DPR Events e Errors an error occurred on the NextMove card e Fast position latch an axis has latched position e Digital input active a digital input has become active e Move buffer low the numbers of moves in a move buffer drops below a specified threshold e Reset the NextMove PCI card has reset e Serial receive the controller has put a character into its pseudo serial transmit buffer e Stop switch a stop switch has become active e Timer the timer event period has expired The events are prioritised in the following order op Fast position latch 38 PC Based Motion Control DPR event Move Buffer Low Axis Idle Note The reset event is generated if the controller resets hence this is not generated by the firmware and is consequently not subject to the priority scheme The NextMove PCI controller will check for a pending event every 2ms
39. ea is as follows Address l Use LO Analog 0 L Analog 1 L Expansion Analog 4 Expansion Analog 5 BEEE E IIE 120 Auxiliary Encoder 0 vel Reserved 122 Auxiliary Encoder 1 vel Ojo I 2 STS S D SS On Expansion 1 Digital Outputs 27 Expansion 2 Digital Inputs 28 Expansion 2 Digital Outputs 29 12A Reserved 12B Reserved 2C Sl x xX o X o X x Reserved E Reserved 12F Reserved o X N ojo X N N o X Not applicable to NextMove PCI H Symbolic Constant rANALOG_0 rr ANALOG_1 roANALOG_2 rrANALOG_3 roAUXENC_0_VEL roAUXENC_1_VEL roEXP1_OUTPUTS D Reserved ____ Appendix 1 DPR Map l Data Size Auxiliary Encoder 0 rAUXENC_0_POS float 121 Auxiliary Encoder 1 roAUXENC_1_POS float float 23 Auxiliary Encoder 2 rrAUXENC_2_POS float 24 Auxiliary Encoder 2 vel roAUXENC_2_VEL float 5 Expansion 1 Digital Inputs roEXP1_INPUTS int 32 roEXP2_INPUTS int 32 roEXP2_ OUTPUTS int 32 Reserved HS 61 Mint v4 PC Programming Guide The layout of the section is compatible to the current layout on NextMove PC The locations used on NextMove PC for the upper 16 bits of data are unused All data is written every 2ms 6 6 Comms Array The Comms area simulates protected Comms communications on serial based controllers The Comms array uses an area of DPR from address 0x1D6 to 0x29A The data is accessed a
40. ed above this line although comments can be In the Project menu select Settings This will open the Project Settings dialog Select the C C tab In the Category drop down select Precompiled Headers Select All Configurations in Settings For on the left Click on Use precompiled header file pch and enter precomp h in the Through Header text field The dialog should now look similar to the screen shot below Press OK to store these changes This will instruct the project to use the pre compiled file 12 Using the Library with Various Languages ieee stele Figure 3 2 Visual C 6 0 Project Settings step 7 8 Select precomp cpp in File View Right click with the mouse and select Settings This will open a dialog similar to the dialog in step 3 but this time the dialog will only apply to precomp cpp Again select Settings For All Configurations and the Precompiled Headers Category on the C C tab This time select Create precompiled header file pch and add precomp h to the Through Header field Check the dialog resembles the one below and press OK Mint MN1278 05 2001 13 Mint v4 PC Programming Guide KHE TTA ME E odeti cpa EE Hoeder Fies E Resource Filas i Mint iterace Library E l a 4 Header TTU Heaney E Baza cop ITUNE ET E paed e bot Figure 3 3 Visual C 6 0 Project Settings step 8 9 Rebuild the project Precomp cpp should now be the first file to build This causes the pre c
41. ere is a space in the transmit buffer This means that the serial buffer must be emptied by the host application for the Mint program to proceed There are several ways of doing this Call one of the read functions e g getSerialChar until the buffer is emptied Set the terminal mode to be overwrite or off The terminal mode controls how the serial buffer is used If the mode is overwrite then the oldest characters in the buffer are overwritten by the new characters If the mode is off all characters are discarded as they are placed in the buffer See the TERMINALMODE keyword in the Mint v4 Programming Guide for further details The functions setTerminalmode tmRS232 tnmOVERWRITE will set the terminal mode on the RS232 port to be overwrite setTerminalmode tmDPR tmmOFF will disable all serial communications on the pseudo serial buffer on NextMove PC or PCI The terminal mode can also be set for NextMove PC and PCI when firmware is downloaded to the controller Specify TRUE for the bEchoOverwrite parameter of doUpdateFirmware doUpdateFirmwareEx This will set the pseudo serial communications into overwrite mode To download and upload and Mint program and configuration files to Mint the functions doMintFileDownload and doMintFileUpload are used These are unaffected by the setting of terminalmode MN1278 05 2001 7 Mint v4 PC Programming Guide The following is a summary of the functions used to access the Mint command line d
42. hen click Form to create an instance of the control Examining the properties of the control should show that the name is MintController1 4 We now have to edit the FormCreate function Double click on Forml to open the FormCreate function The line of code depends on the controller being used It will tell the COM server which type of controller we want to communicate with These means the code will depend on the controller you have The consts should be editted to match your system 32 MN1278 05 2001 Mint Using the Library with Various Languages MintDrive procedure TForml FormCreate Sender TObject const NodeNumber 10 const CommPort 1 const BaudRate 57600 begin MintControllerl setMintDriveLink NodeNumber CommPort BaudRate TRUE end NextMove PC procedure TForml FormCreate Sender TObject const NodeNumber 0 const Address 23c begin MintControllerl setNextMovePCLink NodeNumber Address end NextMove PCI procedure TForml FormCreate Sender TObject const NodeNumber 0 const CardNumber 0 begin MintControllerl setNextMovePCIlLink NodeNumber CardNumber end end 5 Add a button and double click on it to edit the Button Click procedure Add the following code procedure TForml ButtonlClick Sender TObject var wbEnabled WordBool begin Read the current state of the drive enable MintControllerl getDriveEnable 0 wbEnabled Write back the toggled value
43. ind the file motion XYZ Squash Could not find the file constant XYZ Squash Error reading from file to squash Squash Error writing to squash output file 72 erSQ_INVALID_OUTPUT_FILE_STRING erSQ_INVALID_INPUT_FILE_STRING erSQ_INVALID_PATH_STRING erSQ_TOO_MANY_BASIC_KEYWORDS erSQ_TOO_MANY_MOTION_KEYWORDS erSQ_TOO_MANY_CONSTANTS erSQ_VARIABLES_NOT_INITIALISED erCANNOT_WRITE_TO_INTERRUPT erNO_LINK_TO_CONTROLLER erFIRST_ARRAY_ELEMENT_IS_SIZE erPOS_ARRAY_REQUIRED erARRAY_SIZE_MISMATCH erPARAMETER_CANNOT_BE_NEGATIVE erCAN_INIT_FAILED erEEPROM_CRC_FAILED erINSUFFICENT_MEMORY erCANNOR_RUN_APP erEVENT_HANDLER_IN_USE Appendix 3 Symbolic Constants Squash Name of file to squash not NULL terminated Squash Name of squash output file not NULL terminated Squash Path to squash tables not NULL terminated Squash Too many basic keywords contact technical support Squash Too many motion keywords contact technical support Squash Too many constants contact technical support Squash Internal error contact technical support No write access to interrupts Must use a setXX XLink function The first element in the array must specify the number of elements not including itself The postition array is not optional One or more array s are the wrong size The parameter cannot be negative Initialisation of CAN failed EEPROM failed CRC check Insufficent memory to run application Cannot run a
44. ion information for the device driver Windows NT 2000 Locate the file NMPCI SYS in the WINNT SYSTEM32 DRIVERS directory using Windows Explorer Right click the file and select Properties The Version tab of the displayed dialog gives version information for the device driver 2 2 NextMove PC NextMove PC requires a device driver under Windows NT and Windows 2000 See the NextMove PC Mint v4 Installation Guide for details on installing the device driver 2 3 Dual Port RAM on NextMove PCI and PC All communication between NextMove PCI PC and the host is performed using Dual Port RAM DPR This is physical block of memory on NextMove which can be accessed by either NextMove or the host Various locations in DPR have been set aside for special purposes such as sending control codes and passing I O information Other locations have been left for the user to pass any required information back and forth 4 MN1278 05 2001 Mint Communicating with a Controller The main features and uses of DPR are e Support for the Mint Comms protocol This is a method of asynchronously updating variables in a Mint program from the host e Mint pseudo serial buffer This allows communication with the Mint command line and Mint program and configuration loading saving e Reporting of Mint status The host can read whether Mint is at the command line and if not which line it is executing e Automatic reporting of motion variables Eve
45. k MsgBox Error Exit Sub End Sub 30 MN1278 05 2001 4 rint Using the Library with Various Languages 3 4 Borland Delphi 5 0 NOTE Before any programs including the examples can be built the type library must be imported See step 2 This section will guide you through creating a simple Delphi application The application will contain one button which will toggle the state of the drive enable output for axis 0 Note that the axis must already be configured as servo use the Mint WorkBench to do this 1 Open Delphi and create a new project 2 If this is the first time a Delphi Mint Interface Library application has been created on this machine a type library file will have to be created Select Import ActiveX Control from the Components menu Find Baldor Motion Control Library XXXX for Mint XXXX in the list and check the box In this example the version 1109 is being used but this will have changed by the time this manual is printed If there is a choice of several versions choose the most recent unless you want to target an older version of Mint Hit Install and follow the default options Mint MN1278 05 2001 31 Mint v4 PC Programming Guide SI RT DELPHI LO DELPHI Ein 4 CELFH mpor fetal E coment tmp Figure 3 14 Delphi Installing Mint Component 3 Select the ActiveX tab on the toolbar The rightmost icon should now be the MintController Mint icon Click the icon and t
46. ller setMoveR 0 100 myController doGo 1 axis0 Wait until move is completed Do myController getIdle 0 isIdle Loop Until isIdle 4 1 Limitations of PC based applications There are a number of event handlers available in Mint such as HONERROR Only NextMove PCI supports events to the host This means that event handlers can be installed in the host application that are called directly when a Mint event occurs For other controllers the event handlers must be placed in a Mint program Commands called from the host execute slower than if called directly on the controller See Appendix 2 for example timings The host functions take priority over the Mint program running on the controller If MML functions are called continuously from the host this will slow the execution speed of the Mint program Mint MN1278 05 2001 37 Mint v4 PC Programming Guide 4 2 Events and Interrupt Control on NextMove PCI The NextMove PCI controller requires a device driver to be installed on the host PC in order for communication to be established between it and the controller The use of device drivers makes it possible for interrupts from the card to be trapped and handled The Dual Port RAM interface allows the PC to interrupt the controller and the controller to interrupts the host Interrupt handling using the NextMove PCI controller is supported under both Windows NT and Windows 95 and 98 4 2 1 Writing and Installing an Interrupt Handler When th
47. mmsEventHandler void pController _ int32 1CommsEventPending __int16 installCommsEventHandler TCommsEventHandler pHandler Mint MN1278 05 2001 39 Mint v4 PC Programming Guide DPR The install function for DPR events it accepts a pointer to a function if this is a NULL pointer the handler is uninstalled typedef void TDPREventHandler void pController __int16 nCode __int16 installDPREventHandler TDPREventHandler pHandler Errors The install function for error events it accepts a pointer to a function if this is a NULL pointer the handler is uninstalled typedef void TErrorEventHandler void pController __int16 installErrorEventHandler TErrorEventHandler pHandler Fast Position Latch The install function for fast position latch events it accepts a pointer to a function if this is a NULL pointer the handler is uninstalled typedef void TFastInEventHandler void pController __intl6 installFastInEventHandler TFastInEventHandler pHandler Digital Input The install function for digital input events it accepts a pointer to a function if this is a NULL pointer the handler is uninstalled typedef void TInputEventHandler void pController __intl6 nBank _ int32 lActivatedInputs __int16 installInputEventHandler TInputEventHandler pHandler Move Buffer Low The install function for move buffer low events it accepts a pointer to a function if this is a NULL pointer the handler is uninstalled typedef void
48. o the example This is code that should be replaced with code specific to that operating system Only code in the files MySimplePCI h and MySimplePCI cpp should be modified Do NOT modify SimplePCI h and SimplePCI cpp Constructor A constructor must be supplied This constructor must call the CSimplePCI constructor passing the node and card number Any other parameters required by the class may be passed The CMySimplePCI constructor is as follows CMySimplePCI Function Constructor Argument list int nNode Node number not currently used int nCard PCI card number Return value Fn A ee CMySimplePCI CMySimplePCI int nNode int nCard CSimplePCI nNode nCard i J daea eee k START Replace this eN m_hndFile INVALID_HANDLE VALUE a A A Find if we are running under Win9X or WinNT Taa eien A A i A i Eaa Po are OSVERSIONINFO VersionInfo VersionInfo dwOSVersionInfoSize sizeof OSVERSIONINFO GetVersionEx amp VersionInfo m_bWinNT O VersionInfo dwPlatformId amp VER_PLATFORM_WIN32_NT doDeviceOpen The constructor should initialize any required data and then call doDeviceOpen to allow communications with the controller to start 48 MN1278 05 2001 Mint NextMove PCI and Non Micorsoft Operating Systems doDeviceClo
49. oMintBreak Sends Ctrl E to Mint bypassing the pseudo serial buffer on NextMove PC and PCI doMintRun Write RUN lt ENTER gt getSerialChar Read a char from the pseudo serial buffer if one is available getSerialCharTimeout Read a char from the if one is available within the setSerialChar setSerialCharTimeout setSerialStringTimeout Writes a string timing out if the pseudo serial transmit buffer is full Using the Library with Various Languages Using the Library with Various Languages This chapter details the use various different programming languages The languages covered are O C O Visual C 6 Visual Basic 6 Imprise Delphi Mint v4 PC Programming Guide 3 1 C The Mint Interface Library was written in C The source code is provided and can be included in your project The only supported compilers are Visual C v6 0 and Watcom 11 All other compilers must use the ActiveX control to communicate with controllers 3 1 1 C the Classes The Mint Interface Library contains a C class for each controller In each case the class is defined in the header file in the right of the table All of these headers are included in precomp h see later Controller Header file to include NextMove PC _NextMove PCI NM PO A seee CNextMovePCI1 nm_pcil h MintDrive 2 CMintDrive mintdrvh ServoNode 51 CServoNodeS51 snode51 h The simplest way to interface to any of these controllers is to cre
50. ode Mint for NextMove REM COMMS location uses DEFINE control COMMS 1 DEFINE paraml COMMS 2 REM Flags for control location DEFINE completed 0 DEFINE special_routinel 1 REM I O DEFINE open _gripper OUTO 1 DEFINE gripper_fully open IN6 1 DEFINE gripper_error IN7 WHILE 1 IF control special routinel DO OUT1 paraml REM Use param supplied by top end open_gripper PAUSE gripper fully open REM Wait for an event paraml gripper_error REM Data to pass back to host control completed REM synchronise with host ENDIF ENDW 6 MN1278 05 2001 AINT Communicating with a Controller 2 5 Interfacing with Mint The Mint command line allows manual execution of Mint keywords Using the Mint WorkBench the Mint command line can be used when testing commissioning and debugging Mint programs There are several functions in the Mint Interface Library for direct access to the serial buffer setSerialChar setSerialCharTimeout setSerialStringTimeout getSerialChar getSerialCharTimeout and getSerialStringTimeout These allow characters and strings to be passed to and from a Mint application A Mint application may use the serial buffer for program control user information or debug information For example myNextMoveBX setSerialStringTimeout MA 0 100 GO 0 n 100 2 5 1 Preventing Deadlock Situations If Mint has a character to write to the serial port it will wait indefinitely until th
51. og 0 133ms 0 182 ms 0 648ms setSpeed 0 138ms 0 184 ms 0 656ms This is the speed for a function called from a C application with the Baldor Motion Toolkit C source code compiled into the project Using the ActiveX interface adds approximately 1ms to each function call This can be reduced by setting the DCOM and Events Enabled property to false This makes ActveX access times approximately equal to the C times but you cannot use events from NextMove PCI Mint MN1278 05 2001 67 Mint v4 PC Programming Guide 68 MN1278 05 2001 Mint Appendix 3 Symbolic Constants Appendix 3 Symbolic Constants The library functions can return error codes or can be passed parameters for which a number of symbolic constants have been defined in appropriate header files These values are shown below Error Codes erSUCCESS erINITIALISING erNOT_RUNNING erBAD_COMMAND erBAD_ADDRESS erBAD_ERASE erBAD_BURN erCANNOT_OPEN_FILE erINVALID_FORMAT erERROR_DOWNLOADING erTIMEOUT erDPRAM_LOCATION erNOT_ENOUGH_MEM erBAD_BOOT_DEVICE erCARD_NOT_FOUND erINVALID_VME_TYPE erINVALID_NEXTMOVE_TYPE erINVALID_STRING_FORMAT erNO_Mint_PROMPT erNO_WIN95_VME_SUPPORT erCOMMAND_ABORTED erFRONT_ACTIVE erCOMMAND_INTERRUPTED erRETURN_INVALID erFRONT_DISABLED No error Loader initialising Loader not runnning Unrecognised command code Invalid address received Flash erase failed Flash program failed File bad or does not exist File no
52. ompiled header file to be built All the other files will now use this pre compiled header as opposed to having to re compile all the header files each time 3 1 3 A Visual C 6 0 Tutorial This section will guide you through creating a Visual C application The application will contain one button which will toggle the state of the enable output for axis O Note that the axis must already be configured as servo use the Mint WorkBench to do this 14 MN1278 05 2001 Mint Using the Library with Various Languages 1 Open Visual C and select New from the File menu Select MFC Appwizard exe from the Projects tab Enter the name VCTutorial for the project and press OK Figure 3 4 Visual C 6 New Project step 1 Mint MN1278 05 2001 15 Mint v4 PC Programming Guide 2 At Step 1 of the wizard select Dialog based and press Finish Engish Listed Setas APPWZENUOLL Figure 3 5 Visual C 6 Application Wizard step 2 3 Delete all the controls from the dialog OK button Cancel button and TODO Place dialog controls here Text 16 MN1278 05 2001 M mut Using the Library with Various Languages 4 Select Settings from the Project menu Select All configurations from the Settings For drop list Select the C C tab and add _INC_STDAFX_H_ to the end of the Preprocessor definitions list This will cause the existing
53. on if this is a NULL pointer the handler is uninstalled typedef void TUnknownEventHandler void pController __int16 nCode __int16 installUnknownEventHandler TUnknownEventHandler pHandler This handler will pick up any otherwise un handled interrupt codes on the host Under normal circumstances it will not be called as all interrupts will be routed to the appropriate event hander If this handler is not installed then unknown interrupts will be discarded Example The following code sample will install a timer event handler prototypes void cdecl FAR myTimerEventHandler void p _ int16 nTimerEventNumber main program void main void Create an instance of the CNextMovePCI class CNextMovePCI1 myPCI 0 O install timer event handler myPCI installTimerEventHandler myTimerEventHandler myPCI setTimerEvent 1000 set periodic timer event to 1000ms while 1 myPCI setRelay 0 1 Turn the main board relay on myPCI doWait 500 Wait for 500 ms myPCI setRelay 0 0 Turn the main board relay off myPCI doWait 500 Wait for 500 ms Mint MN1278 05 2001 41 Mint v4 PC Programming Guide timer event handler void myTimerEventHandler void p _ int16 nTimerEventNumber cout lt lt Timer Event lt lt endl When a host PC event handler is called the embedded application running on the controller will continue to execute 4 2 2 Event Control
54. operation to finish its operation in a certain time the default for Visual Basic is five seconds It should be able to change these timeouts or remove the check completely the method will be different for each language The following sections give advice on how to do this in Visual Basic and Visual C Component Request Pending in VB This error as shown in the dialog above can be prevented by adding the following code before the function which times out is called App OleRequestPendingTimeout 60000 This will increase the timeout to a minute the timeout is in milliseconds If this is still not long enough the value can be increased Server Busy in a Visual C MFC Application Server Dusy This is described fully in the Microsoft MSDN article Q248019 HOWTO Prevent Server Busy Dialog Box From Appearing During a Lengthy COM Operation To solve the problem add the following lines of code to the CWinapp derived classes InitInstance function AfxOleInit 26 MN1278 05 2001 Mint Using the Library with Various Languages AfxOleGetMessageFilter gt EnableNotRespondingDialog FALSE The file will have to include afxole h 3 3 Visual Basic 6 3 3 1 Error number conversion The error numbers returned in Err after a function call in Visual Basic differ from the constants defined in mil bas To convert from an Err code other than 0 to a MIL error mask off the top 17 bits by ANDing with amp H7FFF an
55. or m_pController gt getDriveEnable 0 amp b return Mint MN1278 05 2001 23 Mint v4 PC Programming Guide SR aa Toggle it Y A E E MILError m_pController gt setDriveEnable 0 FALSE b 3 1 4 Compiling an ATL COM Project with Visual C When compiling an ATL COM project in Visual C define VO_AFX_ This prevents AFX and MFC files being included 3 1 5 RS485 Networks Individual controllers on an RS485 network can be accessed from within one application built using the source code One CController derived object can be created for each node on the network and they will share the serial port Other applications will not be able to access controllers on the same port When using controllers on an RS485 link remember to call setHandShakeMode 0 to disable hardware handshaking If there are several CController objects sharing the port setHandShakeMode 0 only has to be called for one of the controllers 3 2 All Other Languages The ActiveX Control OCX The ActiveX control is known as the Baldor Motion Library When used a TMintController object is created This can be used with a large number of languages This section documents the use of the control with Visual Basic 6 and Delphi 5 but the principle is the same in any language 3 2 1 The ActiveX Control And The Languages It Can Be Used With The control is a Active X COM control It can be used with any languages that support e
56. ppendix 1 DPR Map Address Use Read Only 0x12F 0x12F 10 Data A 0x110 0x110 Ox10F 0x10F H Axis 7 Data oxoro Ox0EF Axis 6 Data Y 10x0DO oxor Axis 5 Data Y 0x0B0 OXOAF Axis 4 Data Y ox090 0x08F Axis 3 Data Y 0x070 Ox06F Axis 2 Data Y 0x050 Ox04F Axis 1 Data Y 0x030 0x02F Axis Data Axis 0 Data Y 0x010 0x010 Ox00F 0x00F Reserved Y e 1ms Timer Tick 0x00D 0x00C Axis Configurations 8 11 Y 0x00B 0x00A MINT Error Line C 0x008 MINT Status 4 0x007 MINT Line Number LES 0x006 2ms Timer Tick L 0x005 BuildID T 0x004 Analog I O Mix Y Y Status Control Registers 0x003 Digital I O Mix al de MN1278 05 2001 Mint v4 PC Programming Guide Address Use Axis Mix DPR Status Regi Read Only 0x000 0x000 DPR Control Register 6 2 NextMove PC DPR Map Dual Port RAM on NextMove PC has 1K of 16 bit data Address 0x3FF 0x3FF i Ox3FE Ox3FD Control Registers 0X3FC 0x3FB 0x3FB Ox3FA Ox3FA Use Interrupt Host Interrupt NextMove Scratchpad Unused Functionality Code Application Code i Interrupt Data Read Only Ox3F9 Ox3F9 Interrupt Data Pseudo Serial 0x150 0x110 0x110 Ox10F 0x10F I H 1 Ox0FO OxOEF Ox0DO ICM handshake Comms 99 locations Serial Receive Buffer IO Data Axis 7 Data Axis 6 Dat
57. pplication for unknown reason Event handler already installed MN1278 05 2001 73 Mint v4 PC Programming Guide updateFirmware Codes nBootDevice Parameter 0 tmFLASH Load program to flash memor i Load program to RAM updateFirmware Codes nTarget Parameter T 2 Boot from serial port 3 bdNV BootfromNVRAM File Upload Download Codes Use with uploadMintFile amp downloadMintFile E oca 2 fileCONFIG Configuration file 3 fileARRAY Array file getControllerType Codes gt 3 9 10 set getHandshakeMode Codes RISICTS Handshaking Cee Update Callback Codes update WAITING_POWERUP Waiting for the user to power cycle the controller update ERASING_FLASH Controller is erasing flash updateSCANNING_FILE Scanning the firmware file 74 Appendix 3 Symbolic Constants 4 updateDOWNLOADING Downloading the firmware use the percentage parameter updateRESETTING Resetting the controller updateRUNNING Running the application MN1278 05 2001 75 Mint v4 PC Programming Guide 76 MN1278 05 2001 Mint Bibliography 11 2 3 4 5 All manuals can be found on the Baldor Motion Toolkit CD ROM Bibliography Bibliography Mint v4 Programming Guide MN1262 Mint v4 Advanced Programming Guide MN1270 Mint v4 PC Programming Guide MN1278 Mint v4 CAN Programming Guide MN 1282 Mint v4 Function Reference Guide MN1280 77 Mint v4 PC Programming Guid
58. r This is not true of applications written with the C source code where only one application can access a serial controller 3 2 4 The ActiveX Control and RS485 Networks To access several nodes on an RS485 network create one MintController object for each controller The Visual Basic RS485 example shows how Immediate commands can be performed and also how the command line of each controller can be accessed When using controllers on an RS485 link remember to call setHandShakeMode 0 to disable hardware handshaking If there are several MintController sharing the port setHandShakeMode 0 only has to be called for one 3 2 5 Distributing an Executable Which Uses The ActiveX Control When distributing a program which uses the ActiveX control the files MILOCXZZZZ OCX and MILSERVERZZZZ OCX where ZZZZ is the version number must be installed in the windows system directory and registered Microsoft DCOM95 must also be installed The easiest way to do this is to use a package such as InstallShield Express and install MDAC2 0 which forces installation of DCOMOS 3 2 6 Server Busy Component Request Pending Errors Mint MN1278 05 2001 25 Mint v4 PC Programming Guide ponent Request Pending When using the Active Control warning messages such as the dialog above taken from a Visual Basic application may be shown for slow operations such as file download This is because the application expects the ActiveX
59. ry 2 milliseconds NextMove writes various motion parameters into DPR such as position and velocity of an axis This can be read at any time by the host e Event control This allows NextMove to interrupt the host and the host to interrupt NextMove e Flags amp control registers Each NextMove application uses control registers to tell the host which features it supports Control registers can also be used to synchronize communications between NextMove and the host e User area There is an area in DPR which has been left to allow NextMove and the host application to exchange whatever application specific data is required Appendix 1 shows the layout of DPR and describes the functionality of each section in detail 2 4 Mint Comms Array All Controllers The Mint Comms Protocol is a secure communication method allowing asynchronous transfer of floating point data to and from a Mint controller This is a 255 element array where the first 99 elements can contain user data and the remaining elements contain pre defined data such as axis position and velocity Comms provides the best way of communicating data between a Mint program running on a controller and the host at run time It can be used for simple data transfer or as a method of synchronizing events Comms can also be used for transferring data directly between controllers For further information on the uses of Comms see the Mint v4 Programming Guide section 5 Mint Comms Communications
60. s Address Comms Location location 1 1 location 3 T location 98 location 99 Each location is a float value The area is the same as NextMove PC at 99 locations Comms is accessed using the COMMS keyword in MINT or the getComms setComms functions 6 7 Immediate Command Mode The ICM area is used for the transfer of Motion Generator commands The start of the ICM area is 0x130 and has the symbolic constant oFRONT_START 62 MN1278 05 2001 Mint Appendix 1 DPR Map 6 8 Pseudo Serial Interface The serial interface works by implementing a 64 word circular buffer within DPR There is one such buffer for the receive buffer and one for the transmit buffer Head and tail pointers are also located in DPR allowing both sides of DPR to check the status of the buffers The serial interface occupies DPR locations 0x150 to 0x1D5 in the following configuration 0x85 Txd Buffer 0x46 Txd Reserved 0x45 Txd Tail 0x44 Txd Head 0x43 0x42 Rxd Buffer 0x03 Rxd Reserved 0x02 Rxd Tail 0x01 Rxd Head 0x00 The buffer itself has two sets of symbolic constants depending on which side NextMove or host that is using them Offset Symbolic Constant Host Symbolic Constant NextMove ofTXD_HEAD ofNM_RXD_HEAD ofTXD_TAIL ofNM_RXD_TAIL ofNM_RXD_BUFFER ofNM_TXD_HEAD ofNM_TXD_TAIL ofNM_TXD_BUFFER The offsets from the start of the serial interface are shown in hex The start of the serial I O buffer has a symbolic
61. s required include simplepci h class CMySimplePCI public CSimplePCI public START These functions MUST be defined YN A a a a a a CMySimplePCI int nNode int nCard __int16 doDeviceClose void __int16 getDeviceOpen BOOL bOpen __int16 doDeviceOpen void __intl6 getLong __int16 nAddress __int32 FAR lplValue protected __int16 InternalSetLong _ int16 nAddress __int32 lLong __int16 PLXRead __int16 nRegister _ int32 plValue __intl6 PLXWrite __int16 nRegister _ int32 lValue END These functions MUST be defined START Replace this A A protected bool m_bWinNT true WinNT false Win9X HANDLE m_hndFile Handle to the device driver Jd cane ae SS ii o ee END Replace this AA eo EE EEEE t eoo oooooooo oooooooo ooooso START Replace this t o o oeoo ooooooo oso oo Mint MN1278 05 2001 47 Mint v4 PC Programming Guide END Replace this Ji cooosccsooeoootecoodecsceseressecsiscscsetoosscsceseteescorsessst which show code that is only relevant t
62. se This function releases any resources which had been taken by the class getDeviceOpen This function must report whether the class has control of any resources it requires to communicate with the controller and whether that controller is physically present In the MySimplePCI example this reports whether it can communicate with device driver In Windows 95 on instance of the device driver is created in memory per device it finds so if the device driver instance exists in memory the NextMove PCI is present Under Windows NT there is one device driver to handle all NextMoves so the device driver must be interrogated to find if that card number is present doDeviceOpen This function must take any resources required to communicate with the controller In the MySimplePCI example this creates a handle to the device driver getLong This function must read from DPR block 3 in section 5 2 This may take the form of as in the MySimplePCI example instructing the device driver to perform the task The read should be a simple 32 bit read from the memory address the DPR has been mapped into Block 3 internalSetLong This function must write to DPR block 3 in section 5 2 This may take the form of as in the MyMySimplePCI example instructing the device driver to perform the task The write should be a simple 32 bit write to the memory address the DPR has been mapped into Block 3 PLXRead This function must read from the PLX chip Block 3
63. should be read to determine which buffer is currently being executed Mint Status The Mint Status flag consists of various bit masks for status information The top 8 bits convey the current Mint error status If a programming error occurs that results in the termination of a program the top 8 bits will reflect the error The Mint Line Number register will determine the line on which the error occurred Command line interface not available mkNOT_COMMAND_LINE Program or config file running Config buffer if 0 program buffer if 1 mkPROGRAM 1 if Mint is executing code __ mkEXECUTING ATT Reserved AAA Mint Error The Mint ERR code for the last Mint error that occurred Mint Error Line The Mint line number where the last Mint error occurred Axis Configurations NextMove PC The current axis configurations are written to two 16 bit locations each axis configurations represented by 4 bits Each four bit location holds the axis CONFIG value DPR location Bits 12 15 Bits 8 11 Bits 4 7 Bits 0 3 AT Axis Axis 5 Axis 4 Appendix 1 DPR Map NextMove PCI Axis Configurations gives the current configuration of each axis in 4 bits Axis7 Axis6 Axis5 Axis4 Axis3 Axis2 Axisl Axis0 Oo tl ll Ais Axisi0 Axis9 Axis8 Values are 0 Axis is configured off 1 Axis is configured as a servo axis 2 Axis is configured as a stepper axis 3 Axis is configured for PWM
64. t an attempt to build the code will fail at the link stage as the source for getErrorString has not been included Add host_def cpp to the project and the code should build MN1278 05 2001 21 Mint v4 PC Programming Guide 12 13 Select ClassView Right click on CVCTutorialDlg and select Add Member Variable Copy the dialog below Rill Menber Variable temer 0 Y CContraliar 9 Cancel Wenab e Hame i_pcamtciles CIS l r Public T Protected C Piee e Figure 3 11 ClassView Dialog step 12 Find CVCTutorialDlg OnInitDialog in the file VCTutorialDlg Replace the comment TODO Add extra initialization here with code to initialise the CController object This will depend on the controller being used Note that m_pController could have been declared as the class that will be created e g CMintDrive in which case lt dynamic_cast gt would not have to be used The define values should be modified to reflect the system being used MintDrive define NODE 10 define COMMPORT 1 define BAUDRATE 57600 m_pController dynamic_cast lt CController gt new CMintDrive NODE COMMPORT BAUDRATE TRUE NextMove PC define NODE 0 define ADDRESS 0x23C m_pController dynamic_cast lt CController gt new CNextMovePC NODE ADDRESS NextMove PCI define NODE 0 define CARDNUMBER 0 m_pController dynamic_cast lt CController gt new CNextMovePCI1 N
65. t proper COFF format COFF download failed Loader did not respond in time DPR location out of range Insufficient memory for program Bad boot source id Unable to locate NextMove Bad VME parameter Bad NextMove parameter Must use NULL terminated string for string parameters Command prompt was not avaiable for up download Should use MintBreak to stop a running program NextMove VME not currently supported under Windows 95 User aborted front command Front resource already in use Command was not passed to MG try again Return code invalid Call getSystemErr Immediate Command Mode has been MN1278 05 2001 69 Mint v4 PC Programming Guide erINVALID_ HANDLE Error 1026 Removed erPROTOCOL_ERROR erFILE_ERROR erINVALID_FILETYPE erNO_PROMPT erNO_NT_SUPPORT erRESPONSE erTEMP_FILE_ERROR erCODE_ERROR erIN_COMMS_ROUTINE erDOWNLOADING erUPLOADING erIN_Mint328_ROUTINE erPORT_NOT_OPEN erCORRUPTION erPORT_OUT_OF_RANGE erNOTIFY erCHECKSUM_ERROR erNAK_RECEIVED Error 1045 Removed erERROR_OPENING_PORT erINVALID_CARDNUMBER erINVALID_AXIS_PARAM erINVALID_CONTROLLER_TYPE erINVALID_COMMS_ADDRESS Error 1051 removed erPORT_UNAVAILABLE erUSER_ABORT disabled The handle had not been correctly initialised Unknown protocol on upload download The file could not be opened or was corrupted The filetype parameter passes to up downloadFile was not correct The function failed as Mint was not at
66. vent In this example the timer event is set to trigger every second the code within the timer event handler will toggle the state of the relay 44 MN1278 05 2001 Mint NextMove PCI and Non Micorsoft Operating Systems NextMove PCI and Non Microsoft Operating Systems This chapter details how to use the NextMove PCI with operating systems other than Windows NT and Windows 9x Mint MN1278 05 2001 45 Mint v4 PC Programming Guide This Chapter covers implementing an interface to NextMove PCI in under an operating system other than the systems supported by the standard Baldor Motion Toolkit for example QNX Linux etc A special version of the CNextMovePCI1 class has been written This class called CSimplePCI provides all the functions required except the actual hardware interface functions which must be provided by the user 5 1 How to Recognize the NextMove PCI To find the NextMove PCI the computer s PCI controller must be interrogated The method for this will differ between operating systems Each PCI device can be recognized by its Vendor ID and Device ID For a NextMove PCI the following applies Vendor ID 145F Hex Device ID 0001 5 2 Host Accessible Hardware on NextMove PCI The are three blocks of hardware which can be accessed on NextMove PCI One of these is mapped into both memory and IO space so it appears as if there are four blocks which can be accessed 128 bytes This is NextMove s PCI chip
Download Pdf Manuals
Related Search
Related Contents
取扱説明書 Complete User Guide ELECTRONIC MDD BABY SCALE MODEL 630 Copyright © All rights reserved.
Failed to retrieve file