CAI Webcontrol Analog Reading

MobileMe

Active Member
I have a webcontrol board with a ultrasonic range finder which I'm using to measure the salt depth in my softenter. My issue is getting a stable analog reading. Is there a way to stablilize the reading?
 
I played with Maxbotix ultrasonic sensor and used its RS-322 capabilty and managed it with xapmcsSonar. I did software filtering to smooth out the higher frequency components of the signal. You could do the same thing with the software you use to interface the WebControl. I would think you could also add a RC filter to the analog input to achieve similiar results. This is especially true since your input rate of change is very slow. In my case I did not want to over filter because I wanted to detect moving objects.
 
What is the full voltage range of the sensor and what does that correspond to as far measuring the salt level? How much bounce are you getting in your voltage readings and how much would you like it to be?
 
The board itself, to my knowledge does not have a way to smooth out the reading. I'm using a Maxbotix LV-EZ2. The board is pushing +5V and it seems that the range is 0 to 50 for my appication considering the salt tank is only 4 foot deep. The bounce reading is about 15 give or take. I would like to be around 3. This way I can program the board to email me when the level gets to 50. RIght now the bounce would make it difficult to get an accurate level reading.

I did read on another forum that I can put in a capacitor between the ground and analog pin to get a more stable reading. Do you think this will help? If not, are there any other ways to get this reading to not bounce so much?

Thanks in advance for the advice.
 
Right now the analog input is 10V full scale for reading about 1024. If your input level is low, you could eitehr add amplifier in front of the analog input, or modify the board. R26/R28/R30 are analog input dividers at 200K. If you change the resistor to 45K, you will get about 5V full scale. Or 1K to 3.3V full scale. But you don't want to make it zero, since the proteciton diode could be damaged without this resistor.

Adding capacitor to filter the input spikes will help. Make sure using high quality capacitor with low leakage. Capacitor leakage could introduce noises.

Modifying the baord will void warranty of the board.
 
Let me understand.

The full range of the analog unltrasonic distance device is 0 to 5v. If you are saying the cai range on your 4 foot distance is 0 to 50, then I am understanding that we are talking 0 to 1/2v total range (since a value of 50 on cai is roughly 1/2 volt).

That is a fairly small range to measure and noise will certainly come into play.

You can use CAI's variables and run an averaging algorithm using PLC. You take the variable multiply by 1000, add the analog value, divide by 1001, then repeat. When the variable value hits your target, have it send you an email. You can watch your variable value and see how steady it is. If you need to go bigger like 2000 or 5000 you can do it.
 
Sorry but thats a little over my head. I can do basic PLC programming. I'm not sure what you mean by the variable? I have not idea where to start with an averaging algorithm.
 
That Maxbotix Unit will only put out 10 mVolts per inch. You have a 48" maximum depth so as Lou said above, you will not get a reading above .5 volts (on empty).

Your WebControl analog input is 10 volts full scale which on a ten bit resolution will yield 1024 counts. (2[sup]10[/sup])

So, you will only see counts of around 50 with your tank empty. ( 1024/10 * .5 ).

I'm betting you have a long length of wire between the sensor and the WebControl board. Also, not sure if your power supply is well filtered as well. This will definitely give you fluctuations as the analog output reading of the sensor is just to low for this application.

IMO the only way to get a viable reading is to amplify it as the source (sensor) and insure you have a well filtered power supply.

I have done this exact project, except I used the RS-232 output in lieu of the analog output for this very reason.

I wound up abandoning the concept though as that RS-232 reading would constantly update and I did not ever figure out how to set it up to 'poll'.

Also, it would help greatly if the WebControl board's 'full scale' capability of the analog inputs was adjustable. This way you could set it up for say 0,5 volts full scale and the 1024 maximum counts would be evenly divided over this range instead of the 10 volt current range.

Your input would still vary for reasons stated above, but you could just see what 'count' reading you wanted to trigger a comfortable notification on a desired level.

There are others that have after market fixes such as Gerry from RGB LED (I believe that company does not exist), and Michael M. also has some experience as stated above.

It would help if the WebControl's analog inputs full scale readings were adjustable, say to 0.5 volts, this way the 1024 counts would be divided evenly across that range instead of the current 10 volt range. You would still get fluctuations, but I'm betting you could just decide on a count number that would represent a comfortable level to designate when you need to refill the softener.
 
Brave Sir Robbin: You can adjust webcontrol's input range but it requires soldering a different resistor in as described (sort of) by Cai supports post above. So it's only kind of sort of adjustable.

But the problem I see it with that is that you still will have the noise and instead of the noise bouncing around 5 or 10 units (just a guess here) it might now bounce around 100 or 200 points, so in the end adjusting cai's range from 0 to 10v to 0 to 1/2 volt doesn't get you much better off.

