Hi everyone,
I’m trying to understand how to access PWM signal inputs rather than voltage via the Sensor Inputs for the Servo RP2040 board.
The goal is to have the Servo board interpret the inputs, overlay a decisioning logic and output that to the servos.
I have CircuitPython 8.0 installed as i needed I2C slave support.
Using CircuitPython pulseio.PulseIn, I can see 2 pulses being detected, with one returning the right PWM signal of Signal_1 however I have no idea how to take it further. All experimented ways are not identifying per pin signal. I know my execution is wrong but i don’t quite understand how to access each sensor pin across a shared_adc variable so i can then monitor each pin.
Any help would be greatly appreciated :) I would love to be able to read PPM through the signal but currently i’m using the Servo_18 to read the input.
Thanks and love the Servo RP2040 so far.
import time, board
from digitalio import DigitalInOut, Direction, Pull
from analogio import AnalogIn
import pulseio
pulses = pulseio.PulseIn(board.SHARED_ADC,idle_state=True)
addr0_pin = DigitalInOut(board.ADC_ADDR_0)
addr0_pin.direction = Direction.OUTPUT
addr1_pin = DigitalInOut(board.ADC_ADDR_1)
addr1_pin.direction = Direction.OUTPUT
addr2_pin = DigitalInOut(board.ADC_ADDR_2)
addr2_pin.direction = Direction.OUTPUT
def get_voltage(pin):
return (pin.value * 3.3) / 65536
def select(address):
addr0_pin.value = address & 0b001
addr1_pin.value = address & 0b010
addr2_pin.value = address & 0b100
while True:
print(len(pulses), end=":")
if (len(pulses) > 0):
# Pause while we do something with the pulses
pulses.pause()
for i in range(len(pulses)):
#select(i)
# Print the pulses. pulses[0] is an active pulse unless the length
# reached max length and idle pulses are recorded.
print(pulses[i], end=",")
# Clear the rest
pulses.clear()
pulses.resume()
print("\n", end="")
time.sleep(0.5)