• You are viewing the forum as a Guest, please login (you can use your Facebook, Twitter, Google or Microsoft account to login) or register using this link: Log in or Sign Up

How to use a PLC to control your fish tank.

ian_m

Global Moderator
UKAPS Team
Joined
25 Jan 2012
Messages
5,425
Location
Eastleigh
Zeus also built a PLC controlled fish tank. Below is Zeus's build notes & pictures.
https://www.ukaps.org/forum/threads...ntrol-your-fish-tank.42993/page-3#post-489803

How to use a PLC to control your fish tank
This article explains how you can use a PLC (programmable logic controller) to control all your fish tank electrics, namely lights, CO2, dosing pumps, air pumps etc, so instead of having multiple mains timers, you now control everything from a single PLC unit.

With more advanced design ideas (not shown here), one can implement automatic water changers and CO2 & temperature controllers.

What is a PLC.
According to the great Internet of truths, Wikipedia, a PLC is;

“a digital computer used for automation of typically industrial electromechanical processes, such as control of machinery on factory assembly lines, amusement rides, light fixtures or high tech fish tanks” (my bit in italics).

Below are some diagrams of what is possible, fish tank control wise, using a PLC.
upload_2016-10-3_13-37-22.png

Figure 1 PLC Example 1

Automated electrics. Make use of PLC timer facilities to turn lights, CO2, dosing pumps on at correct times of the day.
upload_2016-10-3_13-37-39.png

Figure 2 PLC Example 2

Automatic reverse osmosis (RO) water changer. On Thursday night (for instance), the PLC turns the RO on and fills water butt to half full, as sensed by level switch. It then fills rest of water butt with mains water giving 50:50 RO & tap water. Then it adds dechlorinator and turns on the water heater to warm the water. It then pumps out 50% of tank water, the 50% level being sensed via float level switch in the tank. Finally it pumps the contents of water butt into tank the tank full level being sensed by a float switch in the tank. Once every so often the PLC reverse flushes the RO unit, to keep the membrane clean.
upload_2016-10-3_13-38-14.png

Figure 3 PLC Example 3

Water temperature and CO2 ppm controller. The PLC measures the water temperature and turns heater on and off at desired temperature. It also measures the pH (and temperature compensates the pH probe) and turns on enough CO2 to give a pH drop of 1 unit, giving 30ppm CO2.

This article is mainly concerned with diagram 1, I will leave it to others to implement the other two diagrams.

Unfortunately using a PLC is not really a standard off the shelf solution, DIY construction, wiring, setup and programming is required.

The ability to wire up mains electrics safely is required, if you can strip wires and wire a 13A plug correctly you are probably OK.

As well as wiring in its simplest form a PLC will require some setup/configuration, not really programming per se, but will require configuring of timers and outputs.

I thought the programming bit would be complicated but upon investigation the actual programming was very easy and quite simple.

The PLC used in the article.
Below is the PLC (and expansion module) I am using and will be describing are Siemens Logo!8 series.

The module with display on the left of the picture, is the main PLC with 8 inputs and 4 relay switched outputs. It is connected to an expansion module, the module on the right, with a further 8 inputs and 8 relay outputs. This is a 230V (and 120V) device and can be used directly off the mains supply. This setup gives 12 relay switched outputs and mains level 16 inputs.

Note this is Logo!8 series, the older models Logo!7 and earlier PLC’s are not equivalent.

This PLC also has an Ethernet interface that can be used to program upload & configure, as well as remotely monitoring its operation, so no manufacturer specific (ie expensive) programming lead are required.

upload_2016-10-3_13-38-57.png

Figure 4 Siemens Logo! PLC and Expansion Module

Why should I use a PLC as opposed to time switches ?
Main reason, in one word, is reliability.

PLC’s are industrial control electronics and are built from components that are in a completely different league of reliability compared to the components used in most mains time switches, that all now seem to originate from China. Siemens for instance quote a lifetime of over 100,000 hours for their devices and relay switching operations rated at over 3 million operations.

I have been through so many mains time switches on my fish tank, all failing in one way or another after a couple of years use.

Over the years I have had time switches that;
- Completely die. No display, no response.
- Very commonly, just reset to 00:00 and loose all their time clock settings.
- Their internal batteries run flat, so after a power failure they don’t retain their settings.
- Sometimes fail to turn on for their time period.
- More dangerously for fish keeper, fail to turn off at end of time period or jam on. OK for air pump, no damage done, but I had a time switch fail to turn off and dumped a large amount of liquid carbon into my tank, killing both plants and fish.

I have also experimented with wireless controlled mains sockets, nice as you can get many sockets in a small space, but I have had a few socket failures, where they no longer respond to the wireless commands. Also I have also confirmed that the words “wireless” and “reliable” do not occur in the same sentence, I have had sockets working for years then randomly one day, fail to turn on (or off). I ended up dumping 1litre of macro EI solution into my tank, when my dosing time switch failed to turn off after 15minutes. Luckily as fish are not affected by high nitrate and phosphate all was well.

My most reliable time switch, I bought early 1990’s, was in fact a UK made one, by Timeguard and still works. It is just rather large. Timeguard still make & sell timers, which are highly regarded but cost £25 each.

Also bear in mind, cost. A PLC will cost around £100, further I/O module another £100 and development software, if required, £40 odd. But compare this to buying the much more inconvenient time switches at say £10-£20 a go.

PLC’s
I first started looking to use a PLC in around 2012. I had converted my tank to high tech and pretty soon was messing around with 6 or more time switches, lights, CO2, power head, air pump, macro dosing, micro dosing and liquid carbon dosing. I kept having the feeling there must be a simpler, more reliable way of controlling the electrics. Also I started suffering failed timers as well, luckily failed to work so no damage done.

