LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview PLC and databse connection

Hello,

 

I have some problems with saving the data acquired from a Siemens PLC,after the data_ready becomes true I want to save the data acquired from the PLC open a link to my SQL database and save only once.I've tried multiple iterations of the same program but this one seems the most viable.

 

The problem is the VI saves data multiple times in MySQL,data_ready becomes true every 12-16 secs depending when the battery is tested,and it becomes false after approximately 3 secs delay included.I've tried making the VI wait ,but I want to steer away to messing with timings,I want to save only when the data_ready is true,and the data_readed if possible to be used as a indicator through a light bulb connected in the PLC.

0 Kudos
Message 1 of 10
(2,983 Views)

Hey Lopimank,

 

You might want to try extending your flat sequence structure to cover the case structure after. Also, I would have a default value for data_ready in your inner loop because the previous value will be saved. So the value it has when it leaves the loop will be the one it has when it enters again. 

Gerald M.
Applications Engineer
NI
0 Kudos
Message 2 of 10
(2,939 Views)

@GeraldM wrote:

Hey Lopimank,

 

You might want to try extending your flat sequence structure to cover the case structure after. ..


Data flow eliminates the need for that extra frame.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 3 of 10
(2,933 Views)

Haven't looked to closely but you might want to check the properties of the data_ready variable to see if it is configured to buffer inputs. When you install DSC I think that becomes the default configuration for some reason.

Matt J | National Instruments | CLA
0 Kudos
Message 4 of 10
(2,918 Views)

Sorry I couldn't respond over the weekend,I wasn't able to get to my office.

 

Well I've changed the buffer like you said,made some changes by making a local variable,as the "Data_ready" value cannot be changed as it's coming from a PLC.But MySQL still makes 3 saves of the same reading from the PLC.I want to know if this coming from my LabView VI or the PLC itself.If it Labview then it's beyond my current understanding of it,if it's from the PLC I can change it how much I want.

 

Thanks for all the help.

0 Kudos
Message 5 of 10
(2,898 Views)

You need to make your code look for changes to the save data flag. Save on the first occurrence when the flag is true. Then you need to reset once you see the flag go false after the 3 seconds. This will get rid of saving the data three times. You can not just write data when the condition is true. You need to do it when it is true and it is the first time through the loop.

Tim
GHSP
0 Kudos
Message 6 of 10
(2,882 Views)

Hello Tim,

 

Thanks for responding so fast.Do you think you can give me an example on how to do that? Do I need to use an event structure or is there any other way.I don't have the expertise to use Labview to it's full extent.

0 Kudos
Message 7 of 10
(2,878 Views)

I would use a shift register to set the save status. The first time you see the data ready go true, set the shift register value to true (software copy and not tied to the PLC value). Read and save the data. set the shift register to false. Then you need to look to see if the last time you read the data ready (PLC copy) and this time (PLC copy) have changed. when it changes to false do nothing but when it goes back to true you set the shift register back to true. Write once and then back to false until the next time it sees true again.

Tim
GHSP
0 Kudos
Message 8 of 10
(2,873 Views)

I no longer have the time to make any kind of changes to the VI today,but thanks for the info.Tomorrow I will try your idea and give you an update on it.Have a nice day and I will keep you updated to see if it works.

0 Kudos
Message 9 of 10
(2,869 Views)

Well it took me a long time to answer but I have made some changes to my VI and made a few changes in the PLC as well,from what I have seen the PLC was the problem not the VI.The communication between them was the problem,and changed some blocks in the PLC as well.

Thank you all for the help.I will attach the new VI with the new changes but I doubt it will of importance.

Balan Felix Adrian

0 Kudos
Message 10 of 10
(2,829 Views)