From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Transfer a binary byte from RPi to PCIe 6321 & BNC 2110. Problem happened in analog reading.

Hi, Friends:

 

My purpose is to communicate between RPi and PC. The UART port has been occupied, so I have to use a single GPIO pin (36) to generate a binary byte (LOW level is around 0, and HIGH level is around 3.3 V) , and transmit this byte to BNC 2110 board (Port: AI0). After that, I will convert the analog input from AI0 into digital bit, and store that byte into an array for other usage.

 

I wrote a code in RPi by Python (attached), and can see the waveform in a scope; however, when I plan to read the data from the LabView in my PC, the data can not be read. The LabView code is shown as following.

 

Would you please point out my fault? or any advice on how to realize my purpose?

 

Appreciate for any help.

Capture.PNG

Download All
0 Kudos
Message 1 of 6
(2,696 Views)

HI colorizedice,

 

When you say that the data can not be read, are you getting an error or are you just not getting any data in your array? 

Adena L.
Technical Support Engineer
National Instruments
0 Kudos
Message 2 of 6
(2,654 Views)

Thanks for reply.

 

Here is the update of my question:

 

At the receiving part, the "reading" vi will read the data continuously. For example, if at the sending part (RPi), the duration of low level (stand for zero) is 1 second, and the sampling frequency at the PC is 1KHz, there will be 1000 "0s" being read. However, my purpose is just reading one bit.

 

Today, I made a cable, so I guided the binary signal into the "Digital input (P0.0)"  of BNC2110. From the digital read vi, I can see the same digits with the Pi side, but if I recorded the data, it will generate too many 0's and 1's. Same thing happened.

 

Next, I will try to use some clk signal.

 

I hope I can make my point clear.

0 Kudos
Message 3 of 6
(2,651 Views)

Thank you for the clarification. So you are able to output the binary data from your Raspberry PI and then read it in through a digital input line on your BNC board. When you say you are seeing the same digits as the Pi side, but it is recording too many 0's and 1's, is this because you are sampling much faster than the RPi is changing value? On the PC, do you see the data you are acquiring change from lows to highs at the expected time? Also, what DAQ hardware is your BNC board connected to?

Adena L.
Technical Support Engineer
National Instruments
0 Kudos
Message 4 of 6
(2,623 Views)

The DAQ is PCIe 6321 card.

 

Yes, I think that's due to the sampling frequency is much higher than the sending frequency.  If I connected a LED light as the indicator in PC labview part, I can see the LED turns on and off; however, if I switch the LED as a numerical indicator, I can only see many zeros.

 

Thanks.

0 Kudos
Message 5 of 6
(2,621 Views)

Can you change your sampling frequency to be slower so that you only sample once per change in value? You could also look into using a counter task to determine whenever there is a rising or falling edge. 

Adena L.
Technical Support Engineer
National Instruments
0 Kudos
Message 6 of 6
(2,607 Views)