Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Noe

Pages: 1 [2]
16
Open Discussion / Cross Threading Error
« on: December 03, 2013, 06:46:41 PM »
I had been programming for more than 6 months (and learning VB as this is my first contact with it) an application that uses AHMI to capture data and send database results to two PLC's (a Control Logix and a SLC 505). So far has been working really fine using v3.54, but this week has been a nightmare related to VB. I been getting an error message for "Cross-Threading operation not valid..." when trying to write or read labels from another thread. This is something I was not aware of, as never happened before and I just been reading for two days how to solve it, with little success. Too complicated for something simple like changing a text box content (text property) when a serial.datareceived event is triggered, that is to use a delegate method (still not quite getting how it works, but it works). See second method in here:
http://www.dreamincode.net/forums/blog/143/entry-2337-handling-the-dreaded-cross-thread-exception/

I have two questions for anybody who would help me before I loose all my hair:
1. This method solves the write issue, but not when you read. How can you do that?
2. If my application has lots of portions of code like this since day one, why did not happened before? This is what is more disturbing, as I been experimenting "changes" like this for one day to another that cannot be explained.

I already tested my previous versions to see if I changed something but all the previous versions do the same thing. Even took a new hard drive, installed everything from zero and tried again but getting to the same point, so I really do not understand why this is happening.

Any help will be really appreciated.

17
Hi

I am using an integer value at PLC side as a way to define actions taken by PLC and VB app. Some values trigger actions as VB has an .onvaluechange event, and some trigger actions at the PLC.

Works like this:

A basiclabel reads the value on the integer variable at the PLC side.
Onchangevalue event will compare value and, if applicable, takes some actions.
If actions were taken, VB will write a new value (using a write command) to the same variable for the PLC to know it, and also reset it to an idle state or advance in logic.

Problem is that sometimes the integer value is not being written after the actions are finished at the VB side, like if the PLC would not accept the write command from AHMI.

Questions are:

Does this have to be with subscriptions working on basic labels and not with command write (that's is what I understood so far)? Like the read process is not finished when I try a write from code so the PLC ignores it. This happens only if I do it very quickly manually, changing the integer value at the PLC side a couple of times. In auto, it happens occasionally, like a 5% of the times I tried.

Is there another way to write values to PLC from AHMI that would be a warranty they will be written? I've seen Archie's post asking people about if they used code or just controls as this could be a cause.

Can some one point me to some information about subscriptions?


Any help will be gladly welcome, I am sorry if this has been discussed before, but I already searched the forum and couldn't find any similar information.

18
Hi Archie

First of all kudos for all your hard work, you are getting everybody to do things very hard to do in the past.

I just downloaded your recent 3.51 beta, but when opening VB says "Solutions folders are not supported in this version of the application error. Solution folder "Solution Items" will be displayed as unavailable.

Is this normal? I have VB Express 2010 and also 2008, in Windows 7 x86.

Pages: 1 [2]