Micrologix and HSC and PID

hounddog

Member
Join Date
Jun 2003
Posts
79
Have a motor that is rated a max speed of 1750 rpm. This motor will have a gearhead with a rating of 15 to 1. The max speed of the output of the gearhead will then be 1750/15 = 116.6, or 117rpm.

This will be coupled directly to some drive rollers, and a encoder will be mounted on one of the rollers.

This rate of 0-117rpm, will then be used as a master reference for another motor that will be slaved to it. I downloaded a sample file from AB web site that showed how to use a micrologix plc and determine rate, and it appears to work. I can place a tach on the head of a cordless drill which I am using to turn the encoder, and the value in the lad for the rate and the tach are the same.



How can I take this information and use the encoder that will be mounted on the second motor and set up a PID to then control the speed of the slave motor, which will have a encoder on it as well? The encoder for that motor will be a 0-1000 pulse per revolution encoder as well. What I am wondering is how can the rate value from the first motor be used to determine the speed that the 2nd motor will need to run, and a encoder that will be mounted on the 2nd motor to show the actual rpm from that motor showing that rate that motor is actually turning, both be used in a PID.

Would both the rate values have to be scaled for PID.

Attached a sample piece of code where I used a SCP instruction on the bench to try and scale a analog output based on the rate from the input. Not quite sure how to use a PID instead of the SCP.
I have been reading all of the post that deal with PID, and still a little confused.


Have not ever had a project where I used the PID, and any advice would be appreciated. I hope my explanation is understandable.



Thanks
 
I wouldn't think you need a PID at all. You are getting a speed from a 'master' encoder already. Scale that value to the drive you want to follow the speed and send this to the drive via your command channel of choice (analog, DNet, CNet, etc.). If the slave axis isn't going the right speed either your speed scaling from the PLC to the drive isn't right or the drive velocity loop isn't tuned right.

By the way, how accurately do the speeds need to match? That might decide whether you need more hardware capability than you already have.

Keith
 
Thanks

The only thing I can say about putting it in a PID loop, is that the bossman has required that a encoder be put on the slave motor as well as the master.

The master will tell the slave to run, but if for some reason there is any reason why he wants a encoder on the slave motor so that it will be a closed loop type system.

I am sure you know how it is, when the bossman says that is the way it is going to be, no matter how right or wrong you might think it is, then that is the way you work to try and do it.
That is why I am working to figure out the best way to do that in a PID loop.
As far as accuracy, not exactly sure yet. There will be chemicals, and dye applied as the fabric is traveling, so accuracy will have to be pretty tight.
 
Originally posted by hounddog:

...a encoder be put on the slave motor as well as the master.

So the encoder is NOT wired to the VFD connected to the motor but to the PLC? Interesting implementation.

In the end it all comes down to scaling. In the plc make sure both axes are scaled to the same value for the same surface speed. Use a unit that is common to both items, like feet per minute. That way tweeking the scaling will be much easier.

You may need to perform further scaling before you send the values into the PID instruction. I don't know if the PID will take engineering units, if it needs to be percent or if it needs to be in an integer format up to some value.

Finally, make sure you use the master speed value as a bias to the PID instruction. There is no sense in waiting for the PID to generate a value you know you will need anyway.

The moral of this story is don't be afraid of scaling. If you try to wrap everything into a singe scale factor you will get very confused when you try to adjust things. If you have to scale multiple times, so be it.

Also, if you really need high accuracy, you shouldn't be doing this in a MicroLogix anyway. It is nowhere near powerful enough to do a high accuracy speed loop closure.

Keith
 
first attempt at PID

Here is my first attempt at PID

I am totally confused, and hope some of the PID experts on this site will give your advice.

N7:50 is the value from a encoder mounted on a roller driven by a motor that I reference as Chamber Mtr1. I only have one encoder at the moment, so on the bench, manually putting a value between 0-117 to simulate that the encoder from that roller has been scaled to be 0-117 rpm.

N7:40 is the rate from a encoder mounted on a roller that I reference as Main Motor Master Encoder. It is scaled to give a value between 0-117 for 0-177rpm.

From what I have read on this site as well as another forum site, I took this value and used a SCP to scale it to be between 0-16383 to be used in the PID as the setpoint.

I then took N7:50 ( which I manully put a value of 0-117 into )which is the encoder reading from the roller referenced as Chamber Mtr1 and used a SCP and used it as the Process Value for the PID.

As expected, when the encoder count from the first roller ( setpoint) increased from 0-117, the output from the PID, which I fed into another SCP to give a output of 0-10v increased when I had a value of 0 in N7:50.

For example, if the setpoint for the PID saw a value of 117, then the output from the PID that is going into the SCP, caused N7:53 to be 31206 (output of 10v)

If I manually increased the value of the process value from 0-117, the output decreased.



Here is where I am confused. The first encoder will see a speed that a roller is turning, and if the second encoder sees that the second roller is running slower, then the 0-10v signal out to the motor will be high enough to cause the second roller to turn faster, once the two encoders see the same speed, the PID will cause the output N7:53 to go down.