However back then there were major issues with PLC’s, as far as I was concerned, that put the PLC controller project on a back burner:

- Cost. A decent PLC was £300 or more.
- Most PLC’s were 12V or 24V powered, not mains, thus a 12/24V power supply would also be needed.
- Development software for the “better” PLC’s was £150 or more.
- Most PLC’s needed to be programmed via RS232 leads !!!.
- A USB to RS232 lead, required to use a modern PC, would be needed, another £100 odd.
- Using a USB to RS232 lead meant the development PC would have to be located locally to the fish tank to allow setting up and program updating.
- No networking capability.
- No way to monitor/control over the Internet (might be a good thing of course).

However Siemens introduced their Logo!8 PLC's with the following interesting features:

- Start at £100 (8 in 4 out).
- Mains powered versions available, no messing with power supplies.
- Development software only £40.
- Ethernet connection for web access, programming and setup. No expensive programming lead or PC located near PLC required.
- Using the Ethernet it can be monitored/controlled over the Internet.

DIY PLC's
Of course there is nothing to stop you making your own PLC from a processor module eg Raspberry PI, Beagle Board etc, or a PC and a collection of relays, switches and some software. Many companies offer DIY PLC modules or more suitably PLC motherboards with relays and mains inputs that you plug your Raspberry Pi (or other processor board) into.

I spent ages looking into this as a solution and as an electronic engineer and programmer by trade, I initially thought this would the best way forward.

However all of these suffered, in my opinion, from major drawbacks.

- Would require some serious DIY construction to make suitable cases, power supplies and wiring for these modules.
- Most solutions would end up being physically large and there is only so much room under my fish tank.
- Would require some serious programming to get these setups working. I am a programmer, by trade, thus was well aware of the complexity required.
- There is open source PLC programming software, you draw block diagrams of the functions you want, but is all very amateur compared to the commercial £250 proper development software.
- Interfacing to displays and buttons is not easy and would require much programming effort.
- Reliability. People who have built their own PLC’s still report reliability issues both flaky hardware and buggy software.
- Cost. By the time you have added all the bits and pieces up, Rasberry PI £20, PLC motherboard £80, power supply £10...it ended up not being any cheaper than commercial PLC.

So in the end I decided I wanted to spend time setting up and configuring my PLC rather than spending time programming and building a PLC.

Siemens Logo! 8 PLC’s
An overview of the Siemens Logo! 8 series is below.

http://w3.siemens.com/mcms/programmable-logic-controller/en/logic-module-logo/overview/Pages/default.aspx

I bought a Logo! 8 starter kit for £150 from Conrad electronics. It shipped from Germany in a couple of days.

The LOGO! 8 Starter Kit 230RCE starter kit is part number 6ED1 057-3BA02-0AA8.

http://w3.siemens.com/mcms/programmable-logic-controller/en/logic-module-logo/logo-starter-kit/Pages/Default.aspx#LOGO__208_20Starter_20Kit_20230RCE

This includes a Logo! 8 module, part number 6ED1052-1FB00-0BA8, Logo! Soft Comfort V8 (development software), WinCC Basic V13, nice green industrial Ethernet lead and a Siemens screwdriver all in a tough storage box.

I also bought a LOGO! DM16 230 R module providing another 8 inputs and 8 outputs. Part number 6ED1055-1FB10-0BA2

Below is the link to the Logo!8 hardware user manual

https://support.industry.siemens.com/cs/document/109741041/logo!?dti=0&pnid=13618&lc=en-GB

If you are "going advanced" you will need the full version of Siemens PLC development software Logo!8 Soft Comfort.

http://w3.siemens.com/mcms/programmable-logic-controller/en/logic-module-logo/demo-software/pages/default.aspx

There is a demo version available so you can play & test & simulate. However the demo version cannot upload programs to the PLC.

Below is the link to the Logo!8 Soft Comfort user manual.

https://support.industry.siemens.com/cs/document/100782807/logo!soft-comfort-online-help?dti=0&pnid=13617&lc=en-GB

You will also need some form of box/enclosure to put the PLC in, to cover up the mains terminals and wiring.

I used a Bopla box from RS (rswww.com), part number 773-9632, for £30 odd.

If you search Amazon for “Siemens logo case” you will find a seller selling nice acrylic cases for Logo devices. Check sizes before buying.

Wiring up your PLC, simple 4 channel version.

upload_2016-10-3_13-46-42.png

Figure 5 PLC Wiring

Basically you need to wire the PLC as in the diagram above. The PLC output relays connect to 13A trailing sockets to allow items to be easily plugged in eg light, CO2 etc. Using a 13A socket enables you to easily disconnect the item if needed for repair, replacement or upgrade.

Mains live needs to go to the PLC pin L1 (at the top) and connection pin 1 of all 4 relays.

Connection pin 2 of the relays needs to go to the item you wish to control. eg in picture above, relay 1 is tank lighting, relay 2 is CO2 solenoid, relay 3 is macro dosing pump & relay 4 is micro dosing pump.

All this wiring needs to be done neatly, preferably in an enclosure/box, so that accidental water splashes won't be a shock risk (or damage the PLC).

Further ideas for mounting & connecting are shown below.

upload_2016-10-3_13-49-16.png

Figure 6 PLC Build Ideas

Setting up the PLC
Once your PLC is wired up, mains supply to its power inputs and connected to your tanks electrical devices (lights, CO2, pumps etc) the PLC will need setting up and programming.

First time setting up is quite simple, basically at this stage it consists of entering the correct date and time and time zone. See page 282 of user manual on how to set the clock and date using the LCD and cursor keys on the front panel.

