Core32F4 J5a Encoder

i want to connect one Encoder directly to J5a

i know that in my Code i have to

initalize this pins:

// initialize pin 2 of J5A, as Digital input with internal Pull-UP //connect to ground MIOS32\_BOARD\_J5\_PinInit(0, MIOS32\_BOARD\_PIN\_MODE\_INPUT\_PU); MIOS32\_BOARD\_J5\_PinInit(1, MIOS32\_BOARD\_PIN\_MODE\_INPUT\_PU);

and i also can observe the state of the J5a pin by putting following code into APP_Background:

MIOS32\_BOARD\_J5\_PinGet(0) MIOS32\_BOARD\_J5\_PinGet(1)

all clear so far, and working good with buttons (with hardware debouncing ):

debouce-circuit

 

how does a Encoder-Code look like (without any Acceleration), and how does Hardware debouncing look like (the same like for buttons?), i want to use as less code then possible…

 

thx 4 any tips

 

Explained in detail in following tutorials:

http://svnmios.midibox.org/listing.php?repname=svn.mios32&path=%2Ftrunk%2Fapps%2Ftutorials%2F014b_enc_j5_relative%2F

http://svnmios.midibox.org/listing.php?repname=svn.mios32&path=%2Ftrunk%2Fapps%2Ftutorials%2F015b_enc_j5_absolute%2F

Best Regards, Thorsten.

thx

Hi!!!

Leveraging the topic.
I use the LCP1769
I’m testing the example “014b_enc_j5_relative”.
It only works J5A (A0 … A3) and J5B (A4 … A7) does not work.

This example tests all inputs A0 … A7 on the J5A and J5B connector? How do I set up so that all inputs A0 … A7?

I tested J5A / B as analog inputs and they all worked. I just set “#define MIOS32_AIN_CHANNEL_MASK 0x00ff”

This Settings in “mios32_config.h” are working for 0-7A (5a,5b) - i am on a stm32f4

#define MIOS32\_AIN\_CHANNEL\_MASK 0x00ff // AIN define the deadband (min. difference to report a change to the application hook) #define MIOS32\_AIN\_DEADBAND 31 //7Bit

 

Hi !!

 

Strange, would not that just be for analog inputs? A0 … A3 work fine without setting “#define MIOS32_AIN_CHANNEL_MASK 0x00ff”.
I do not want analog inputs. I want 4 encoders

 

Tks Marco.

ahhh sorry, may fault…

what i have done with J10A-B (if you replace J10 with J5 i think its the same)

@top of programm (declaration)

// ENCODER SR begin with 1, ENC with 0) // setup the Pinout of Encoders const mios32\_enc\_config\_t encoders[1] = {{ .cfg.type=DETENTED2, .cfg.speed=FAST, .cfg.speed\_par=3, .cfg.sr=7, .cfg.pos=0 }};

 

void APP\_Init(void){ BLM\_SCALAR\_Init(0); // initialize BLM\_SCALAR driver // Set GPIO @ J10A+B int pin; for(pin=0; pin\<16; ++pin){ MIOS32\_BOARD\_J10\_PinInit(pin, MIOS32\_BOARD\_PIN\_MODE\_INPUT\_PU);} // Set Menue Encoder int enc; for(enc=0; enc\<4; ++enc) { mios32\_enc\_config\_t enc\_config = MIOS32\_ENC\_ConfigGet(enc); enc\_config.cfg.type = DETENTED3; // see mios32\_enc.h for available types enc\_config.cfg.sr = 0; // must be 0 if controlled from application enc\_config.cfg.pos = 0; // doesn't matter if controlled from application enc\_config.cfg.speed = FAST; enc\_config.cfg.speed\_par = 0; MIOS32\_ENC\_ConfigSet(enc, enc\_config);} }

 

void APP\_SRIO\_ServicePrepare(void) { // get current J10B value and update all encoder states int enc; u16 state = MIOS32\_BOARD\_J10B\_Get(); for(enc=0; enc\<4; ++enc) { MIOS32\_ENC\_StateSet(enc, state & 3); // two pins state \>\>= 2; // shift to next two pins } }

 

Hi , 

this example should work the 4 encoders?Im mine LPC dont work, only 2 encoders(j5A).

http://svnmios.midibox.org/listing.php?repname=svn.mios32&path=%2Ftrunk%2Fapps%2Ftutorials%2F014b_enc_j5_relative%2F

 

Tks, Marco.

Just got a flashback: this is actually a known issue and I thought that I fixed this some years ago… somehow the change didn’t find it’s way into the repository.

I updated mios32/LPC17xx/mios32_board.c, please update your repository

Best Regards, Thorsten.

1 hour ago, TK. said:

Acabei de receber um flashback: este é realmente um problema conhecido e achei que consertei isso há alguns anos … de alguma forma, a mudança não encontrou o caminho para o repositório.

Eu atualizei o mios32 / LPC17xx / mios32_board.c, atualize seu repositório

Atenciosamente, Thorsten.

Hi TK,

Thank you so much!!! Now it works !!! I’ve been looking for where the bug would be for two days and today I would look at “mios32_board.c”. Thanks for the quick help !!!

Marco.