Read(), Write() and new questions

Hi,

as my first project is going on I find some difficulty understanding and choosing the easiest codes/choices for both speed and accuracy of both reading of the A0 pin of my Nano v3.0 and writing to AnalogWrite() .

First question I probably already did errors: having started with Arduino since few weeks I thought settings all the outputs (even the not-PWM ones) of the Nano would have let me use the AnalogWrite() function for the "brightness" part for the LEDs so I already soldered the LEDS from pin 12, 10, 8, 6, 4, 2 to have a sort of dBm(VU) meter depending on the voltage reading on A0. So set OUTPUT to all the pins and used the functions, it gave me no errors and sort of work, but I was asking myself if it's actually using brightness values for the not-PWM pins or just a DigitalWrite() similar 0 to 5 volts output.

Second: the module I'm reading from, gives out a very fast 10ns voltages from around 2.10 to around 0.40 volts, linear decreasing depending on the increasing of dBm measured. As much as I can understand from these weeks of reading, soldering, burning my fingers during the pcb building :D, I'm just using the internal Vcc reference 5V as the usual sketch suggest. But this make quite some problems cause for both LEDs and possibly LCD, I need both accurated reading and very fast reading; I've measured like +/-0.05 volts differences from my multimeter with the 1023 readings of A0 (and feel like the whole read->write to LEDs is not fast enough for real time sensible feedbacks for the next question). So I understood I could use the INTERNAL 1.1 volts reference that seems a bit better if measured on AREF pin and coded inside the sketch for that Vin range, or an EXTERNAL one I'd buy and install on the PCB to set up for example a precise 2.50 volts to take values from.
Is the last one the best option? Cause if I use the INTERNAL and my range of voltages is about double that, will I need a "voltage divider" I can't easily install at this point on the project.. or I could just double the measured 1.044 volts (example) internal reference measured number * 2 and use the result as the range approximately similar to what I need?

Third: Speed of both reading and writing. I've seen there're different ways to increase reading speed of both reading and writing, register modifications, etc... but I can't really choose the easiest one to just code to have a something close to the 10ns variations I'd have to the input A0. What code/library would you suggest to easily increase the sensibility of A0 reading? And about the AnalogWrite() I'd have same problem for both LEDs or LCD that may or not even light up if the variation would be fast and I was thinking maybe I could sort of save the last peak value to still have the information at the next cycle.

EDIT: 10ns is not the right time, maybe 1.5us.

Thank you for any explanation I still need to understand about these. I've read that some kind of modifications at registers or lower level would change all the other timing possible values I'd need later.

Thanks

10ns, on a processor with a minimum cycle time of 62.5ns?
And an analogue sample time of around 100us?

... to display something to a human with a visual reaction time of perhaps 100 milliseconds ?

TheMemberFormerlyKnownAsAWOL:
10ns, on a processor with a minimum cycle time of 62.5ns?
And an analogue sample time of around 100us?

The chip module datasheet talks about "Pulse response time: 10ns/12ns (fall/rise)" but I'd easily live with anything that speed up the reading as possible leaving cpu cycles/memory for future possible features I may add to the project. :slight_smile:
Obviously as said above I don't think I need such speed with the human eyes limits :smiley: but still the normal time taken from the reading unaccurated Vcc one to the writing to LEDs, I feel like I am loosing values and most of the time I may not even see a LED on if there're no really long and powerful reading. As I was thinking, I may sort of save peak values to let the highest LED for the time taken to the next cycle or the MAX value reading in a LCD value beside the LEDs feedbacks. :confused:

Rise/fall time is not the same as pulse length.
What is this mystery device?

TheMemberFormerlyKnownAsAWOL:
Rise/fall time is not the same as pulse length.
What is this mystery device?

It's a power meter AD8318 chip. I thought that was the response time sorry.
Maybe this: pulse period of 1.5us, width 0.1us, delay 0.04us.

First question: If you 'analogWrite()' to a non-PWM pin you will get 0V for values below 128 and +5V for values above 127. To get analogWrite() to do PWM you have to use the PWM pins. See: analogWrite() - Arduino Reference

johnwasser:
First question: If you 'analogWrite()' to a non-PWM pin you will get 0V for values below 128 and +5V for values above 127. To get analogWrite() to do PWM you have to use the PWM pins. See: analogWrite() - Arduino Reference

Thanks, beside how much I read it I am still learning through errors. :smiley: Have to de-solder again... :frowning:

Maybe this: pulse period of 1.5us, width 0.1us, delay 0.04us.

Maybe not.

That’s the test setup - it’s pretty much irrelevant, unless you have an R&S SMT06.

I’m pretty certain that’s not the case.

TheMemberFormerlyKnownAsAWOL:
Maybe not.

That's the test setup - it's pretty much irrelevant, unless you have an R&S SMT06.

I'm pretty certain that's not the case.

But if that values is taken as a possible "average" pulse time, would the Nano A0 pin usual AnalogRead() be capable of read it fast enough? I was convinced the speed difference was really big until now so maybe it's already fast enough.