Programming the PLC
As for programming, this can be done in 3 ways:-

Front panel programming.
Suitable for simple setups ie lights on at 5pm off at 11pm, but is rather like decorating your house via the letterbox, possible to do if simple, but hard for anything complicated.

This is a very easy way to start, requiring no development software.

Development software running on a PC
With the development software Logo! Soft Comfort you connect “blocks” in the software ie a timer block connected to an output block meaning the output relay is now controlled via a timer, perfect for fish tank lights, CO2 etc.

Below is an example for a light timer with lights connected to output relay Q1. This timer is lights on 17:00-23:00 on Sunday to Thursday and 18:00-23:45 on Friday and Saturday. The timer block has three time slots, if you require multiple time periods.
upload_2016-10-3_13-50-8.png

You then simply upload the program to the PLC, via the network interface and start the program running, job done.

This is a much better method than entering your program via the front panel, as you can also simulate & test your design, in Logo!Soft Comfort, before uploading to the PLC. It is also possible monitor/debug what is going on in the PLC to test & verify your design again using Logo!Soft Comfort.

µSD memory card
You can also load a .BIN file (generated by a licensed copy of Logo!Soft Comfort) onto an µSD card, insert into the PLC and power it on and the program will run. Job done.

No development software, no front panel programming is needed

The program can be edited/modified via the front panel keys, but is generally hard and difficult to do.

Programming via front panel example
Below is an example of programming, via the PLC front panel with the following specification.

upload_2016-10-3_14-0-29.png


With PLC powered on using the cursor, OK and ESC front panel keys follow the pictures below.

upload_2016-10-3_14-2-12.png

upload_2016-10-3_14-2-41.png

Select “Program” Select “Program “, press OK Select “Edit Prog”, press OK

The final picture shows that block B1 (our weekly timer block) is connected to output Q1. Whenever the timer block output is set, based on time (and off times) the Q1 relay, connected to our lights, is closed.
upload_2016-10-3_14-3-34.png


To change the on & off times, whilst the PLC is running.
upload_2016-10-3_14-4-28.png


If this program is downloaded into Logo!Soft Comfort, it looks like this.

upload_2016-10-3_14-4-59.png

Figure 7 PLC Program

If you can’t be bothered to enter the program then download the .BIN file below to a µSD card (formatted FAT32), pop into PLC, power on, done. Also included is the .lsc source.

https://1drv.ms/f/s!AgIGUdnorxMQl9wov206rryCrnkaJg

My Controller , The “Big Boy” PLC
The PLC controller I built is shown below.

upload_2016-10-3_14-8-41.png

Figure 8 PLC Controller Under my tank.

My basic design idea started with the following:
- Had to fit in my existing Juwel cabinet.
- As tank is in my lounge and PLC will be visible, it had to have WAF (wife acceptance factor).
- Had to have manual overrides, so that I could turn lights, filters etc on & off for when doing water changes, adding fish etc. For this I decided to use toggle switches connected to the PLC’s inputs rather than settable via the PLC front panel buttons.
- A quick toggle on the switch turns toggles the relevant output on or off. Handy to quickly turn the lights on and off when feeding and quick tank inspections.
- A longer held toggle, 3 seconds, disables/enables the relevant timer output.
- Use the display to indicate status, when outputs are on.
- Time settings and enable/disable configurable via front panel buttons, so the access to a PC is not required to change settings.
- Accessible via network for monitoring and configuration.

I used the 240V Logo!8 module along with the 230V 8 input and 8 output module, giving 16 inputs and 12 outputs in total.

My design has the following timer specifications. The holiday mode has reduced lighting & dosing times for when on holiday. Holiday mode is set via front panel keypad or web access.

upload_2016-10-3_14-9-19.png

*Sets either just 2 tubes on or all 4 tubes on.
+ For future use.
** Using a 3ml per minute pump giving about 40ml in my 180l tank.
++ Using a 1ml per minute pump giving about 5ml in my 180l tank.

Hardware Build.
I used a Bopla case from RS, part number 7739632 (about £30). http://rswww.com. This has a hinged transparent front door.

It was mounted in the centre section of my Juwel Vision 180 stand, held in by screws at the top and an aluminium bracket underneath. All the mains connections come out the back of the case and pass through into the cupboard next door, via an 80mm hole. This is where all the equipment is plugged in.

Inside the case the PLC and expansion module was mounted on an aluminium bracket. See Figure 9.

The long bolts in Figure 9 allowed correct setting up of PLD height, within the box, so the side fixing holes could be drilled accurately. These bolts were replaced with shorter bolts once side fixing was complete.

upload_2016-10-3_14-9-58.png

Figure 9 PLC Mounting Bracket.

A suitable hole was cut through the front panel to allow the PLC keys to be accessed. I covered it with a plastic film (decorator’s carpet protector) to stop scratches during the build. I even flame polished the cut edges, though one ended up flame “charred”.

upload_2016-10-3_14-10-7.png

Figure 10 Front Panel Cutout.

The internals was wired up as in Figure 11. The “arrowed wires” in the diagram go to further mains sockets to connect to devices. The wires go out to single 13A mains cable sockets so the devices, lights, solenoid etc can be simply plugged in.

upload_2016-10-3_14-10-43.png

Figure 11 PLC Wiring.

The relay outputs of the PLC were wired for the following functions.
upload_2016-10-3_14-11-10.png


The corresponding PLC inputs I1 to I12 were wired to 6 off front panel toggle switches. The labelling (including missing FOOD ??) was made using a laminator.

upload_2016-10-3_14-11-34.png

Figure 12 Front Panel Switches.

