Setting an output on or off rather than toggling it.

Describe your system and processes, and post your config file.
User avatar
bbrally
Posts: 210
Joined: Sat Mar 27, 2010 3:59 am
Bot?: No
Location: Vancouver, BC
Contact:

Setting an output on or off rather than toggling it.

Post by bbrally »

With the uinputo.dat file I can toggle an output on and off.

Is there a file where I can set an output either on or off, rather than just toggle it?
User avatar
bbrally
Posts: 210
Joined: Sat Mar 27, 2010 3:59 am
Bot?: No
Location: Vancouver, BC
Contact:

Re: Setting an output on or off rather than toggling it.

Post by bbrally »

I had a glitch with the wireless this morning. Maybe it dropped offline for a moment or aliens paused time, but it only lasted a moment. Then all my future toggles for that one output were reversed.

I'd also like my interface to be able to have an "all stop".

To prevent this kind of error and have "all stops" do I need to look at the output value in ucsysio.dat and use that to determine whether to toggle the output with uinputo.dat.

Seems kind of cumbersome.
gbrewer
Posts: 264
Joined: Wed Feb 11, 2009 8:20 pm
Bot?: No
Contact:

Re: Setting an output on or off rather than toggling it.

Post by gbrewer »

Can you explain what you are trying to do and perhaps we can help answer this as a group.
User avatar
bbrally
Posts: 210
Joined: Sat Mar 27, 2010 3:59 am
Bot?: No
Location: Vancouver, BC
Contact:

Re: Setting an output on or off rather than toggling it.

Post by bbrally »

I'm creating a custom interface for the brewery.

Most of what I was initially trying to do is working, but I've stumbled into two problems. The second turning into the biggest.

1 - By only being able to toggle the outputs, if any information gets "dropped" (information not getting to the bcs such as from a loss of signal from the wireless) the next signal will be turning off the output when my computer will think it's turning it on. There's also the ability to have an "All off" or reset, so that all outputs go to off. With toggling, the only way to set them all off is to compare the output state that's stored in the bcs and use that to determine whether or not to toggle it to turn it off. Just seems kind of cumbersome.

So here's what I've done:

With the ucsysio.dat file (http://192.168.10.111/ucsysio.dat) I get the on/off state of all the outputs in the bcs. With the uinputo.dat file (http://192.168.10.111/uinputo.dat?proc=3&out=X&) I can toggle the outputs, where X is the output number to control. I compare the output on/off state found in ucsysio.dat with the state I want, and if it's not, I call to uinputo to change the output, otherwise I leave it alone. Seems to work, just extra programming steps.


2 - I haven't seen anyway to control the expansion card outputs or to monitor their state. So at the moment, all the valves on the expansion card are uncontrollable through my interface. I'm hoping the wiki documention just hasn't been updated to include the expansion card info or else I'll have to shelve my interface.
JonW
Site Admin
Posts: 1726
Joined: Sun Jul 18, 2010 7:51 am
Bot?: No
Location: Huntington Beach, CA
Contact:

Re: Setting an output on or off rather than toggling it.

Post by JonW »

For your monitoring, I would use ultemp.dat instead of ucsysio.dat. I don't know the difference in the frequency of updates between the two structures, but the wiki says that structure is "monitored frequently". It is also the structure that the built in BCS web pages use for monitoring.

I agree that having commands to directly turn something on/off would be nice. I don't know what programming language you are using, but writing a function or two [Output_On(x) / Output_Off(x) ] would easily simplify your ability to force them on and off in your code.

For the expansion ports, it seems that you should be able to use ucsysio.dat. When I tested, I was not seeing any change in value there, but I did not physically have a board attached, so it may be checking for that so I wouldn't be able to test the changes without a board.
User avatar
ECC
Posts: 676
Joined: Fri Sep 12, 2008 12:29 pm
Bot?: No
Contact:

Re: Setting an output on or off rather than toggling it.

Post by ECC »

1)You're correct, currently you can only toggle the output.. This is a very reasonable request. I can add a new control file to force on or off.

2) Currently the only way to control expansion card outputs is through a process. They are controlled in the ulstate.dat file. Expansion control is done in big endian, which makes it a little confusing...
http://www.embeddedcontrolconcepts.com/ ... cstate.dat
http://www.embeddedcontrolconcepts.com/ ... lstate.dat
  • Pick a process to control the expansion I/O, say p7
  • Enable expansion ports to be controlled by the process, ucstate.dat [115] = exp_digien (0:3) = 0x8 (this enables exp0)
  • Set the desired data ulstate.dat[21] = exp_digital0 Output Data (0:11) = your data here
  • uinputp.dat?proc=7& Run the process (this is a toggle too)
User avatar
ECC
Posts: 676
Joined: Fri Sep 12, 2008 12:29 pm
Bot?: No
Contact:

Re: Setting an output on or off rather than toggling it.

Post by ECC »

There is an "All Stop" function, but looks like it was missing from the wiki. Added it:
http://www.embeddedcontrolconcepts.com/ ... #estop.dat
User avatar
bbrally
Posts: 210
Joined: Sat Mar 27, 2010 3:59 am
Bot?: No
Location: Vancouver, BC
Contact:

Re: Setting an output on or off rather than toggling it.

Post by bbrally »

Thanks for the help. I'll put my programming skills to the challenge over the coming days to make this work.
User avatar
bbrally
Posts: 210
Joined: Sat Mar 27, 2010 3:59 am
Bot?: No
Location: Vancouver, BC
Contact:

Re: Setting an output on or off rather than toggling it.

Post by bbrally »

I'm having some difficult writing to ultemp/ulstate.
I've tried the following but this doesn't work and I'm sure I just don't understand the syntax.

http://192.168.10.111/ulstate.dat[4]?data=900&p=0&s=0&

My thought is this would change the value in the 4 position to 900 in process 0 and state 0.

Am I going wrong with the position syntax?
User avatar
ECC
Posts: 676
Joined: Fri Sep 12, 2008 12:29 pm
Bot?: No
Contact:

Re: Setting an output on or off rather than toggling it.

Post by ECC »

The correct syntax is http://192.168.10.111/ulstate.dat?p=0&s=0&
When writing data, you have to use the POST method. Include the full comma separated as the data content, preceded by "?data&p=0&s=0&". Currently you can't update a single element of the file, read the whole array, modify your value, and write it back.

An example (in perl, but your syntax should be similar) is the post_ucsysio function here:
http://www.embeddedcc.com/wiki/index.ph ... rl_Library

Also, note that ultemp is read only, you can use other methods to write the data from that file.
Post Reply