Keith Baxter wrote: ↑Thu Apr 01, 2021 4:11 pm
HI
My Last post on this.
Lets take a 12 position rotary switch. Picture it as a clock.
If the switch is at position 2 O-clock then the AM logic tells us that it is position 1. We all understand that.
Now lets move the rotary switch "SLOWLY" to the 3 O-clock position. When I say slowly I mean 30 seconds between leaving 2 O-clock and arriving at 3 O-clock.
AM will only record the position change when the switch arrives at 3 O-clock.
AM "ASSUMES" that the switch is still at 2 O-clock until it arrives at 3 O-clock.
AM might know that the switch is in transit, but it does not convey/return the the logic value. And that value is a nil.
My 2C
Keith
Hello and good morning brother Keith
- this reply is more to help Brady as I believe
you know what you refer to, but, I think the use of the word 'assumes' and the use of 'nil' could certainly be construed as confusing here. AM doesn't assume anything. it knows, it is digital high or low,
AM - when assigned a single switch with more than 1 position - meaning anything with 2 positions and above, is programmed internally to IGNORE the change of state of the port pins during switch rotation. In this type of hardware switch AM will only respond to an active low on one of the pins assigned and only one per assigned switch. The non active state during switching (which is simply all the port pins registering logic high (1) as they are inactive - is DELIBERATELY ignored, never assumed. The API is designed and programmed to only return a position value only when a different port pin is pulled low. No assumption and most importantly the value is
NEVER NIL. During a switch movement transition there are simply all logic 1'a on the port pins. Again , there is no 'intermediate state', no 'NIL'.
Why I believe this is important to stress is that is because when using a single toggle switch AM is also fully aware of the state but in this case does
not IGNORE the 'inactive' or what has been referred to, possibly also confusingly I believe, as 'open circuit'
The change that the API is looking for here is from an active state on the single assigned pin, to a non active state. Or, to put it another way, from a logic 1 (HIGH LEVEL) on the port pin assigned when the switch is open (inactive) to a logic 0 (LOGIC LOW) on the port pin (active) when the pin is grounded by the switch. It returns a 0 or 1 depending on the state of the switch, active or inactive. In this case, AM is responding to a logic change on a single pin because it is programmed to do that.
In a rotary switch, for example, or, any switch with more than one pin in use, it is simply programmed to ignore any transition as it is programmed to respond only to a change from one pin being pulled low (active / closed switch on that pin / port pin pulled low or however someone may want to defne it ) to another pin being pulled low by another part pole of the switch being connected to ground (active). It will simply ignore the period where no segment of the switch is active. - which again, is never 'NIL' - it is simply all logic 1's on the pins. Apples and oranges etc.
So, to sum up, on a multi pin assignment for a single switch, the API only responds to an active low on one of the pins as this is how it is programmed to respond.
In the case of a single switch with 1 data input pin, then this is
not the case as it is programmed internally in AM to do this. When the single switch is active then the port pin is pulled low (Logic Level 0) and AM sends a 1 as the return value. Conversely, When the port pin is high - non active, (and it is only HIGH (logic 1) due to the arduino internal pull up resistors being assigned to the arduino pin by AM) s now, then it KNOWS that the switch is in an inactive position and returns a 0 value on the callback return.
To use use the word 'assume' when referring to coding can certainly cause confusion.
I UNDERSTAND WHAT YOU ARE GETTING AT.. but for others it may not be the case. Especially when comparing a single data pin switch to a multi data pin switch which are programmed to respond in completely different ways in AM. Again, I think this may be leading to some of Brady's understandable confusion. There is no 'nil' state ever involved here. It is probably better to replace 'assumes' with 'ignores'.
Just for shits and giggles
, there are also two types of multipole switches - 'Make before Break' and 'Break before Make'... yikes ! but, AM takes care of both due to the way it is programmed and they are used interchangeably.
Joe