I used centre lockable toggle switches, you have to pull the toggle out before it will toggle up or down. This is to prevent accidental knocking of the switches. These were from www.mouser.co.uk part number 633-M201805 @ £4 each.

The filter and heater connections were slightly different and were connected via a relay board, fitted in the case.

upload_2016-10-3_14-11-46.png

Figure 13 Filter and Heater Relay Board.

The function of the relay board was to “invert” the operation of the PLC outputs Q10 (filter) & Q11 (heater) so that if all PLC outputs are off, the filter and heater would be on. Energising PLC Q10 or Q11 switches off the filter or heater. This is so that, with all PLC outputs off, as in most of the time when not PLC doing anything “interesting” or when programming or fiddling, the filter and heater would always be on.

Also if the PLC crashed !!!! (very very very very never heard of unlikely) the filter and heater would always be on.

Figure 14 shows wiring inside in progress.

This also shows, on right hand side, two 6.3A fuses (not wired yet in picture).

One fuse was used solely for the filter and heater and other fuse on all the other devices. This was to ensure a fault in some non essential item eg light, CO2 etc did not knock out filter and heater.

On the bottom right is an Ethernet bulkhead connector to connect to the PLC Ethernet. Ethernet connection within the case was made using a 25cm flat Ethernet cable.

All wire ends were crimped with bootlace ferules to enable easier insertion into the relevant screw terminals as well as securing multiple wires in one ferrule.

Lacing cord was used to keep the wire bundles under control and in place. Cable number markers were used to so that wires could be easily tracked.

upload_2016-10-3_14-14-9.png

Figure 14 Wiring in progress.

The extra holes in the case above were for pH probe & temperature probe...however complete lack of space, both wiring and software wise, prevented that use. A future upgrade ?

upload_2016-10-3_14-14-23.png

Figure 15 Testing before wiring the switches.

upload_2016-10-3_14-14-33.png

Figure 16 It was a squeeze when all done.

upload_2016-10-3_14-14-47.png

Figure 17 Done, ready to put in cabinet.

upload_2016-10-3_14-15-44.png

Figure 18 All Cables Squeezed in cabinet next to controller.

Fish Feeder

Another item to control is a fish feeder. As most fish feeders are standalone battery operated and generally include some form of timer control ie feed twice every 24 hours some internal rewiring would be required.

Opening up a Hydor fish feeder revealed batteries, controller circuit board, motor, a toothed wheel and a sensing switch.

Its normal operation is as follows:
- At feeding time the controller energises the motor
- The toothed wheel to rotates and vibrates.
- This wheel is connected to the food container, which rotates one revolution whilst vibrating out a portion of food.
- The toothed wheel has a tooth on it which pushes a micro switch so the controller can tell the wheel has done one revolution.

So by cutting internal wires and PCB tracks on the controller board circuit board the following circuit was obtained. The controller board had to be left in as part of it formed connections to the battery. The switch should be open circuit when pushed by the tooth on the wheel.

upload_2016-10-3_14-16-13.png

Figure 19 Fish Feeder Wiring.

The operation is now as follows:
- The PLC controller, connected to the fish feeder by a 3.5mm to 3.5mm connecting lead, closes its relay for 1 second.
- This powers the motor which rotates the toothed wheel.
- Once rotated the switch closes keeping power applied to the motor.
- The PLC opens its relay after 1 second.
- The toothed wheel keeps rotating until the switch opens, due to the tooth on the wheel, cutting power to the motor.
- Fish are fed.

upload_2016-10-3_14-16-28.png

Figure 20 Fish Feeder, Motor, Toothed Wheel and Switch.

Continued in part 2....
 

Attachments

  • upload_2016-10-3_13-47-1.png
    upload_2016-10-3_13-47-1.png
    253.7 KB · Views: 878
  • upload_2016-10-3_13-47-20.png
    upload_2016-10-3_13-47-20.png
    132.2 KB · Views: 612
  • upload_2016-10-3_13-47-46.png
    upload_2016-10-3_13-47-46.png
    110 KB · Views: 617
  • upload_2016-10-3_14-1-15.png
    upload_2016-10-3_14-1-15.png
    31.1 KB · Views: 581
  • upload_2016-10-3_14-1-23.png
    upload_2016-10-3_14-1-23.png
    31.1 KB · Views: 587
  • upload_2016-10-3_14-12-12.png
    upload_2016-10-3_14-12-12.png
    379.7 KB · Views: 583
  • upload_2016-10-3_14-13-54.png
    upload_2016-10-3_14-13-54.png
    379.7 KB · Views: 617
Last edited:
upload_2016-10-3_14-21-16.png

Figure 21 Fish Feeder, Wires Bypassing Controller.

upload_2016-10-3_14-21-41.png

Figure 22 Fish Feeder 3.5mm Jack Socket.

Initial PLC Setup
The main thing on the PLC that needs configuring before use/programming is its IP address so it may be accessed over the network. This is explained on page 109 of Logo User Manual and is shown in the pictures below. You might also want to set the clock, but this can also be set over the network later.

upload_2016-10-3_14-22-6.png


Enter IP address using cursor keys. OK when done. Esc to go back. I am using 192.168.10.25 for my controller IP address.
upload_2016-10-3_14-22-33.png


Connecting Logo!Soft Comfort
In order to transfer programs to the PLC you will need a licensed version of Logo!Soft Comfort, the free demo version cannot transfer programs, though can be used to design, simulate & test your design.

Logo!Soft Comfort uses Java, so you need to ensure you have the latest version of Java installed.

Once the software is installed, I have it running on Windows 10 64bit it can connect the PLC.
1. Start Logo!Soft Comfort, select File -> new.
2. Select File -> Properties then Online settings.
3. Enter the IP address of the PLC and press Connect.

upload_2016-10-3_14-22-55.png

Figure 23 Online Settings, Connecting.

4. Once connected the PLC clock can be set. Do “Read from PC” followed by “Apply to LOGO!”.
upload_2016-10-3_14-23-5.png


5. You can also set the timezone, so that the clock changes automatically for summertime/wintertime.
upload_2016-10-3_14-23-13.png


6. Also recommended is to set a password for remote access (for access from Logo!Soft Comfort), disable App access, enable Web server and set a web server password.
upload_2016-10-3_14-23-37.png


Creating and Loading Your First Program

In Logo!Soft Comfort create a simple test FBD (functional block diagram) by dragging the blocks on the left of the screen onto the workspace and wiring them together.

upload_2016-10-3_14-23-50.png

Figure 24 Connecting two blocks.

This circuit connects input I1 to output Q1. Asserting 240V (actually above 85V) on the input I1 will close relay Q1.

The circuit can be simulated by pressing F3 or clicking the simulate button.

Pressing the I1 switch or clicking on the I1 block toggles the input. High levels are shown in red and the resultant Q1 light bulb is lit.

upload_2016-10-3_14-24-33.png

Figure 25 Simulation.

The program can be uploaded to the PLC by Tools -> Transfer -> PC->LOGO!. (or CTRL-D).
upload_2016-10-3_14-24-41.png

Figure 26 Uploading Program.

Which will then load the program to the plc & start running on the real PLC device.

Notice the Copy to SD card button. This also copies the SD card as well as the PLC internal memory.

The operation of the internal memory and SD card is as below.
- If no SD card is present and a program was running, when the PLC is powered up it will run the program.
- If an SD card is present with a program on it and a program was running, when the PLC is powered up it will copy the program from the SD card and run the program.

This is important to realise as you can get into situation (at least I did) where you upload your latest and greatest creation, accidentally to memory only. It works fine until you power cycle the PLC and it reverts to an old version of your program “left over” on the SD card.

Testing the wiring.
In order to test the wiring was correct I wrote a small Logo test program so that I could test each input and output connection.

Using the cursor keys on the front of the PLC (use ESC + cursor key) use the up down keys to select and input/output from I1/Q1 to I12/Q12. Pressing the right & left cursor keys turns the corresponding output on & off. Asserting the relevant input also toggles the output on and off. The status of the inputs and outputs is shown on the display.

https://1drv.ms/u/s!AgIGUdnorxMQl9wqiTQyOgrAVrQpMQ

upload_2016-10-3_14-25-46.png

Figure 27 Test Program Display for I1/Q1 (Lights 1)

My Program
Initially I started with just 10 timers connected to the 10 timed outputs and the filter and heater outputs off (so they are permanently running as inverted by relay board).

upload_2016-10-3_14-25-56.png

Figure 28 10 Timers.

This is will work fine, CO2 will come on, lights will light etc.

The timers can be updated via-
- Editing the block parameters via the front panel cursor keys.
- Uploading a new program with the updated timer times.
- Running Logo!Soft Comfort in On Line Test mode ( button on toolbar), where you can remotely set the timer values by right clicking on the timer block, as shown below.
upload_2016-10-3_14-26-14.png

Figure 29 Remotely Editing

This fish feeder control, in this diagram, generates 3 pulses to emulate pressing buttons on the fish feeder. This was before I produced a rewired fish feed as shown before.

However it is lacking in the following:
- No manual override via the front panel switches ie not possible to just turn on or off the lights.
- Not possible to disable any of the outputs ie 4 tubes not required.
- Not possible to turn filter or heater off during maintenance.
- No on screen status of what is switched on or off.
- No access via network.

The MNDD Version (mutts nuts doggie danglers version)
Below is the final version I am now using (version 3.5), as shown in initial start up screen. The ZIP file contains the Logo!Soft Comfort .LSC source file, the PDF is a print out of the program and .BIN file a file suitable for placing on and uSD card (rename to LOGO_U_P.BIN first).

https://1drv.ms/u/s!AgIGUdnorxMQl9wrMvJGa-fAoqKz7g

https://1drv.ms/u/s!AgIGUdnorxMQl9wseqCDRKhXzIG55Q
Figure 30 Rename to LOGO_U_P.BIN to use.

I will not describe the finer details of the program as you can load it into Logo!Soft Comfort (demo software version is fine) to see its operation. There are comments within the program, as well is the important blocks having relevant names (eg 2 Tubes Time) to aid understanding.

It has the following features:
- Separate timer control for:
  • 2 light tubes.
  • 4 light tubes.
  • CO2 solenoid.
  • CO2 pump (for future use).
  • Wavemaker/powerhead.
  • Air pump
  • Macro dosing pump.
  • Micro dosing pump.
  • Liquid carbon dosing pump.
  • Fish feeder (two time sessions).
- Also has control (on/off) of (for water change/maintenance sessions):
  • Filter
  • Heater
- Controller alternates which set of two tubes are on, so both pairs of tubes wear out evenly.
- Manual override of outputs via front panel toggle switches.
- Momentarily toggling the switch, toggles the output, so, for example, it is possible to turn lights on (and off) at any time. Handy for maintenance.
- The manually overridden output is reset at end of the time period, thus lights will not accidentally remain on 24/7 if manually turned on.
- Macro, micro & liquid carbon only run for 60seconds if manually turned on, to prevent over dosing.
- Holding the switch for more than 3 seconds disables the relevant timed output.
- Any change in output or output being disabled/enabled is indicated on the display (and temporarily changing to orange).
- Separate timer to turn on display backlight, so display is off at night.
- Display turned on if light, CO2, wavemaker or dosing pumps active outside of display time period.
- Display turns on if set up menus are accessed.
- Status display, shown when lights, CO2, wave maker or air pump is active.

