DC stepper control using a DCC1002 module - position reached

Comments & issues
Post Reply
julien
Phidgetsian
Posts: 5
Joined: Tue Feb 07, 2023 3:04 am
Contact:

DC stepper control using a DCC1002 module - position reached

Post by julien »

Hello,
I've been playing with the servo phidget and the stepper phidget in the past but this is my first time using a DCC module.

It's not clear to me how I can make my motor positioning synchronous.
In the past I was monitorting the positionChanged event and blocking until the current position is the target position, but with a DC motor and depending on the PID, the motor might overshoot.

So here are my questions:
- Do you confirm that voidPhidgetMotorPositionController_setTargetPosition() is asynchronous?
- Do you confirm that the callback of voidPhidgetMotorPositionController_setTargetPosition_async() is not called when the position is reached, but when the targetPosition has been sent to the microcontroller?
- How do you recommend to program the detection of "position reached"?

Thanks in advance.
User avatar
Patrick
Lead Developer
Posts: 3403
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: DC stepper control using a DCC1002 module - position reached

Post by Patrick »

setTargetPosition() is synchronous in that it returns once the command has been accepted by the board. setTargetPosition_async() is basically the same, but returns immediately. It can take 10s of milliseconds to send a command to the board and hear back - the async call is there for sending commands to multiple channels in parallel.

You'll need to monitor the PositionChange or DutyCycleUpdate events to determine when it's reached position.

-Patrick
julien
Phidgetsian
Posts: 5
Joined: Tue Feb 07, 2023 3:04 am
Contact:

Re: DC stepper control using a DCC1002 module - position reached

Post by julien »

Thanks a lot, works great this way.
I have one last question: is it possible to use an input from the VINT Hub and use it as a homing switch for the encoder?
This can of course be done from the PC, but I was wondering if it can be done at the micro-controller level.
Thanks in advance.
Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests