Sauraen Posted November 27, 2013 Report Share Posted November 27, 2013 Hi TK, In the manual configuration for encoders, I see you have only four options for connecting encoders to a DIN shift register: 0:1, 2:3, 4:5, and 6:7. It says "If you notice that the encoder increments in the wrong direction, the pins have to be swapped at the hardware side!" Is there any chance you could also include 1:0, 3:2, 5:4, and 7:6 as allowable modes? I'm laying out a board for a front panel that encoders will be permanently mounted in, and I don't want to power it up and find out half the encoders turn in the wrong direction, because I can't swap the wires on the hardware at that point! (Plus it makes it easier to lay out if I can swap the order arbitrarily.) I'm sure you could figure this out quite easily, but this is a quick way to swap bits 1 and 0, 3 and 2, 5 and 4, 7 and 6. It would seem to me to be as easy as making a copy of the input data byte from the shift register, modifying the copy as follows, and then reading from either the original or the copy according to the configuration line. data = ((data & 0x55) << 1) | ((data & 0xAA) >> 1); //or in assembler, assuming data is in r1 mov r2,r1 andi r2, 0x55 rol r2 andi r1, 0xAA ror r1 or r1,r2 Thanks, Sauraen Quote Link to comment Share on other sites More sharing options...
TK. Posted November 28, 2013 Report Share Posted November 28, 2013 I updated MIOS32_ENC, so that pins are swapped if an odd number is specified in the .pos item So: .pos = 0 or 2 or 4 or 6: works as usual .pos = 1 or 3 or 5 or 7: pins swapped Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
Sauraen Posted November 29, 2013 Author Report Share Posted November 29, 2013 (edited) Thank you for the fast fix! In the User Manual, this item is called ".pins", not ".pos". However, I see in $MIOS32_PATH/include/mios32_enc.h that the appropriate variable is in fact mios32_enc_config_t.cfg.pos. Is this what you changed the handling for? If so, does the NGC parser simply read the first of the two pins specified and set that value into mios32_enc_config_t.cfg.pos, so we should simply be able to write our configuration files with ".pins=1:0", etc., with no further changes? Edited November 29, 2013 by Sauraen Quote Link to comment Share on other sites More sharing options...
TK. Posted November 29, 2013 Report Share Posted November 29, 2013 Yes, I changed it in MIOS32, and I guess that the MIDIbox NG application doesn't take care about the pin alignment, so that the configuration value will be directly passed to MIOS32 Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
TK. Posted November 30, 2013 Report Share Posted November 30, 2013 Ok, understood the problem: the .NGC file parser was too restrictive - I released a mbng_file_c.c change in the repository which allows swapped pins, and which should raise an error message on unsupported pin combinations. Please help to test this (critical) change - we've to avoid that valid pin combinations are refused by the parser due to a potential programming error! Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
Sauraen Posted December 1, 2013 Author Report Share Posted December 1, 2013 (edited) It's going to be a couple weeks before I will be able to test this (my front panel is still raw aluminum and copper clad board), but once I build it I should be using each valid combination. But can't you just take a controller you already have, swap each pin statement in the configuration file (e.g. change 0:1 to 1:0) and see if all the encoders turn backwards? Edit: Working fine, thanks very much! Encoder rotates backwards with pins in wrong configuration, then switching them and saving causes it to rotate correctly again. Edited January 4, 2014 by Sauraen Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.