DO NOT MERGE WIP. Add support for external SPI ADC on rp2040 and rp2350#65
Draft
thomasfla wants to merge 11 commits intosimplefoc:rp2350_current_sensefrom
Draft
DO NOT MERGE WIP. Add support for external SPI ADC on rp2040 and rp2350#65thomasfla wants to merge 11 commits intosimplefoc:rp2350_current_sensefrom
thomasfla wants to merge 11 commits intosimplefoc:rp2350_current_sensefrom
Conversation
…itting 64bits per samples, in a ring buffer from witch the CPU can take the last samples.
…dc values from buffer)
Member
|
I changed it into draft mode - that way it can’t be merged by accident… |
|
Memory usage change @ 4aa83b6
Click for full report table
Click for full report CSV |
…n, validated on RP2350 with 3 ADCs
… the loop, only do abc, only 12bits
…sing the same PIO with different state machine, ans also be compatible with other library that uses other PIOs (encoder for example)
|
Memory usage change @ ff1108c
Click for full report table
Click for full report CSV |
Member
|
I was just about to ask you for the #if conditional compilation :-) thanks so much! Thanks for all your amazing effort on this! |
|
Memory usage change @ 488eff6
Click for full report table
Click for full report CSV |
Member
|
I have a board in development that will hopefully allow me to test this out :-) the way I see it there is still the todo to make the trigger from the timer to the PIO.
|
Member
|
Looking at this a bit more, I am not sure there is any TODO for the ArduinoFOC code... In the RP2350PIOCurrentSense we can do the following: #include "drivers/hardware_api.h"
// get the driver params
RP2040DriverParams* params = (RP2040DriverParams*)driver->params;
// create a 1PWM timer on the trigger pin using the same frequency
RP2040DriverParams* paramsTrigger = (RP2040DriverParams*)_configure1PWM(params->pwm_frequency, pinTRIG);
// set the correct duty cycle for the desired trigger point, we could provide a convenience function for that
_writeDutyCycle1PWM(0.29f, paramsTrigger);and for IRQ based triggering with WAIT IRQ in the PIO: #include "hardware/pwm.h"
RP2040DriverParams* params = (RP2040DriverParams*)driver->params;
pwm_set_irq_enabled(params->slice[0], true); // using PWM_IRQ_WRAP_0
// TODO check the IRQ isn't being used on the interrupt controller, because then it can't be used for PIO
irq_set_enabled(PWM_IRQ_WRAP_0, true);
// for the PIO code we will probably have to make an alternate version that uses WAIT IRQ PWM_IRQ_WRAP_0 1
// instead of the two WAIT GPIO instructions? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Current Sense for RP2350
warning Work in progress
Implementation of current sensing on RP2350 using the PIO to read SPI based ADCs.
Wiring:
Temporarly, for this to work, we need to add a PWM chanell in Arduino-FOC rp2040 hardware specific files. The duty cyctle needs to be computed to trigger the ADC at the right-time.
TODO: