BIG CAP testing
This commit is contained in:
@@ -35,5 +35,5 @@ rustflags = [
|
||||
runner = "probe-rs run --chip RP2040 --protocol swd"
|
||||
|
||||
[env]
|
||||
DEFMT_RTT_BUFFER_SIZE = { value = "4096", force = true }
|
||||
DEFMT_RTT_BUFFER_SIZE = { value = "16384", force = true }
|
||||
DEFMT_LOG = { value = "info", force = true }
|
||||
45
src/main.rs
45
src/main.rs
@@ -43,7 +43,7 @@ pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_GENERIC_03H;
|
||||
/// if your board has a different frequency
|
||||
const XTAL_FREQ_HZ: u32 = 12_000_000u32;
|
||||
|
||||
const NUM_ADC_SAMPLES: usize = 1024;
|
||||
const NUM_ADC_SAMPLES: usize = 8192;
|
||||
|
||||
/// Entry point to our bare-metal application.
|
||||
///
|
||||
@@ -95,13 +95,15 @@ fn main() -> ! {
|
||||
MyPin::new(MyPinMode::Input, pins.gpio13.into_dyn_pin()),
|
||||
];
|
||||
|
||||
let mut brute_force_pin: MyPin = MyPin::new(MyPinMode::Floating, pins.gpio9.into_dyn_pin());
|
||||
|
||||
let dma = pac.DMA.split(&mut pac.RESETS);
|
||||
|
||||
let mut adc = hal::Adc::new(pac.ADC, &mut pac.RESETS);
|
||||
let mut adc_pin = hal::adc::AdcPin::new(pins.gpio26.into_floating_input()).unwrap();
|
||||
let mut adc_fifo = adc
|
||||
.build_fifo()
|
||||
.clock_divider(24000, 0)
|
||||
.clock_divider(192, 0)
|
||||
.set_channel(&mut adc_pin)
|
||||
.enable_dma()
|
||||
.start_paused();
|
||||
@@ -158,6 +160,7 @@ fn main() -> ! {
|
||||
adc_fifo.resume();
|
||||
let (ch, adc_read_target, buf_for_samples) = dma_transfer.wait();
|
||||
let avg = avg_fifo(buf_for_samples, false);
|
||||
let max_v = avg;
|
||||
println!("Avg: {}", avg);
|
||||
|
||||
adc_fifo.pause();
|
||||
@@ -170,12 +173,18 @@ fn main() -> ! {
|
||||
test_pins[2].switch_into_output();
|
||||
test_pins[2].set_low();
|
||||
delay.delay_ms(200);
|
||||
// this needs to resume before we start floating the other pin,
|
||||
// otherwise we're often too slow to catch the initial drop
|
||||
// some data post-processing will be needed anyway to trim begin/end
|
||||
adc_fifo.resume();
|
||||
test_pins[0].switch_to_floating();
|
||||
let (ch, adc_read_target, buf_for_samples) = dma_transfer.wait();
|
||||
let avg = avg_fifo(buf_for_samples, true);
|
||||
delay.delay_ms(10);
|
||||
let avg = avg_fifo(buf_for_samples, true);
|
||||
println!("Avg: {}", avg);
|
||||
if avg >= (max_v * 9) / 10 {
|
||||
println!("Probably a large capacitor, alt test recommended");
|
||||
}
|
||||
|
||||
adc_fifo.pause();
|
||||
adc_fifo.clear();
|
||||
@@ -183,6 +192,36 @@ fn main() -> ! {
|
||||
|
||||
// TEST 4
|
||||
delay.delay_ms(1000);
|
||||
println!("Alt Testing floating");
|
||||
brute_force_pin.switch_into_output();
|
||||
brute_force_pin.set_high();
|
||||
// test_pins[0].set_high();
|
||||
test_pins[2].switch_into_output();
|
||||
test_pins[2].set_low();
|
||||
delay.delay_ms(200);
|
||||
// this needs to resume before we start floating the other pin,
|
||||
// otherwise we're often too slow to catch the initial drop
|
||||
// some data post-processing will be needed anyway to trim begin/end
|
||||
adc_fifo.resume();
|
||||
brute_force_pin.set_low();
|
||||
test_pins[0].switch_into_output();
|
||||
test_pins[0].set_low();
|
||||
let (ch, adc_read_target, buf_for_samples) = dma_transfer.wait();
|
||||
delay.delay_ms(10);
|
||||
let avg = avg_fifo(buf_for_samples, true);
|
||||
println!("Avg: {}", avg);
|
||||
if avg >= (max_v * 9) / 10 {
|
||||
println!("Probably a HUGE capacitor, alt test recommended");
|
||||
}
|
||||
|
||||
// cleanup
|
||||
brute_force_pin.switch_to_floating();
|
||||
adc_fifo.pause();
|
||||
adc_fifo.clear();
|
||||
dma_transfer = single_buffer::Config::new(ch, adc_read_target, buf_for_samples).start();
|
||||
|
||||
// TEST 5
|
||||
delay.delay_ms(1000);
|
||||
println!("Testing resistance");
|
||||
test_pins[0].switch_into_output();
|
||||
test_pins[2].switch_into_output();
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user