Replies: 7 comments 20 replies
-
I quote a reply from @DocMoebiuz on the discord channel, adding some considerations:
An encoder using multiplexed pins need not know anything different from the board json.
The firmware only needs to receive two more values in the configuration, ie the mux selector values for its two pins). If these values are e.g. 0xFF, the encoder simply skips the selector setting when reading pins, everything else is unchanged.
This is an (obvious) intrinsic precondition to use MuxEncoders. No need to automate the creation: if no digIn multiplexer is previously configured by the user, obviously an encoder can't use multiplexed pins.
This is almost trivial, and inexpensive (at least for the case at hand), see above.
Yes, a device for multiplexed analog inputs could be created just as done for digital inputs (clearly with its peculiarities).
Indeed, but this is entirely another topic, which is already under discussion here; the first step is "shared driver pins for devices", then "SPI devices behind multiplexers". |
Beta Was this translation helpful? Give feedback.
-
I realized I forgot to tag anybody, so this discussion might remain unnoticed... shoutout to @neilenns @elral @tigert @Pitj3 and anybody else interested |
Beta Was this translation helpful? Give feedback.
-
It's probably useful to add this summary of the details of my proposal; I'm not sure if I might have missed something, so please let me know your comments.
And this is a summary of the total impact:
End note - Input Mask improvement: Ideally, the mux inputs assigned to an encoder should be registered in a mask (on the mux device) in order to:
|
Beta Was this translation helpful? Give feedback.
-
First of all, sorry for my late answer, I was quite busy with my daily work. But it should be better now ;) I thought long about the support of encoders via multiplexer, and I see still "only" one reason to go this way. As the main stream supported Mega has enough I/O's for encoders, buttons, ... the now supported Pico lacks on I/O's and beside the shifter registers support of encoders via multiplexer might be sensefull. On the firmware side this new device must be implemented and slight changes on the encoder routines are necessary to read in the pin status from the mux device. I assume that the changes are negligible. /edit: I forgot to mention, that it would be benefitial first to implement sending the deviceID instead of the names to free up the RAM consumption. Also it could be benefitial to use the deviceID to access the defined multiplexer (but haven't thought in detail about this topic) |
Beta Was this translation helpful? Give feedback.
-
Just out of curiosity... how much weight does the compatibility with SimVim/RSC have in your opinion, when considering whether to adopt a feature? Assuming of course features which could make sense for themselves anyway, not ones to be introduced just for the sake of SimVim compatibility at the cost of disrupting the operation of MF. |
Beta Was this translation helpful? Give feedback.
-
I think it's great to provide a migration path to users who are coming from SimVim. For me that's one of the main reasons we introduced multiplexers in the first place We had already Output and Input Shifters, the 74hc4067 are just more widely used. At least that is my impression. So it's a great alternative for other users too. |
Beta Was this translation helpful? Give feedback.
-
I did some tests to which time the "debounce" time for encoders could be increased.
So I would say targeting 2ms for reading the encoder inputs is OK, if it ends up "sometimes" to 3ms or 4ms (time delay in the main loop() for some reasons) it would be also OK. In one of the graphic libs I saw that they implemented a "fast I/O" to speed up accessing the I/O's. As we mostly access the I/O's, we could think about to use it (or similiar). But that would mean to refactor nearly all files... |
Beta Was this translation helpful? Give feedback.
-
Since questions about this possible improvement pop up from time to time, showing that there is interest (often from SimVim users), and since I also believe it makes sense, I'd like to start with a few thoughts about it.
Firmware-wise, "feeding" an encoder with an input from a multiplexer would be easily feasible with very little penalty:
multiplexer inputs can be directly addressed rather quickly (just 4
DigitalOut()
instructions per pin to set the address) and independently (i.e. you can change the multiplexer address in any moment).Their impact on the speed of the polling cycle should be therefore very limited, regardless on where, on which pins of which multiplexer, they are connected.
The situation would obviously be very different for input shifters, where a complete and slow scan cycle (and intermediate storage of the results!) would be required.
A slightly more demanding modification is required on the Connector side.
Currently, on the Connector, the encoder inputs are simply defined by the Arduino pin number; with multiplexer inputs, in order to fill the selection list, a reference must be made to other devices (the multiplexers) which may or may not be present.
The program should first scan for the existence of input multiplexer devicess (and read on which pin they are connected), then insert their inputs as list items, assigning a special name.
For example, for all 16 inputs of the multiplexer connected to pin 23 this name could be something like e.g. "23/0", "23/1" ... "23/15".
In the encoder configuration message, for each encoder pin, the multiplexer pin (or "channel") number - the second figure above - would need to be added to the current message payload, to be used by the firmware as the multiplexer selector/address value.
The pin number already present would be set to the pin number associated to the multiplexer.
There might be side effects to consider, e.g. a situation where an encoder uses inputs from a multiplexer device which is subsequently removed, leaving the references invalid and possibly undetected.
Beta Was this translation helpful? Give feedback.
All reactions