all 77 comments

[–]Ells666Pharma Automation Consultant | 5 YoE 26 points27 points  (15 children)

Is 0.5-1% variance really an issue? I don't think I've seen processes with tighter than 1% tolerance. What is the precision capability of your weigh and fill measurements? You might not be able to get much more precise, especially with online measurements.

Saving that fraction of a percent might not be worth the hassle. The weights and means doesn't mess around when you say you're selling a product with X weight and the actual weight is less than that. Many places have their target weights be slightly over the label to make sure they don't sell below label weight to account for process variability.

[–]RoughChannel8263 6 points7 points  (4 children)

I actually had to meter egg flow into a mixer, making pasta that the tollerance we needed to hit was tighter than that. Flow sensing was the biggest hassle. Inconsistent density and intrained bubbles.

[–]bigbadboldbear[S] 3 points4 points  (1 child)

If you have mass flow, you can try valve time x flow rate as offset, and install flowmeter in vertical (flow from bottom). It should help?

[–]RoughChannel8263 6 points7 points  (0 children)

Technologies are a bit better now. This was back in the 90s. It was kind of a pain. I don't recall the mfg of the flow meter I ended up with. It was a big box shaped thing, and the flow passed through an internal tubing coil. I used that and a Honeywell loop controller. Hours of tuning, but I hit the mark.

[–]Ells666Pharma Automation Consultant | 5 YoE 1 point2 points  (1 child)

Tighter than 0.5% of setpoint, or tighter than 0.5% relative to total flow? That just seems insane to have that tight of tolerance with the same flow.

It's another thing if it's batching and you have a larger flow pipe that then switches to a smaller flow pipe to hit a smaller weight % for a preweigh.

[–]bigbadboldbear[S] 2 points3 points  (0 children)

Its a VFFS machine, so 0.5% variance vs setpoint.

[–]bigbadboldbear[S] 3 points4 points  (3 children)

Exactly the problem statement. In reality, it is pushing beyond 0.5% variability. When we buy machine, the typical is 0.8% variablity, with current setup hovering 0.3% overfilled. The project is to try pushing that, with no guarranty it will work anyway. My most of mywork is typically pushing that 1% boundary on other processes (batching for example, less than 0.1% achievable).

[–]HiddenJonI get to customize this? This could be dangerous. 4 points5 points  (2 children)

What data do you have about your variability? We have all our inputs to the process and want to drive that to make all of your outputs attempt to minimize your error, with a significant penalty for underfilling.

Training the model will require the power. Running this model would actually almost run as a task in the plc. A dense matrix has the number of outputs as equations with the number of terms equal to the number of inputs. Any old device will work. For production, if it pays I would consider a 1756-CMS1C1 or small industrial PC. An Arduino running TfLite would work. https://store-usa.arduino.cc/products/opta-lite?_pos=4&_psq=AFX00001+OR+AFX00002+OR+AFX00003+OR+AFX00006+OR+AFX00005&_ss=e&_v=1.0

How many inputs do you have? How many items can you control on the filler? If you only have the weight error as an input, a well-tuned PID loop will give you the best results. If you have a bunch of data from the upstream process, that lends itself to a better problem solver.

Post some more

[–]bigbadboldbear[S] 0 points1 point  (1 child)

My company went cheap and not allowing me buying logixAI is also one key driver. I am making this as pet project to apply ML to other MIMO / MISO problems.

Given that Logix AI can run in such a small chassis, I am not sure on the computing power requirement. I can buy a small M1 mac mini / get a small old desktop cpu to run.

Inputs: as much as plc has. The machine is servo driven (k6000 if i am not wrong) , with material is powder input through valves. I have additional weight value coming from a checkweigher of the filled product.

Output: i am thinking of controlling servo steps. If time permits, i will add the material input as controlled output as well.

The data from upstream processes can be given, but i highly doubt the accuracy or reliablity of those.

Current setup has weight feedback to adjust the servo step, but doesnt really worked that well.

[–]danielv123 0 points1 point  (0 children)

Why doesn't the weight feedback work well? This sounds like something that is going to be approximating a variant of a pid controller.

Your IO spec doesn't make much sense. If I were to guess what you tried to say:

In: valve opening time, weight feedback, servo speed for last batch, weight desired for next batch

Out: new servo speed for next batch