How can I use N7:53 to control the speed of the second motor that is being used to control the roller for the second encoder?

I know this has to be not as difficult as I am seeing it at the moment, but it appears that if the two encoders saw the same value, then I would be sending 0v out to the drive, and the drive would not be turning. This would cause the fabric to just be what is causing the roller to turn and not the motor.

Could someone take a look and tell me if I am just way out in left field, or that I just do not fully understand how to use a PID to ensure that motor 2 is running the same speed as motor 1, with encoder feedback from a roller driven from each motor.

Have to be honest, been messing around with this for a couple of weeks, and seem to be getting nowhere. It is a project that I have coming up in a couple of weeks, so now seeking advice.

THANKS A LOT IN ADVANCE FOR ANY GOOD ADVICE TO HELP ME OVERCOME MY CONFUSION, FROM
 
If I understand you correctly, the master conveyor will run at some set speed and the slave will follow the master using feedback from encoders.

If this is correct, you should have one PID loop which controls the slave speed. The PID output is the slave speed, the PV is the RPM of slave, and the Setpoint is RPM of master.

Looking at your program, it looks like the Setpoint is RPM of master which is correct but, in the PID settings, you have no Setpoint MAX entered. The PV should be RPM of slave, not master. The CV should be the speed output for slave, not master.

The PID also needs a Output Max (100%) and a Rate Ti. With a Ti of 0, the PID output will never achieve the desired output. It will only use the current error to add to the output, not the accumulated error over time.

This should get you started in the right direction.
 
gmferg said:
If I understand you correctly, the master conveyor will run at some set speed and the slave will follow the master using feedback from encoders.

If this is correct, you should have one PID loop which controls the slave speed. The PID output is the slave speed, the PV is the RPM of slave, and the Setpoint is RPM of master.

Looking at your program, it looks like the Setpoint is RPM of master which is correct but, in the PID settings, you have no Setpoint MAX entered. The PV should be RPM of slave, not master. The CV should be the speed output for slave, not master.

The PID also needs a Output Max (100%) and a Rate Ti. With a Ti of 0, the PID output will never achieve the desired output. It will only use the current error to add to the output, not the accumulated error over time.

This should get you started in the right direction.

thanks for input
Apologize for confusion in my labeling in the program.
These are two seperate encoders on two different motor/rollers setup.
The Master motor is the RATE MAIN MOTOR MASTER ENCODER, which i used for the setpoint
The slave motor is CHAMBER MTR_1 MASTER ENCODER, which i used for the process value.
So If i set the Output max (100%) and the Rate Ti, then does what I posted seem to be correct.

Still trying to understand all i can about the PID loops, been out to rons website and downloaded all of his material about pid, but still working to fully understand it.

Thanks
 
Recall what I mentioned about bias in post #4?

If you don't use this bias you will need the PID integral term to come up with this difference. I suspect you have only entered a proportional gain in your controller. If this is the case then, as you said, the PID output will be zero when the PV=SP. However, if you have any integral gain and the error stays around long enough the integral sum will increase until the required output is reached.

But let me say this again just so I am clear.

YOU KNOW HOW FAST YOU NEED TO GO BASED ON THE MASTER ENCODER SIGNAL. SEND THAT OUT IN PARALLEL WITH THE PID OR SEND IT INTO THE PID AS A BIAS. THERE IS NO SENSE LETTING THE PID INTEGRATOR COME UP WITH A VALUE YOU KNOW ALREADY KNOW YOU WILL NEED.

Keith
 
kamenges said:
Recall what I mentioned about bias in post #4?

If you don't use this bias you will need the PID integral term to come up with this difference. I suspect you have only entered a proportional gain in your controller. If this is the case then, as you said, the PID output will be zero when the PV=SP. However, if you have any integral gain and the error stays around long enough the integral sum will increase until the required output is reached.

But let me say this again just so I am clear.

YOU KNOW HOW FAST YOU NEED TO GO BASED ON THE MASTER ENCODER SIGNAL. SEND THAT OUT IN PARALLEL WITH THE PID OR SEND IT INTO THE PID AS A BIAS. THERE IS NO SENSE LETTING THE PID INTEGRATOR COME UP WITH A VALUE YOU KNOW ALREADY KNOW YOU WILL NEED.

Keith

Thanks
Hate to look so dumb, but i guess i am, will read more about the pid tonight and your info as well.
Could you explain how you send it into the PID as a Bias. I looked at the instruction, and could not see how you would do that. Is it the same as putting the setpoint
 
It's not a smart/dumb thing. It's more a myopia thing. If the boss wants the see and you feel you need to show him a PID, then do what you need to do. However, this doesn't mean the PID can be the only source for the command. It also doesn't mean the boss is right just because he is the boss. It just means he is the boss.

It looks like the MicroLogix PID has a field for feed forward but no variable tied to it. So you will need to add a bias in parallel with the PID.

