Jump to content

Recommended Posts

Hello everyone, 

I'm using SD functions to create a CSV file to save data such as temperature / pressure / date hour etc... and I would like to understand what the value of my MI900 means when I'm online mode.
I kind of get my other operand purposes but this one is difficult to identify. 

Here is a screen capture for you

When SB41 is activated this value turns to 24900 for a couple of seconds and then restore his previous value (here it's 14129 sometimes it's 14486 or 12200 and idk why). That's what I don't get. 

I'm asking you this because usually the program works very well until last time where everything kind of froze and I had to reinitialize my V130 to make it work again. Also my SD card was not full at all. 
Below you can see the entire subroutine when it failed to write data. Only my column titles were written on my CSV but then nothing more every minutes.   




Also, you must have guessed but I'm a complete beginner. The program is not even mine, but from someone who left and I'm trying to learn a bit.

Anyway, I'm looking forward your support. Any suggestions will be appreciated. Thank you !

Model and software used : V130 & Visilogic  9.7.55

Link to comment
Share on other sites

MI900 is the beginning register of a line that will be written into CSV file by block "Write -> SD". So MI900 and couple of registers after it (MI901, MI902...) will contain ASCII stuff to be written, each register is 16 bits, so it will hold two 8-bit characters, it's difficult to interpret what those registers contain just by looking at them.
Help file is useful, open every block and click help to see what it does.

How big is that file that you are writing into? Maybe there is a limit to how large it can be. If you are writing every minute it can get big over time.

Link to comment
Share on other sites

Hello Isakovic, 

Yes I looked at help files for every block which helped me understand what those blocks were for.
But I'm afraid it still doesn't explain MI 900 value.  You're right, it's difficult to interpret it. 

If I got it right : 
MI 900 - the start of my vector where my data will be stored  
ML 40 - the actual number of bytes sent to the vector
ML 45 - a status message

And then with my second block "Write->...", my data - which is previously stored in my MIs - is written to a CSV. 

My file is not that big... I'd say less than 3 MB depending on time spent recording data. I extract those data from my csv every one or two days. 
Also I'm using a 4GB micro SD card and I delete my file each time so that it doesn't gain too much weight. 
I believe if the default was due to my sd card, ML45 would turn to something wouldn't it ? 

I was thinking maybe my bug was caused by a non reset variable or something. The thing is, when SB41 was on (when someone pressed the key 1 of my V130), only column titles were written on my file and then nothing.  

Anyway, I really thank you for your time and for answering me.

Link to comment
Share on other sites

No problem Johschr, glad to help.

You could see what is stored in MI900 and following registers by opening block "SD Utility Delimited Line". There you will see data that is written. It will be couple of rows of what is to be written into CSV file, each row in this block will be data in consecutive columns.
#1 Indirect text - ML 15 (Because you have a function block that turns date into ascii in line 1 of your code)
#2 Indirect text - ML 10 (Because you have a function block that turns time into ascii in line 1 of your code)
#2 Numeric field - MI0 (Maybe a process value, pressure)

So block "SD Utility Delimited Line" will take all those fields, add delimiters on the end and store all that into one line of ascii characters starting from MI900. That's how to see what is in MI900, basically one row of your CSV file.
It could be that MI900 quickly changes value when function is called because it first holds titles of columns until they are written in line, and then gets overwritten with process data.

Can't really say what is causing PLC to freeze. Looks like up arrow on keyboard is used to reset status bits from one write function to allow the next one to be called, from what I can see in the pictures. Does data get written into CSV after pressing it? Maybe there is some sort of conflict if you are accessing and SD card while PLC is writing to it. Just guessing now, troubleshooting someone else's work can be difficult.

Link to comment
Share on other sites

Yes indeed, that's exactly it. 
I've got two blocks "SD utility delimited line" : the first one is mostly for constant texts (my column titles) and the second one contains data such as date, hour (ML15 & ML10) and process values. 

On 7/20/2018 at 7:46 AM, Isakovic said:

It could be that MI900 quickly changes value when function is called because it first holds titles of columns until they are written in line, and then gets overwritten with process data.

I think you may be right on this one since when the key button is pressed, it writes titles on my CSV and then it writes values. 
So that could certainly explain the value changement of MI900... thanks for your explanations. It's not so obvious when you begin. 

That button is also used to start a process sequence. So it means I can find in my CSV the process beginning by looking for titles.

But from what I know, data is non-stop written. I don't necessarily need to press the key to start recording data. When I extract data and then delete my file on SD card, if I look a few minutes after, I will have values on it. Basically, pressing the key button is only used to write titles in this code. 

I tried accessing the SD card (using unitronics SD card suite) for a while and then looked at the file but there wasn't any time gap so I'm not sure there's a conflict. 
Also, I can't really explain why SB41  is used to reset MB252 because, to me, MB252 is always set.  If it wasn't, it couldn't be possible to write data continuously. I guess there's a better way of coding it but changing everything could be risky.  

Again, thanks for your support. At least, I'm learning and understanding better thanks to you. 

Take care. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...