User Tools

Site Tools

한국어

moacon:motorsetup:index

motorSetup

void motorSetup (u8 motionID, u8 stCh, u32 freqBase, u32 freqTop, u32 stepAccel)

motionID : The ID of the Motion Control Module
stCh: The channel on the Motion Control Module (0 or 1)
freqBase: The starting frequency (speed) in Hz to be sent to the motor driver (maximum: 50KHz)
freqTop: The top frequency (speed) in Hz to be sent to the motor driver.
freqAccel: The acceleration/deceleration in Hz/sec to be sent to the motor driver

Sets the starting speed, top speed, and acceleration/deceleration that the motor should use when the motor starts and stops. The motor is identified by the id of the Motion Control Module, motionID, and the module's channel, stCh.

#include "moacon500.h"
 
//Waits for motor to finish moving
void motorWaitToFinish(u8 motionId, u8 stChannel)
{
    //Get the current number of pulses left to send
    u32 pulseCount = motorStat(motionId, stChannel);
 
    //While there are still pulses remaining (i.e. the motor is still moving)
    while(pulseCount > 0)
    {
        //Get the current number of pulses left to send
        pulseCount = motorStat(motionId, stChannel);
 
        //Print the number of pulses remaining to the debug console
        printf("%d pulses remaining\r\n", pulseCount);
        delay(500);                             //Give the CPU a break.
    }
}
 
void cmain(void)
{
     motorSetup(0, 0, 500, 5000, 1000);      //Initialize the motor
     setMotorPos(0,0,0);                     //Current position is at its starting position
     motorMove(0,0,100000);                  //Move the motor to position 100,000
     motorWaitToFinish(0,0);                 //Wait for the motor to finish moving
     motorMove(0,0,0);                       //Move motor back to starting position
     motorWaitToFinish(0,0);                 //Wait for the motor to finish moving
}

MOACON Home

moacon/motorsetup/index.txt · Last modified: 2022/11/02 08:48 by COMFILE Technology