Hi, just got an Uno R4 yesterday and I want it to display the output of six opto sensors, essentially I'm trying to make a six channel oscilloscope.
Just to get started I wrote a loop to output six random high/low values (coded so that Ch1 is 0 or 1, Ch2 is 4 or 5 etc in order to separate them on the plot) and written to the serial port for display by the Serial Plotter (IDE 2.3.3 Windows 10).
Problem is the display is not what I expected, the high/low/high transitions are not displayed as vertical lines but rather as slopes.
Below is the type of output I expect, taken from my PC 'scope, and below that is the actual output plus the raw data.
My guess would be that you do not have nearly enough samples along the time line to show vertical slopes. You are seeing two sequential samples, which if they were a lot closer could approach a vertical line, as a slope.
The above scope image will have thousands of samples along the time line.
Thanks for that, I assume you mean samples at the plotter end?
You could be right, but my instinct suggests if that were the issue, it would actually produce a square output. I tried the sine wave example which worked fine, if it was not doing enough samples that would have been notchy, I feel? Plus, I've seen fairly good squarewaves on YouTube.
Printing the results can be a bottleneck, even if you use a high baud rate.
You can get round this by taking a few hundred samples as fast as you can, and storing them in an array, and then go back and serial print the array at your leisure
It sounds like you're trying to visualize the output of your opto sensors as a digital signal using the Arduino Uno and the Serial Plotter. The issue you're encountering with the output not appearing as vertical lines but instead as slopes could be due to the sampling rate or how you're sending the data to the Serial Plotter.
To help you troubleshoot and improve your code for better visualization, could you please provide the code you're currently using? With the code, I can offer suggestions on how to adjust it to achieve the desired output.
Additionally, it's worth considering the following points:
Sampling Rate: Ensure that your Arduino is sampling the opto sensor inputs at a sufficiently high rate. The Serial Plotter may not accurately represent fast transitions if the sampling rate is too low.
Data Format: Make sure you're sending the data in the correct format to the Serial Plotter. For digital signals, you typically want to send 0s and 1s representing the low and high states, respectively. Sending analog values or incorrectly formatted data may result in unexpected visualizations.
Serial Communication Speed: Check the baud rate of your Serial communication. Setting it too high may cause issues with data transmission. The default baud rate for Arduino Serial communication is usually 9600.
By addressing these points and sharing your code, we can work together to refine your project and achieve the desired output on the Serial Plotter.
I've not even connected the opto sensors yet. I'm just simulating them in software to get the plotter working. For the example above my data rate is 1 kHz and I'm sending this to my plotter (just a few lines copied from my Serial Monitor):
1
0
1
0
As to speed I tried from 9600 to 115200 and a few in between
Do you understand why? If not, please try the thought experiment proposed earlier in the thread:
Serial Plotter simply plots the data points your board prints and then connects those points with lines. So the plot you got is exactly what we expect from the sketch running on your board.
As already explained, you can get something closer to what you were hoping for by printing many data points:
I think I get it now. I did see the previous post about the dots, but didn't get that it was a thought experiment. Now it makes sense. The plotter seems to work differently to the graphing library I use in another language.
Tired now after a long day so will have a detailed look tomorrow!