Jump to content

Core32F4 J5a Encoder


Phatline
 Share

Recommended Posts

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

 

Link to comment
Share on other sites

  • 5 months later...

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"

Link to comment
Share on other sites

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

 

Edited by Phatline
Link to comment
Share on other sites

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
    }
}

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Edited by kmargos
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...