[SOLVED] Water Pump controlling using PIC16F628A is behaviouring strange!

Status
Not open for further replies.

Mrunal Ahirrao

Full Member level 2
Joined
Nov 26, 2012
Messages
133
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Location
India
Visit site
Activity points
2,213
Hi everyone,
I have developed a project which control all the water monitoring using PIC16f628A controller. The project works correct on prototype but fails on real time! All the code is followed correctly on prototype and when connected in Real situation it behaves strangely! As it works correctly on Prototype it means the code is correct, but in practical situation it fails.I have that its because EMI caused by relays. So I replaced Electromechanical relays with solid state relays. but it still behaves the same. In the enclosure I admit that the control PCB is very near to SSR's but I believe it won't create any problem.(am I correct)!?I am attaching the image of the system where its situated. The sad strange behaviour is it has been programmed t check waterlevel of lower tank first if it satisfies then switch ON the Pump and fill the overhead tank.this command works on prototype but don't on Real time instead of checking the water level it directly Switches ON the Pum when water is not there! Any help would be appreciated!
 

The clasic symptoms of EMI on processors is they behave unpredictably and randomly. If your design is doing the same wrong action every time it suggests an electrical design fault or a software bug. My first guess at what may be different between simulation and real hardware is that your water level switch is not providing the correct logic levels to the processor. If it is a simple switch, do you have a pull-up or pull-down resistor to set a default logic level when the switch is open?

Brian.
 

Most likely your 'real-life' sensors aren't doing the job properly. What sort of sensor are you using ?
 


It works well outside the enclosure.but when fitted in enclosure then it behaves strange and yes I have used Pull down resistors. I have also tested the logic levels on those "faulty" pins and unfortunately it shows some 3 Volts at those pins. but ideally it should show zero volts! is this the symptom of EMI? because the SSR's are near the control PCB. and more over the pump is also near to it roughly 1/2 ft distance.

- - - Updated - - -

Most likely your 'real-life' sensors aren't doing the job properly. What sort of sensor are you using ?

simple electrolysis based level sensors. and to avoid corrosion I have programmed in such a way that controller would switch ON sensor when needed and switch it off after completion

- - - Updated - - -

Post your circuit. It will help to get the problem solved

I have attached schematic.
 

Attachments

  • mainSchematic.zip
    10.2 KB · Views: 130

If your sensors read 3V it will be seen as a logic high so they are passing enough current in their 'off' state to overcome the pull-down resistors. Either reduce the value of the pull-down resistors or if that isn't possible, add a comparator circuit to the sensor outputs so they give a clear high/low output when they operate.

I assume the MCLR pin is set to input mode and you have the reset internally tied to VDD.

To answer your question - this is not an EMI issue, it's just that the sensor outputs are not well enough defined for their logic state to be used reliably.

Brian.
 

What is the functionality of MCLR (pin 4) ?
Alternate I/O function

- - - Updated - - -


Ok I will do as you directed and tell you the results. Thank you. But if this was so, then it works well outside the enclosure or( when SSR are not connected to Pumps). But it behaves strange when all SSR's are interfaced with controller PCB (SSRs which are connected with pumps).
 
Last edited:

It still has nothing to do with EMI. Dropping the pull-down resistor values will help but it does not explain the underlying problem.

I can think of two things to check:

1. you say you are using electrolysis probes, if this is simply two metal probes in the water, is it possible you are actually generating a voltage between them (like a battery). What are the probes made of?

2. Is there an electrical connection (maybe an Earth connection) to the pumps or the tank itself which is not at the same ground potential as your logic circuit? What I'm suggesting is that the water itself is conducting the voltage from some other connection which is above your circuits ground potential.

If idea 2 makes sense, try disconnecting the probe inputs to your circuit completely and see if any residual voltage is still on them with respect to ground.

Brian.
 


Thanks for reply.Your idea 2 is correct because the earthing is not done to one pump. and yes I have disconnected sensors and but it still shows some residual voltage.

and the metal for sensor probes is steel.
 

Try grounding the pump, it should be grounded for safety reasons anyway. Also, if the tank is metal, try grounding that as well.


Brian.
Its working. The error was in my code! We cannot call it as an error,as I am just switching sensors ON/OFF when needed to avoid corrosion.But this don't know why made PIC to behave strange! So I removed that instruction and made sensor to switch ON forever! and now its working... thanks .
 

The clasic symptoms of EMI on processors is they behave unpredictably and randomly.

Brian.

This is very true! I too designed a Pump Controller, and had to go thro abt 4 different versions of it. In one I simply converted the (11) levels (sensed using reed switches + magnet) to an analog voltage and then used the PIC adc to decode the level. Big mistake. The 200+ feet or wire between the reeds and the PIC would pick up an unbelievable amount of noise. The levels would mysteriously change to random values when the float was in-between levels. Then I tried using a '165 (5V) to serialize the levels. That too failed. It worked fine on the bench, and even with a roll of 200' feet of 3-pair wire I had lying around. But when actually installed it just wouldnt work. The interference with the power cables in the same conduit as the signal wires corrupted the signals. Finally I used a diode matrix encoder and 15V logic, and LM339's to convert to TTL at the PIC end. Thats works fine. So far.

Actually it turns out that the actual electronic design effort is insignificant compared to the mechanical robustness required in this quite hostile environment.

Who knew a seemingly simple project could turn out to be so difficult in practice?

vkj
 

Can beat that...

I have a system very close which uses CAT-5 UTP to carry power and two serial links, it's around 50m (~150 feet) long, and runs parallel and about 2 metres away from a long wire antenna pumping out around 150W peak AM power at various frequencies between 2MHz and 60MHz. You think you have problems with 50/60Hz pick up - try HF !! The data goes to a transmitter at the remote end of the CAT-5 and the antenna runs back toward the computer system.

The solution in my case was to change to RS422 data format which solved the problem completely. The interference is still several volts on the lines but being a differential system, the common mode interfering voltage is of little consequence.

Brian.
 

Why not try a simplified way, using PNP transistors as sensor to water level low and high level, and ON the pump when both transistors are turned ON.
The MCU will OFF the pump, when both transistors are OFF.
The circuit is attached.

oook
 

Attachments

  • WaterLevelMonitor.pdf
    12.9 KB · Views: 120

Why not try a simplified way, using PNP transistors as sensor to water level low and high level, and ON the pump when both transistors are turned ON.
The MCU will OFF the pump, when both transistors are OFF.
The circuit is attached.

oook

You dont really need any MCU for such a simple setup. A couple of logic ICs will do. However if you have a more ambitious plan of including a numeric display of the level (say from 0 (empty) to full (10)) then that might call for a more complex design involving an MCU. Also typically the water is pumped from an underground sump, and indication of the sumps water level is also desirable.

Using the conductivity of the water itself for level indication is not very reliable. Typically after a few months the sensing electrodes corrode and/or water seeps inside the insulation.

vkj
 

The Problem was in Tanks! actually the tanks in which I have used sensors with are electrically connected to each other! so when sensors are switched in one tank the other tank sensor also gave output which was the root cause for strange behaviour of Microcontroller! Thanks all of you by the way!...
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…