Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Watering system Contrioller
Goto page 1, 2  Next
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM Project Blog
View previous topic :: View next topic  
Author Message
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Sun Mar 10, 2013 11:53 am    Post subject: Watering system Contrioller Reply with quote

I was going to start this part of my automation later on but to give another bascom user some ideas I have started it now.

What it is:

I need to control the watering of lawns, garden & potted plants. The water is pumped 4.5 meters out of the ground by two pumps, one is a venturi type pump the other a brass turbine type, they are used individually and together depending on the amount of volume needed (with both in use the venturi pump feeds the turbine) the measured efficiency is high with both pumps running as only 25% more power is used as compared to one yet both are the same rating 700watts. So the system will need to decide what pump to run or both pumps, it will need to monitor them for temperature, lack of water and run time. It will need to have a clock running so that events can be triggered we will need some way to enter the time and the events, turn things on & off, send data about this to an outside system so that I can see the state of the system & pumps from my remote location and change the settings remotely.

To achieve this I am going to have two RS232 ports one that I can plug a PC into and get & change data, another that can be used for wireless devices controlled by the system, an infrared interface to use a infrared remote control at the unit to change settings or review them, an I2C buss for nearby sensors humidity, temperature etc and a TCPIP port to hook it up for remote control. This should make the system versatile it could be used as a simple watering timer or a complex monitoring system.

I am drawing on code from the other projects as these were my way of developing the parts needed to make this work, the web-server, the matrix clock, getting more inputs and outputs with 74HC595 & 74HC165, simple clock using CPU clock

This is the first stage where I have pulled together code from the other projects its nearly 500 lines with comments and still more to bring in. I will be putting lots of comments in the code to try and make it as informative as possible I welcome comments from others where they see I could have done something better this will help myself and others to learn from it.

This is the beginning of the code although it compiles without error it has not yet got to hardware

Regards Paul
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Wed Mar 13, 2013 11:20 am    Post subject: Reply with quote

I have now put together some hardware a 64 x 128 SED LCD and a mega 644 40pin dip using the board below. I have loaded a value into L2 to provide a legitimate time and date to display , a ticking clock will be displayed in the center of the LCD showing date under which will be the time. If we had loaded L2 with the time from a RTC or from a NTP time server we would show the correct date but for now this tests the hardware.

Regards Paul

Back to top
View user's profile
bibibo

Bascom Member



Joined: 30 Nov 2009
Posts: 168

slovakia.gif
PostPosted: Wed Mar 13, 2013 5:36 pm    Post subject: Reply with quote

Paulvk, What does the DATE(12) and TIME(12) mean ? Is this a DATE and TIME Array ?
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Wed Mar 13, 2013 11:08 pm    Post subject: Reply with quote

These are inbuilt in bascom using the datetime.lbx . DATE(L2) this converts the value of L2 to to give the date, this is why I said in the other posts that you need not worry about hours, min, secs bascom will do it for you so all I have to do to work out if an event needs to happen is compare the value against L2 if it is equal or greater than L2 then it is true. When you enter the the time and date for the event you use bascom to convert it to a value in seconds which is a long variable. Note as you can now see its variable L2 not 12 the font makes it hard to see. You can also see the use of flags in the ISR that trigger the events in the main loop.

I next will be connecting an RTC board with a DS1307 on it.


Regards Paul
Back to top
View user's profile
bibibo

Bascom Member



Joined: 30 Nov 2009
Posts: 168

slovakia.gif
PostPosted: Thu Mar 14, 2013 8:30 am    Post subject: Reply with quote

Thanks a lot.
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Fri Mar 15, 2013 9:59 am    Post subject: Reply with quote

I have now added the infrared receiver to the hardware. I have also added some of the RTC clock software but not using it at present. With the infrared I can now have displayed on the terminal the 32 bit code from the handheld remote , also the 32 bits are displayed on the last two lines of the LCD. So now the graphic LCD , the RS232 and the infrared is working in hardware and code.

Regards Paul
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Sun Mar 17, 2013 12:22 pm    Post subject: Reply with quote

Now as this is going to grow quickly in code size I have moved to project mode in bascom.

In this code I have added the ability to store the codes from infra-red remotes if we send Storeon from the terminal we go into storing mode, we then press a button on the remote and the code for that button is stored in a variable the ISR for the infra-red is stopped so not to interfere with us we then type in the terminal Storecode 1 this will store the code to the eeprom as location 1 , Storecode 2 would store it to location 2 etc, once the code id stored we are ready for another, to leave this mode we type Storeoff at the terminal. Note we also get a beep from the speaker each time an infra-red code is received.

Next I will copy the code that works out what to do if we get a valid code sent to us.


Regards Paul
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5922
Location: Holland

blank.gif
PostPosted: Mon Mar 18, 2013 11:23 am    Post subject: Reply with quote

hi Paul,

Nice new project. I followed your other projects with interest too. Thanks for the regular updates.

_________________
Mark
Back to top
View user's profile Visit poster's website
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Tue Mar 19, 2013 9:41 am    Post subject: Reply with quote

Thank you Mark Exclamation

This is one of the projects that the others were the parts needed to build it with so it grows quickly.

I have now added the code to do something when a button is pressed on the remote , also the code to drive the external 4 wire serial buss, as with a 40pin chip when using a graphic LCD we use up pins quickly so now with 74HC595s for outputs & 74HC165s for inputs we can string these together to get as many as we want.

Note I am getting triggering of the IR receiver by my compact florescent lamps so I added code to try to ignore this.
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Wed Mar 20, 2013 8:23 am    Post subject: Reply with quote

Here is code with the RTC working if it does not contain a proper date and time then the default will be loaded. This code shows how to use the seconds long variable to keep time and use the RTC to set it for accuracy next I will add the code to be able to set the time via the command prompt and the infra-red remote.


Regards Paul
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Sat Mar 23, 2013 3:49 am    Post subject: Reply with quote

Some more code and functions.

Now we have Auto Stor for infra-red codes by typing Autostoron at the terminal the AVR will respond "Auto Stor On" now when we press a button on the remote its code will be displayed on the LCD , printed to the terminal and we hear a double beep from the speaker telling us that the code has been stored in EEprom starting at the first location Code(1) it is now ready for code 2 we can keep pressing buttons and storing codes till we get to 40 at which it will stop storing we can also type Autostoroff at the terminal at any time to turn the function off the AVR will respond "Auto Stor Off" Now it is easy to use any remote. I have included the eeprom codes for the DX remote as DXremote-codes.bin this was copied from the eeprom and saved it starts at the number button 1 goes to 0 which is location 10 then the on/off button is 11 going left to right we get to 19 the + button skip 0 then 20 and U/SD button is 21. So by loading this file into eeprom you can use the DX.com remote.

Regards Paul
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Sat Mar 23, 2013 9:08 am    Post subject: Reply with quote

Now the output buss is working , the variable Outbussvalue holds the state of the two 74HC595s so all we need to do to change the outputs is to change the corresponding bit in this variable then send it to the 74HC595s and latch them. We can string more 74HC595s together to get more bits, we then also change the size of the variable to match.

Regards Paul
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Tue Apr 02, 2013 4:25 am    Post subject: Reply with quote

Now the input buss is also working so we now have 16 inputs and 16 outputs, 32 pins worth with using only 4 pins on the AVR.

Regards Paul
Back to top
View user's profile
bibibo

Bascom Member



Joined: 30 Nov 2009
Posts: 168

slovakia.gif
PostPosted: Tue Apr 02, 2013 11:19 am    Post subject: Reply with quote

Hello, this is nice project. I do not understand everything.I think this is a different system than my. How do you compare the current time with the starting time ? What about runtime ?
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Tue Apr 02, 2013 12:20 pm    Post subject: Reply with quote

Hello bibibo

I am first building the code that provides the interfaces needed to measure and communicate with the real world this I am doing in a block by block way so that others may take these blocks and use them in their own projects. So now I have shown how to get a real time clock working, have a one second tick (or smaller, milliseconds) going with an ISR driven by a timer, how to use it to run a system seconds variable, how to update this system seconds variable from the real time clock, how to create a command line interface with the RS232 port, how to get lots of inputs and outputs with just 4 pins of the AVR. I am now working on analog inputs using a MAX1238 I2C , 12 port , 12 bit ADC. As I have to make a board to mount the 16pin QSOP IC it is taking a bit of time and having never used this device before I have to learn how to talk to it!

Once I have all the blocks I need to interact with the real world I will then get to work on the code to run as a watering system this will use the basic blocks already built. However there is no reason it has to be a watering system the basic blocks are generic to any system.

A bit long for an answer to your question but trying to explain the way I am building it.

As to the time related events I will have an ON time and OFF time for each event so the difference between these is the run time these will be stored in EEPROM and loaded into variables at start up or on change of them, the seconds flag will cause a comparison to be done in the main loop to the system seconds variable I will have more details later.

Regards Paul
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM Project Blog All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum