CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Tue Feb 19, 2019 3:33 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Thu Jul 26, 2018 4:59 pm 
Offline

Joined: Tue Mar 15, 2016 8:31 pm
Posts: 6
So i'm writing an application where i need to do a HTTP Post request everytime a tag changes status, so i'm using rising and falling triggers to call the program that has the HTTP.Post function block. Every call to the program has different arguments (WString). But i can't get the program to execute ONCE on a status change, so it executes on every scan, or it doesn't execute at all. I feel like i'm missing somethin g very simple, can anyone help?

The program from the images doesn't get called at all...

Any help is appreciated,

-Hector


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Thu Jul 26, 2018 6:35 pm 
Offline
Frequent User
Frequent User

Joined: Tue Dec 03, 2013 11:52 pm
Posts: 106
So it looks like you have at least two problems with this:
1. POSTWebReq2 only gets called ONCE after an R_TRIG or F_TRIG event. POSTWebReq2 is a function block that takes more than one cycle of the PLC to execute. This means that you should always be calling the POSTWebReq2 and not only after the trigger events.
2. In your POSTWebReq2 you set xExecute to true for the HttpClient. xExecute is what starts the process of sending the message. If this is always true it will only send the message once, if you fix issue 1. What you want to do is use the TRIGGERS to set the xExecute to true and when there is either xDone or xError then you need to set xExecute to false. Every time xExecute gets set to true it will go through it's process of sending the message. This means you need to allow enough time for HttpClient to finish before trying to send another message.


Top
   
PostPosted: Thu Jul 26, 2018 8:12 pm 
Offline

Joined: Tue Mar 15, 2016 8:31 pm
Posts: 6
Thanks for your response ComingBack4u...

I do want for the POSTWebReq2 to execute only once there is a trigger event, to notify my server that the tag changed status.

POSTWebReq2 is a program, should i be using a function or function block instead? Because the POSTWebReq2 program always has the arguments from the last rung on the program, so maybe programs are not designed to be taking different arguments.

So before this version, i tried creating an instance of the function/FB that calls that does the request, but since i have 29 slaves (one program for each) i was creating too many instances of it and the PLC was throwing an exception.

I also tried adding a WString (argument) to a FIFO (Element collections) every time an event trigger happened, then i had a task that processed the FIFO, but i ran into exceptions also. I think 2 different tasks were trying to access the same FIFO...

I will take your advice and modify my program, hopefully i'll have a working version soon...

Thanks!


Top
   
PostPosted: Fri Jul 27, 2018 2:31 pm 
Offline

Joined: Tue Mar 15, 2016 8:31 pm
Posts: 6
So ended up switching to a function block, it works as i need it to, but creating so many instances of it will use more memory than what i have available...
I'll try some other way around this.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 4 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited