Skip to content

Commit

Permalink
Modified freq calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
ardyesp committed Feb 26, 2017
1 parent 99ea1c2 commit 3645da8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
File renamed without changes.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# DLO-138
An open source firmware for DSO-138 Oscilloscope.
![Photo](https://github.com/ardyesp/DLO-138/blob/master/pics/pic1.png)

DSO-138 is an excellent piece of hardware based on ARM Cortex M3 core STM32F103 processor and sufficient for most beginner users. The stock firmware, while quite responsive, can use a few improvements. The main shortcoming which prompted the development of DLO-138 firmware is the inability to get waveform data into a computer for further analysis and the lack of a second channel. Engineers troubleshooting hardware issues need to mark reference points on waveform so having another analog or digital channel can greatly improve analysis. This firmware hopes to improve on these issues.

Expand Down
14 changes: 7 additions & 7 deletions capture.ino
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ void startSampling(int16_t lDelay) {

if(lDelay < 0) {

asm volatile(
asm volatile(
" ldrh r9, [%[sIndex]] \n\t" // load sIndex value

"top_1: \n\t"
Expand All @@ -184,9 +184,9 @@ void startSampling(int16_t lDelay) {
" bne notOverflowed_1 \n\t"
" mov r9, #0 \n\t" // sIndex = 0;

" stmfd sp!,{r0, r1, r9, %[keepSampling], %[sIndex], %[triggered], %[ch1], %[ch2], %[dCH], %[lCtr]} \n\t"
" stmfd sp!,{r9, %[keepSampling], %[sIndex], %[triggered], %[ch1], %[ch2], %[dCH], %[lCtr]} \n\t"
" bl %[snapMicros] \n\t" // micros() - r0 contains the 32bit result
" ldmfd sp!,{r0, r1, r9, %[keepSampling], %[sIndex], %[triggered], %[ch1], %[ch2], %[dCH], %[lCtr]} \n\t"
" ldmfd sp!,{r9, %[keepSampling], %[sIndex], %[triggered], %[ch1], %[ch2], %[dCH], %[lCtr]} \n\t"

"notOverflowed_1: \n\t"
" strh r9, [%[sIndex]] \n\t" // save sIndex
Expand Down Expand Up @@ -246,9 +246,9 @@ void startSampling(int16_t lDelay) {
" bne notOverflowed_2 \n\t"
" mov r9, #0 \n\t" // sIndex = 0;

" stmfd sp!,{r0, r1, r9, %[keepSampling], %[sIndex], %[triggered], %[ch1], %[ch2], %[dCH], %[lCtr]} \n\t"
" stmfd sp!,{r9, %[keepSampling], %[sIndex], %[triggered], %[ch1], %[ch2], %[dCH], %[lCtr]} \n\t"
" bl %[snapMicros] \n\t" // micros() - r0 contains the 32bit result
" ldmfd sp!,{r0, r1, r9, %[keepSampling], %[sIndex], %[triggered], %[ch1], %[ch2], %[dCH], %[lCtr]} \n\t"
" ldmfd sp!,{r9, %[keepSampling], %[sIndex], %[triggered], %[ch1], %[ch2], %[dCH], %[lCtr]} \n\t"

"notOverflowed_2: \n\t"
" strh r9, [%[sIndex]] \n\t" // save sIndex
Expand Down Expand Up @@ -308,9 +308,9 @@ void startSampling(int16_t lDelay) {
" bne notOverflowed_3 \n\t"
" mov r9, #0 \n\t" // sIndex = 0;

" stmfd sp!,{r0, r1, r9, %[keepSampling], %[sIndex], %[triggered], %[ch1], %[ch2], %[dCH], %[lCtr], %[tDelay]} \n\t"
" stmfd sp!,{r9, %[keepSampling], %[sIndex], %[triggered], %[ch1], %[ch2], %[dCH], %[lCtr], %[tDelay]} \n\t"
" bl %[snapMicros] \n\t" // micros() - r0 contains the 32bit result
" ldmfd sp!,{r0, r1, r9, %[keepSampling], %[sIndex], %[triggered], %[ch1], %[ch2], %[dCH], %[lCtr], %[tDelay]} \n\t"
" ldmfd sp!,{r9, %[keepSampling], %[sIndex], %[triggered], %[ch1], %[ch2], %[dCH], %[lCtr], %[tDelay]} \n\t"

"notOverflowed_3: \n\t"
" strh r9, [%[sIndex]] \n\t" // save sIndex
Expand Down
8 changes: 4 additions & 4 deletions display.ino
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,8 @@ void calculateStats() {
}

// find out frequency
uint16_t Vavr = freqSumSamples/NUM_SAMPLES;
boolean dnWave = (ch1Capture[sIndex] < Vavr);
uint16_t fVavr = freqSumSamples/NUM_SAMPLES;
boolean dnWave = (ch1Capture[sIndex] < fVavr - 10);
boolean firstOne = true;
uint16_t cHigh = 0;

Expand All @@ -640,7 +640,7 @@ void calculateStats() {
k = 0;

// mark the points where wave transitions the average value
if(dnWave && (ch1Capture[k] > Vavr)) {
if(dnWave && (ch1Capture[k] > fVavr + 10)) {
if(!firstOne) {
sumCW += (sCtr - cHigh);
numCycles++;
Expand All @@ -652,7 +652,7 @@ void calculateStats() {
cHigh = sCtr;
}

if(!dnWave && (ch1Capture[k] < Vavr)) {
if(!dnWave && (ch1Capture[k] < fVavr - 10)) {
if(!firstOne) {
sumPW += (sCtr - cHigh);
numHCycles++;
Expand Down

0 comments on commit 3645da8

Please sign in to comment.