Crimson 3 - Recipes - CompactFlash ?s

jfls45

Member
Join Date
Mar 2012
Location
Pennsylvania
Posts
76
Greetings,

Can anyone assist me with finding a way to save Recipes to the CompactFlash card in Crimson 3? I've been searching through the manual and don't see where this is covered.

I am assuming I need to use some code to make this happen? Would I be saving it to a .CSV file? If so, are there any examples available I can glean from? I've been looking through the sample files and not seeing anything specific to this.

Thanks for everyones help

jfls45
 
I downloaded the Red Lion file (posted in the link above) into my HMI and it doesn't work properly. It is not saving any data to the CompactFlash.
 
Last edited:
Can anyone give me a hand with figuring out the proper syntax for writing recipes to a .csv file? I've figured out how to make a directory and create the file, now could use some help with the code itself.

Here are the actual names of my tags, (just a few of them) if anyone wants to show me with an example please do.

ProductionOrder (this is a 7 digit integer)
GapRoll1 (these are all floats)
GapRoll3
AngleRoll1
AngleRoll2
DeflectRoll4
DeflectRoll6

I would like to save them onto the CompactFlash card.

Hopefully someone out there has a few minutes and willing to help me out here.

thanks
 
As an update to the above posts, (even though noone is responding) I discovered that you need to dismount the flash card to write to it.
 
I've been saving oven recipes as simple .txt files instead of .CSV so notepad can edit them,
will try to convert program routines to text files and post them later with samples.

We also save the oven running status every 'tick' so recovery from a power problem is easy.

write tags to files using Tag.AsText then add description string afterwards, when text is converted back to a number the extra text after number is ignored.

e.g.
WriteFileLine( FileNumber, GapRoll1.AsText + " GapRoll1" );

GapRoll1 := TextToFloat( ReadFileLine( FileNumber ) );

hope this helps

Kenny
 
Kenny, I've managed to write my parameters to the CompactFlash, now I need to be able to load them back into the Recipe page.

Here is a copy of my code to save the recipes, perhaps you can give me some pointers how to load them back in.

int hfile; //file opened index
int i; //array scanning index
// Create a new folder if it doesn't exist
CreateDirectory("/recipes");
//Create the file if it's doesn't exist
CreateFile("/recipes/recipe.csv");
//open the file
hfile= OpenFile("/recipes/recipe.csv",2);
//Write each recipe as a line in the file
//Copy each array index as a file line beginning by the recipe index
for (i=0;i<1;i++){
WriteFileLine(hfile,AsText(i)+","
+ProductionOrder.AsText+";"
+GapRoll1.AsText+";"
+GapRoll3.AsText+";"
+GapRoll5.AsText+";"
+GapRoll7.AsText+";"
+GapRoll9.AsText+";"
+AngleRoll1.AsText+";"
+AngleRoll3.AsText+";"
+AngleRoll5.AsText+";"
+AngleRoll7.AsText+";"
+AngleRoll9.AsText+";"
+AngleRoll2.AsText+";"
+AngleRoll4.AsText+";"
+AngleRoll6.AsText+";"
+AngleRoll8.AsText+";"
+AngleRoll10.AsText+";"
+DeflectRoll4.AsText+";"
+DeflectRoll6.AsText+";"
+DeflectRoll8.AsText);
}
//Close the file
CloseFile(hfile);
 
needed tags
hfile number tag // file handle
Data string tag // holds string read from file
Index number tag // current location in Data
Token string tag // holds string between delimiters in Data

needed programs
GetNextData() // reads next line of text from file
GetNextToken() // gets next value string from Data
LoadRecipeFile() // opens, reads, closes file

program GetNextData()
Data := ReadFileLine( hfile );
Index := 0; // reset to beginning of Data string
// end of program

program GetNextToken()
Token := "";
while ( Data[ Index ] != "," ) &&
( Data[ Index ] != "," ) &&
( Index < len( Data ) )
{
Token := Token + Data[ Index ]; // build Token
Index := Index + 1; // move to next digit
}
Index := Index + 1; // skip over delimiter
// end of program

program LoadRecipeFile()
int i;
hfile := OpenFile( "/recipes/recipe.csv", 1 ); // read from start mode
for ( i:=0; i<1; i++ )
{
GetNextData();
GetNextToken();
if ( len( Token ) > 0 ) ProductionOrder := TextToInt( Token, 10 );

GetNextToken();
if ( len( Token ) > 0 ) GapRol1 := TextToFloat( Token );

. . .

GetNextToken();
if ( len( Token ) > 0 ) DeflectionRoll8 := TextToFloat( Token );
}
CloseFile( hfile );
// end of program

hope this helps
Kenny

( i think your tags need to be arrays indexed by
otherwise you will just get the last Data read )
 
Thank you Ken. I really appreciate you taking the time to do this. If your ever in the Pittsburgh PA area let me know and I'll buy you lunch.

Jfls45
 

Similar Topics

Hi all. I using a Red Lion panel and crimson 3 to produce a control for an oven. I need to store several values for 13 products. Each product as...
Replies
4
Views
1,803
Hello, I need some help on creating 3 recipes in Crimson 3. When I select a recipe button (1-3), a value is written into 16 other integer tags...
Replies
9
Views
2,458
Hi Guys, Although quite new to Crimson 3.0, I have read through and written specific recipe routines using the tutorials Red Lion sent through...
Replies
6
Views
8,236
Hey guys, hoping someone here could give me a little advice. I'm working with a CR1000-04000 in Crimson 3.1 and I was interested in adding the...
Replies
4
Views
114
Hi, I'm having an issue in crimson 3.0 when I create a programme using a case statement referencing a fault word that each bit needs to change the...
Replies
4
Views
169
Back
Top Bottom