ABZ Encoder
ABZ Encoder
Hi.
I need to develop the reading of a 2048 pulse abz encoder with wroom32 and visualgdb. I tried with the rotary encoder sample but it doesn't work. Can you help me?
Thanks to everybody.
I need to develop the reading of a 2048 pulse abz encoder with wroom32 and visualgdb. I tried with the rotary encoder sample but it doesn't work. Can you help me?
Thanks to everybody.
Re: ABZ Encoder
Hi, based on my experience with esp32 it is not possible to accurately read an encoder as determinism is not accurate.
-
- Posts: 9745
- Joined: Thu Nov 26, 2015 4:08 am
Re: ABZ Encoder
The ESP32 has a pulse counter specifically for this purpose with examples showing how to use this that as far as we know hasn't had any bugs or issues. Can you specify what you mean with 'determinism is not accurate'?
@edo76mal: You'll have to be a bit more precise than 'it doesn't work' for us to be able to help you. What results do you expect and what results do you get? What have you tried doing yourself to fix the issue?
Re: ABZ Encoder
The code example I use is rotary encoder. I am not able to read encoder pulses using only one channel. I want to count the square waves, so I can use only one channel (channel A in my case)
-
- Posts: 9745
- Joined: Thu Nov 26, 2015 4:08 am
Re: ABZ Encoder
Aside from the Z, an ABZ encoder is the same as a rotary encoder, isn't it? Why wouldn't you be able to use the pulse encoder example then? (I assume you're refering to this one)
Re: ABZ Encoder
Yes, the sample in that.
An ABZ encoder has A, B and Z signals and I want to use only A signal. So, I expect to read each square wave that comes from the A signal of the encoder but it is not true. I don't read the pulses.
FurthermoreI don't succeed in setting 4 ms task, I noticed that task can run to 10 ms.
An ABZ encoder has A, B and Z signals and I want to use only A signal. So, I expect to read each square wave that comes from the A signal of the encoder but it is not true. I don't read the pulses.
FurthermoreI don't succeed in setting 4 ms task, I noticed that task can run to 10 ms.
-
- Posts: 9745
- Joined: Thu Nov 26, 2015 4:08 am
Re: ABZ Encoder
Okay, so you're effectively wanting to count pulses of a square wave? You should be able to get there by modifying all references to channel B in that example, setting the level_gpio_num of channel A to -1 (to indicate you're not using it) and to remove all pcnt_chan_set_*_action statements and replace it with ESP_ERROR_CHECK(pcnt_channel_set_edge_action(pcnt_chan_a, PCNT_CHANNEL_EDGE_ACTION_INCREASE, PCNT_CHANNEL_EDGE_ACTION_INCREASE)); . This should count both positive and negative edges. Suggest you also read the Pulse Count Controller section of the TRM.
Re: ABZ Encoder
Hi ESP_Sprite, because I try to go up to 250 deterministic cycles, but seems that over 100hz the freertos has some problems. Can you explain me why that?
-
- Posts: 94
- Joined: Tue Sep 07, 2021 12:07 pm
Re: ABZ Encoder
You should use an interrupt handler. gpio_isr_handler_add would be a starting point. As the doc says, do the least work you can in the isr handler, update state information and return. Don't call anything. Use an async task to consume the state information. The state information lives in static variables. For a quadrature encoder, the isr could manage a tiny state machine that updates a counter. Yes, look into the pulse counter. Looks like a better idea than writing your own!
As I recall, the vTaskDelay can't go smaller than a fairly large delay, 1/100 1/1000 ? sec perhaps...been a while. Sounds like you might be trying to use that in a way it isn't designed to be used.
As I recall, the vTaskDelay can't go smaller than a fairly large delay, 1/100 1/1000 ? sec perhaps...been a while. Sounds like you might be trying to use that in a way it isn't designed to be used.
Last edited by Craige Hales on Fri Jun 10, 2022 3:02 am, edited 1 time in total.
Craige
-
- Posts: 9745
- Joined: Thu Nov 26, 2015 4:08 am
Re: ABZ Encoder
The pulse counter specifically is a *hardware* device that does the pulse counting. It doesn't need software or FreeRTOS to do anything. How does your implementation require 250 interrupts per second? (Also, if you really need that, you could use esp-timer, a hardware timer, or if you really need to, increase FreeRTOSses tick granularity)
Who is online
Users browsing this forum: No registered users and 89 guests