I am considering a project with a nano 33 ble (or rp2040) to read 8 pwm channels from a rc receiver @ 380hz, output them, albeit changed, to servos at the same frequency, publish on a BLE connection and trigger some relays. Additionally I would be getting distance sensor data from 2 I2C devices, and from 2 analogue temp sensors.
Does the nano have sufficient processing power for a project like this, without inducing significant delay in the replicated servo commands? What kind of delay could I expect, assuming no blocking calls and just basic logic?
Processing power is probably not a problem. You being a newbie sounds more like an issue for what you describe. What are your skills (electronics, programming)?
Also, I am not sure you have enough I/O. Maybe I misunderstand your requirements. Do you want to read 8 PWM and output them on individual I/O? That would be 16 I/Os already.
How do you want to read the PWM channels? What are your requirements e.g., resolution, sampling rate?
Thanks Klaus. I see 12 digital and 8 analogue pins. I can get sensors for the I2C interface, and would still be left with 18 pins. I need to sample the 8 PWM channels, but I will not need to replicate all of them. Basically I want to override operator input on some of the RC channels dependng on the state of the system.
I was planning on attaching interrupts on rising and falling signals to maintain volatile variables with the current state of the channels. Not sure how stringent the servos are on frequency, would need to find that out. The receiver is outputting a 380hz signal, so that is my starting point.
From what I've read the servo library functions writes at a fixed 50hz frequency with 8 bit resolution. I need to research this a little more, but I'd like to keep the frequency and a resolution of 10 bits, so the servo library is not an option, right?
Would replicating the PWM signal on the Interrupt Service Routine to the output pin be a stupid idea? Response time of the radio system is 3ms, so anything below 300 us, would be an acceptable degradation.
From my experience with full sized processors, ISRs should be as lightweight as possible, but don't know how the M.bed OS on the arduino is architected.
Let’s do the math. At 380Hz you have a period of 2.6ms. You want 10bit resolution. That is 1024 different values. 2.6ms / 1024 ~ 2.6us. So, you need to be able to tell the difference between ~ 3 and 6us. If all PWM signals trigger at the same time, the slowest interrupt will have to wait for all other interrupts to be handled and still read a timer with a maximum delay of around 1us.
You can capture a PWM signal with a timer and a capture compare unit. You do not have 8 of them.
Another option is to filter the PWM signals to get voltages and then use the ADC to measure them. You have 8 channels, but you said you wanted to additional analog inputs.
Sometimes functions are mapped to specific pins, and you cannot move them around. So, you might not be able to use all pins. You will need to review all pins and functions required to be sure.