PID Dual Motor Control with PIC18F4685
Moderator: Benj
PID Dual Motor Control with PIC18F4685
Hi everyone, i am trying to control 2 motor to keep the same speed with PID algorythm, But i got some problem, On the Flowchart i upload here, i try to update the PID 100 times per second, but i am pretty shure it is not doing it that often, right now at 100 times per second, i got about 106 encoder impulsions at full 16 000 rpm But i got bigh problem being able to tune the PID value, I have brought down the error ratio to get it on 255 value since the Duty Cycle is on 255, but still it is not stable at all. Can some of you take a look at this and maybe give insight on how it can be done properly? I am still learning a lot, maybe i don't call the macro at a good place!! Because right now as soon as i go over 1 for P,I or D multiplicator, it got crazy! Thanx a lot!
- Attachments
-
- WIP_PID.fcf
- (73.7 KiB) Downloaded 343 times
Re: PID Dual Motor Control with PIC18F4685
I have just made some more testing and have found that because of the LCD write command, the PID is running only once every second, Is this normal, As soon as i write 1 line on the LCD, The program loop only once a second. Is there anyway to use the uLCD-32PT without loosing too much speed on the program loop ? If i remove the LCD from the loop, it got to 2500-3000 loop per second. But i cannot get the PID update loop to go over twice a second, Can someone tell me what i am doing wrong here? Because, as it is now, there is no way that can be usable! Thanx a lot everyone!
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: PID Dual Motor Control with PIC18F4685
Hi Speedy2k,
What about using timer interrupt to set a flag to 1 every 500ms or 1sec for example.
Then when flag = 1 call both gLCD macro's : Set Flag to 0
Since you have already got scrn_updt every second, I have use this.
Martin
What about using timer interrupt to set a flag to 1 every 500ms or 1sec for example.
Then when flag = 1 call both gLCD macro's : Set Flag to 0
Since you have already got scrn_updt every second, I have use this.
Martin
- Attachments
-
- WIP_PID1.fcf
- (74.74 KiB) Downloaded 327 times
Martin
Re: PID Dual Motor Control with PIC18F4685
Yea, this is what i have done, but it only bring the pid update rate to 2 times per second, is it normal that the pid calculation, the adc read and the to duty cycle change slow down the chip like that?
Re: PID Dual Motor Control with PIC18F4685
Ok i have worked on this pretty hard and i think i have found a way to force the PID update 20 times per second, But now i got a LCD problem. i have done a choice from 1-4 each choice are different gLCD pages. Everything goes fine until i got into option 4, the graph is going pretty well all is good, but as soon as i repush the button to go back to graph 1, The chip just hang there, timer are still running, but the main program just seems to stuck there and i cannot find why!!
Here is the flowchart, probably it is obvious, but i am really in eed of some help on this one!! But i still don't understand why i cannot get much refresh rate then that on the LCD, in the graphic mode it is going pretty fast, but every other page are not faster the 4 update per second, the page 4 (Graph) goes to 20 update per second.
Here is the flowchart, probably it is obvious, but i am really in eed of some help on this one!! But i still don't understand why i cannot get much refresh rate then that on the LCD, in the graphic mode it is going pretty fast, but every other page are not faster the 4 update per second, the page 4 (Graph) goes to 20 update per second.
- Attachments
-
- WIP_PID_TESTING2.fcf
- (72.96 KiB) Downloaded 374 times