Show Posts
Pages: [1]
1  Using Arduino / Microcontrollers / Re: Speed tests of Arduino Uno R3's pins. on: February 28, 2014, 07:47:32 am
Thank you every one for your replies.

I will try changing the code inside of the loop by adding the Volatile keyword. I will also look into the hardware timers as a better way of detecting pulses. Once I get a chance to get back to the lab at school at re-run the tests with the changes I'll post again.


I tried something similar, meaning I wrote directly to the port registers and yes it was very fast but the pulse shape was terrible. I think I found it somewhere near 2 GHz ouputs, but the pulse were more like a distorted sine wave. Of course I can add delays and such to make it nicer. I didn't have time to pursue that in the lab the other day. I will look at directly writing to the registers while making the speed more reasonable so as to make the pulse shape more ideal. Also, thank you for the tips on the timer, I didn't know that and good point about the datasheet for the ATmega.

Regards all,

2  Using Arduino / Microcontrollers / Speed tests of Arduino Uno R3's pins. on: February 27, 2014, 10:23:46 pm
Good evening,

Tonight I ran some tests on the Arduino Uno's input/output pins.

I hooked a single Arduino pin to an oscilloscope and measured the frequency at which the Arduino could toggle the pin from high to low. I used the following code:

    for (int i = 0; i < 10; i++)
      digitalWrite(7, HIGH);
      float test = 13/.0777;
      test = test * 1.030232;
      for (long int t = 0; t < 10000000; t++)
        int x = 3;
        float y = x / 2.3;
      digitalWrite(7, LOW);

The frequency came out to be about 120KHz. As a comparison, I re-ran the code without loop in between the digitalWrite calls.

Without any thing else happening, I found that the Arduino was able to toggle the pins at the same frequency (120KHz).

To test the reading rate, I setup a 50% duty cycle pulse train at varying frequencies and then attempted to detect the rising edge using the following code:

    unsigned long w = 500;
    _t = millis();
    while ((millis()-t) < w)
      if (PIND & (1<<7)) state = HIGH;
      else state = LOW;
      if (state == HIGH && _state == LOW)
      _state = state;
    Serial.print("Time during sensing: ");
    Serial.print("Number detected: ");

Now, as I vary the frequency of the pulse train I compared the number of pulses that should have been sent to the arduino along with the number the arduino reportedly detected. Up to 40KHz the numbers were usually the same (within 1 or 2) but past 40KHz, the Arduino couldn't keep up. At 50KHz the Arduino only reported detecting about 24000 pulses during a half second detection cycle. That is a pretty hefty loss if you ask me.

Now, my question is this: Does any one know how, electrically and physically, the Arduino detects when the digital pins are high or low? I still need to do some research on these things and compare the Arduino to other microcontrollers/microprocessors out there, but overall I found the results interesting.

I hope this information helps the community,


3  Topics / Science and Measurement / Arduino Logic Analizer on: February 02, 2013, 11:50:18 pm
Well, this project started out of necessity. I'm taking an integrated circuit logic course at my school. The lab projects aren't difficult but I wanted to be able to build the circuits and check the output at home without the effort of attaching switches and LEDs and making sure every thing works on the "checking" side as well as debugging my homework (circuits). I wanted a program on the Arduino Uno R3 that could set input and read the output via the software. The reason being I could write an algorithm that would check a truth table for a given number of inputs and outputs.

Well, I wrote a program that does all of that and so far I have 4 outputs and 2 inputs. I was thinking that I'd like to expand this project a bit and make it a stand alone device. Perhaps using a keypad to toggle the states of the outputs and run the algorithms. I'd like to tie the out puts to an LCD display.

All of that seems challenging but doable. My question is what way is the best way to handle all of the information. I need to receive keypad input (which I can use a keypad breakout board or an old ps/2 keypad I have) and then set a logic level on the output channels and read digital data on the input channels.

My ideas were:

1) Have an SR flip flop tied to a single input channel. The outputs connect to a series of and gates and effectively control which way the signals can propagate (between input and output). The "inputs" or, the logic states that I want to "analyse" are then stored in flip flops. Once the routine in the software is done (a certain amount of time) the signal direction is reversed and the flip-flop data is brought in. Finally, the data is displayed on an LCD screen.

2) My other idea was to use a demux IC to get the data from the keypad and then a multiplexor to set flipflops for the "output" channels. The inputs would be read through a shift register.

So, really, the question comes to: What do you guys think is an easier way of handling this? I do apologize for rambling and I hope I made sense through all of it.



Pages: [1]