News:

  • November 23, 2026, 12:06:16 PM

Login with username, password and session length

Author Topic: BRX File System Error with SD Card File Write System  (Read 17048 times)

Cap

  • Newbie
  • *
  • Posts: 8
BRX File System Error with SD Card File Write System
« on: March 12, 2024, 03:15:21 PM »
Re-Posted from AD Forum because of lack of response.

I've been using a BRX DM1E-XXX with Expansion and Remote I/O to run my Wasteplant for the Past Two Years.. and Slowly I'm utilizing the Features afforded to me by the BRX..

I was using the RAMfile System to Store Daily Totals of Water etc, Pumped through the Plant.. The File System worked as planned, EXCEPT, the File would erase every-time I did a Program Change or Update to the PLC..

It's not a BIG Deal, as I have my own File System I wrote to Display on the C-More to allow a Years worth of Data to be stored.. Then I also do a 'Screen Shot' of my Data Display in an E-Mail every morning at 6 to my E-Mail..    So I have Backups for my Backups..

But if I'm able to keep the RAMfile intact, I can do a Copy/Past in Excel to do my Water Reports.. But with the RAMfile not surviving a PLC Software Update, that gets Difficult.
The Suggestion Posted to me in Forum, was use the SDfile Option..

I grabbed an SD Card.. Changed the RAMfile Instructions over to SDfile Instructions. Changed the Open/Write/Close Command Boxes, and then Put in the SD Card..