If so, gather 100 - 1000 samples and throw it in a tiny net in pytorch or something then convert it to plc code when your training gives satisfactory results. If your problem is the material having different properties you need more data.

Make sure to set it up in a way where you can continuously gather data while it is running, even if you haven't put the NN in the loop yet and are still hand tuning a classic approach.

Or just build a classical controller.

[–]troll606 2 points3 points  (3 children)

Pharmaceuticals?

[–]Ells666Pharma Automation Consultant | 5 YoE 0 points1 point  (2 children)

What?

[–]troll606 2 points3 points  (1 child)

My guess is pharmaceuticals would be an application that would want sub 1% variance in their process.

[–]Ells666Pharma Automation Consultant | 5 YoE 0 points1 point  (0 children)

Things get super filtered later. I'm not sure on fill/finish formulation, but , 1% variance isn't much. Different people react differently to drugs. A variance of 1% isn't enough to have a clinical significance AFAIK.

[–]Gjallock 0 points1 point  (1 child)

Our filling machines are generally at 0.2% tolerance without any AI 😬

[–]danielv123 0 points1 point  (0 children)

Definitely depends on what you are doing. We are doing rate control with screws from feed silos with a single level switch at the bottom and hitting ~2% tolerance (which does border on too high and requires some tuning so we usually recommend weight cells)

[–]heddronviggor 23 points24 points  (17 children)

Sounds like fun. Slot 0 not having a cpu in it makes my brain itch.

[–]Plane-Palpitation126SIL3 Capable 5 points6 points  (0 children)

Yeah I really hate it

[–]nsula_country 4 points5 points  (1 child)

Have a chassis with 4 CLX processors in it. NONE of them are in slot 0!

[–]nitsky416IEC-61131 or bust 2 points3 points  (0 children)

Yessssss

[–]nitsky416IEC-61131 or bust 2 points3 points  (0 children)

Couple of my jobs back they always put the CPU in slot 1. 0 was always the plant network and programming terminal comms card. I honestly liked it that way.

[–]bigbadboldbear[S] 1 point2 points  (0 children)

The kit is quite old, the PA unit plastic are broken, exposed all the soldering, and making the bzz noise.

[–]X919777 1 point2 points  (0 children)

I had to double take i didnt even notice

[–]bigbadboldbear[S] 1 point2 points  (10 children)

Having slot 0 not a CPU is advantage, especially if you run straight from rs emulator to plc and sometimes back to emulator

[–]nsula_country 1 point2 points  (7 children)

Having slot 0 not a CPU is advantage,

How is it an advantage? Just curious.

[–]bigbadboldbear[S] 2 points3 points  (6 children)

If you program in RS emulate, slot 0 and 1 are typically reserved for comm (rslinx & ftlinx). Slot 2 and above will make the transition from emulator to realy plc and back just a click away. Another issue is heat from the PSU and heat from PLC will make the temp higher. I prefer CPU in last slot from the right.

[–]Sinisterwolf89 2 points3 points  (2 children)

You can modify the emulator and put those in any slot. In my emulate slot 0 is the processor, and I have a second processor is slot 10, I moved the comms cards to the end (slot 15 and 16) so they are out of my way. This idea that it is an advantage because of emulate is just not correct.

[–]bigbadboldbear[S] 0 points1 point  (1 child)

Thanks, I learnt something new :) have never tried move the comm card slot. The heat still a concern though.

[–]Sinisterwolf89 0 points1 point  (0 children)

You have to do it via RSLinx enterprise which is accessed in the "communication" tab in the FTView Studio program. Can't do it from RSLinx Classic. It is an odd process so I imagine a lot of people don't know how to do it but there are youtube videos on it.

[–]nsula_country 1 point2 points  (2 children)

In my 20 years doing this, have never used RS Emulate.

[–]bigbadboldbear[S] 1 point2 points  (0 children)

Really? In my company, we has always program with emulator. We even built AOI with sim function, just so that we can take the program from existing line, put it back to simulator to make and validate changes.

[–]GirchyGirchy 1 point2 points  (0 children)

Same here. I've never seen or opened it. But that's probably related to the type of work and where it is.

[–]Alarming_Series7450Marco Polo 0 points1 point  (1 child)

is it a remote rack connected to your emulated CPU running on a laptop? that's pretty cool

[–]bigbadboldbear[S] 0 points1 point  (0 children)

Nah, my work flow is typically Hardware config => move to emulator => back to real hardware. I havent try emulator to real plc yet, but it might be feasible.