upload_2016-10-3_14-29-19.png

Figure 31 Status display.

- Status display shows:
  • Date & time
  • +3.22 is 3 days 22hours since water change.
  • 921 is the number of hours the controller has been running for.
  • Indicates only 2 tubes are on.
  • CO2 solenoid is on.
  • Wave maker is on.
  • Display scrolls and also shows, CO2 pump off & air pump off.
- The water change timer is reset to zero, when either the filter or heater is turned back on after BOTH have been turned off.
- All changes of output are logged to SD card.
- A holiday mode, in which a different set of timers applies to allow for shorter light, CO2, wave maker, dosing and feeding times, to “slow the tank down” whilst away.
- Timer and output setup menus accessible from both front panel and network connections (web server).
- Setup menus (accessible via ESC+UP/DOWN arrow on front panel and web page to navigate settings menus) have the following:


Settings 1 - Set/clear holiday mode.
Settings 2 - Set 2 tube on/off times.
- Turn on/off 2 tubes (left right arrow keys).​
Settings 3 - Set 2 tube holiday on/off times.
- Enable/disable 2 tubes (left right arrow keys).​
Settings 4 - Set 4 tube on/off times.
- Turn on/off 4 tubes.​
Settings 5 - Set 4 tube holiday on/off times.
- Enable/disable 4 tubes.​
Settings 6 - Set CO2 on/off times.
- Turn on/off CO2.​
Settings 7 - Set CO2 holiday on/off times.
- Enable/disable CO2.​
Settings 8 - Set CO2 pump on/off times.
- Turn on/off CO2 pump.​
Settings 9 - Set CO2 pump holiday on/off times.
- Enable/disable CO2 pump.​
Settings 10 - Set wave maker on/off times.
- Turn on/off wave maker.​
Settings 11 - Set wave maker holiday on/off times.
- Enable/disable wave maker.​
Settings 12 - Set air pump on/off times.
- Turn on/off air pump.​
Settings 13 - Set air pump holiday on/off times.
- Enable/disable air pump.​
Settings 14 - Set macro dosing times.
- Turn on/off macro dosing pump for 1 minute.​
Settings 15 - Set macro dosing holiday times.
- Enable/disable macro dosing.​
Settings 16 - Set micro dosing times.
- Turn on/off micro dosing pump for 1 minute.​
Settings 17 - Set micro dosing holiday times.
- Enable/disable micro dosing.​
Settings 18 - Set liquid carbon dosing times.
- Turn on/off liquid carbon dosing pump for one minute.​
Settings 19 - Set liquid carbon dosing holiday times.
- Enable/disable liquid carbon dosing.​
Settings 20 - Set fish feeder time 1.
Turn on fish feeder.​
Settings 21 - Set fish feeder time 2.
- Enable/disable fish feeder.​
Settings 22 - Set fish feeder time 1 holiday.
Settings 23 - Set fish feeder time 2 holiday.
Settings 22 - Turn on/off off filter.
Settings 22 - Turn on/off heater.

- In setup menu if no button is pressed for 20seconds the display reverts back to the status display.
- Turning either filter of pump off, via holding front panel switch 3 seconds or via setup menus, flashes the screen red to indicate one of them is turned off.
- They will stay off until turned back on manually.

upload_2016-10-3_14-34-48.png

Figure 32 Filter/heater off screen.

- The timer at the bottom indicates (hour:mins:secs) how long either the filter or heater has been turned off.
- The controller’s screen is accessible via the network connection, the screen being rendered as a web page, so is equally usable from a web browser on a PC as well as mobile devices.
upload_2016-10-3_14-35-4.png

Figure 33 Web Broswer Login Page

upload_2016-10-3_14-35-17.png

Figure 34 Web Browser Logged In
upload_2016-10-3_14-35-29.png

Figure 35 Log In From Mobile.

upload_2016-10-3_14-35-41.png

Figure 36 Screen From Mobile.

- The setting menu is accessible by pressing ESC + UP ARROW on front panel of the controller or tapping ESC followed by UP ARROW on web/mobile.

upload_2016-10-3_14-35-54.png

Figure 37 Settings Menu 2 on a Mobile.

upload_2016-10-3_14-36-4.png

Figure 38 Double Click on Value to Edit.

Was It All Worth It.
Of course, I have to say it was....even after..

- Probably spending £300-£400 on hardware (still got lots of interesting tools & bits left over of course).
- Specifying and designing what was actually required to do the job as opposed to inventing something far too complicated and bug ridden.
- Learning and playing with new development software.
- Developing the control software, which in the end was quite easy to design, easy to enter and easy to test.
- Designing various ways of connecting it all up.
- Experimenting various ways of presenting the control interface via the front panel and web interface.

And finally
- Seeing 100% reliable switching of the electrical devices on my fish tank. No ferts overdosing, no liquid carbon overdosing...
- Seeing after a power cut, all will came back working.
- Knowing that industrial quality electronics has been used.
- Not seen any funnies in the 4000hours it has been operating.
- Being able to engage holiday mode on holiday, “cos I forgot”.
- Being able to check on what is happening from my phone whilst on holiday.
- Being able to change things via the front panel whilst at my tank during water change time. Noticed a bit of BBA appearing, so back of lights & CO2 & power head by an hour. Easy.Was able to verify the settings later using my phone.

Disadvantages
- Cost.
- Time to make and assemble.

What’s Next
CO2 controller of course....

ian_m 3rd Oct 2016.
 
