Are there any commercially available PLC's that can compile/ download programs through an API?

You can definetely use a PLC for this. Except, you don't want to change the PLC code for each "smoothie recipe".
You should write a PLC application that reads recipes from any source, like sd cards, network storage, internal storage or even QR codes if you're feeling fancy.

Often PLC's already have a feature for this, where a recipe is a set of parameters you can load (and edit with the HMI).

real-time IO to external devices with minimal processing

Whatever you choose to use, do not invent your own PLC. It's probably not worth the time. And don't think the software or additional module is expensive, you are not able write it for that price.

I will assume that this is a pretty simple task for a minimal plc, rather than something using advanced industrial PLCs

I will also assume that this is industrially useful, which is to say, that the recipe should be able to be changed in 10 years time, by the customer. Also that its usefulness should survive you going out of business or moving on to new products.

Many systems will require some special piece of software to download and/or compile, as you say. In the long term , your customers will find that Windows 11,12,13 won't run the software anymore. To avoid this, you want the program to be plain ascii, sent over a serial port of some kind. This has been going for about 50 years now, and shows no sign of disappearing.

Forth is able to be "compiled" on the target, so the customer only has to send ascii to it from a terminal. It will never be obsoleted.

Part of the Forth ethos, is that you write domain specific primitives ("AddBanana", "Blend", "Pour") that your customers treat as a specific language for the product. While Forth is considered arcane by computer people, it is conceptually very easy to use for end users - this would be a valid program.

10 grams Thickener 500 grams Banana 15 seconds Hi Blend 50 grams Blueberry 5 seconds slow Blend Pour 5 seconds wait CleanCycle

As an example you could use a small Arduino based PLC and load FlashForth There are many other choices, e.g. MPEForth and an ARM -cortex based PLC

Your software is now any editor, and some program to send serial. There are standard tools for this, and long after you are gone, the customer can make it work from scratch, as it is so simple.

A failing with your whole idea, is that the customer is programming the product and can of course stuff it up by doing the wrong thing - whatever apporach you take.

Because it is just ascii files, its quite easy for you to make a fancy shell for the customer, but the product still will work without it.

Don't mess with Arduino, etc., for an industrial application. PLCs are designed with reliability, robustness, standards and long-term support in mind. The company I work for is running at least one Texas Instruments PLC since 1987 and several others from the early 1990s. Spares are still available from industrial sources on eBay, etc.

Use a PLC and an industrial HMI with enough power to do what you require. I have recently completed a mixer job where we wanted recipe flexibility with automated and manual steps. The sequence is controlled by stepping through an array which is programmed via the HMI.

  • Step number. e.g. '5'.
  • Description. e.g. 'Auto weigh out banana', 'Manual load cherries', 'Scrape down'.
  • Mix speed (RPM). e.g. '25'.
  • Mix time (s). e.g. '120'.
  • Scrape-down required at end of step? (Y/N) e.g. 'Y'.
  • Heat required? (Y/N) e.g. 'N'.
  • Temperature (°C). e.g. '0'.

We designed the system with an array of twenty steps which is enough for the foreseeable future but could easily be expanded, if required. All settings have min and max values set in the HMI application.

This leaves the system very flexible and editable. We have a robust system with a PLC and HMI familiar and supportable by any of a huge number of companies.