私はこの問題を解決するのに夢中です: PC から RX ピン経由で Arduino に送信されたデータを読み取るように Analog Discovery を構成する必要があります。PC と Arduino は、1 スタート ビット、8 データ ビット、1 ストップ ビットの UART プロトコル標準を介して通信します。Analog Discovery 周波数の分周器を使用して、RX ピン経由で信号をサンプリングしようとしました。
質問: Analog Discovery によるサンプル読み取りは、送信された実際のビット値ですか? 1 ビット サンプルを使用してデータをビット単位で読み取る必要がありますか、または実際のボー レートの 1/10 で 10 ビット サンプルを使用して 8 (+2) ビットすべてを読み取る方法はありますか?
2 番目の解決策として、Python スクリプト コードの一部があります。
[...]
# baud rate for arduino uno is 9600 / 10 byte
# sample rate = system frequency / divider, 100MHz/104166.6p = 960Hz
dwf.FDwfDigitalInDividerSet(hdwf, c_int(104166))
# with this command we setup the incoming frame on 10 bit
dwf.FDwfDigitalInSampleFormatSet(hdwf, c_int(10))
# we instantiate a pool of 10 samples
cSamples = 10
rgwSamples = (c_uint8*cSamples)()
dwf.FDwfDigitalInBufferSizeSet(hdwf, c_int(cSamples))
# disable auto trigger
dwf.FDwfDigitalInTriggerAutoTimeoutSet(hdwf, c_double(0))
# one of the analog in channels
dwf.FDwfDigitalInTriggerSourceSet(hdwf, trigsrcDetectorDigitalIn)
# with this command, we demand for a sampling after trigger in a buffer
# which has same specified size
dwf.FDwfDigitalInTriggerPositionSet(hdwf, c_uint(cSamples))
#dwf.FDwfAnalogInTriggerConditionSet(hdwf, trigcondRisingPositive)
#With this command we setup the falling edge triggered on the channel 0
#each field of the function is a bitmask
dwf.FDwfDigitalInTriggerSet(hdwf, 0, 0, 1, 0)
#give it the time for a breath!
time.sleep(1)
#let's begin the acquisition
dwf.FDwfDigitalInConfigure(hdwf, c_bool(0), c_bool(1))
while sts.value != stsDone.value:
dwf.FDwfDigitalInStatus(hdwf, c_int(1), byref(sts))
# get samples, byte size
dwf.FDwfDigitalInStatusData(hdwf, rgwSamples, cSamples)
samples = [0] * cSamples
rgpy=[0.0]*len(rgwSamples)
for i in range(0,len(rgpy)):
rgpy[i]=rgwSamples[i]
samples[i] = rgpy[i]
[...]
ご支援ありがとうございます!