Thank you Ian for taking the time to write such a helpful informative post ☺ unfortunately the controller is a bit beyond my budget but I really hope this post is made a sticky - it would be be a great reference point in the tutorials for members with a more high tech set up where precision is very important.
 
Great work Ian :) what you need is some monitoring incorporated into that also measuring various values and graphing it on the app ;)
 
Attached a PDF of the FBD (functional block diagram) I have in my controller. Easy peasy'ish.

The PLC can produce graphs if connected to an analogue module.

upload_2016-10-4_8-50-46.png

This is on the front panel display showing the input changing with time.

upload_2016-10-4_8-49-43.png

This on the mobile app.

upload_2016-10-4_8-53-29.png

Finally if you use Siemens WinCC you can get very advanced features.

upload_2016-10-4_8-54-49.png

Finally there is an Ethernet remote display if you want to change settings not on front panel (£160 odd) or via web server.

There is also a SMS module that can send and receive texts, so you could get it to send you an SMS if temperature is too high or a daily tank status, for example.
 

Attachments

  • upload_2016-10-4_8-35-49.png
    upload_2016-10-4_8-35-49.png
    2.4 KB · Views: 600
  • upload_2016-10-4_8-38-48.png
    upload_2016-10-4_8-38-48.png
    40.5 KB · Views: 615
  • upload_2016-10-4_8-39-33.png
    upload_2016-10-4_8-39-33.png
    40.5 KB · Views: 581
  • upload_2016-10-4_8-39-46.png
    upload_2016-10-4_8-39-46.png
    114 KB · Views: 593
  • V3.5_printed.pdf
    955.4 KB · Views: 685
  • upload_2016-10-4_8-54-37.png
    upload_2016-10-4_8-54-37.png
    40.5 KB · Views: 574
Great writeup ian, i have been looking for something like this for some time now added to Christmas List (if i can wait that long).
Have looked at using my RPI to control relays etc, but was going to take more time to build than i can spare.

My only question is, how can i intergrate the PH reader to control the CO2 levels, and a tempature sensor for heaters into the logo8?
i.e. how do you calobrate the anology inputs e.g. PH of 8 to show a PH of 8 and not 5. Is this detailed in the siemens manual?

Thanks
 
There were numerous reasons I never added CO2 control to mine:
- I am using 383 out of 400 blocks in mine. So basically it is full.
- Mine has no analogue inputs (the 230V ones are 230V digital inputs only).
- The analogue input module, which I could add to my 230V PLC, runs on 12-24V, so I would need to add a 12/24V power supply to my system.
- The case I put mine in is full.

So if I was to build a pH controller I would use another Logo8 PLC, possibly a LOGO! 12/24 RCE that has analogue inputs and relay outputs, all powered from 12V supply.

You could either use the relay output to control the mains CO2 solenoid straight off or use the network connectivity of Logo's to turn the CO2 on an off on the other PLC.

You would need a circuit like below to interface the pH probe. You would also need to change the gain on U2 so that the say pH 5-11 (typical tank range ?) gives 0-10V suitable for the maximum range of PLC input. The PLC reads this input as a value of 0 to 1000 on its AI input block.
upload_2016-10-14_15-58-9.png


There is a Raspberry PI pH probe circuit similar to above available as an analogue add on board.

Just messing now with Logo SoftComfort, you connect an analogue input (AI1 in my case) that gives 0-1000 for 0 to 10V input to analogue comparator B003, selecting measurement range 50 to 110 (for 5 pH to 11 pH x 10, so can have 1 decimal place) and it calculates the gain and offset values to do this range change. Thus 0V input will give value 50 and 10V input value 110. The on/off thresholds are set at 1/2 the difference between 50 and 110 -> 30, which in our case is pH 7. The 30 is held in a counter. You need be able to set the counter value ie pH to switch at, to determine when the output switches.
upload_2016-10-14_16-43-24.png


Now running the simulator and displaying a text box...an input of value of 0 (analogue input of 0V from pH probe of 5) see arrow below gives a B003 output of 50, displayed to 1 decimal place (set in B003 properties) ie divided by10. The output is off, no CO2.
upload_2016-10-14_16-47-10.png

An analogue input of 10V (a pH of 11) gives reading of 11.0 and CO2 is on trying to lower pH.
upload_2016-10-14_16-48-15.png


Done. Easy.

In practice...
- Might want to add a slight difference between on and off values, to stop output changing too quickly.
- Might want to add a delay so that the output of B003 has to be active for say 1 second before it switches so that any noise doesn't cause spurious switching.
- Clever bit. Convert the pH to display ppm CO2. A log function is required but could probably be quite close using x^2+x type function, especially if pH is limited to say 5 to 11. Would be nice to display 30ppm CO2 on display rather than pH.

The control of temperature is similar to CO2 control above.
 

Attachments

  • upload_2016-10-14_16-13-23.png
    upload_2016-10-14_16-13-23.png
    16.4 KB · Views: 568
  • upload_2016-10-14_16-18-44.png
    upload_2016-10-14_16-18-44.png
    8.1 KB · Views: 563
  • upload_2016-10-14_16-20-42.png
    upload_2016-10-14_16-20-42.png
    8.3 KB · Views: 566
If anyone is following this or using Logo!SoftComfort, Siemens have released an update to V8.1.

It can be updated by Help -> Update Center in the menus.

Main things I have noticed is Java not crashing with NUL pointer exceptions anymore when expanding some of the block properties. Also supports the newer Logo8.FS4 devices, main thing that looks nice is the Logo can access a NTP time server.

They have also updated the Logo & Logo!SoftComfort user manuals.
https://support.industry.siemens.co...o_system_manual_en-US_en-US.pdf?download=true
https://support.industry.siemens.com/cs/attachments/100782807/Help_en-US_en-US.pdf?download=true

