|
ANY-maze Help > The ANY-maze reference > The Protocol page > The elements of a protocol > Inputs and outputs > On/off inputs > Selecting I/O ports Selecting I/O ports
IntroductionHaving included an I/O element in a protocol, you will need to specify the actual physical port which the device is connected to. For example, this might be an ANY-maze interface General Purpose I/O port. Choosing portsEvery I/O element in a protocol has one or more Port to use sub-element. In most cases, there will just be a single sub-element; however, if you have specified that the ports the element uses can vary depending on the location of a movable zone, then there will be one sub-element for each position that the zone can adopt. The Port to use page itself consists of one drop-down list for each apparatus item defined in the protocol. Thus, if, for example, you have defined four open fields (numbered 1 to 4) and each one has a light over it which can be switched on and off, you will have one on/off output element (probably called 'Light') and this will have a Port to use sub-element showing four drop-down lists; one where you can choose the physical port that the light for Open field 1 connects to; one where you can choose the physical port that the light for Open field 2 connects to; etc. The default entry for a port is '- None -' (because ANY-maze has no idea which port the device is connected to); if you leave the port set to '- None -' then the input or output whose port you are setting up simply won't work. This isn't wrong, but it's not of any practical use. What ports are listed?The actual drop-down list of ports is filled in with one entry for each port of the relevant type provided by each of the I/O Devices you have included in the protocol and which are currently connected to your computer (so the ports of I/O devices that are not connected will NOT be listed, even if you have included the device in the protocol). Using multiple ports
For some types of input and output, the port's list includes an entry for '- Multiple ports -'. This allows you to choose more than one physical port for the input or output element to use. For example, in a plusmaze you may have placed a lamp over each of the two closed arms, and you may have created a switch element called 'Closed arm lights' to control them. Now you need to specify which physical ports the lights are connected to - but you've connected one of them to 'Output 1' of your AMi device and the other one to 'Output 2'. So, in this case, you would specify that the element uses multiple ports and then select both 'Output 1' and 'Output 2' in the window that appears. Thus, when you activate the 'Closed arm lights' element, both ports will be activated and both lamps will switch on. When you choose a port on this page, ANY-maze will automatically check that the port is not already being used by some other element. For example, if you specified that the 'Lamp' element was connected to 'AMi output 1' and then you tried to specify that the 'Shocker' element was also connected to this port, the software would complain, because the port is already being used. Situations where one port is used by more than one elementIn fact, there are circumstances where the same port could be used by more than one element. In the first case, you may have specified that the port that is used for a certain element depends on the location of a specific zone. For example, imagine a Y maze which has lamps over the three arms. These lamps connect to 'Output 1', 'Output 2' and 'Output 3' on your AMi device. Now you want to create an element called 'Start arm lamp' which will control the lamp over the arm where the animal will start the test. If the animal always starts in the same arm, then this would be very easy - you'd just look to see which lamp is over that arm, see which output it connects to (let's say 'Output 2'), and then specify that the port for the element is that port. But what if the start arm varies - for example, during the first trial it's arm 'A', but for the next trial it's arm 'B'? In this case, you can't look to see which port the lamp over the arm connects to, because you don't know which the 'start' arm will be. This problem is resolved by specifying that the ports the element uses depend on the location of the start arm. This means that ANY-maze will, in this example, provide three 'Port' sub-elements, one for each of the three possible positions of the start arm. These elements will be labelled 'Port to use when Start arm is in position A', 'Port to use when Start arm is in position B', etc. So then you can define the port. BUT, let's now imagine that you designate another arm in your Y-maze as the 'goal' arm, and you want to create an I/O element called 'Goal arm lamp' (which might turn the goal arm lamp on after a certain duration). Like for the 'start' arm, this 'goal' arm can vary its position between different tests - that's no problem; you simply specify that the port used for the 'Goal arm lamp' depends on the location of the goal arm. And, like for the 'start arm', you'll then be given three port sub-elements labelled 'Port to use when the goal arm is in position A', 'Port to use when the goal arm is in position B', etc. and you'll select the appropriate ports. But hang on a minute - the port to use for the goal arm light when the goal arm is in position A will be the same as the port to use for the start arm light when the 'START arm' is in position A (because there's only one lamp over the arm). This seems to mean that the same port will be used by two elements at the same time, but if you think about it, you'll realise that this would only happen if the goal arm and the start arm are both in position A in the same test, which one assumes they wouldn't be. So, the upshot of all this is that you can use the same port in more than one element when the port is shared between elements whose ports depend on the positions of a variable position zone. It's then up to you to satisfy yourself that elements won't try to use the same port at the same time. ANY-maze will advise you should you get in to this situation, and ask you to confirm your selection. Output switch aliasingIn fact, there is another situation in which the same port can be used by more than one element, and this creates so-called 'Port aliases' - but this ONLY applies to 'switch' outputs. Essentially 'port aliases' allow you to give two 'uses' to the same port. For example, imagine in our Y-maze example, above, that in an earlier stage of our experiment, we simply wanted all the lamps to be switched on. So far, we have defined a 'Start arm light' and a 'Goal arm light', both of which use different ports depending on the position of different zones. So when we want all the lamps switched on, we could turn on the 'Start arm light' and the 'Goal arm light', but this would still leave one arm with the light off, and which arm that is would be hard to determine, as it would depend on the locations of both the start and goal zones. It would be much easier to create a new 'switch' element and call it 'All lights'; we'd then specify that this element's ports are always the same, and that they are 'Output 1', 'Output 2' and 'Output 3'. Now, activating this element would switch all the lights on. Of course, this element would be using the same ports as the 'Start arm light' and the 'Goal arm light', but we'd be saying that this is just an 'alias' for the ports; in other words, another (easier) way of talking about the same ports. Of course, if we do alias ports in this way then we could create apparent conflicts in what the port is supposed to do; for example, the 'Start arm light' element could be active while the 'All lights' element is inactive - should the light then be on or off? ANY-maze uses a simple rule about this; if ANY alias element specifies that a port should be active, then it is active (for the technically inclined, the state of the elements is logically ORed).
© Copyright 2003-2026 Stoelting Co. All rights reserved ANY-maze help topic T0144 |