Skip to content

Reliable sampling by isolating CPU core #1

@rowsto64

Description

@rowsto64

// Without employing a real time kernel, dropped samples can be minimised by isolating a cpu core to use for the acquisition code
// Arbitrarily selecting core 1

append isolcpus=1 to /boot/cmdline.txt

// should look something like below
//
$ cat /boot/cmdline.txt
console=tty1 root=PARTUUID=4c484480-02 rootfstype=ext4 fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles isolcpus=1

//
// Reboot

sudo reboot

// Test to see if it worked
//

$ cat /sys/devices/system/cpu/isolated
1

// increase SPI clock to 12.5MHz (should be OK with ADUM4151 briz? 17MHz? I don't have one...)
//

sed -i 's/600/12500/g' readFromADS1262andSave.go

// increase sample rate to 2400 sps (fastest I can get reliably)
//

sed -i 's/adc.MODE2_DR_20/adc.MODE2_DR_2400/g' readFromADS1262andSave.go

// change digital filtering from FIR to sinc4, required for fast sampling
//

sed -i 's/MODE1_filter_FIR/MODE1_filter_sinc4/g' readFromADS1262andSave.go

// Compile it
//

go build readFromADS1262andSave.go

// Run it with "real time" fifo scheduling on cpu core 1
//

taskset -c 1 sudo chrt -ff 99 ./readFromADS1262andSave

pi:/Code/piadcs/Examples $ taskset -c 1 sudo chrt -ff 99 ./readFromADS1262andSave
[3 0 0 0 0 0]
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
Exited gracefully
$pi:
/piadcs/Examples

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions