Newer additions and some changes:

A

Thread Starter

Anand

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
 
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.

Basically, there are two ways:

1) casual contribution:

- check out the cvs using the "Anonymous CVS Access"
- make changes
- use "cvs diff -u" to make a patch
- submit the patch to the Patch-tracker, or e-mail it to the person
responsible for that part of the project

One of the regular developers will act as a moderator and put the
changes into the CVS.

2) regular contribution:

- check out the cvs using "Developer Access"
- make changes
- use "cvs ci" to check them in

For this, you need to have the appropriate authorization, and no
further checking takes place. The changes just go in.


Either way, you use the "cvs upd" command to keep up-to-date with whatever
changes other people are making to the CVS. It'll automatically merge what
you changed and what other people changed.

> I know ftp and generally use a GUI client now (gftp, cuteftp etc.) but
> could not get cvs using gftp.

CVS is its own program that does its own thing - it doesn't really
interface with ftp or anything. I think there's a GUI interface for it, but
I've never tried it.


Hope that makes sense...

Jiri
--
Jiri Baum <[email protected]>
http://www.csse.monash.edu.au/~jiribvisit the MAT LinuxPLC project at http://mat.sourceforge.net

_______________________________________________
LinuxPLC mailing list
[email protected]
http://linuxplc.org/mailman/listinfo/linuxplc
 
B

Bob Peterson

Might I make a suggestion? Since you are trying to emulate a PLC5, perhaps the done/enable/timing bits should actually work the way they do in a PLC5 so that one does not have to modify any programming to take a PLC5 program and make it work in your emulator. You have made these bits asynchronous to the RLL scan but in a real PLC5 they are not. In a real PLC5 these bits (and the
accumulated register) only get updated when they are scanned in the RLL program. This is actually quite useful. It means that timers that are
jumped (or are in subroutines that are not called) are not updated at all. Its also useful to be able to use these bits in your RLL program but if you do not know exactly when they will be coming on you cannot.

Bob Peterson
_______________________________________________
LinuxPLC mailing list
[email protected]
http://linuxplc.org/mailman/listinfo/linuxplc
 
Thanks for the suggestion.
I believed that running the routine everytime would add to the program length. Especially the check weather the timer tick of 10 ms is on and then update the values. But since we are talking of a powerful processor and RAM, this may not matter. The user program could call the update routine everytime the timer ticks for that timer and that should help.
Anand
_______________________________________________ LinuxPLC mailing list
[email protected]
http://linuxplc.org/mailman/listinfo/linuxplc
 
Anand:
> I believed that running the routine everytime would add to the program
> length. Especially the check weather the timer tick of 10 ms is on and
> then update the values. But since we are talking of a powerful processor
> and RAM, this may not matter. The user program could call the update
> routine everytime the timer ticks for that timer and that should help.

- If this is a separate module, then the bits automatically get buffered.
They can only change at the top (bottom) of the ladder diagram (when the
plc_update() function gets called).

- If this is to be a part of the language, we can save the time at the top
of the scan and use the saved value for all timer calculations. That'll
also save separate system calls, so it should wind up more efficient.


Jiri
--
Jiri Baum <[email protected]>
http://www.csse.monash.edu.au/~jiribvisit the MAT LinuxPLC project at http://mat.sourceforge.net

_______________________________________________
LinuxPLC mailing list
[email protected]
http://linuxplc.org/mailman/listinfo/linuxplc
 
D

Dan L. Pierson

Jiri Baum <[email protected]> writes:

> CVS is its own program that does its own thing - it doesn't really
> interface with ftp or anything. I think there's a GUI interface for it, but
> I've never tried it.

I use the Cervisia GUI on my local machine as well as the command line everywhere. I find that the GUI helps by giving quick overviews of what files have changed in a directory, visual maps of the branch history, and easy access to visual diffs and merges. None of this is essential, but it is convenient. (Note, this is mostly for non-Linuxplc work...)

_______________________________________________
LinuxPLC mailing list
[email protected]
http://linuxplc.org/mailman/listinfo/linuxplc
 
Top