First File Entry ( at 6 ) worked fine.. Next Day, no Write.. I looked at the SDfile Instruction and the File Open Instruction was in Error.. The .Mediainstalled was good, and the .MediaMounted was good, but the Instruction was in Error.. I manually triggered it a Few Times and Sometimes it would open.. Sometimes Not, Sometimes the File Write would Fault... Sometimes Not.. :(

OK.. Figured something was up with the SD Card.. Got a New one.. Formatted it.. Tossed it in ( Powerd down First ) then Tried the Write. Sometimes Error.. %&(##@!@

OK.. So I added the RAMfile Instructions AFTER the SDfile Instructions.. SD Card File usually Faults.. RAMFile ALWAYS works..

I updated the OS on the PLC to the Latest of 2.9.9.. Same Issues..

Called Tech Help at AD.. Talked to two Techs.. Stumped them.. Never herd of this.. Thanks..

Anybody have any Insite as to what is up with this?..

Thanks..

 Cap

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3858
    • Host Engineering
Re: BRX File System Error with SD Card File Write System
« Reply #1 on: March 12, 2024, 03:32:24 PM »
Post your OPEN/WRITE/CLOSE code.

Cap

  • Newbie
  • *
  • Posts: 8
Re: BRX File System Error with SD Card File Write System
« Reply #2 on: March 12, 2024, 04:05:27 PM »
Here is a Pic

Cap

  • Newbie
  • *
  • Posts: 8
Re: BRX File System Error with SD Card File Write System
« Reply #3 on: March 12, 2024, 04:08:32 PM »
Here is one Live.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3858
    • Host Engineering
Re: BRX File System Error with SD Card File Write System
« Reply #4 on: March 12, 2024, 04:35:09 PM »
I highly recommend using Stage to guarantee the correct sequence.  Stick these in their own program code block (WriteToFile).  Have your contact logic you currently have drive the RUN WriteToFile

WriteToFile is simply...

RST C99  // error bit

SG S0
FILEOPEN OnSuccess JMP S1 OnError JMP S99

SG S1
FILEWRITE OnSuccess JMP S2 OnError JMP S99

SG S2
FILECLOSE OnSuccess JMP S3 OnError JMP S99

SG S3
EXIT

*** EDIT ***
SG S99
FILECLOSE OnSuccess  JMP S98 OnError JMP S98

SG S98
SET C99
EXIT
« Last Edit: March 12, 2024, 04:40:38 PM by franji1 »

Cap

  • Newbie
  • *
  • Posts: 8
Re: BRX File System Error with SD Card File Write System
« Reply #5 on: March 12, 2024, 04:36:48 PM »
Thank you.. 

I'll try it.. 

Cap

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6180
  • Yes Pinky, Do-more will control the world!
Re: BRX File System Error with SD Card File Write System
« Reply #6 on: March 12, 2024, 04:48:35 PM »
Thank you.. 

I'll try it.. 

Cap

The RAM disk completes everything in a single scan, but the SD card can't. By firing all operations off the same edge, you are getting out into no man's land and I'm not exactly sure how it will behave. I could build a case why it should work, but it isn't designed to work like that so I'm honestly not sure what happens. Obviously not what you hoped, or you wouldn't be here.  ;)

By sequencing with stages, you are allowing each operation to complete before moving to the next operation. For most instructions with OnSuccess and OnError outputs, this is the preferred implementation.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Cap

  • Newbie
  • *
  • Posts: 8
Re: BRX File System Error with SD Card File Write System
« Reply #7 on: March 13, 2024, 12:50:29 PM »
Thanks all

And by Moving my File Instruction out of my $t1Second Subroutine worked as well.. 

I have no Idea why I put it there, but It's functional now..  But to Bobs Point..  Likely the RAMfile is a 1 Scan Completion..  but not the SD Card File.

( feel so much smarter now )

Thanks Again..

Cap

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6180
  • Yes Pinky, Do-more will control the world!
Re: BRX File System Error with SD Card File Write System
« Reply #8 on: March 13, 2024, 01:01:54 PM »
Thanks all

And by Moving my File Instruction out of my $t1Second Subroutine worked as well.. 

I have no Idea why I put it there, but It's functional now..  But to Bobs Point..  Likely the RAMfile is a 1 Scan Completion..  but not the SD Card File.

( feel so much smarter now )

Thanks Again..

Cap

Glad it's working!

Yeah, the subroutine adds yet another layer of potential trouble.

As I mentioned, when the instruction has an OnSuccess/OnError pair they really should be sequenced. The easiest way to do that is via stages, as Franj described, but it can also be in normal ladder using C bits. The most important point is that for asynchronous operations like comm, or motion, or file access the instruction should be triggered and the containing code (program block, task, or stage) needs to continue to run until the OnSuccess/OnError turns on. Interrupting the execution prior to completion can cause weird behavior. The system does a pretty passable job of cleaning up behind you, and in many cases it'll still work out, but cleaning up the code will usually cure the ailment.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3858
    • Host Engineering
Re: BRX File System Error with SD Card File Write System
« Reply #9 on: March 13, 2024, 01:05:18 PM »
And by Moving my File Instruction out of my $t1Second Subroutine worked as well.. 
That would do it.

The warnings point to the issue as well:
[Warning]   $t1Second#1(@0)   W454 Fully-asynchronous instruction (FILEOPEN) used in a continuously-enabled task with a non-zero interval (ENTASK $t1Second)
[Warning]   $t1Second#1(@12)   W454 Fully-asynchronous instruction (FILEWRITE) used in a continuously-enabled task with a non-zero interval (ENTASK $t1Second)
[Warning]   $t1Second#1(@20)   W454 Fully-asynchronous instruction (FILECLOSE) used in a continuously-enabled task with a non-zero interval (ENTASK $t1Second)

Basically, that code block ($t1Second) runs for one scan every second (continuously-enabled task with a non-zero interval).  A task that runs continuously with a zero interval behaves similarly to a program in that it would run EVERY scan as long as the ENTASK has power flow, so you could have done it in a continuous 0-second interval task with manual sequencing (no stage support in Tasks, only Programs).

However, a Program code-block with Stages makes the sequencing easy-peasy.

Open up the Project Browser and expand the WriteToFile PROGRAM code block below the Control Logic tree node and then turn Status ON to watch the Stage sequencing LIVE (the cyan colored toolbar button in the Project Browser toggles Project Browser status on/off)!