![]() | |
| Home Page | Mark Forums Read | Today's Posts | My Replies | Classifieds | Reviews | Photo Gallery | Web Links | Share Files | Advertise With Us | Ad List |
| |||||||
| Servo Motors and Drives Discuss servo motors, drivers and other related topics here. |
| This forum is sponsored by: |
![]() |
| | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
| |||
| |||
Hi, I have implemented a new pid algorithm with delphi for controlling a small DC motor with an encoder attached. When I enter a coordinate motor reach there with pid corrections. It works fine. I will now implement the code in an atmel or pic microcontroller. I will use this servo driver circuit with mach3 so it has to work with pulse and dir signals form pc parallel port. Please let me know what kind of change has to be done with the algorithm. Regards, Nuri Erginer |
|
#2
| |||
| |||
| The algorithm has to be changed such that it takes step/dir inputs and adjusts the motor position accordingly. Hope this helps. But seriously, you are not very clear on what you are asking. The encoder is your feedback element The step and direction lines are your control (desired position). The error is going to be the difference between your desired position and your true position (from the encoder feedback). The PID algorithm deals with correcting that error. |
|
#3
| |||
| |||
It is hard to tell but I will try; Suppose that you are at position 0 and want to go to position 100. It is easy to implement that with pid. Calculating the error and check if you are at position 100. But it is hard to understand the last position from incoming pulses. Will I wait and count them all up to the last pulse or will I just correct my position for every single pulse? Regards, Nuri Erginer |
|
#4
| |||
| |||
| Just create a signed variable called TARGET_POSITION, initially set to zero. Whenever a step pulse come in, you will either increment or decrement the variable, depending on the DIR signal. You PID algor will simply run continuously to put the rotor at TARGET_POSITION. Mach2 does not output absolute positions, just pulses. |
|
#5
| |||
| |||
I see what you are saying But there will be a delay for the system to go to the target position. What will happen if the direction signal changes at that moment and the target position degreased before the system reached the desired location? |
| Sponsored Links |
|
#6
| |||
| |||
| If your code is implemented properly, it will continuosly recalculate the drive current, hundreds of time per second. If the direction changes, the PID code will just continue to re-calc the drive level. If your system is well tuned, the motor will be able to track the command position will only a slight lag. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
| |