I was reproducing the Girino (the Instructable by Caffeinomane) bundled with the Girinoscope (the Java GUI by Chatanga). The results worked well and I went on to see if the oscilloscope can go up to higher kS/s.
In short, originally only upto prescaler 8 works. I removed PWM pin and it works upto 4 but prescaler 2 strangely behaves. Here are the details:
I did a preliminary test on prescaler 32 (~38.5kHz). Settings as follows and the same in other tests.
- The signal (the same hereafter) is generated by a 555 timer astable multivibrator running at 4.5V (3 AA batteries).
- The circuitry was simply omitted. I just tied 3.3V of Arduino NANO / ATmega328 to digital pin 6 as the trigger level.
- There is no +2.5V offset done by the original Girino. (The scale should be 0~5V and the signal is 0~4V)
So then I wanted to try if it can speed up more. The code optimization quoted by Chatanga allowed prescaler 8 and 16 (76.9kHz and 151.8 kHz).
In order to push it the poor Arduino to the limits, I disabled PWM pin in the original Girino which sets the trigger level with duty cycles (PWM from pin ~3 being fed into pin 6). It's because I simply used a fixed 3.3V trigger level.
Prescaler 4 is unlocked.
Ambitious I go on to test prescaler 2. The GUI did not provide this option so I simply set it in the Arduino code.
I thought it did not work. I noticed if the prescaler is exceeding the Arduino's capability, TXRX simply does not blink. But this time the TXRX is just blinking! To verify this, I shifted the wait duration.
In previous screenshots, the leftmost green line is dashed (probably because it's below fullscale deflection). But in the last two, be it offset or not, the line is solid.
The debug output is like this: (8bits 0~255 given by ADC)
- many 0 then suddenly 255 thereafter. (matches the GUI output)
I suspect it's due to slow TXRX? How to solve this? Or anything I overlooked?
Hope that this overdetailed question does not sicken you.