ADICON Support Forum Applied Digital, Inc.
Page 1 of 1 1
Topic Options
#16632 - 11/06/06 11:20 AM Code snippet needed to get started
will1234 Offline
newbie


Registered: 08/08/06
Posts: 7
Hello all,

I have connected my window shades to my Secu-16 and they work great but I need a bit of code to help watch over them. By this I mean, the shade controllers have three connections arranged as "CW common CCW". With the CW and common shorted the motor turns clockwise and with the common and CCW shorted it turns counter-clockwise. So 'CW common' are on relay #1 and 'common CCW' are on relay #2. What I think I need is a bit of code that will help gaurantee that both relays #1 and #2 will be closed at the same time. I really don't know what would happen if both were closed at the same time but at roughly $100 a pop, I really don't want to find out.

Anyone got any ideas?

-Rob

Top
#16633 - 11/06/06 12:26 PM Re: Code snippet needed to get started [Re: will1234]
Guy Lavoie Administrator Offline
Beyond All Hope
*****

Registered: 12/21/02
Posts: 6548
Loc: Montreal, QC, Canada
One simple way would be to always include both the on and off commands in your code logic, like this:

IF (condition to turn CW)
THEN SECU16 Relay 1 Turn ON
THEN SECU16 Relay 2 Turn OFF

IF (condition to turn CCW)
THEN SECU16 Relay 1 Turn OFF
THEN SECU16 Relay 2 Turn ON

etc.

Since the Ocelot always sends a complete bit image of all the relays at the same time, you should not have any problem with two relays being on simultaneously.
_________________________
"If you don't know what you're doing, do it neatly..."

Top
#16634 - 11/06/06 04:12 PM Re: Code snippet needed to get started [Re: Guy Lavoie]
bakers12 Offline
journeyman


Registered: 06/06/04
Posts: 80
Loc: Chicago
Guy, is it possible that the bit map could be sent between two THEN statements? If so, the Turn OFF for one relay should always preceed the Turn ON for the other relay.

If the bit map is sent at a predictable time, then this doesn't matter.
_________________________
Have fun storming the castle!

Top
#16635 - 11/06/06 08:39 PM Re: Code snippet needed to get started [Re: bakers12]
Guy Lavoie Administrator Offline
Beyond All Hope
*****

Registered: 12/21/02
Posts: 6548
Loc: Montreal, QC, Canada
I can not say for sure if that is possible or not, so I can't totally exclude that possibility. If this poses a real risk, then a timer could be used to lockout any new ON command for a certain time after any OFF command was sent. This is only practical if you are sure that any one pair of outputs will not be switched back and forth several times in quick succession, since there is no easy way to implement a command queue with variables. Instead, a timer steps through the two steps required to change an output. Something like this:

IF (condition to turn CW)
THEN SECU16 Relay 2 Turn OFF
THEN Timer #1 = 1 //start interval timer

IF Timer #1 becomes > 3 //a couple of seconds later
THEN SECU16 Relay 1 Turn ON //send the ON command
THEN Timer #1 = 1 //and stop timer


IF (condition to turn CCW)
THEN SECU16 Relay 1 Turn OFF
THEN Timer #2 = 1 //start interval timer

IF Timer #2 becomes > 3 //a couple of seconds later
THEN SECU16 Relay 2 Turn ON //send the ON command
THEN Timer #2 = 1 //and stop timer

etc.
_________________________
"If you don't know what you're doing, do it neatly..."

Top
#16636 - 11/07/06 08:53 AM Re: Code snippet needed to get started [Re: Guy Lavoie]
bakers12 Offline
journeyman


Registered: 06/06/04
Posts: 80
Loc: Chicago
It's going to be simpler to just reverse the 2nd and 3rd statements. You end up with:

IF (condition to turn CW)
THEN SECU16 Relay 2 Turn OFF
THEN SECU16 Relay 1 Turn ON

IF (condition to turn CCW)
THEN SECU16 Relay 1 Turn OFF
THEN SECU16 Relay 2 Turn ON
_________________________
Have fun storming the castle!

Top
#16637 - 11/08/06 12:41 PM Re: Code snippet needed to get started [Re: bakers12]
will1234 Offline
newbie


Registered: 08/08/06
Posts: 7
Thanks guys. I have a ticket open with the shade motor manufacturer to find out just how much of a problem it actually poses if both contacts are shorted at the same time. The controller does have some intelligence within but I have no idea how much or about what. I will proceed using the code you provided. Thanks again.
Top
Page 1 of 1 1


Moderator:  Dan Smith, Monte G, ADI Tech Support, Guy Lavoie 
Hop to:
Who's Online
0 registered and 72 anonymous users online.
Recent Posts
Shout Box

Newest Members
brigiel, vevevie, zhutree, 416, saiqul
3003 Registered Users
Forum Stats
3003 Members
19 Forums
3999 Topics
23425 Posts

Max Online: 132 @ 11/13/16 10:07 AM
June
Su M Tu W Th F Sa
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30