Comments on: Arduino – Poor Man’s Oscilloscope https://randomnerdtutorials.com/arduino-poor-mans-oscilloscope/ Learn ESP8266, ESP32, Arduino, and Raspberry Pi Wed, 09 Nov 2022 12:38:36 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Gene https://randomnerdtutorials.com/arduino-poor-mans-oscilloscope/#comment-796739 Wed, 09 Nov 2022 12:38:36 +0000 http://randomnerdtutorials.wordpress.com/?p=154#comment-796739 In reply to lvanvan.

An int in this context is 16 bit (two bytes). Arduino’s ADC is 10-bit, indeed. So, any result of analogRead will obviously have the upper 6 bits as zeros. The code above wants to write the data to serial output. Serial.write can write bytes, strings or arrays (must specify the length). The author of the above code decide to write it as bytes. A 16-bit int consists of two bytes (in our case the upper byte has only 2 relevant digits, the rest are zeros, but it doesn’t really matter). To extract the upper and lower bytes from an int, we can use respectively (val >> 8) & 0xff and val & 0xff. This is basic binary arithmetic. Just write 16 random binary digits on a piece of paper and do these operations by hand: “shift right by 8 positions, with the overflowing digits just disappearing, then bitwise AND 111111111”, or just “bitwise AND 11111111” and you will see how it works.
You mentioned val & 0x00 (might as well have written val & 0), this doesn’t make sense, this will be always zero (anything & 0 is 0). If something’s still not clear, just read up on bitwise binary arithmetic operators

]]>
By: lvanvan https://randomnerdtutorials.com/arduino-poor-mans-oscilloscope/#comment-781948 Thu, 08 Sep 2022 20:07:34 +0000 http://randomnerdtutorials.wordpress.com/?p=154#comment-781948 In reply to Gene.

sorry but 16 bit is around 65k resolution. So 1024 is 10 bit resolution and 8 bit is only 256 but dont understant why the corect way is not “Serial.write( val & 0x00 );”?? i get that left shift 8 positions and then write “val” witch is 10 positions but after that 0xff is 256 or 8 bit .. and last 2 bits are they not somehow colide with your 10 bit val… i know i missing something πŸ™‚

]]>
By: Javier https://randomnerdtutorials.com/arduino-poor-mans-oscilloscope/#comment-579598 Sat, 27 Mar 2021 06:20:10 +0000 http://randomnerdtutorials.wordpress.com/?p=154#comment-579598 What is the maximum frequency it could currently display, and what could be modified to support higher frequency signals.
Is there a possibility that they update the project and make it for an ESP32 or maybe a Raspberry Pico?

]]>
By: Gene https://randomnerdtutorials.com/arduino-poor-mans-oscilloscope/#comment-479567 Fri, 24 Jul 2020 20:55:54 +0000 http://randomnerdtutorials.wordpress.com/?p=154#comment-479567 In reply to Shabtai.

I know this was asked a long time ago, but in case someone is reading this and wondering, the code reads read the value (voltage) from pin ANALOG_IN (defined earlier as pin 0) into variable “val” of type integer (which is 16-bit). This value is from 0 to 1023 (corresponding to the range of 0 V to VCC V – 5V or 3.3V depending on which Arduino board is it). It then sends this value to the serial port (-> USB port of the computer), with a “magic” prefix of 0xFF. (val >> 8) & 0xff is the upper 8 bits of the 16-bit int, and val & 0xff is the lower 8 bits – >> and & are just binary operations (right shift and binary AND).

]]>
By: Shabtai https://randomnerdtutorials.com/arduino-poor-mans-oscilloscope/#comment-278040 Thu, 18 Feb 2016 12:26:11 +0000 http://randomnerdtutorials.wordpress.com/?p=154#comment-278040 In reply to Rui Santos.

OK – room for the serial plotter to improve, I guess.

You still didn’t answer my first question πŸ™‚

What is this code doing:
int val = analogRead(ANALOG_IN);
Serial.write( 0xff );
Serial.write( (val >> 8) & 0xff );
Serial.write( val & 0xff );

Thanks!

]]>
By: Rui Santos https://randomnerdtutorials.com/arduino-poor-mans-oscilloscope/#comment-278031 Thu, 18 Feb 2016 12:18:15 +0000 http://randomnerdtutorials.wordpress.com/?p=154#comment-278031 In reply to Shabtai.

More information on the serial plotter: http://randomnerdtutorials.com/arduino-serial-plotter-new-tool/
Yes, but the serial plotter is very limited and it doesn’t offer most of the features that processing does

]]>
By: Shabtai https://randomnerdtutorials.com/arduino-poor-mans-oscilloscope/#comment-277984 Wed, 17 Feb 2016 11:13:10 +0000 http://randomnerdtutorials.wordpress.com/?p=154#comment-277984 Hi Rui,

Can you explain what the code is doing?
Can the o’scope traces be displayed in the serial plotter? How would you do that?

Thanks!

]]>
By: Rui Santos https://randomnerdtutorials.com/arduino-poor-mans-oscilloscope/#comment-262231 Wed, 22 Jul 2015 19:07:05 +0000 http://randomnerdtutorials.wordpress.com/?p=154#comment-262231 In reply to Hitesh kher.

You can only upload one program to an Arduino

]]>
By: Hitesh kher https://randomnerdtutorials.com/arduino-poor-mans-oscilloscope/#comment-261647 Wed, 15 Jul 2015 19:04:20 +0000 http://randomnerdtutorials.wordpress.com/?p=154#comment-261647 Dear Sir,
Can possible multi program upload 1 arduino broad ? and multi output?

]]>
By: Ellie https://randomnerdtutorials.com/arduino-poor-mans-oscilloscope/#comment-251663 Tue, 14 Apr 2015 16:54:19 +0000 http://randomnerdtutorials.wordpress.com/?p=154#comment-251663 In every port, you will be amused by the different
activities such as partying in the different dockside establishments.
You will spend less time building your boat if the
plans are clear and easy to follow, you will spend less money trying to fix
problems due to inadequate or poorly designed plan elements.
But what good is sailing without food that appeals to the palate.

]]>