Shop OBEX P1 Docs P2 Docs Learn Events
Weird Data Results. Need help understanding — Parallax Forums

Weird Data Results. Need help understanding

So I have been measuring the time delay from a 555 timer with different frequencies running this code:

' {$STAMP BS2}
' {$PBASIC 2.5}
x VAR Bit

DIR14 = 1
DO
x = IN3
OUT14 = x
LOOP


I have been expecting a Normal Bell Curve for a histogram analysis and instead I am getting more bi-model like. Im not sure how to interpret the data. Is there are background process that the Boebot is doing the is affecting the results?

Comments

  • Looks like I/O14 = I/O3 through a low pass filter.

    P'raps you could post a schematic and a little something about how you are measuring the output.
  • I've been trying to figure out how to do that. I think I found out how, but Im about to leave for work so Ill do it tonight when I get back. How I am measuring the time is just by hooking up an Oscilloscope with a channel connected to a wire going to pin 3 (input) and having the second channel connect to a wire coming out of pin 14 (output) and using the scope to measure the time delay from the first rising edge of the input wave to the first rising edge of the output wave.
  • tomcrawfordtomcrawford Posts: 1,129
    edited 2016-04-18 23:39
    The difference in the delay time is going to be one pass through the loop: on the order of 1 sec mSec or so.
  • The time Im getting for it ranges from ~.5ms to ~1.1ms. From that data, I've done a histogram analysis and would expect that it would get a normal bell curve, but rather it has to 'humps' with a dip in the middle.
  • What frequency is being supplied by the '555? Oh, you say, "different frequencies". How so?
  • I change the resistors for each test, 720K, 160K and 82K, and as a result the frequency of the 555 are; 61.61 Hz for the 720K and 539.7 Hz for the 82K. I don't have the number for the 160K resistor. It appears that the timing of the 555 really impacts the time delay. The results with the slowest time delay is that of the 160K resistor. suggesting that the processor has an optimal timing and will work faster and more efficiently towards that timing.
    Bin Frequency
    500 3
    600 22
    700 28
    800 23
    900 26
    1000 25
    1100 18
    More 3

    Here is the Histogram for the 82K resistor

    Bin Frequency
    400 0
    500 23
    600 23
    700 19
    800 15
    900 22
    1000 26
    1100 20
    1200 2
    More 0

    Here is the Histogram from the 720K resistor. Both of these were made from the data gathered running the code above. This was all done through Excel 2010.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2016-04-20 21:16
    Trevor,

    I am not clear on why you're piping the input through the BASIC Stamp 2 I/O pin and right back out. If you read the output of the 555 Timer it will be a real-time reading, however when you pipe that signal into the BASIC Stamp 2 I/O pin with your code what will happen is that the state of the output on the BS2 in relation to the input will be delayed as well as skewed somewhat.

    The BS2 will fetch a token from the EEPROM, parse it and execute it, one instruction at a time. When it gets to the line x = IN3 it will place the current state of P3 into x. Next it will output the variable x to P14, however, while this is happenning the state of P3 could be changing, but the BS2 will not be able to update P14 again until the next pass through the loop, at which point IN3 could have been changed for an indeterminate length of time.
  • Here is the schematic of the 555 timer I am using.

    *Link to the picture of the 555 timer.*

    http://physics.usask.ca/~angie/ep326/lab2/astableschem.jpg

    I'm using an Oscilloscope with a single sequence function to look at the time delay between the input and output wave of the microprocessor.

    Is there any more info in regards to schematics that you need to understand what I am doing? If so please let me know and I will do my best to provide it. I am sorry for my confusion on what you guys need in order to answer my question and I greatly appreciate the help!


  • pinkdolphin02pinkdolphin02 Posts: 13
    edited 2016-04-20 21:37
    Chris,

    Im doing this as a research project to better understand latency and what effects the micro-controller has on it. So what Im doing is comparing the real time signal from the 555 timer and the signal outputted from the pin, and measuring the time it takes for the signal to pass through. To start off, I wanted to see what the "base" delay was for the processor running the most straight forward code. It was originally just this:

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    DIR14 = 1
    DO
    OUT14 = IN3
    LOOP


    However, it got me the same results as the one above did. One of my professor's suggested I tried it "poking at" the code and processor a bit but having it the signal get saved to the memory and see if that had any impact on my results. which it just made the delay longer but still producing a bi modal distribution.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2016-04-20 21:40
    I'm assuming if you're measuring delays that you're monitoring both the input and output of the BS2? See my previous post for why.
  • Yeah Im monitoring both the input and output of the BS2 through an Oscilloscope.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    Did you see in my post where I mentioned that the point in the program where the I/O pin is being captured, versus when the output is being updated is indeterminate? I would expect the results to be erratic to a degree based on that, although I have not done the experiment myself.
  • Yeah I did see that. Thank you for that cause that is not something I did not know or think about at all haha. however when my code was not going to a memory and then being pulled, i.e

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    DIR14 = 1
    DO
    OUT14 = IN3
    LOOP

    it was producing the same results with the bi modal system.
  • pinkdolphin02,

    What kind of results are you expecting besides a Gaussian (Normal) distribution?

    A Propeller microcontroller running PASM may give you the results you want.
  • Well, I'd expect more like a uniform distribution. Consider that the shortest time will happen if the transition occurs just before the BS2 reads the pin, whereas the longest time will happen if the transition is a tad to late, after it has read the pin. Supposing the transition is random in time with respect to the Stamp cycle, then it would tend to exhibit every possible interval. Nevertheless, suppose that the '555 period and the duration of the BS2 DO-LOOP are happen to be related in a small integer ratio, then the times would tend pile up into peaks, because the transition tends to fall at specific relative times. That might be apparent in a relatively small sample of intervals. But since the '555 and the Stamp loop are not locked, they would gradually drift and over a longer sample erase the peaks.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2016-04-21 04:36
    To illustrate, I set up your experiment into a 'scope with histogram capability. The input signal on trace #1 comes from a signal generator set at 100Hz. Trace #2 is the output from the Basic Stamp using your program. Trace #D is math, the difference between the input and output, which is the delay we want to measure,. It is displayed expanded at 0.2ms instead of 1ms per division. Finally the top trace in blue is a histogram of the delay. The three screens show it captured after progressively higher numbers of scans. The first one at 143 scans definitely shows the bimodal distribution like you observed. Bimodality still shows but not as strongly after 641 scans but is all but obliterated and approaches a uniform distribution at 33420 scans.

    Notice that the highest interval after many samples is 995µS and the lowest is 335. The 995 represents the time to get all the way around the DO:LOOP after having just missed the transition, while 335 represent the shortest path, detection of the transition going right to the output.

    This is a case where the signal input period is close to an integer multiple of the DO:LOOP execution time, which is close to 1ms. You are getting into sampling theory!
    D027.pngD028.pngD029.png
    640 x 480 - 8K
    640 x 480 - 9K
    640 x 480 - 9K
  • Tracy Allen.
    Thank you so much for this data. Sorry it took me so long to get back, I have been super busy. This really helped me understand what was going on and makes me so happy to find out that I was on the right track but just had to take a whole hell of a lot more data points. I have been looking into sampling theory and its so very interesting stuff. Again I appreciate you help so much.
Sign In or Register to comment.