[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

G/ retards didn't post shit like usually when it's

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 44
Thread images: 4

File: DSC_0088~01.jpg (212KB, 1386x916px) Image search: [Google]
DSC_0088~01.jpg
212KB, 1386x916px
G/ retards didn't post shit like usually when it's about some real question.
So, I am making simplified oscilloscope, and i don't know how to retrieve specific data from samples array. It's about triggering ofc.
Im not asking for ready code in any particular language (i use bas for xmega...). More like easy algorythm. I need like retrieve 3 or more samples that are related and in a row or in a short distance, like there are 3 samples in a row and one after one is higher or lower than first, or like 3 or more aren't higher than some level.
I just don't know. I was trying finding it in for and if's loops conjoined but it was working like once in a time. It was useless, embedded comparator or comparing register in adc also didn't work like i was expecting. Time between occuring rising moment and detonating interrupt was too long and pretty random.
>>
>>1107448
>I need like retrieve 3 or more samples that are related and in a row or in a short distance, like there are 3 samples in a row and one after one is higher or lower than first, or like 3 or more aren't higher than some level.
not really sure how this is supposed to work but i'd try whatever you're doing in C (in something like visual studio), feed it random data, and step through it so that it works as intended. then figure out why it isnt working in that other language
>>
>>1107448
put log/print statements everywhere until you understand the flow of the code. I would try and make sure you can capture all samples before you worry about capturing subsets of samples.
>>
>>1107656
Thats exactly what i do. I collect 3000 of 8bit samples to array, and then i try to operate on them, i was coding like 3 time if condition, if that 3 ifs were true then jump to copy to buffer from place that those 3 samples were found, but worked like once for 2-3 seconds or something which was nonsense.
It was something like:
If sample 1 > 50 then
if sample 2 > sample 1 then
if sample 3 > sample 2 then
jump to recopy buffer to itself but from sample 1(and that number was supposed to be found)
else
do nothing
end if
end if
end if
>>
>>1107663
//how I would do it in java
int sample1;
int sample2;
int sample3;

List<Integer> sampleList = new ArrayList<>();

for(int i = 0; i < collection.length; i++) {
//iterate all items
if(i > 50 && sample2 == null && sample 3 == null) {
sample1 = i;
}
if(sample1 != null && sample2 == null && && sample3 == null && i > sample1) {
sample 2 = i;
}
if(sample1 != null && sample2 != null && i > sample2) {
sample 3 = i;
}

if(sample1 != null && sample2 != null && sample3 != null) {
//add them to your array
sampleList.add(sample1);
sampleList.add(sample2);
samepleList.add(sample3);

//set the sample back to null and let the process run again
sample1 = null;
sample2 = null;
samepl3 = null;

//then every 3 items in your array is a data set
//there are better ways to do this but this would work.
}

}
>>
>>1107448

Do you know english well? explain what you are trying to do
>>
>>1107670

Don't try to read this code, this anon is retarded
>>
>>1107716
what exactly is wrong with my algorithm? I'm just going off the vague explanation I was given.
>>
>>1107716
are you bitching because I didn't use a code tag and indent? Because I wasn't sure if this board supports it.
>>
>>1107718
>>1107720

You don't get how an oscilloscope or a computer works

your algorithm:
> uses array lists when the size is known at compile time (c doesn't even have those)
> doesn't make sense because we don't have OP's code
> iterates through 3000 values on a 16 bit microcontroller when it should be continuous

an oscilloscope:
> triggers at a fixed level (no point in checking for the samples to be larger than eachother)
> needs to be lightning fast in order to be usable
>>
>>1107728
lol your retarded m8
>>
>>1107728
he asked for a code example for an algorithm in any language. None of the things you said were in these parameters of the request. I expanded on what he shared with me as what he had so far in his algorithm. You are a dumb cunt.
>>
>>1107734
>>1107733
He's trying to optimize that algorithm because It's shit and any indian off the shit filled streets of Bangalore can see that

> Im not asking for ready code in any particular language
>Time between occuring rising moment (rising edge?) and detonating time between detonating interrupt (what ever that means) was too long and pretty random
>>
>>1107743
his algorithm was never written incorrectly, That's why he thought the results were pretty random. It endlessly detects the highest wave length. Sometimes it hits a high wavelength early in the process and takes a long time to find a higher result to store. That's why I wrote him an algorithm that actually collects 3 sets of increasing numbers correctly in the data feed, all thought it will still return a varying size result. I can't think of a solution to this problem that would return a fixed result in one iteration. All he needs to do is collect the results of the oscilloscope and place it in an array and pass it into this algorithm converted to whatever language he is running. This isn't rocket science, assuming I actually understood OPs question.
>>
>>1107743
Also fuck off for making some retarded pun about poo2loo java. There are more java jobs in the USA than any other language you fucking NEET. You know nothing of being a software engineer. And we sure as fuck don't use oscilloscopes in enterprise software development you fuggin electrical engineer pretending to be a real software dev. The average electrical engineer can't program their way out of a paper page, they know how to write a little c to interface with microcontrollers.
>>
File: waveleng.gif (2KB, 386x241px) Image search: [Google]
waveleng.gif
2KB, 386x241px
>>1107749
>>1107747

You obviously have no clue what's going on, pic related

What the program should be (this will run orders of magnitude faster):

> treat the array of samples as being circular (assume all indexes I mention are being checked for below 0 / above 2999, when they get over 2999 set to 0/below 0 set to 2999)
> make a counter starting at 0, and a counter starting at 1500, increment every time an interrupt comes
> store new values at the higher counter
> check the lower value for being high enough to trigger
> when it does trigger you stop the ADC and write to the screen with the lower counter in the middle and the higher counter to the right
>>
Could you try and explain again? I'm not quite sure I get it.

But as I understand it you're implementing a more complex triggering system for an oscilloscope.
I have ideas for how to make more generic systems for triggering but it all looks like overkill for an oscilloscope.
>>
>>1107728
I'm fairly certain he's looking for the rising edge. Which necessitates comparing values.

If op gave us some information concerning what he has right now it'd be way easier to solve this problem.
>>
>>1107760

so if it is one above the trigger level you just check the few previous values to make sure a > b > c
>>
>>1107757
kid i know what a synwave is. If you don't like my program write on yourself otherwise fuck off.
>>
>>1107761
I already wrote a program to do this above you guys have autism
>>
>>1107761
Yeah there's many ways of implementing this. What I'd do just for flexibility is record a second array which states how many of the last samples were below the current sample. That way you can determine if you've got a rising edge even when the signal is jittery. For instance pic related might never trigger if your sample rate is low and you do the a<b<c comparison. But if you have an array that records the number of samples that were below the current value. And you then check that every sample is larger than at least 50% of previous values. You can still detect a shallow voltage incline even with jitter.

For very steep inclines (like you'd find with DC usually) you won't have issues just doing a<b<c of course.

It's all about what you want though
>>
>>1107763
Yeah. Well. It's a fairly hacky solution so I can see people being displeased with it.

I'd do something like:
[code]
bool trigger(int* samplesArray, int currentSample, int lookBack) {
int start=currentSample-lookBack;
if(start<0)
start=0; // alternatively if we had a circular array for this we'd do start=arraySize-start; but I'm on my phone so I'm gonna do the non-circular array version. Too much typing
//But it's worth noting that in this lazy version we will get false triggers because we might be testing too few values
bool flag=false;
for(int i=start;i<currentSample;i++) {
if(!samplesArray[i]<samplesArray[i+1])
break;
if(i==currentSample-1)
flag=true; //we went through the entire array and sA[start]<sA[start+1]<...<sA[currentSample]
}
return flag;
}
[/code]
It looks like shit. But I can't get any perspective on it on my phone. Hard to read anything when all you got is 6 lines of text.
Hopefully the idea is conveyed well.
>>
>>1107728
>>1107670
So i got this code, first it collect all the samples (3000 bytes)
and then i find or like try to, the point that signal is rising, too bad i have no sine wave generator, only square pwm

If Segx(cnt) < Lvl Then
If Segx(cnt + 10) > Lvl Then 'trigger level

For Cs = 1 To 3000
Segx(cs) = Segx(cs + Cnt) - 43 'offset cutting
Next 'and place where condition was found

Cx = 0
Cs = 0
For Cs = 1 To 3000 Step Div 'how many samples going to be ommited
Incr Cx ' for lower frequency signals
Disp(cx) = 140 - Segx(cs) 'copy to display Buffer
Next
Cnt = 1
Else
Incr Cnt
End If
End If

Looks like works, but really shitty, its doing this anly once for couple of loops, but pwm is stiil there ofc.
>>
>>1107757
>>1107747
Im thinking about amplifying this to the level like with 10-20 times for any level signal, and treat it as normal pin interrupt to collect whole array.
But there would be problem with the highest aplitude signals, i shouldnt try to amplify something that is allready at VCC level.
Goddamit analog!
>>
Which chip are you using for this? I didn't see it stated. Some oscilloscope/multimeter specific chips are out there, like the Cypress FX2line (which is basically a microcontroller with a bunch of options generally useful for this). The other common way to do this is with an FPGA like the dslogic pro and sump2 (both are open source, so might help if you read their docs).

If you're just using the analog pins on a generic microcontroller, it can still work, but; you'll be doing a lot of work, probably more work, for mediocre results.
>>
>>1107933
No im not doing Tektronix :D
Just simple one so i can see anything. Like when i started mc34063.
Im using Xmega a3, so im getting about 3MSPS max with 8bit samples, which is enough. I write in basic i could try C but i hate it so much...
Basicly its simple, just 1/10 resistor divider some trimmer 2pF or so, and to pin. Some 320x240 for 3$ from aliexpress & thats it.
>>
>>1107973
For what it's worth, I'm pretty sure the BASIC you're using isn't a traditional interpreted one, so it probably won't perform that much slower than compiled C. But, you'll find more examples and libraries already written for you in C, and will be able to find more help.
>>
>>1107903

you should just make it continuous (check the results as you are getting them)

what would make this be "random" like you said is how far the program has to iterate through to find the rising edge
>>
>>1107981
>you should just make it continuous
i dont get it, check after every sample if it is what i need?? By the time signal would be in completely different place.
>>
>>1108147

yes

but do not iterate through your entire array

I describe it here in detail >>1107757
>>
>>1108147
That's how real digital scopes usually do it. Fill circular buffer continuously while waiting for trigger condition. When found, continue taking samples 50% of buffer's length (or 90% or whatever). That way you can see what happened before the trigger event, which is a rather handy feature.
Or, if you start storing data only after finding the trigger event, the results would be comparable to an analog scope.
>>
>>1108152
>>1108153
Ill try all that.
Also i was trying comparator that is also built in, but i couldnt turn that crap off for collecting samples so it wouldnt interrupt endlessly. But ill try again maybe...
>>
File: derpscope.jpg (144KB, 869x652px) Image search: [Google]
derpscope.jpg
144KB, 869x652px
>>1108153
So i got R2R DAC and pwm on atmega16, and looks like DAC working well enough to see. For now on clock 12 288 000 Hz is generating about 44Khz sine wave, that is 128 points (or 127).
I will try now that analog built in comapartor, this time in window mode. I failed last time cause i didn't know how to turn interrupts of for collecting sample array. I hope im gonna figure it out.
>>
OP here. So i run internal comparator, int dac is reference for comparator, it is reacting and executing interrupt on specified voltage, it is not stopped by any condition just straight to array filling but still little waving...
>>
I did it dudes!
Turns out i was always very close...i didnt just realize this.
I don't member what i did wrong, some dumb shit. No independent actions. It is chain.
Heres a code, im not the author of line drawing part:
>>
>>1109044
If _pause = 0 Then 'obvious
If _fast = 0 Then '3MSPS or 5KSPS
$include "array1ch.bas" 'collect fast array
For Cs = 1 To 3000
Segx(cs) = Segx(cs) - 42 'offset cut
Next
Else
While Cx < 1200
Segx(cx) = Adca_ch0res : Waitus 200 'collect slow array, very low freq about 4-5 KSPS
Incr Cx
Wend
For Cs = 1 To 3000
Segx(cs) = Segx(cs) - 42 'offset cut
Next
End If

If Edge = 0 Then 'edge falling, bit
For Gh = 1 To 100
If Segx(gh) < Lvl And Segx(gh + 1) > Lvl Then 'this is trigger condition,
'edge and level
Cx = 8 'better reset them
Cs = 0

For Cs = 1 To 3000
Incr Cx
Disp(cx) = 140 - Segx(gh + Cs) 'setting zero line level
Gh = Gh + Div 'how many ommited for lower freq displaying
Next 'and number of sample where condition whas found
End If
Next
End If
'same just edge rising
If Edge = 1 Then
For Gh = 1 To 100
If Segx(gh) < Lvl And Segx(gh + 1) > Lvl Then

Cx = 8
Cs = 0

For Cs = 1 To 3000
Incr Cx
Disp(cx) = 140 - Segx(gh + Cs)
Gh = Gh + Div
Next
End If
Next
End If

End If

For C = 10 To 300 'draw oscylogram
Y1 = Disp(c)
Y0 = Disp(c - 1)
X0 = C - 1
Call Lcd_line(x0 , Y0 , C , Y1 , Yellow) 'delete same oscylogram for refresh
Next
If _pause = 0 Then
For C = 10 To 300
Y1 = Disp(c)
Y0 = Disp(c - 1)
X0 = C - 1
Call Lcd_line(x0 , Y0 , C , Y1 , Kolor)
Next
End If
>>
>>1107670
kys
>>
>>1110769
>bumps thread from the last page just to add "kys"
Have you considered kyserizing yourself?
>>
>>1109045
Now put that thing in a decent enclosure instead of that retarded yellow brick, and you actually have a nice product.
>>
>>1110774
It's green gbc. And it's prety cool enclosure. More cool than common bricks for electronics, that i cant cut to make decent hole for LCD that doesnt look like burned by meteor crater.
I just need some stand for it.
>>
>>1110799
One does not use toy enclosures for serious hardware. Even if they are Japanese enclosures. One day you'll regret ruining a gameboy for that case and ruining a scope for being in that case.
>>
Not trying to hijack the thread but I got a techtronix 212 scope that suddenly stopped working when I used it today. I was setting it up to do gains on an my amp and a blob appeared I. The screen and then it shut off. The only article I found was on the batteries needing to be good but I don't think that it would suddenly just quit, especially since I had it plugged in to a 1.5 amp inverter. It pulls 30 watts
>>
>>1112545
I couldn't find anything better that doesn't need cutting and working on it. I could print some enclosure and propably i will sooner or later.
Thread posts: 44
Thread images: 4


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.