Multi control on relay card
Denis
Posts: 163
Hi
I would like to know if is there an another away of select active to do control on relay card
I have to control six shade dc motor, up and down and stop when I need. I will use 5 relay for each motor shade. I would like program it as I can select a group of shade and press only one button to raise other button for down and other one for stop
any cue will be appreciate
I would like to know if is there an another away of select active to do control on relay card
I have to control six shade dc motor, up and down and stop when I need. I will use 5 relay for each motor shade. I would like program it as I can select a group of shade and press only one button to raise other button for down and other one for stop
any cue will be appreciate
0
Comments
DEVCHAN dvcRelay1 = {dvRelayPort, 1}
DEVCHAN dvcRelay2 = {dvRelayPort, 2}
DEVCHAN dvcRelay3 = {dvRelayPort, 3}
DEVCHAN dvcRelays[] = {dvcRelay1, dvcRelay2, dvcRelay3}
Now, ON[dvcRelays] will turn all three relays on at once, etc.
By the way, you can also create your DEVCHAN array without declaring each relay seperately -
DEVCHAN dvcRelays[] = {{dvRelayPort, 1}, {dvRelayPort, 2}, {dvRelayPort, 3}}
Tanks DHawthorne
But my real question is to do what I want I'm looking someting who can replace select active as: etc.....
I have DC motor
BUTTON_EVENT [dvtp,1]
BUTTON_EVENT [dvtp,2]
{
PUSH:
{
ON[dvBLIND1, DIR_UP]
}
}
.
BUTTON_EVENT [dvtp,1]
BUTTON_EVENT [dvtp,5]
BUTTON_EVENT [dvtp,6]
{
PUSH:
{
ON[dvBLIND2, DIR_UP]
}
}
The above way is not good if you do it too often because you are creating multiple events for each button push, which can cause event stack overflows.
Otherwise try using DEVCHANS for touch panel buttons
Assuming those are touch panels, you also want to avoid referencing channels on them in that fashion. If you want to know if a button is being held while running your mainline/feedback code, have a variable set on the push, cleared on the release - and test that variable instead.
If you're trying to test if a button is lit, on the other hand, test the same thing that lit it up in the first place.
People have experienced erratic behavior when trying to use the state of a button channel the way you have it shown above...
- Chip
Hi
Is it possible to get advice from expert?
To resolve my problem, I staked event handler, I isolated IF condition with pairs of {} and I would like to know if I can get problems in the futur. This code seem to work fine and do what I need. If I process with select active, I get a very long code to cover all possibility
I created array nSTORES_PISCINE [6] ( french words meaning blinds in swimming pool)
Denis,
I think I can help you.
First, the braces {} around each {IF{code}} are not required.
Second, why is the variable nSTORES_PISCINE[] defined as an array or required in your program?
Could your code be written like this?
The button channel array nShadeUpButtons[] can be any channel numbers you like since it we are only looking at the index of the array in the Switch - Case section. Also, you do not need the variable nSTORES_PISCINE unless it is used elsewhere in your program.
I hope this helps you.
DEV relays[] = {dvSTORES_P_1, dvSTORES_P_2, dvSTORES_P_3, dvSTORES_P_4, dvSTORES_P_5, dvSTORES_P_6}
BUTTON_EVENT[dvTP,nShadeUpButtons]
{
PUSH:
{
STACK_VAR nIDX;
nIDX = GET_LAST(nShadeUpButtons);
OFF [RELAY[nIDX],1];
OFF [RELAY[nIDX],3];
ON [RELAY[nIDX],2];
ON [RELAY[nIDX],4];
OFF [RELAY[nIDX],5];
OFF [RELAY[nIDX],7];
ON [RELAY[nIDX],6];
ON [RELAY[nIDX],8];
}
}
Hi guys
Tanks for your advices and codes samples, but I tried both and they give same results. The reason why I used the braces {} around each {IF{code}} is to isolate each if itself.
The goal what I'm looking for is if I choose shade one, shade 3 and shade 4, after selection I press up button and these 3 shades go up in the same time. I want to select any shade ( from 6 ) and when I press up or down button the shades selected move in the same time. If I use many relay cards, it's for I control DC motor and I needs reverse polarity to get up and down.
(12 shades, 4 relays by shade )
The code as I asked an expert advice, is the best I found to do what I need, but since I'm beginer in this world, I need to know if it's the best way take
I can think of a different way to accomplish what you are trying to do, but it doesn't mean that it is any better than the way you have chosen. I don't see any problems with the code you have posted, and unless you are looking to do something else in addition to what you are already doing, I wouldn't change it. Basically, if it's not broken, don't fix it.
Just my humble opinion,
Jeff
There are many ways to do this efficiently. the code above (which I've not checked) is the way that I would do it, but I don't think it's inherently better than a select active or switch case.
Hi Hedberg
I don't if it's me but I get this message
"ERROR: (468): C10231: Cannot reference STACK_VAR [IINDX] inside a WAIT
"
Right. I should have compiled the code to check.
Another solution would be to take out the wait -- I don't think it's necessary. Also, the two loops could be combined -- turn off the flags in the same loop after they are tested.
Sorry for the error and any confusion.
Harold
WAIT 1
nSTORES_PISCINE [1] = 0
nSTORES_PISCINE [2] = 0
nSTORES_PISCINE [3] = 0
nSTORES_PISCINE [4] = 0
nSTORES_PISCINE [5] = 0
nSTORES_PISCINE [6] = 0
But, if the client selects shades 1, 3, and 5, then pushes the down button, then decides to stop them halfway, the selections will have cleared after the down button was pushed. In order to hit the 'Stop', the client would have to re-select all the shades that are moving, then hit 'stop', which isn't very easy. You'd have to select a period of time for the selections to be active that's roughly equal to the length of time for the shades to go from full up to full down, to make sure the client will be able to stop them without re-selecting even as they get near the top or bottom of their travel. Plus, you can light up the selections on the touchpanel (turn the button ON to indicate that they're selected), and they'll turn off about when the shades land most of the time -- which would be pretty slick in my opinion.
Besides that, you're code looks good. Harold's code is very efficient and would be my choice.
--John
Hi everybody
Tanks for your sugestions, I will try them in few days. For the moment I have to prepare the " Festival Son & Image 2006" of Montreal www.fsiexpo.com
I will continue this job when the preparation of this show will be complete