Discussion forum for the BasicX family of microcontroller chips.
|
PID code Version 1.1 Dear BX folk, This is the PID code for the BX24 that I adopted from Martin "The Selma Man" Hebel's adoptation of PID algorithm for BS2. It is a straghtforward approach without "auto-tune", "adaptive logic" or any other useful sophistications. This is, so to speak, the plain hamburger of PID. A good controller does not have to use all P, I and D parts. PI controllers sometimes work better in a noisy environmen. You can switch these parts of the algorithm off by assigning 0.0 to their K's. For instance in this code Kd = 0.0. That means that the D from PID is Off and effectively its a PI controller. This code lacks the "minus drive", like an active cooling action for a heating application. You can easily add that yourself, since the sign of the Drive is is preserved. Martin also did a very nice job of making a beautiful Selma Plot application for monitoring and tweaking all the PID variables in the BS2 incarnation of this code. One can only hope that he will do the same for us one day. However, the commented codeline included to watch the sensor output on SelmaWare V2 or 3. Somehow its different on free version 1, so use V2 or 3. This appears to make system unstable, althought it works most of the time with no problems. Other weird stuff - 1. Delay(0.25) call in the main loop of the PID code if deleted makes everything stop working. Sleep(0.0) does not help. Even adding Sleep (0.0) statement after the Delay statement usually hangs everything. The absense of the debugger drives me crazy! An addition of the auto-tune or adaptive code would be also exciting. As far as I know, these algorithms are mainly proprietary for now. If anyone knows different, please, let me know. All and any suggestions will be greatly appreciates, along with criticism, sneers, applause, and cases of French wine. But no fruit baskets, please. I hate fruit baskets. Alex Chaihorsky Reno, Nevada. |
|
|
|
Thanks for the post, and the kind words. Being in education, it's nice to be appreciated sometimes. Though I'm not setup to test it out, it looks good. I could recognize the main body :) Are you currently trying to plot with StampPlot? I looked through several modules but didn't notice any serial comms (other than the serial module). The example I have on the site should plot reasonable well with a few lines of code. I can try to adapt for that if anyone is interested, though it would just be using standard Debug.Print. I'm rusty on BX 24 serial control. I had some old BX 24 examples doing duplex comms, but that was before the Vals functions were added, so should be even easier now. Might have to dust off my BX 24..... While also playing with an Atom, and finishing up a Javelin class example.... all the while putting finishing touches on StampPlot V3.... and getting ready to teach the 8051 this summer.... and working on a tutorial for the BasicStamp.... so much micro fun I could explode... Well, rambled enough.... If you all need any help with BX-24 and StampPlot, drop me a note. I only glance over the summaries from the yahoo groups these days. -Martin http://www.selmaware.com/stampplot --- In basicx@y..., "biovirus1" <alex_chaihorsky@h...> wrote: > PID code Version 1.1 > > Dear BX folk, |
|
|
|
--- In basicx@y..., "selmaware" <martin@s...> wrote: > Thanks for the post, and the kind words. Being in education, it's > nice to be appreciated sometimes. Well, it is partially your fault. there is no info on you on your site, no photo and nothing that would make a personal connection. The only reason I know your last name is because I got some mails from you in the past. :) We are ready to be greatful, but you have to make yourself available. > Are you currently trying to plot with StampPlot? I looked through > several modules but didn't notice any serial comms (other than the > serial module). There is one commented out statement in the code that plots the sensor temperature. It appears to make the program unstable, although most times it works good. > The example I have on the site should plot reasonable well with a few > lines of code. I can try to adapt for that if anyone is interested, > though it would just be using standard Debug.Print. I'm rusty on BX > 24 serial control. Look at the total numbers of messages on yahoo basicx and basicstamps. Its roughly 1/2 -1/3. That would be the ratio I use to divide my efforts between the platforms if I were in a business similar to yours. Having SP talking to BX24 would be wonderful for this community. And for your sales. I would gladly recommend my customers to buy SelmaPlot to tweak the PID on site. That is easier than to spend hours on the phone with them. > > I had some old BX 24 examples doing duplex comms, but that was before > the Vals functions were added, so should be even easier now. > -Martin > http://www.selmaware.com/stampplot Just do it, Martin! You have a fabulous product, just make it easy for us to work with it. You won't regret it. Respectfully, Alex. |