A
Hello,
I was not able to get the cvs and going file by file on the net is too time consuming.
So I spent some time in brushing up my C and reworking on the timer function. It uses arrays instead of database. There is only one timer as against three used previously.
The no_of_timers and the timer preset values come from another program which is a one time configuration.
the timer still uses the jiffies bit as i could not get the timer file to study how the time increments were handled (the time pulses).
The timer still stresses on the use of the timer timing, timer done and timer enabled bits. This is because of my varied use of these bits while doing ladder and st programming on PLC's, DCS etc.
The main program calls the timer function every 10 milli seconds. I have used tempj and jiffies again to do this, but in case there are better methods then this can be eliminated from the timer module.
The Totalizer function has been reqworked and uses the switch of C. For totalization the "ip" value is the input which generally is the linearized analog input for flow.
The last functionality that has been added is the characterizer block, fnchar1. i=10 defines a ten step characterizer.
The purpose of this characterizer is to give a x to y relationship. The value of x can be time and y can be a setpoint or x can be an input value before linearization and y can be the value after linearization the same logic can be used for the LinuxPLC thermocouple and RTD input modules if the same are intelligent ones and linearization is done by software, the array size will of course be bigger.
Timer Function:
Global variables used
long tempj;
int no_of_timers;
struct tim {
int en;
int t;
int d;
long pre;
long acc;
}
struct tim timer[no_of_timers];
t001b ()
{
int i;
i=0;
while (i <= no_of timers) {
switch timer.en {
case 1: {
if timer.acc < timer.pre
{timer.acc++;
timer.t=1;}
if timer.acc=timer.pre
{timer.d=1;
timer.t=0;}
} ;
break;
case 0:
{timer.acc=0;
timer.t=0;
timer.d=0;
};
break;
}
}
tempj==jiffies;
return tempj;
}
TOtalizer function:
The totalizer function has also been modified using switch:
fnu passes integers 1 if rate is in /hr basis (kg/hr, lph etc.)
fnu passes integers 2 if rate is in /hr basis (kg/min, lpm etc.)
fnu passes integers 3 if rate is in /second basis (kg/s, lps etc.)
totalizer (float ip,val ;
int fnu)
{
switch fnu
{
case 1: val=ip/36000+val ; break;
case 2: val=ip/6000+val ; break;
case 1: val=ip/100+val ; break;}
return val;
}
Fixed length Characterizer.
Global variables
struct characterizer {float x;
float y;
}
struct characterizer char1[10];
fnchar1 (float x1, int i)
float y;
if x1 > char[i-2].x
y=(char[i-1].y-char[i-2].y)/(char[i-1].x-char.x)*x1;
else {
i--;
do while (--i=>1)
{if x1 > char[i-1].x && x1 < char
y=(char.y-char[i-1].y)/(char.x-char[i-1].x)*x1;
}
return y;
}
Anand.
P.S. though I have done work on software etc., I have not worked on any open source project previously, and hence I am unable to understand how to go about making online changes to cvs etc. Will there be a moderator who will change the files on the cvs tc. I know ftp and generally use a GUI client now (gftp, cuteftp etc.) but could not get cvs using gftp.
Is there a C expert who goes through the program and debugs it before putting it on the site.
_______________________________________________
LinuxPLC mailing list
[email protected]
http://linuxplc.org/mailman/listinfo/linuxplc
I was not able to get the cvs and going file by file on the net is too time consuming.
So I spent some time in brushing up my C and reworking on the timer function. It uses arrays instead of database. There is only one timer as against three used previously.
The no_of_timers and the timer preset values come from another program which is a one time configuration.
the timer still uses the jiffies bit as i could not get the timer file to study how the time increments were handled (the time pulses).
The timer still stresses on the use of the timer timing, timer done and timer enabled bits. This is because of my varied use of these bits while doing ladder and st programming on PLC's, DCS etc.
The main program calls the timer function every 10 milli seconds. I have used tempj and jiffies again to do this, but in case there are better methods then this can be eliminated from the timer module.
The Totalizer function has been reqworked and uses the switch of C. For totalization the "ip" value is the input which generally is the linearized analog input for flow.
The last functionality that has been added is the characterizer block, fnchar1. i=10 defines a ten step characterizer.
The purpose of this characterizer is to give a x to y relationship. The value of x can be time and y can be a setpoint or x can be an input value before linearization and y can be the value after linearization the same logic can be used for the LinuxPLC thermocouple and RTD input modules if the same are intelligent ones and linearization is done by software, the array size will of course be bigger.
Timer Function:
Global variables used
long tempj;
int no_of_timers;
struct tim {
int en;
int t;
int d;
long pre;
long acc;
}
struct tim timer[no_of_timers];
t001b ()
{
int i;
i=0;
while (i <= no_of timers) {
switch timer.en {
case 1: {
if timer.acc < timer.pre
{timer.acc++;
timer.t=1;}
if timer.acc=timer.pre
{timer.d=1;
timer.t=0;}
} ;
break;
case 0:
{timer.acc=0;
timer.t=0;
timer.d=0;
};
break;
}
}
tempj==jiffies;
return tempj;
}
TOtalizer function:
The totalizer function has also been modified using switch:
fnu passes integers 1 if rate is in /hr basis (kg/hr, lph etc.)
fnu passes integers 2 if rate is in /hr basis (kg/min, lpm etc.)
fnu passes integers 3 if rate is in /second basis (kg/s, lps etc.)
totalizer (float ip,val ;
int fnu)
{
switch fnu
{
case 1: val=ip/36000+val ; break;
case 2: val=ip/6000+val ; break;
case 1: val=ip/100+val ; break;}
return val;
}
Fixed length Characterizer.
Global variables
struct characterizer {float x;
float y;
}
struct characterizer char1[10];
fnchar1 (float x1, int i)
float y;
if x1 > char[i-2].x
y=(char[i-1].y-char[i-2].y)/(char[i-1].x-char.x)*x1;
else {
i--;
do while (--i=>1)
{if x1 > char[i-1].x && x1 < char
y=(char.y-char[i-1].y)/(char.x-char[i-1].x)*x1;
}
return y;
}
Anand.
P.S. though I have done work on software etc., I have not worked on any open source project previously, and hence I am unable to understand how to go about making online changes to cvs etc. Will there be a moderator who will change the files on the cvs tc. I know ftp and generally use a GUI client now (gftp, cuteftp etc.) but could not get cvs using gftp.
Is there a C expert who goes through the program and debugs it before putting it on the site.
_______________________________________________
LinuxPLC mailing list
[email protected]
http://linuxplc.org/mailman/listinfo/linuxplc