Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reliable sampling by isolating CPU core #1

Open
rowsto64 opened this issue Mar 21, 2022 · 0 comments
Open

Reliable sampling by isolating CPU core #1

rowsto64 opened this issue Mar 21, 2022 · 0 comments

Comments

@rowsto64
Copy link

// 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant