Hello all,
I have an application where I have an m20ia and a r-30ia controller with handling tool controlling a plating rectifier. I have one 4-20ma analog input that corresponds to the current of the rectifier. The process has to run until a certain amp hour reading is achieved. My question is can you essentially graph an analog reading over time and integrate it on the fly continually updating a register? Perhaps using BGlogic?
Thanks in advance for any input!
Calculating and keeping track of amp hours based off of two analog inputs.
-
robot take over -
June 30, 2015 at 10:24 PM -
Thread is marked as Resolved.
-
-
Yes, a BG logic program can calculate continuously, if you set it to "Ignore pause conditions".
It will not support exponents, logarithms or trigonometry, but only basic mathematical functions. -
Thanks for the reply Sergei, Is there an accurate clock that can be used as a value in the calculation?
-
There is a Heartbeat signal in I/O -> Cell outputs that goes Off -> On -> Off.
You can set interval in MENU -> Setup -> Prog Select.
Maybe you can use this ...
-
The $FAST_CLOCK system variable is a free running 4 msec increment.
Numerical and boolean system variables may be accessed from TP programs via register instructions. -
I'm attempting to write the BG logic program but am running into an issue. In the below program I am taking an analog reading and multiplying it by a change in time to calculate Amp-hours. Then adding this value every cycle to R[5]. The issue is the scan time seems to be faster than the $Fast_Clock variable increments between my two readings so each reading is the same value giving me zero when i subtract the two readings. I was able to get it to work by inserting a WAIT() between the two fast clock readings, but found out when trying to run it as background logic I can not use a WAIT() instruction.
Any feedback/ideas on how to get this to work will be much appreciated!
1: R[1]=0 ;
2: R[2]=$FAST_CLOCK ; First time reading
3: R[3]=0 ;
4: R[4]=0 ;
5: R[1]=AI[6:rectifier current feedbk] ; Read analog value that corresponds to the current of a plating rectifier
6: R[3]=$FAST_CLOCK ; Second time reading
7: R[3]=R[3]-R[2] ; Calculate change in time (delta T)
8: R[4]=R[3]*R[1] ; multiplying change in time by analog reading to get AMP-hours
9: R[5]=R[5]+R[4] ; adding current and prior amp hour values together -
try making it a non motion program
put the wait in there
and do not run in background. RUN (not CALL) it as a multi task program.
it will stop on a fault unless you set it to ignore pause. there will most likely be other obstacles to overcome.
and also you will need to jump from the bottom back up to the top until you reach whatever value it is that you are looking for. -
Thank you for the idea dmbj! Ill give it a try.