A good power supply and a short wire are certainly good ideas as you mentioned. Athough, CAI does have it's own voltage regulator on board and you can pull the 5v for the ultrasonic device off of the cai itself which should be pretty cleaned up. In my experience using 5v pressure transducers (freescale) powered off of CAI itself with around 6feet of cat5 connecting them, I only get about 3 or 4 points of bounce (noise) on my readings, although I can't say for sure that it isn't the pressure transducer itself doing it.

Mobileme:
Read the instructions off of CAI's manual on how to write PLC code and the memory locations. There are 8 variable (VAR1, VAR2, . . .VAR8) and 8 ram locations (RAM1, .. ETC). These are used to store values. The Var values are displayed in the gui, the ram are not. The var values can be saved through a power failure where ram values can not.

Something like this is all you need.

START
MUL VAR1 1000 RAM1
ADD RAM1 AIP1 RAM1
DIV RAM1 1001 VAR1
END

In this way, as the value of the aip1 changes, it is only given a weight of .1% as it is averaged together with the old value of var1. This will clean out most of the noise.
 
Building a simple amplifier is easy, look this datasheet page 8 fig 2, it does not take much to build a x10 DC amplifier:
http://www.ti.com/li...link/tl081a.pdf
The IC is also low cost: http://www.digikey.c...211-1-ND/378290

You don't have to use this particular IC, any operational amplifier IC will do. Pick one best fit your power source. The gain is easy to calculate: feedback resistor / input resistor = gain.

You can read more about operational amplifier at here:
http://en.wikipedia.org/wiki/Operational_amplifier
The section of non-inverting amplifier section is better fit your need. "The voltage gain of the entire circuit is determined by 1 + R[sub]f[/sub]/R[sub]g[/sub]"
 
I'm trying to setup the PLC code to average out the analog input, but I can't see to get it to work for me. Can anyone tell me what I'm doing wrong?

START
SET RAM1 0
SET RAM2 0
SET RAM3 0


LOOP:
CALLSUB RESETRAMS
DELAY 500
TSTLT H1 54
CALLSUB HUMOFF
DELAY 500
TSTGT H1 64
CALLSUB HUMON
TSTEQ IP1 1
CALLSUB SETVAR1
TSTGT AIP1 60
CALLSUB ALERT1
CALLSUB AVERG
GOTO LOOP
END

HUMON:
TSTEQ RAM2 0
GOTO ON
RET

HUMOFF:
TSTEQ RAM2 1
GOTO OFF
RET

RESETRAMS:
TSTEQ IP1 0
SET RAM1 0
TSTLT AIP1 40
SET RAM3 0
RET

SETVAR1:
TSTEQ RAM1 0
ADD VAR1 1 VAR1
SET RAM1 1
DELAY 500
RET

ON:
SET OP1 1
DELAY 500
SET OP1 0
SET RAM2 1
DELAY 500
GOTO LOOP
OFF:
SET OP2 1
DELAY 500
SET OP2 0
SET RAM2 0
DELAY 500
GOTO LOOP
ALERT1:
TSTEQ RAM3 0
EMAIL EM1
SET RAM3 1
DELAY 500
RET

AVERG:
MUL VAR2 1000 RAM4
ADD RAM4 AIP1 RAM4
DIV RAM4 1001 VAR2
RET
 
Without spending a bunch of time an analyzing everything, I would think that your problem is all of the delays. For the averaging program to work it has to run that subroutine several thousand times before it finds a steady state. This happens in a second or two normally. However, you have delays of 500 ms all over the place which means that it would take a long time before the averaging subroutine runs a few thousand times.

Try writing your PLC code with the averaging program being the only thing in there. Then watch your GUI screen and see what var2 does. It should start at 0 and then gradually move up to the correct number over a few seconds and then sit fairly steady. Move your ultrasonic detector closer/further from the target and watch how the number responds. You can adjust the number (1000/1001) to something bigger or smaller. The bigger the number, the less responsive, but also the less bounce. It would seem that for salt disolving in a softener, a quick response is pretty meaningless.

Assuming all that works, you would need to consider a different way to write the other plc code to get rid of all the delays. Or, alternatively, you could have the averaging subroutine loop on itself a few thousand times every time the subroutine is called.
 
I did get it to work, but the number did not change very fast. Although it would work for the application I was using it for, I other a sensors that it would not work for. It did however give me an idea. I use just a basic averaging system to get a much more stable reading. I took the variable(VAR1) and added the analog reading to it and put it into a memory slot(RAM1). Then I added a delay and then repeated the process 5 times, then divided RAM1 by 5 and put it into VAR1. So it would average AIP1 over a period of 2 seconds or so. That number would not bounce very much. Every 2 to 3 seconds, the number would change and not bounce so much. Just what I wanted it to do. Now I have a bounce of about 2 to 3 instead of 10 to 15.

I can now run conditions on VAR1 with some desent acceracy.

Thanks for the idea.
 
Back
Top