Thanks for quickly trying the provided code.
The second pulse looks closer to the expected value.
If you only print out pulses[1] ignoring the pulses[0] does that start to provide pulseIn data that is matching to your Arduino.
Arduino to Circuitpython code conversion
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
- Daft_vagabond
- Posts: 92
- Joined: Thu May 28, 2020 2:53 pm
Re: Arduino to Circuitpython code conversion
The results are nearly the same
Which doesn't surprise me, as I think as the array fills up, they just start to cycle through, right?
Code: Select all
27
27
27
27
27
27
27
27
28
27
28
9
19
11
17
17
7
27
27
27
27
28
28
28
27
8
8
27
28
11
27
27
27
27
27
7
7
27
27
27
28
13
27
28
22
7
27
28
27
27
28
28
28
7
9
28
8
28
7
10
27
27
7
28
6
27
28
27
6
27
27
28
27
27
28
27
27
28
6
27
28
27
9
17
8
28
8
7
27
28
28
27
28
27
27
27
28
7
7
8
28
27
28
28
27
27
7
17
27
10
27
17
27
27
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Arduino to Circuitpython code conversion
Looking through the docs for pulseio.PulseIn() one thing that stands out is pulse.resume(80) using a trigger pulse.
It would probably be best not to pass pulse.resume(80). btw in you last code example code paste it looks like you might have dropped pulse.resume()? I did not see the last line after the comment.
https://circuitpython.readthedocs.io/en ... s/pulseio/Using trigger pulse with a device that drives both high and low signals risks a short. Make sure your device is open drain (only drives low) when using a trigger pulse. You most likely added a “pull-up” resistor to your circuit to do this.
It would probably be best not to pass pulse.resume(80). btw in you last code example code paste it looks like you might have dropped pulse.resume()? I did not see the last line after the comment.
- Daft_vagabond
- Posts: 92
- Joined: Thu May 28, 2020 2:53 pm
Re: Arduino to Circuitpython code conversion
Would you mind Eli 5ing that for me? (Other than the part about the pull up/pull down resistor, I understand that that is just a resistor that is only strong enough to influence the logic in one direction or the other while the signal is idle)
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Arduino to Circuitpython code conversion
I'd like you to try to use pulse.resume() with no arguments. Get the 80 out of there. That '80' value is for an optional trigger pulse and I don't think that is helpful in your case.
- Daft_vagabond
- Posts: 92
- Joined: Thu May 28, 2020 2:53 pm
Re: Arduino to Circuitpython code conversion
Oh, yeah, I hadn't been using the (80) parts. I thought that by introducing more pulses, it'd only further throw off my readings.
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Arduino to Circuitpython code conversion
@Daft_vagabond,
Looking at the github repo for PulseIO (PulseIn) for CircuitPython an issue stands out as you are attempting to measure < 10us pulses.
"PulseIn drops very short pulses #4946"
https://github.com/adafruit/circuitpython/issues/4946
Looking at the github repo for PulseIO (PulseIn) for CircuitPython an issue stands out as you are attempting to measure < 10us pulses.
"PulseIn drops very short pulses #4946"
https://github.com/adafruit/circuitpython/issues/4946
- Daft_vagabond
- Posts: 92
- Joined: Thu May 28, 2020 2:53 pm
Re: Arduino to Circuitpython code conversion
I'm guessing Arduino/C++ doesn't have this issue?
Since I'm not measuring IR, would it be simple enough to lower the minimum?
In that thread, DavePutz mentions it as a possibility.
https://github.com/adafruit/circuitpyth ... -872975351
Since I'm not measuring IR, would it be simple enough to lower the minimum?
In that thread, DavePutz mentions it as a possibility.
https://github.com/adafruit/circuitpyth ... -872975351
- Daft_vagabond
- Posts: 92
- Joined: Thu May 28, 2020 2:53 pm
Re: Arduino to Circuitpython code conversion
Or even, could we add a parameter that can control the minimum lengths or even turn them off.
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Arduino to Circuitpython code conversion
@Daft_vagabond,
That seems reasonable to me. There is a maxlen parameter why not have a minlen so these short pulses can be caught.
Would you like to suggest that on the open issue?
https://github.com/adafruit/circuitpython/issues/4946
In terms of a shorter term work around I don't see an obvious setting in the CircuitPython PulseIn to adjust for minimums. You might be able to get something going based rp2pio / adafruit_pioasm examples here:
https://github.com/adafruit/circuitpython/issues/4983
That seems reasonable to me. There is a maxlen parameter why not have a minlen so these short pulses can be caught.
Would you like to suggest that on the open issue?
https://github.com/adafruit/circuitpython/issues/4946
In terms of a shorter term work around I don't see an obvious setting in the CircuitPython PulseIn to adjust for minimums. You might be able to get something going based rp2pio / adafruit_pioasm examples here:
https://github.com/adafruit/circuitpython/issues/4983
- Daft_vagabond
- Posts: 92
- Joined: Thu May 28, 2020 2:53 pm
Re: Arduino to Circuitpython code conversion
I posted a comment on the open issues you linked to. Lets hope this is something that can be implemented. It would open up an array of uses outside of IR-related projects.
Please be positive and constructive with your questions and comments.