Other Parts Discussed in Thread: DRV8301
Hi,
A bit of background first. We are developing a new elevador door control system, we have an old desing that we want to migrate to instaspin. We bought the DRV8301 kit and we are spinning the same bldc motor we already use. We already identified the motor and the inertia succesfuly and ran all the labs, so I already know the basics of instaspin. As my main area of expertise is not microcontroller programming, and the project is estimated to be finished within 3 or 4 months, i need some advice.
Our idea is to implement a position control with an encoder feedback. Right now the encoder and the position planning is working correctly.
We now want to include a routine to automatically recognice the distance between the Open and Closed state. The idea is to start at any position, set a controlled opening speed, once the door is open this position will be set to cero (with st_posconv_obj->Pos_mrev=0). Then set a controlled closing speed, when the QEP velocity is 0 we assume that the door is closed and save the position Pos_mrev as the closed position. With this position we want to configure the position planning.
The problem I'm facing is that i dont really know WHERE to implement this routine. In order to spin the motor i have to enter the main loop, but i'm supposed to configure the position planning before this loop. The main ISR will also need to change, at first i just need to spin the motor without the position planning and after the recon routine i need to control the position.
My idea is to implement two main loops and two ISRs, one for the recon, and once the distance is measured, get out of the loop, reconfigure the ISR to another one using the position planning and enter the main loop to control the position. But i dont really think this is the most efficient approach.
Is this a good idea? How do you advice to solve this problem?
Thanks in advance.