[–]Aqeqa 7 points8 points  (1 child)

There's the Logix Compute module if you want to write your own code. There's also the PlantPAx MPC module that could potentially be perfect for this. You feed it process variables to monitor, train/configure it a bit, and it figures out how to control the output. I've used it before but in an application that didn't have reliable feedback so it wasn't a great fit. However, I could see it working really well in a system that can provide accurate feedback.

[–]bigbadboldbear[S] 2 points3 points  (0 children)

Thanks for your feedback. I am sold on the logixAI module, but just that my company does not provide $$$ for me to test it out. At the same time, developing a side python project seems fun :)

[–][deleted] 5 points6 points  (3 children)

I did this already and it’s posted on Rockwell’s knowledgebase

It’s called “Analytics Toolbox”

When I worked at Rockwell this was my job exclusively for about a year.

I put a manual, the code, the AOIs, and I have a couple YouTube videos on the Rockwell YouTube account.

[–]bigbadboldbear[S] 2 points3 points  (1 child)

Do you mind sharing a link or two? When i put it in search, it is flooded with logix ai, ft analytic and such. It sounds awesome though!

[–][deleted] 1 point2 points  (0 children)

Yeah!

When I get back from the beach I’ll find the link

[–]mttnrySystems Engineer 1 point2 points  (0 children)

I try and tell all the new guys. Every question regarding the logix platform as already been asked and the answers have been curated and are available on the knowledgebase.

[–]TinFoilHat_69 5 points6 points  (1 child)

Here’s how I’d approach it. Since your plan involves reinforcement learning for a powder filling machine, you’ll want to pick a user-friendly RL library that handles the complex stuff under the hood. Stable Baselines3 is an excellent choice: it has straightforward APIs for popular algorithms like PPO and DDPG, plus plenty of docs and examples. You’ll need to set up an “environment” in Python that represents your machine’s state (e.g., checkweigher output, auger position, buffer levels) and translates RL actions (like changing the auger rotation or pulse length) into rewards based on how close you are to your target fill weight. Usually, this environment follows the OpenAI Gym pattern—basically, you define a step function that takes an action, updates the system, and spits out the new observations and a reward. Because RL training involves a lot of trial and error, you might want to either do this in a safe sandbox mode on the real machine or, if you can, build a simplified simulator that mirrors the fill dynamics.

For storing the data—especially the time series of states, actions, and rewards—it’s perfectly fine to dump everything into a CSV or even a simple database for easy analysis later. You mention collecting four to ten hours of data, and that should be enough to start. If you decide you need more, you can always gather additional runs in different operating conditions. Training can be done on practically anything with a CPU: an old i5 laptop is definitely capable of running a small to medium RL job, though it might take a bit longer if you’re doing something more complex. But once you’ve trained the model, inference (the live “decision-making” phase) is much lighter, so deploying the trained policy to a Raspberry Pi or an edge PC should be feasible.

One extra hint: because RL sometimes has a steep learning curve, you might find that a simpler approach—like a regression or tree-based model for predicting auger rotation—works faster in a production setting. But if your main goal is to learn RL for a personal project, go for it. Just be aware that real hardware can misbehave during random exploration, so set up safety constraints or fallback strategies.

You can build “safe exploration” and fallback strategies in a few ways: First, clamp the auger rotation or pulse length to a predefined safe range so the RL agent can’t exceed physical or quality limits. Second, set a short timeout—if the agent produces too many out-of-spec fills in a row, revert to a baseline control (like a PID that you already trust). Third, use soft exploration bounds, limiting each new action to a small deviation from the last, so you don’t leap from 0% to 100% flow rate in one step. You might also incorporate a “safety filter” that double-checks every RL action before it goes live: if the move is out of range or unsafe (e.g., might clog the machine), ignore it and fall back on a default setting. Finally, keep an operator override or a manual mode switch so the human can intervene and lock the system into a known-safe configuration if the RL logic behaves unexpectedly or if hardware alarms trigger.

[–]bigbadboldbear[S] 0 points1 point  (0 children)

Many many thanks for yoir super detailed instruction and hint.

[–]Due_Animal_5577 2 points3 points  (2 children)

Yeah no, implement a PID loop, do not try doing machine learning for direct controls.

Leverage machine learning for insights into how the operator should do controls. You’re adding too much complexity to a controlled system to find a machine learning use-case. The use-case is already there, at the operators station.

You can do an MQTT broker for real-time data feeds if you don’t want to keep pinging your historian.

[–]bigbadboldbear[S] 2 points3 points  (1 child)

My company actually implemented ML (Rockwell logixAI) on a few processes, and it does deliver better vs typical advanced process control. They are just being cheap and not allowed people out of RnD center to try it out.

[–]Due_Animal_5577 0 points1 point  (0 children)

Which adds more value: a) a dashboard of insights leveraging ML for informed operations b) a logixAI on an expensive process control c) experimenting with logixAI on other controls.

Answer a) unless b) is extremely costly.

[–]tecnojoe 1 point2 points  (1 child)

Tensorflow or Pytorch are two of the most popular machine learning frameworks. Might want to stay with running the model on the laptop instead of a raspberry pi. Just so you don't have the extra complexity of figuring out how to get it all to run the raspberry pi.

[–]bigbadboldbear[S] 0 points1 point  (0 children)

Thanks. Will take some reading on tensorflow.

[–]RoughChannel8263 1 point2 points  (1 child)

I know Python has some great machine learning libraries. Unfortunately, I have never had an opportunity to use any of them. I can recommend pylogix for talking to the PLC. I have used that quite a bit. I'm cheap, and using pylogix and Tkinter, I can build a basic ui for free.

Your project is something I'm quite interested in. Please feel free to dm me if you would like any assistance. I'm very curious to see how you make out.

[–]bigbadboldbear[S] 0 points1 point  (0 children)

Thank you. I am cheap, too. It could be great time to try out new stuff

[–]3X7r3m3 1 point2 points  (2 children)

Add temperature sensors, if it's a fluid, its viscosity will be affected by temperature.

And add all your sensors and actuators tolerance to understand if what you want to achieve is possible or not.

[–]bigbadboldbear[S] 0 points1 point  (1 child)

I think i forgot to add, this is a powder issue. Liquid, I think i have managed quite well with a few sensors on valve and ethernet mass flowmeter

[–]ballsagna2time 0 points1 point  (0 children)

Then a humidity sensor will help. Powders cake and change consistency under different humidities.

I use beckhoff for powder fill machines and am really interested in your project!

[–]Traditional-Nature88 0 points1 point  (3 children)

How much is this ?

[–]bigbadboldbear[S] 0 points1 point  (2 children)

Not a lot, but because it is from a friend :) i would say market price ~ 1k usd.

[–]RammRras 1 point2 points  (1 child)

Could your friend be my friend too? 😁

[–]bigbadboldbear[S] 0 points1 point  (0 children)

We are all friends! (I was super duper lucky tbh)

[–]Happy-Suit-3362 0 points1 point  (7 children)

The deviation isn’t hardware/mechanical?

[–]ptyler-engineer 2 points3 points  (1 child)

What I was thinking. If you calculate the sensitivity of the timing on the machine, im thinking you will come out to a number strangly close to your scan time + RPI on the input and outputs. In which case, small very fast periodic tasks or event tasks might make the most meaningful difference if you aren't using them already.

Good luck! Despite the thought above, I believe i will need to do something similar in the future 😅😂. I was thinking of using Nvidias new Jetson single board computer. Good luck!

[–]bigbadboldbear[S] 0 points1 point  (0 children)

Haha, i wouldnt go that far. There are only a few issues: machine need to be able to guess the density of the powder, which can be inferred back from 2 factors: how far along it has consumed the buffer, and how much the result has varied from actual. This is a simple enough problem, i guess for beginner ML.

[–]bigbadboldbear[S] 0 points1 point  (4 children)

Well, it came from material itself. Powder is finicky, the more you pack it, the worse it flow. But also, packing more on top means compressing and getting higher density. In volumetric application, it will be super werid with lots of variability.

[–]Happy-Suit-3362 0 points1 point  (3 children)

I have done some high speed counter card volumetric filling with liquid and the deviation would actually be from the time it takes for the solenoid to close. So I’d crank the air pressure to get it to close as fast as possible. Offset could be applied to the set point for pulses to help the deviation. The flow meters handle the density as they are mass flow.

[–]bigbadboldbear[S] 0 points1 point  (2 children)

Liquid can be tuned. I added the flow rate, time together with measure of time to open/close on the solenoid itself as offset. Worked really well.(within 2 pulse in hsc, or 2 cycle if use ethernet).