Use an open integer element for the output of your PID. Add this value to the scaled speed of the master, which in your case should the the setpoint for your PID. Send that out to the slave drive. By doing this the PID doesn't need to come up with the speed value that you already know is needed based on the reference. It only needs to tweak the speed command to the slave to conmpensate for non-linearities or scaling errors.

Keith
 
kamenges said:
It's not a smart/dumb thing. It's more a myopia thing. If the boss wants the see and you feel you need to show him a PID, then do what you need to do. However, this doesn't mean the PID can be the only source for the command. It also doesn't mean the boss is right just because he is the boss. It just means he is the boss.

It looks like the MicroLogix PID has a field for feed forward but no variable tied to it. So you will need to add a bias in parallel with the PID.

Use an open integer element for the output of your PID. Add this value to the scaled speed of the master, which in your case should the the setpoint for your PID. Send that out to the slave drive. By doing this the PID doesn't need to come up with the speed value that you already know is needed based on the reference. It only needs to tweak the speed command to the slave to conmpensate for non-linearities or scaling errors.

Keith

Thanks Keith
Could you add that code to what I posted. I just am not quite understanding it.
I probably should just let this die, until the ab rep comes in, but from talking to him over the phone, he seemed to be as confused as me, that is why i posted to try and get some help.
I can take the value from the first encoder, and scale that and then use that to value to know what value to send out to another motor, based on the percent value from a display, but totally lost on how to implement a pid for the second motor. Everything seems okay, until I manually put the value for the second enoder in that matches the first, as you know that is when the pid/scp output goes to 0, which is what will stop the motor temporarily.
Hate to keep bothering anyone, but just lost,lost,lost. PID is very new to me.
 
I posted some changes. Everything is in rung 8. The PID setup now has a value of 8192 set in the feed forward field. In addition the branch under the PID subtracts 8192 from the PID output. This is a way to allow for bipolar correction even though the instructions doesn't want to.

The branch under that implements what I have been calling feed forward. N7:9 is the target speed. You have everything scaled equally. So make N7:9 part of the slave command right up front. That is the value you want to reach anyway. Don't make the PID figure that out. Just send it out.

A man smarter than I sugested that since you are using encoders you could just do a simple proportional correction on the scaled difference between the actual positions. But without knowing how the MicroLogix handles rollover you may want to steer clear of that. What I have shown should get you pretty close. Start wiith proportional only correction. Add some integral if you have a steady stated error you need to get rid of.

As a side note, don't expect too much from your AB rep. His expertise is really in getting the instructions into the plc. He can't be expected to understand your process nor be able to develop a software solution to it. This is kind of like calling Black & Decker becasue you don't know how to cut your roof trusses so they match up. The Black and Decker guy will tell you to plug in the saw and pull the trigger but that doesn't really answer your question.

Keith
 
Thanks to everyone for your advice.
Also got some good advice from Mrplc.com that helped me as well.

What I did, was take the two values from the encoders, and feed the first encoder as the setpoint for the pid and the second encoder as the process value and output the result of the pid and added that to the value going out to the slave motor. Works great on a small test setup. Still just in the planning stages at the moment, got to get some other projects completed first, just trying to keep this one in the back of my mind when I get some spare time.
Right now, its just a test, End machine will still have a master encoder, and then 32 other motors that will be slaved to it.
With the final, will end up using either Control logics or maybe even a Omron. Not quite decided yet.
Thanks to everyone for your advice, but actually a guy that I know that I spoke to that has been doing this longer than I have, gave me some advice that led me in the right direction.
Was not asking anyone to write the code, only for assistance. Had me stumped for a few days, until I just put it to the side, and when I came back a few days later, boom-saw a solution very quickly.
I been working on a chemical tank farm with 45 chemical tanks for Dominican Republic and using a Omron CJ1 and Indusoft and the Allen Bradley just had me pretty confused.
Folks like TWcontrols and some others who use this site have been very helpful, always look for what they post.
This site has been very helpful, especially when you trying to do multiple projects with AB, Omron, Setex and Indusoft at the same time, especially when not as talented as some folks who use this site, with plcs.net and mrplc.com, would be totally lost half the time.
Thanks
 

Similar Topics

Hi, everyone I’m working on a registration project where I’m counting encoder pulses between registration marks. I’m expecting to see around 1800...
Replies
2
Views
444
I am trying to program a Micrologix 1400 to control a beer keg filler using an IFM SM6001 flow meter. The meter will be set up for a pulse...
Replies
5
Views
1,850
Is it possible to set up the HSC in the 1766-L32BXB as a ring counter. So it will roll over to 0 counting up and continue to count up that...
Replies
2
Views
1,102
Hi everyone first of all. This is first question in the forum. I am using HSC application. I'm reading A and B pulse count. 1 round of the motor...
Replies
12
Views
4,378
I am using a Micrologix 1400 high speed counter to monitor an encoder on a rotating shaft. I have an STI running every 2ms which takes the encoder...
Replies
5
Views
2,177
Back
Top Bottom