Home AMX User Forum AMX General Discussion

PULSE ?

Newbie self taught with lots of help. NI-3000 sending IR to a WDTV LIVE my code is

PUSH[TP_LOFT,67]
SEND_COMMAND WDTV,"'SP',POWER_TOGGLE"

This command actually turns it ON then OFF, when I test it using 'Diagnostics' in NS and use Control Device the same thing happens when pulsing channel '9' with the pulse set at 3/10. When I change the pulse to 1/10 and do the PULSE it works. Am I missing something in the code or is this something that I missed in the IR transfer. Sorry for what probably is a simple fix, but this is how I learn.


Thanks,

Paul

Comments

  • viningvining Posts: 4,368
    You could check your CTON/CTOF values and adjust as necassary. They should be set in the ONLINE _EVENT handler for that particular IR port. This thread has some info: http://www.amxforums.com/showthread.php?7043-DIRECTV-HR24&highlight=CTON.

    Are these learned commands? If so you may learned a double command and the shorter pulse cuts off transmisison of the 2nd command but you should able to do the same using SP by adjusting the CTON/OFF values.
  • thepainterthepainter Posts: 69
    These are learned commands but I double checked to make sure it was just one command and not doubled up.
    You could check your CTON/CTOF values and adjust as necassary. They should be set in the ONLINE _EVENT handler for that particular IR port.

    I'm not sure how to do this but after reading in a couple of different Threads I used the TO and it worked, not exactly sure WHY? (as opposed to the SEND_COMMAND which work with my other sources)

    PUSH[TP_LOFT, 67]
    TO[WDTV, POWER_TOGGLE]
  • PhreaKPhreaK Posts: 966
    thepainter wrote: »
    I'm not sure how to do this but after reading in a couple of different Threads I used the TO and it worked, not exactly sure WHY? (as opposed to the SEND_COMMAND which work with my other sources)

    IR devices are stupid. What an AMX box (and any control system/universal remote) does when you're controlling an IR device is attempt to mimic what the remote the manufacturer built does. In an ideal world there might be some more 'concrete' standards as far as protocols and timings go, but that would take all the fun out of it.

    Generally, what tends to happen is when you press a button on an IR remote you are sitting in front of the device. What this means is as soon as it does what you are asking it to do, you see/hear that and lift your finger. This doesn't quite work so well when its a computer pressing that button because it can't see anything changing (unless you have some form of sensor in the signal chain). Because of this, the time to hold down that button on the remote must be predefined, and if that's not done correctly you end up with accidentally repeated commands - in your case the the power command.

    With the IR device inside the AMX masters you've got a few differnt of ways of interacting with it. It entirely possible to treat it purely as a channel based device:
    • You can use PULSE which will turn a channel on and then turn it off again after the time defined by SET_PULSE_TIME (0.5s by default)
    • If it's been triggered by a button event (or another channel) TO can be used to emmit the command as long as the button is held or the channel remains on
    • MIN_TO can be used in the situation above but if the button is released quickly it will keep emitting for at least the time defined by SET_PULSE_TIME
    • ON and OFF can be use to discreetly start and stop emmitting
    Check the NetLinx help file for more info on these.

    The other way you can approach it is to communicate via commands to the device, similar to what you were initially trying to do. What the SP commond does is say "hi there mr IR device, when you're done doing what your doing can you please emmit the command in this slot, please" (it's a buffer). To make that play nice with all IR devices there are also some other commands for setting timings etc CTON/CTOF. Using this allows you to set up different command timings for each device rather than relying on a global timing setup. All the info you need for this can be found in AMX-PI under 'NI Device Controller for NI-xxxx.
  • viningvining Posts: 4,368
    thepainter wrote: »
    These are learned commands but I double checked to make sure it was just one command and not doubled up.
    You could check your CTON/CTOF values and adjust as necassary. They should be set in the ONLINE _EVENT handler for that particular IR port.

    I'm not sure how to do this but after reading in a couple of different Threads I used the TO and it worked, not exactly sure WHY? (as opposed to the SEND_COMMAND which work with my other sources)

    PUSH[TP_LOFT, 67]
    TO[WDTV, POWER_TOGGLE]

    One thing to keep in mind regarding the "TO" command is that it's great for things like channel up/down, numeric entry and the like since that's when you want to mimic a standard remote use but for things like the power toggle you'll usually want them in some sort of macro and issue the command during some sort of start up routine so the "TO" command won't really work for this.

    Review the AMX_PI as Phreak suggested and get an understanding of the various options, especially the CTON & CTOF when used with the "SP" command.

    Here's an example how it's used in the DATA_EVENT online handler for the IR ports. In this case I'm using an array for the IR ports for the cable boxes.
    DATA_EVENT [dvCATVBOX_Arry]      
         
         {
         ONLINE:
    	  {
    	  STACK_VAR INTEGER nCABLE_BoxIndx ;
    	  
    	  nCABLE_BoxIndx = GET_LAST(dvCATVBOX_Arry) ;
    	  
    	  SEND_COMMAND dvCATVBOX_Arry[nCABLE_BoxIndx],"'PTOF',1000" ;	//time = 0 - 255. Given in 1/10ths of a second. Default is 15 (1.5 seconds).
    	  SEND_COMMAND dvCATVBOX_Arry[nCABLE_BoxIndx],"'SET MODE IR'" ; // sets IR port to IR mode
    	  
    	  //THIS REQUIRES SAME NUMBERS FOR IO & IR PORTS  IR1 TO IO1, IR2 TO IO2, ETC
    	  SEND_COMMAND dvCATVBOX_Arry[nCABLE_BoxIndx],"'SET IO LINK ',itoa(nCABLE_BoxIndx)" ;//1 sets IR port to link with I/O channel 1 (port 17)
    	  //IF THESE ARE DIFFERENT USE A SWITCH CASE OR SOMETHING TO ROUTE TO THE CORRECT CORRESPONDING IO!!!!!!!!!
    	 
    	  SEND_COMMAND dvCATVBOX_Arry[nCABLE_BoxIndx],"'CARON'" ;   	//Enable the IR carrier signals (default).
    	  SEND_COMMAND dvCATVBOX_Arry[nCABLE_BoxIndx],"'CTON',2" ;	//time = 0 - 255. Given in 1/10ths of a second. Default is 5 (0.5 seconds).
    	  SEND_COMMAND dvCATVBOX_Arry[nCABLE_BoxIndx],"'CTOF',2" ;	//time = 0 - 255. Given in 1/10ths of a second. Default is 5 (0.5 seconds).
    	  SEND_COMMAND dvCATVBOX_Arry[nCABLE_BoxIndx],"'XCHM-0'" ;      //Mode 0 Example (default): [x][x]<x><enter>
    	  SEND_COMMAND dvCATVBOX_Arry[nCABLE_BoxIndx],"'PON'" ; 	//rack mounted so leave on, no real power use change!
    	  }
         }
    
    Note I also use the XCHM command for issuing preset changes and the pulse duration and time between pulses are also controlled by the CTON/CTOF values sent when the device comes online.

    FYI. the reason we wait for the online event instead of sending it in define_start is to ensure the device is actually up and ready to receive commands. Otherwise you risk sending these commands to a device that isn't yet ready to receive commands and subsequently those commands never get heard by the device port.
  • thepainterthepainter Posts: 69
    Thanks very much, got it working using CTON/CTOF , I like the idea of setting it up per device rather than a Global setting.

    As Usual the Forum comes through once again.
  • DHawthorneDHawthorne Posts: 4,584
    thepainter wrote: »
    Thanks very much, got it working using CTON/CTOF , I like the idea of setting it up per device rather than a Global setting.

    As Usual the Forum comes through once again.

    I personally consider it mandatory to set up pulse timing by device. There is too much variation these days; some things like the shortest pulses properly, some like them nice and long. Mix both kinds in the same job, and the tracking is miserable to maintain.
Sign In or Register to comment.