TemperedEnterprises

MrPLC Member
  • Content count

    3
  • Joined

  • Last visited

Community Reputation

0 Neutral

About TemperedEnterprises

  • Rank
    Hi, I am New!

Profile Information

  • Country United States
  1. RSLogix 5000 Code Generation using C#

    And here is another video demo of me generating FT View Studio SE Faceplates directly from an Add-on Instruction Definition File. https://youtu.be/KRj43JQJ-9A
  2. RSLogix 5000 Code Generation using C#

    CsvFileDescription d = new CsvFileDescription { SeparatorChar = ',', FirstLineHasColumnNames = true }; CsvContext cc = new CsvContext(); List<Pump> Pumps = new List<Pump>(cc.Read<Pump>(@"c:\tmp\pumps.csv", d)); RSLogix5000Content c = RSLogix5000Content.Load(@"C:\tmp\test.l5x"); Tag PAck = new Tag() { Name = "AlarmsProgAck", DataType = "BOOL", Description = new Description { TypedValue = "All Alarms Program Ack" } }; Tag PRes = new Tag() { Name = "AlarmsProgRes", DataType = "BOOL", Description = new Description { TypedValue = "All Alarms Program Reset" } }; Tag PEn = new Tag() { Name = "AlarmsProgEn", DataType = "BOOL", Description = new Description { TypedValue = "All Alarms Program Enable" } }; Tag PDis = new Tag() { Name = "AlarmsProgDis", DataType = "BOOL", Description = new Description { TypedValue = "All Alarms Program Disable" } }; c.Controller.Tags.Tag.Add(PAck); c.Controller.Tags.Tag.Add(PRes); c.Controller.Tags.Tag.Add(PEn); c.Controller.Tags.Tag.Add(PDis); int x = 1; foreach (Pump p in Pumps) { String InterlockBuilder = ""; if ((p.Interlocks ?? "").Contains(',')) { string[] Interlocks = p.Interlocks.Trim().Split(','); foreach (string interlock in Interlocks) { InterlockBuilder += "XIC(" + interlock + "Running)"; } } Tag PStart = new Tag() { Name = p.Name + "Start", DataType = "BOOL", Description = new Description { TypedValue = p.Description + " Start Command" } }; Tag PStop = new Tag() { Name = p.Name + "Stop", DataType = "BOOL", Description = new Description { TypedValue = p.Description + " Stop Command" } }; Tag PRunA = new Tag() { Name = p.Name + "Run", TagType = "Alias", AliasFor = p.StartOutput, Description = new Description { TypedValue = p.Description + " Run Output" } }; Tag PRunningA = new Tag() { Name = p.Name + "Running", TagType = "Alias", AliasFor = p.RunInput, Description = new Description { TypedValue = p.Description + " Running Input" } }; Tag PAlarmD = new Tag() { Name = p.Name + "Alarm", DataType = "ALARM_DIGITAL", Description = new Description { TypedValue = p.Description + " Start Alarm" } }; Rung r = new Rung(); r.Number = x++; r.Comment = new Comment { TypedValue = "Pump Logic Code for " + p.Description }; r.Text = new Text { TypedValue = "[" + InterlockBuilder + "[XIC(" + p.Name + "Run)XIO(" + p.Name + "Stop),XIC(" + p.Name + "Start)]OTE(" + p.Name + "Run),XIC(" + p.Name + "Run)XIO(" + p.Name + "Running)ALMD(" + PAlarmD.Name + "," + PAck.Name + "," + PRes.Name + "," + PDis.Name + "," + PEn.Name + ")];" }; Routine PumpRoutine = new Routine { Name = p.Name, Type = "RLL" }; PumpRoutine.RLLContent = new RLLContent(); PumpRoutine.RLLContent.Rung.Add(r); c.Controller.Programs.Program[0].Routines.Routine.Add(PumpRoutine); c.Controller.Programs.Program[0].Routines.Routine[0].RLLContent.Rung.Add(new Rung { Number = x, Text = new Text { TypedValue = "JSR(" + p.Name + ",0);" } }); c.Controller.Tags.Tag.Add(PStart); c.Controller.Tags.Tag.Add(PStop); c.Controller.Tags.Tag.Add(PRunA); c.Controller.Tags.Tag.Add(PRunningA); c.Controller.Tags.Tag.Add(PAlarmD); } c.Save("c:\\tmp\\testout.l5x"); Here is the code that generates the ladder logic.
  3. I put together a demo of the c# library I am working on for Rockwell PLC. It basically allows you to parse/construct the L5X files for code generation, documentation, and other uses. https://www.youtube.com/watch?v=kV0nXSyM7Gg