Novice Programmer?
thepainter
Posts: 69
Title says everything but I need a little help. I have a camera at the front door connected to a matrix switch. I would like to have the TV jump to component_2, switch to camera for 10 sec and then jump back to the TV when the door bell is pushed. I currently have a PUSH command to switch while watching...
PUSH [TOUCH_PANEL, 69] (* BUTTON 69 WAS PRESSED ON TOUCH_PANEL *)
{
SEND_COMMAND LCD_TV, "'SP', COMPONENT_2"
{
SEND_STRING MATRIX,'[PT1O03I05]' (* CAMERA FRONT DOOR , COMPONENT 2 *)
}
}
I have one wire to ground and the other connected to channel 1 on device 17 and the other end connected to the door bell. This seems to work in a test run when I contact the wires
(* DOOR BELL RING, FRONT DOOR CAMERA *)
IF ([SENSORS,1]=1)
{
{
SEND_STRING MATRIX,'[PT1O03I05]' (* CAMERA FRONT DOOR , COMPONENT 2 *)
}
SEND_COMMAND LCD_TV, "'SP', COMPONENT_2"
WAIT 100
SEND_COMMAND LCD_TV,"'SP',SOURCE"
WAIT 30
SEND_COMMAND LCD_TV,"'SP',SOURCE"
}
However when in constant contact it seems to be in a loop switching back and forth continuously. Any help would be much appreciated.
Thanks,
Paul
PUSH [TOUCH_PANEL, 69] (* BUTTON 69 WAS PRESSED ON TOUCH_PANEL *)
{
SEND_COMMAND LCD_TV, "'SP', COMPONENT_2"
{
SEND_STRING MATRIX,'[PT1O03I05]' (* CAMERA FRONT DOOR , COMPONENT 2 *)
}
}
I have one wire to ground and the other connected to channel 1 on device 17 and the other end connected to the door bell. This seems to work in a test run when I contact the wires
(* DOOR BELL RING, FRONT DOOR CAMERA *)
IF ([SENSORS,1]=1)
{
{
SEND_STRING MATRIX,'[PT1O03I05]' (* CAMERA FRONT DOOR , COMPONENT 2 *)
}
SEND_COMMAND LCD_TV, "'SP', COMPONENT_2"
WAIT 100
SEND_COMMAND LCD_TV,"'SP',SOURCE"
WAIT 30
SEND_COMMAND LCD_TV,"'SP',SOURCE"
}
However when in constant contact it seems to be in a loop switching back and forth continuously. Any help would be much appreciated.
Thanks,
Paul
0
Comments
Is this an Axcent controller?
A closure on your IO port should appear as a push (assuming input set "LOW"). So, try this:
this will cause the code to be executed when the PUSH occurs either as a result of the TP button being pressed or by the IO port being shorted by your doorbell. It will occur every time the button is pressed so if someone keeps pressing and releasing your doorbell, it will repeat.
Paul
PS - Thanks for the quick response.
I think that you need to use a channel_event for this. It could look something like this:
(where dvIO = 5001:17:0)
CHANNEL_EVENT [dvIO,1]
{
ON:
{
DO_PUSH(TOUCH_PANEL,69)
}
}
I am making an assumption that the doorbell button being pushed will turn on the IO port 1 when the doorbell butoon is pressed, and turn it off when the dorbell button is released.
In that case, the channel_event will register that channel 1 for port 17 is on and will execute whatever code you want. If it does exactly the same thing as a panel push of button 69 you could get away with the DO_PUSH statement. If you are a real die-hard type, you could just duplicate the code here. Instead of doing either of these, I would probably create a DOORBELL() function and call it from both the channel event and the button push.
push[5001:17:0,1]
{
(do something)
}
If you look in the manual for any of the masters (NI3000, for example) you'll find information about how IO ports work. It explains that IO ports may be set to logic 'HIGH' or logic 'LOW'. basically, if your IO port light lights when the circuit is closed, it's set to logic 'LOW'. 'HIGH' and 'LOW' have to do with what voltage applied to the IO ports register as a push.
Also, you'll find that IO ports, when used as inputs, function just like touch panel buttons and register pushes and releases and button events. To the best of my knowledge, you can't trigger a channel_event with an IO port just as you can't trigger a channel_event with a button press.
Try the following code and short out IO ports to ground and see what happens:
Normally you would define a device constant in define_device and use that in your button event, or push statements, rather than specifying the device out. From the code snip you posted, I think you already understand that.
Also, the string to o will appear in a telnet session if you "msg on". Also, in Netlinx Studio diagnostics if you allow internal diagnostic messages. Also, you can see the IO channel pushes in Netlinx Studio if you "Enable Push Message Status Bar Display" and also in notifications.
The way I would do it is this:
I use channel_event with the IO port quite a bit.
I looked at this last night before I posted on it and I had myself convinced that I couldn't get a channel event to trigger based on opening and closing contacts on an IO port. Obviously, I was wrong. If an IO port is set to "low" logic, both a channel_event "on" and a button_event "push" occur when the port is shorted to ground. When opened, an "off" and a "release" occur. If the port is set to logic high, the channel_event on and off do not occur and the push and release on the button_event are reversed: push when contact is broken and release when contact is made.
I don't know that there's an advantage to using either the button_event or channel_event for watching an IO port using "low" logic. Guess it's just what somebody's used to.
Channel_event works and my original sample works (SENSORS = 5001:17:0). My problem, which I have just now figured out is that I am not using a 'Doorbell' I have a 'Doorphone' (Avaya System)for my doorbell so when the button is pushed it actually leaves it on for 'x' secs so I can answer from the phone to see/hear who is at the door. After 'x' secs. it will revert back to original state. (I'll have to read the manual to find out how long). So I am thinking the looping would last for the 'x secs' and then work as expected. Does this make sense? If so how could I code this? Thanks again for the responses.
Paul
PS - Everything worked as expected when I manually touched the wires (like a doorbell) I was so happy, but then hit a snag with the above scenerio when I hooked up directly.