Search found 14 matches

by Leonti
Fri Sep 23, 2022 7:50 am
Forum: General Discussion and Questions
Topic: Reading encoder with interrupts
Replies: 7
Views: 32722

Re: Reading encoder with interrupts

What is a hard interrupt? Does it mean it's a higher priority than the other ones? I have solved my issue by not constantly reading from SPI. I'm using [url=https://github.com/nRF24/CircuitPython_nRF24L01[]this NRF24L01/url] ported to Micropython. It allows you to set up an "IRQ" pin, which will bec...
by Leonti
Fri Sep 23, 2022 5:04 am
Forum: General Discussion and Questions
Topic: Reading encoder with interrupts
Replies: 7
Views: 32722

Re: Reading encoder with interrupts

I think I figured it out. I've updated my code to be this: def handle_enc1(self, pin): if pin.value() != 1: self._false_triggers += 1 if self._enc2.value() == 1: if not self._going_down: self._direction_changes += 1 self._going_down = True self._pos -= 1 else: if self._going_down: self._direction_ch...
by Leonti
Fri Sep 23, 2022 4:05 am
Forum: General Discussion and Questions
Topic: Reading encoder with interrupts
Replies: 7
Views: 32722

Re: Reading encoder with interrupts

After further investigation I can confirm that it's most likely not the CPU. 2 things I noticed: 1. If I change trigger to "Pin.IRQ_RISING" it makes readings more stable overall. They are still not as accurate as I want them to be, but at least they don't skew in a single direction as much, here are...
by Leonti
Fri Sep 23, 2022 12:52 am
Forum: General Discussion and Questions
Topic: Reading encoder with interrupts
Replies: 7
Views: 32722

Re: Reading encoder with interrupts

The pulse rate is about 2 pulses every millisecond, so I'm guessing it's more than enough time to process it before the next pulse comes. The program has a lot of print statements, so I was thinking that maybe interrupts are not processed when serial is being used. Yeah, it's interesting that it's d...
by Leonti
Thu Sep 22, 2022 10:30 am
Forum: General Discussion and Questions
Topic: Reading encoder with interrupts
Replies: 7
Views: 32722

Reading encoder with interrupts

I have a motor with a hall sensor encoder (JGA25-370). I'm building automatic roller blinds and using encoder values to determine position of the blind. However, during my testing, I noticed that there is an encoder drift. For example, when I move the motor to position 0 then to position 100 and bac...
by Leonti
Mon Apr 05, 2021 7:33 am
Forum: Raspberry Pi microcontroller boards
Topic: PIO jmp not_x behaviour
Replies: 6
Views: 3498

Re: PIO jmp not_x behaviour

That is very useful, thanks a lot!
by Leonti
Mon Apr 05, 2021 12:50 am
Forum: Raspberry Pi microcontroller boards
Topic: PIO jmp not_x behaviour
Replies: 6
Views: 3498

Re: PIO jmp not_x behaviour

Wow, thanks Robert!

How do you look at the generated code?
by Leonti
Sun Apr 04, 2021 2:43 pm
Forum: Raspberry Pi microcontroller boards
Topic: PIO jmp not_x behaviour
Replies: 6
Views: 3498

Re: PIO jmp not_x behaviour

Thanks Robert! I thought that it might have been the case briefly, but discarded the idea because I saw this is JMP conditions in RP2040 datasheet (section 3.4.2): !X: scratch X zero and also Is an optional condition listed above (e.g. !x for scratch X zero). If a condition code is not specified,the...
by Leonti
Sun Apr 04, 2021 3:49 am
Forum: Raspberry Pi microcontroller boards
Topic: PIO jmp not_x behaviour
Replies: 6
Views: 3498

PIO jmp not_x behaviour

Hi! I'm working on a simple stepper motor driver with a very basic behaviour: 1. Send pulse to A4988 2. Wait for a specified delay 3. Repeat Here is my code: import time import rp2 from machine import Pin @rp2.asm_pio(set_init=rp2.PIO.OUT_LOW) def stepper(): pull(noblock) # pull new data or recycle ...
by Leonti
Sat Apr 03, 2021 8:59 am
Forum: Raspberry Pi microcontroller boards
Topic: Stepper motors with PIO
Replies: 4
Views: 2984

Re: Stepper motors with PIO

Thank you Robert!

Now it all makes sense!