Rank: Newbie
Groups: Registered
Joined: 4/25/2016(UTC) Posts: 3
Was thanked: 3 time(s) in 3 post(s)
|
Howdy! I've been messing with Embrio for an afternoon, and have all manners of flashing lights and reading pots and such. Sorry if it's been covered, I didn't see much other than someone else asking for port-access.
Now I want to tackle something a little more advanced - a PID loop that turns on defined sets of valves/lights/outputs for various levels of error signal.
It would be nice to get several outs to change in concert - as if writing to a port. I have 4 valves and would like to change port values directly. I might be able to pick a state, then alter just one or two pins... but it seems like more work and less likely to work well, could lead to undesirable combinations of outputs on.
The other is a general question: Can I use arrays in Embrio? Even just something simple - such as a port value - would be awesome. I watched all the tutorials and didn't see anything.
Thanks!!!
|
1 user thanked AbeFM for this useful post.
|
|
|
Rank: Administration
Groups: Administrators
Joined: 12/11/2014(UTC) Posts: 661
Thanks: 1 times Was thanked: 109 time(s) in 104 post(s)
|
There's no way to access node inputs or outputs using an array currently. You will be able to in Version 2 which will be ready and released shortly. Attached is a simple project that shows how to do what you are after. The trick is to define what you call a state in a reusable node group (or you could define a custom node, but this is a little easier). I have 3 copies of a state group, and each one I set different values. The first one turns on pins 1 and 3, the second pins 2 and 4, the third pins 1 and 4. The multi step node controls which state is on at a given time. For your scenario you'll probably want to use a number of "Is In Range" nodes to determine which state to turn on. Note that having all of these nodes on the same agent might not be good design in a bigger project, I just did that to show the idea. Let me know if you have any problems. File Attachment(s): 4 Pin States.zip (7kb) downloaded 6 time(s).You cannot view/download attachments. Try to login or register.
|
1 user thanked EmbrioAdmin for this useful post.
|
|
|
Rank: Newbie
Groups: Registered
Joined: 4/25/2016(UTC) Posts: 3
Was thanked: 3 time(s) in 3 post(s)
|
Thinking about my specific issues, the right question is how do I deal with the issues I'm having. I'm still curious about arrays and ports.... But the other side of the coin is how do I realistically write to a few pins - if it happens fast enough it won't be an issue. If all four change in under a ms or two we're probably going to be ok. It might come down to PWM'ing 0-4 channels, but probably one actively PWM'ing and the rest on or off for 'long' periods.
Here's the example I'd like to see: Read from a pot. Display 4 (or 6...) most significant bits on a series of LED's. I tried a couple ways, with huge messy logic trees. It seems like you could make a node for each state, then call them. I'm sure it can be done ten ways, but a style guide would be helpful here.
Anyway, I'm sure a little guidance on how to use the software is more useful than whining about how it doesn't do what other languages do - sorry if I gave that impression. :-) I've been a little concerned that programs like 'blink' will stumble every few seconds - missing a beat or putting in an extra, running over USB. -Abe.
|
1 user thanked AbeFM for this useful post.
|
|
|
Rank: Newbie
Groups: Registered
Joined: 4/25/2016(UTC) Posts: 3
Was thanked: 3 time(s) in 3 post(s)
|
Ah, missed your post. Excellent, I'll check it out. It sounds like it would do what I want, but if I need 16 states (every combination of 4 digitial outputs) would that still run ok, or is it even better to split out into separate nodes?
The other issue I had: In range and "below", etc, make it hard to cover a continuous range? I was worried about it initially, but now I'm thinking all I'd have to do is make a "in range" and replace a >= with >, save as a new function/node, right? Basically I don't want to have gaps when I'm "below" 5 but not yet "above" 5. If you make an input where you grab the range from the previous node, it seems easy.
Similarly: do chained 'disabled' nodes run each time? Like If/Else/Else/Else (or is there a "case" type function)... If I guess right the first time, do I have to run the other tests?
Thanks again! Really nice environment you have here. -Abe.
|
1 user thanked AbeFM for this useful post.
|
|
|
Rank: Administration
Groups: Administrators
Joined: 12/11/2014(UTC) Posts: 661
Thanks: 1 times Was thanked: 109 time(s) in 104 post(s)
|
play around a bit with making custom nodes. Visual programming is great for a lot of stuff but some things are better to code than try to make out of nodes. For example you could have a node with 4 output activations and one input and the code would be a case statement that sets the outputs based on the input. All nodes fire x times per second (whatever the agents refresh rate is set at). However most nodes implement an "input changes" event instead of "every update" so the code only fires when the input value is changed. Edit: This page has info about making custom nodes. Its currently a little awkward but will be much smoother in version 2. Edited by user Tuesday, April 26, 2016 8:43:36 AM(UTC)
| Reason: Not specified
|
1 user thanked EmbrioAdmin for this useful post.
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.