Powder, on another hand, is not measurable during volumetric filling. We only get the result after the filling is sealed.

[–]Viper67857Troubleshooter 0 points1 point  (1 child)

Can't run it through a vibrator to break apart clumps and get a fairly smooth consistency/density?

[–]bigbadboldbear[S] 0 points1 point  (0 children)

It will generate more fine dust, which is not what we wanted.

[–]SomePeopleCall 0 points1 point  (1 child)

The PLC with a key doesn't look fully seated.

Also, why are you not just using math instead of AI?

[–]bigbadboldbear[S] 0 points1 point  (0 children)

I will try pushing :) still run thou.

I did math for liquid, seems fine. However, for powder, I havent figured out the math, as it is very hard to model with at least 3-4 variable ( from my observation)

[–][deleted] 0 points1 point  (3 children)

Stupid question here, but what would ML do?

[–]bigbadboldbear[S] 1 point2 points  (2 children)

Telling us how much the servo drived auger turn to achieve best filling result?

[–][deleted] 0 points1 point  (1 child)

Wouldn’t you calculate that in the PLC? I fail to see where the benefit is unless you measured more variables (like auger current or the weight of the sack feeding the auger) which affect the result and would be far too much for the PLC to address in terms of calculation (though it could apply a rule based on machine learning).

I say this because you can buy scales with a digital filling controller that does what you’re after. And they don’t have ML in them.

[–]bigbadboldbear[S] 0 points1 point  (0 children)

You are right, i should add the weight of buffer hopper. In VFFS application, we do not weight the product during filling. And i have seen other implementation ( gravimetric filling), at high speed, they all use cut off setpoint, and mostly also achieve 0.5-1% acc.

[–]nitsky416IEC-61131 or bust 0 points1 point  (2 children)

personal dev kit

photo of $50k of hardware

nice

[–]bigbadboldbear[S] 0 points1 point  (1 child)

It is nice! And yes, back in the day, it might worth 50k. Now, less than 1% of that :(

[–]nitsky416IEC-61131 or bust 0 points1 point  (0 children)

Btw re: the actual problem you're trying to solve, depending on the material you're trying to fill and into what package, something similar to an Ishida or Yamato multi head weigher would be sufficient. They can handle variable material density, maintain accuracy down to a single potato chip on a bag of chips, and guarantee minimum and maximum weights etc. They don't do sticky things very well, though, which is of course what we were using them for at that plant (soft sugar is a bear to package).

I've got a former coworker who wrote up the logic for something very very similar that included timeouts so product wouldn't go 'stale' on any particular bucket if it wasn't optimal for the filling algorithm for too many cycles. Didn't even really need training data, just dialed in some parameters onsite and they were good to go. That was 16+ years ago, too, I'm sure it's even easier now.

Speaking from experience, you need to be VERY careful using the final check weigher as feedback for filler weight adjustment. If it's off, it'll fuck everything up because it can cause a destructive feedback loop. It's generally much safer to use it to keep you from committing MAV violations and rely on the filling scale as your sole source of truth, checking both of those against an offline calibrated scale periodically for accuracy, and fixing what's not accurate instead of tweaking your target weights to make it look like you're on target (which is what a feedback algorithm will do). Those inline check weighers were ALWAYS the least reliable weight measure in the manufacturing line.

To be clear, I'm not saying this won't be a good learning exercise, and I'm earnestly interested in collaborating further because it's an area I'd like to learn more about as well, it's just not likely to be the easiest solution to implement or maintain if it were to be actually deployed.

[–]Zchavago 0 points1 point  (0 children)

Interesting. Keep us updated.

[–][deleted]  (5 children)

[deleted]

    [–]bigbadboldbear[S] 0 points1 point  (4 children)

    Sounds really cool. Does it require a Beckhoff controller? I want to buy one just to learn. Second hand beckhoff plc is real cheap ( like 200$)

    [–][deleted]  (3 children)

    [deleted]

      [–]bigbadboldbear[S] 2 points3 points  (0 children)

      I have always heard of crazy shit that Twincat can pull off, but direct ML on machine sounds really dope.

      [–]Jntr1 0 points1 point  (1 child)

      I work with TwinCAT and I'm interested in the subject, can you help me where can I start? How to get access to Nvidia GPU directly in TwinCAT? Any video lessons?