Also a very good support forum for Logo product, though as in most forums there can be a lot of "I can't be *rsed to read the user manual, can you guys design system for me" :(
https://support.industry.siemens.com/tf/ww/en/threads/127/?page=0&pageSize=10

Other than that, my PLC is a really really really boring device, it just sits there working. No fiddling, no tweaking, no maintenance, just really boringly working, turning things on and off 100% of the time. Really disappointed I can't find nothing to tweak or fiddle.:D
 
Really impress with this PLC build write up. Just what I was thinking off without knowing what I was looking for. Completely new to the hobby, so so much to read, but having a reliable timer is a must IMO. Once setup easy config/mod/edit via software via PC over Lan is the way to go.

Do plan to go down the auto dosing EI route long term, so getting the PLC may cost initially but can use it to control the timings on the peristaltic pump so no need for master unit as the PLC will take care of it. Plus siemans are renowned for their quality products.
-------------------------------------------------------------------
a lot to take in at first with what does what o_O

Take it the blocks refer to how much you can program the PLC so more may be better long term?
---------------------------------------------------------------------
had a play with demo after watching a couple of utube videos :thumbup:, not to difficult to work out what to do with the software

So you just press the expansion module (if after for more outputs for stuff or other tank )into the PLC module and program the extra outputs and done. So easy looks really really good.

So for what we are doing a 200 block PLC may well more than enough ?

Wouldn't mine getting a quality temp probe for it as heater can jam on!
 
Glad you liked it. Accessed my plc this morning over breakfast to verify clock had changed and reduce lighting by one hour as getting slight algae.

If you need analogue inputs you need the 12/24 dc versions that have analogue in. However you can also attach a 12/24v analogue module to a 230v controller but it obviously needs a 12/24 supply.

Cant wait to see your design.

Get the demo software and play. Loads of Siemens examples to look at as well. I had not programmed a PLC before this.

Get the demo software here.
http://w3.siemens.com/mcms/programm...-module-logo/demo-software/Pages/Default.aspx

I did some of the on-line training.
https://sitrain.automation.siemens.com/sitrain/open_wbt/logo/index.html

Download and play with the examples below.
http://w3.siemens.com/mcms/programm...-logo/application-examples/Pages/Default.aspx

With respect to blocks the Logo!8 units have the following limits.
  • 400 function blocks.
  • 24 digital inputs.
  • 20 digital outputs (relay of 24v)
  • 8 analogue inputs.
  • 50 text boxes and text box contents.
A function block is one of these below, an OR gate or a weekly timer each are one block. The timer below has three setting, below is Mon, Tues 14:00-15:00, Wed, Thur, Fri 15:00-16:00 and Sat, Sun 17:00-18:00.
upload_2016-10-31_9-0-21-png.92028

If you need more that 400 blocks (or more I/O) you can network two (or more) Logo!8 units together with network inputs and outputs, where say a network output on one Logo!8 sets a network input on another. All just works.

There is a Logo!8 AM2 RTD module designed to connect to (1 or 2) standard PT100 or PT1000 thermocouples for temperature measurement. You can get very tough and reliable thermocouples eg
http://www.omega.co.uk/pptst/HSRTD.html
Just connect to AM2 RTD and suddenly one of the analogue inputs is now temperature.
 
All of this is over my head but wow what an epic write up!!! Kudos!
 
This is my peristaltic pump write up. Was originally two pumps and two timers, but I added circuitry to alternate dose so only one timer was required. Now controlled by PLC.
http://www.ukaps.org/forum/threads/diy-dual-peristaltic-dosing-pump-with-alternate-switching.22332/

And whilst at it, my water butt heater.
http://www.ukaps.org/forum/threads/water-change-heater-project.25877/

I am working on my next version of the PLC software, where you set just one timer, for the time you want the tank lights on, and it automatically turns CO2 two hours early and one hour before lights off, as well as turning on brighter lights and wave maker and air pump all based on just setting one timer.
 
HI...i am a new user here. Thanks for sharing such a helpful content. I was looking for something like this.Have looked at using my RPI to control relays etc, but was going to take more time to build than i can spare.I want to know how can i intergrate the PH reader to control the CO2 levels, and a tempature sensor for heaters into the logo8?
 
HI...i am a new user here. Thanks for sharing such a helpful content. I was looking for something like this.Have looked at using my RPI to control relays etc, but was going to take more time to build than i can spare.I want to know how can i intergrate the PH reader to control the CO2 levels, and a tempature sensor for heaters into the logo8?
See my post #8 above about how to connect a pH probe to a Logo8.

I still haven't added pH control to my controller, though it is on my "love to do someday list". Personally not convinced pH control is needed, as my drop checker is green, plants and fish are fine :D, but would be nice to have, especially the ability to log pH values.

As for temperature you can get a Logo RTD module to connect a thermocouple straight in and read temperature within your programme blocks. However water proof robust thermocouples are not cheap, say £50. Might be better using cheaper thermistor based temperature probes and feeding into an analogue input and doing a bit of analogue calculation to get temperature value.

Its is still running at home, lust logged in, CO2 & wavemaker are on, but no lights yet. Been running 4539 hours (190 days) :cool:.

upload_2017-1-23_15-23-29.png
 
Going on holiday...engage holiday mode (remotely)... Halves light time, CO2 time and fertiliser dosing to slow the tank down whilst away....Done.
upload_2017-2-13_12-0-47.png


Changed.
upload_2017-2-13_12-2-2.png
 

Attachments

  • upload_2017-2-13_12-0-21.png
    upload_2017-2-13_12-0-21.png
    23.6 KB · Views: 527
Back
Top