Problem seems to be triggered when replacing an existing function with a similar function, then any new vars stop working, any changed vars stop working, and the function stops returning any output even though it's getting everything valid input.
Again I start to have this problem where new variables just are not picked up, and they are correctly linked in. They are again not available in the HMI. The PLC value is just "no value" after build and deploy, and I can't get it to set an initial value whatever I try.
I don't get the error about variable 'Variable' unlike last time however.
Any help on how I can get it working. Re-creating entire programs just to get this working again remotely is very time consuming and risky.
Result is: make one small change and large amounts of the program stop working correctly because they are not getting the values needed for the functions to work.
Any thoughts? Or just abandon it all and see if something else is less fragile? Node Red?? Not something I can do remotely right now but worth looking in to?
Yes! So obvious when you see it! Thanks :)
Looking at the debug output, the rand block is running all the time, even though it is only needed to generate one number at a time. I am not sure if this wastes CPU, or if it is more efficient to only enable it when triggered, and turn it off again once the number has been generated. What do you think?
I took your logic and made it behave like TON but with a random time (so, the output of my timer will go in to this, then the output of this will be delayed by some random time, so the result would be, the light will come with a random delay of on up to an hour after 6PM, or whenever the time is set by the timer.)
(This first turns on the rand -> integer sequence for 1s, then after 1s, TON_0 switches on to capture number and to activate the actual switch on delay)
I'd like to do some occupancy simulation so that lights go on at slightly different times every day. I have a Time Program block, which is set for lights to come on at a certain time and/or when it gets dark at dusk, but I'd like to add a function to select a random number of seconds, or minutes between 0 and 60 minutes, and delay the ON from the timer (With a TON by some random time interval up to 60 minutes.)
I've played about with the RAND function and LIMIT, FLOOR, TRUNC etc but it's not quite what I need.
Say for example I want to pick a random number between 0 and 3600 (seconds), convert this to a time and pass it to TON. (Switch On Delay)
My function using rand can return a number higher than 3600, which LIMIT then just sets to 3600, so it returns 3600 more often and is not really random.
Any thoughts on how to do this? Seems like a useful function to have anyway. Could be a function that outputs a new number every time it receives an input, since RAND is a bit difficult to work with because it's constantly generating new random numbers, so it's hard to connect this to TON. (I had to use an Integer shift register + TP) to make it generate a new number just when it receives an input.
Yes, it's very odd.
In the end, I reverted to an older version of the project and just re-did the all the missing parts, since I had 3 days in Austria to deploy it all and needed to fix it before returning to the UK. I can remotely access it via the proxy for the time being though to do updates.
I thought it would be a good idea to put everything in my google drive folder, so that when changes happen, it's automatically backed up somewhere. Mervis IDE does not seem to like this though. During the build when you have HMI parts, it pops up some errors:
I just click "Abort" on each of these errors every time it builds, and it seems to build anyway.
It was working fine with Google Drive before I started to create HMI Projects (e.g. only function blocks) I think it basically tries to delete some files after it builds and something goes wrong as the files are still being worked on by Google Drive syncing, or these files only exist for a short time and it just takes Google Drive a while to catch up with syncing and then deleting them.) Sometimes I get errors about another process having a file open, but usually running the build again or restarting the IDE, it works. Doesn't seem to cause any noticeable problems, but perhaps if that part of the project did not change, it won't cause a problem if it fails to update that particular file.
Then I thought I should save the file as... to a new location on a local directory instead of Google Drive and open this. This gets rid of the errors during build, but the variable problems started to occur as above. Adding new ones doesn't work, even when they are correctly linked to a function block, and worked before. Only thing I have done was replace one function block with different, similar function block, and link it back in as before.
I tried all sorts of things to get it working again, making new variables... clearing the flash variables.. nothing seemed to fix it.
So I had to abandon that project and go back to the one on google drive.
I notice it has this error appearing about a missing part in the file, though I have not noticed anything is broken. I'm not sure how the path got to have "Google Drive\google drive" in there, since this is obviously wrong. (Its somehow in there twice.)
Ok - I've lost another one that was working before. I have changed the logic in the main program to do something slightly different with the global variable. But now it has also gone from the HMI.
Error PLC PLC
WebControl 6 3 Unable to write variable link 'HMI_3_06', check if the property 'Variable' is set properly and build the project again.
Any advice what to do? I don't understand what is going wrong. Start new project again from scratch? :-(
Here's a screen shot from the variables browser. I am not sure why new variables, or this one specifically went wrong after I added a new one - appears crossed out "PLC Value" in the variable browser. Have I reached some maximum in the number that can be defined?
When I try to add variables into an HMI setter, I get the error:
Error PLC PLC
WebControl 1 2 Unable to write variable link '', check if the property 'Variable' is set properly and build the project again.
I have added lots of other variables, but one of them in particular, although it shows in the program, does not show up in the HMI to be used.
If I try to add new variables, they do not show up in the HMI to be used.
I would like to do this to, but I believe it is not currently possible because the windows RT lacks the fastcgi layer in order to support HMI.
Are you able to get Windows RT working at all to simulate unipi devices? I managed to connect to it but then didn't really understand what I needed to do if I just wanted to play about with logic blocks without requiring a unipi device connected.
Yeah, what I mean is, I first downloaded the configuration, saw that the setting was already 0, and then just uploaded it again. I didn't actually change anything in between. Anyway, seems to have now got it set correctly. Thanks for the help!
The multiple interfaces problem is odd, since the two interfaces are NOT both connected at the same time. eth0 was just set to DHCP and not connected, but the wlan0 interface only works properly when eth0 is plugged in. If eth0 is unplugged, the wlan interface works for a while but then eventually stops working properly.
This seems to be a Raspberry Pi issue people are reporting elsewhere, though not easy to debug as the unipi display port isn't accessible to connect, so it's hard to see exactly what's going wrong. (Maybe I will take the SD card and boot it in a regular Raspberry PI with a display connected, so I can better understand what is going on.)
The issue would seem to be a combination of the default ARP behaviour in Linux which responds with the wrong MAC address, DHCP, and that when there is no cable connected, in some situations Raspberry Pi still thinks it's up and tries to use eth0 anyway. (/etc/interfaces "auto eth0" vs. "allow-hotplug eth0")
So far, I have both interfaces set to dhcp, and I did have "auto eth0" in /etc/network/interfaces but looks like this was causing some of the problems, so I set it back to "allow-hotplug wlan0 eth0". and then set:
Now, when eth0 cable is removed, the interface still shows as "UP" but it deletes the routes and remove the IP config from the interface, and then because it responds to ARP with the correct MAC address for wlan0, it doesn't break.
Also set "wireless-power off" under the wlan0 interface config, but not sure if that made any difference. It would seem that some wireless APs are able to send a magic APSD request which causes the interface to go into power save mode. I don't think my AP does this.
I'll see how I get on. Worst case, I will have to just add commands to toggle eth0 down when wlan0 comes up, and toggle eth0 up again when wlan0 goes down, called from up / down hooks in /etc/network/interfaces.