CygniX has left #beagle [Konversation terminated!]
CygniX has joined #beagle
starblue has quit [Ping timeout: 245 seconds]
starblue has joined #beagle
brook has joined #beagle
brook has quit [Remote host closed the connection]
brook has joined #beagle
brook has quit [Remote host closed the connection]
brook has joined #beagle
brook has quit [Ping timeout: 244 seconds]
<set_> About my inquiry...the pwm instance on the BBAI-64 has an overlay which handles the "Fan" pin.
<set_> Dudes...gals. Fans!
<set_> Anyway, I actually had a connector to fit. Now, to do stuff to it. This way, cooling sensations all around!
brook has joined #beagle
notserpe has quit [Quit: Connection closed for inactivity]
Shadyman has joined #beagle
alan_o has quit [Remote host closed the connection]
alan_o has joined #beagle
brook has quit [Ping timeout: 246 seconds]
buzzmarshall has quit [Quit: Konversation terminated!]
brook has joined #beagle
brook has quit [Ping timeout: 248 seconds]
brook has joined #beagle
ft has quit [Ping timeout: 260 seconds]
ft has joined #beagle
ft has quit [Ping timeout: 246 seconds]
ft has joined #beagle
ft has quit [Ping timeout: 248 seconds]
ft has joined #beagle
ikarso has joined #beagle
ft has quit [Ping timeout: 245 seconds]
ft has joined #beagle
ft has quit [Ping timeout: 246 seconds]
ft has joined #beagle
ft has quit [Ping timeout: 245 seconds]
ft has joined #beagle
CaliBunda has joined #beagle
set_ has quit [Ping timeout: 246 seconds]
CaliBunda has quit [Remote host closed the connection]
set_ has joined #beagle
xet7 has quit [Remote host closed the connection]
ft has quit [Quit: leaving]
brook_ has joined #beagle
brook has quit [Ping timeout: 260 seconds]
Shadyman has quit [Quit: Leaving.]
brook has joined #beagle
brook_ has quit [Ping timeout: 244 seconds]
starblue has quit [Ping timeout: 256 seconds]
starblue has joined #beagle
brook_ has joined #beagle
brook has quit [Ping timeout: 240 seconds]
Siegurd has joined #beagle
<Siegurd> zmatt: Hi! Earlier you mentioned CLOCK_RAW_MONOTONIC, is it possible to use this timer?
<zmatt> Siegurd: I mean, sure, though why would you want to?
<zmatt> and what do you mean by "use"
<zmatt> you can query it and I'd guess probably use it with a timerfd (though I've never tried that), but generally you should use CLOCK_MONOTONIC instead
<Siegurd> I am successfully reading data from AD7771 through a pipe in my C++ program in bursts of 32768 bytes and I need the precission timestamps to write data in to data base.
<zmatt> I mean, the measurements are regularly spaced so you can interpolate the block-timestamp alsa gives you
<zmatt> alsa lets you choose whether you want CLOCK_REALTIME, CLOCK_MONOTONIC, or CLOCK_MONOTONIC_RAW as clock source for timestamps
<Siegurd> So that the signals that are received every 32768/32/128000 = 8 milliseconds get into the database in a seamless mode.
<Siegurd> I don't use ALSA lib
<zmatt> if you want your audio blocks to be timestamped you'll want to use alsa directly, obviously you don't have access to these if you're using arecord
<Siegurd> I tried but I couldn't get data from the audio device with 128kHz
<zmatt> then you probably just configured something wrong
<Siegurd> only pipe gives me a desired data stream speed
<zmatt> you should probably configure 96 kHz since we know the kernel thinks it doesn't support 128 kHz
<zmatt> arecord is just a simple demo program that uses the alsa library
<zmatt> like previously discussed, the data rate you'll get does not actually depend on the samplerate you configure via alsa
<zmatt> you just need to configure some rate the kernel thinks is okay, the actual data rate only depends on your configuration of the AD7771
<zmatt> note btw that alsa's audio block timestamps are not super accurate since they're done in software, though obviously they'll be more accurate than any timestamping done in userspace
<zmatt> we actually use PRU for the timestamping because alsa's timestamps were too jittery for our purposes
<Siegurd> Yes, I measured the period of data coming from the pipe and got 8 milliseconds for 1028 measurements, which is expected for a frequency of 128 kHz. Now it remains only to a precise timestamps of each 8ms period.
brook has joined #beagle
brook_ has quit [Ping timeout: 250 seconds]
<zmatt> timestamp relative to what? like, both CLOCK_MONOTONIC and CLOCK_MONOTONIC_RAW are essentially arbitrary timebases, and if you only need a timestapm in an arbitrary timebase then you can just multiply the sample index by 8ms
<zmatt> if you do want timestamps specifically in one of the three timebases supported by alsa then just take the block timestamps provided by alsa and interpolate/extrapolate. to reduce the impact of jitter you may want to apply some filtering
<zmatt> we actually use a PID loop to create a smooth translation between the sampling clock and the timebase we care about (which is CLOCK_MONOTONIC_RAW for us due to very application-specific reasons)
<Siegurd> actually I want to get epoch timestamps. For example, I am subtracting the epoch timestamp and нI'm starting to read data from the AD7771. After about 8ms, when the data is read, I need to make another timestamp to understand how long it took to read the data block. It could be 7887267 or 7935639 ns. Therefore, I need a timestamp that is tied to the PRU so that the time value is not affected by operating system glitches.
<zmatt> if you're only going to store the data anyway then I'd suggest just saving the alsa-provided timestamp of each block of samples received from alsa, and filter/interpolate the timestamps as needed when consuming the data
<zmatt> I don't really understand what you mean
<zmatt> like, I don't get what you're trying to achieve
<zmatt> I assume by "epoch timestamps" you mean CLOCK_REALTIME (the system date/time)
<zmatt> at 128 kHz you'll get exactly 1024 samples in 8ms. if you measure accurately then the measured interval will be 8ms ± some tiny difference due to oscillator frequency error
<zmatt> like, ±100 ppm frequency error (which is quite a large error) would mean that an interval of 1024 samples (measured accurately) takes 7999200 - 8000800 ns
<Siegurd> yes, and I vant to accurately meashure that 8ms period to eliminate those tiny difference due to oscillator frequency error by using PRU timestamps
<Siegurd> now 125 meashurments took 999588136 ns instesd of 1 second
<zmatt> what are you doing right now?
<zmatt> if you're doing something with a pipe and arecord then whatever you're measuring is nonsense
<zmatt> start by using alsa-provided timestamps
<zmatt> if you set a blocksize of 1024 then alsa will give you a block of 1024 samples every 8 ms, along with a timestamp for that block of data
<zmatt> those timestamps will be jittery, but it's not like the beaglebone's system time and date will be ultra-accurate either anyway
<zmatt> like, the fact that you say you want CLOCK_REALTIME timestamps but you also seem to think you want nanosecond accuracy makes me very much question whether you understand your actual needs
buckket has quit [Quit: buckket]
buckket has joined #beagle
<zmatt> if you can explain to me what you're actually trying to achieve then maybe I can give useful feedback
<zmatt> like, the main reason I can think of to get very high precision timestamps in some particular timebase is to be able to relate them to *other* high-precision timestamps in the same timebase
<zmatt> e.g. we get audio data timestamped in CLOCK_MONOTONIC_RAW because we also get Precision Time Protocol (PTP) packets timestamped in that same timebase; we use PTP timesync to be able to convert between the CLOCK_MONOTONIC_RAW of one device and that of another, thus ultimately allowing audio to be accurately synchronized between the devices. all of this required PRU code, a whole bunch of kernel ...
<zmatt> ...patches, and a customized ptp daemon. we didn't really have much choice since it's the only way to achieve such synchronization via the network
<zmatt> I'm kinda hoping for you that you don't actually have a similar need :P
<Siegurd> this is my pipe code that works https://pastebin.com/dsN2Mz1f and this https://pastebin.com/KMVW8L2c is my alsa code that does not give me a 128kHz output. Perhaps this is due to a too small buffer or other settings that I did not take into account.
<zmatt> note only are these measurements bogus, you're also reading arbitrary chunks of data and discarding them
<zmatt> (the first code you gave)
<zmatt> read() will return *up to* the requested number of bytes, it may return less. if you want to read a specific number of samples then you need to track the actual number of bytes receive
<zmatt> d
<zmatt> anyway, don't use arecord or pipe
<Siegurd> it always gives me 32768 bytes
<Siegurd> i check it
<zmatt> there's no checking in the code you pastebinned
<Siegurd> I delete it because it was optional. Here read() this is a blocking call.
<zmatt> like it's possible arecord happens to be buffering the data and writing it in big enough chunks, or maybe it just uses a blocksize that big (I don't know what its defaults are)
<zmatt> regardless, whatever you're measuring is completely at the mercy of what arecord is doing along with linux process scheduling
<zmatt> your alsa version will still be quite inaccurate since you're timestamping in userspace instead of using alsa's timestamps and you're not reading entire blocks
<zmatt> lemme check what our alsa code is doing
<zmatt> btw my guess would be arecord is using snd_pcm_hw_params_set_rate_near (to request the nearest "supported" rate, i.e. 96 kHz) rather than snd_pcm_hw_params_set_rate (which fails on the requested rate because the kernel thinks it's not supported by the codec)
<zmatt> regardless, just set 96 kHz or whatever, it doesn't matter anyhow
<zmatt> ah yaeh we're using the mmap-based access model, snd_pcm_hw_params_set_access(handle, hw_params, SND_PCM_ACCESS_MMAP_INTERLEAVED)
<zmatt> and use snd_pcm_sw_params_set_tstamp_mode and snd_pcm_sw_params_set_tstamp_type to enable timestamping
<Siegurd> alsa snd_pcm_readi took 7037977 ns to read 1024 bytes (32 readings of all channels) that gives 32 readings in 8 ms instead of 1024 readings in 8ms
<Siegurd> ok, will try that
<zmatt> I'm seeing about 7 us per read-call, which seems plausible enough for a kernel call
<zmatt> I don't know what the block size is since you didn't configure it but it'll no doubt be much larger than 32 samples, so you're really just measuring the time it takes to call into the kernel to read some bytes from its buffer
<zmatt> 32 samples would also be an unreasonably small block size
<zmatt> I see in our code we're also using snd_pcm_status_set_audio_htstamp_config() where the config argument is snd_pcm_audio_tstamp_config_t audio_tstamp_config {2,1};
<zmatt> whatever that means
<zmatt> oh the 2 is SND_PCM_AUDIO_TSTAMP_TYPE_LINK
<zmatt> I don't really know much about alsa anyway, but hopefully there exist examples on how to use timestamping
<zmatt> afk
<zmatt> the kernel has some documentation about alsa timestamping: https://docs.kernel.org/sound/designs/timestamping.html
<zmatt> anyway, afk
buzzmarshall has joined #beagle
xet7 has joined #beagle
xet7 has quit [Remote host closed the connection]
xet7 has joined #beagle
brook has quit [Remote host closed the connection]
brook has joined #beagle
jfsimon1981 has joined #beagle
brook has quit [Ping timeout: 246 seconds]
brook has joined #beagle
ikarso has quit [Quit: Connection closed for inactivity]
xet7 has quit [Quit: Leaving]
florian has quit [Quit: Ex-Chat]
ft has joined #beagle
otisolsen70 has joined #beagle
jfsimon1981 has quit [Remote host closed the connection]
jfsimon1981_b has quit [Remote host closed the connection]
notserpe has joined #beagle
PhotoJim has quit [Ping timeout: 246 seconds]
ikarso has joined #beagle
PhotoJim has joined #beagle
PhotoJim has quit [Ping timeout: 240 seconds]
PhotoJim has joined #beagle
SJFriedl has quit [Ping timeout: 248 seconds]
SJFriedl has joined #beagle
SJFriedl has quit [Quit: Leaving]
xet7 has joined #beagle
SJFriedl has joined #beagle
otisolsen70 has quit [Quit: Leaving]
ikarso has quit [Quit: Connection closed for inactivity]
Siegurd has quit [Read error: Connection reset by peer]
brook has quit [Quit: Leaving...]
lucascastro has joined #beagle
darkapex has quit [Remote host closed the connection]
darkapex has joined #beagle
lucascastro has quit [Read error: Connection reset by peer]
lucascastro has joined #beagle