LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Logical Shift 8 bits of 1 byte in LabView FPGA

Solved!
Go to solution

Hello,

I am trying to implement my own SPI communication on LabView FPGA (NI sbRIO 9607). In order to send a constant 1 byte data, I prepared a vi that is attached to this post (screenshot is provided below). I am trying to send the bits of the byte one by one. I checked the hardware line, it is working correctly, I can send a clock signal on this line with any clock, with a very similar (shift registers and an boolean inverter is used) vi.

Could anybody help me with this issue, thank you.

ONUR YILDIZ

byte to BIT one by one.png

 

0 Kudos
Message 1 of 6
(3,655 Views)

Hi onrep,

 

what is your problem with your VI?

Do you get any errors?

Why don't you use a FOR loop instead of the inner while loop?

Did you set the numeric constant to binary display mode? Why don't you show the radix?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 6
(3,626 Views)
Solution
Accepted by topic author onrep

1) Make sure your number is actually binary 11000101 (decimal 197), and not decimal 11000101. Set it to U8 representation, and show radix (right click visible items)

2) The shift register is taking the carry from the previous iteration, when you actually need the value from the current iteration. If you are stopping after 1 cycle this won't matter anyway (and you don't need the bool shift register. Also, you should use 7 for your stop condition as the iteration is zero-indexed. You could use the rotate function instead, then you'll have to pull out the MSB value still.

 

I suggest changing to use "Number to boolean array", then auto-indexing this through a for loop where you set the value and have the timer etc. Still need to make sure you have a 197 decimal in this case.

 

Lastly, there are several SPI implementations which already exist for FPGA, just google it. Might save you a lot of effort.

Ian
LabVIEW since 2012
Message 3 of 6
(3,624 Views)

Hi Ian and GerdW,

My problem is actually I can not see any signal other than noise on my oscilloscope, while I am trying to send a serial data to my microcontroller by this code. I checked my hardware and confirmed for several times, osciloscope and microcontroller pins are working properly. Indeed, I can send HIGH or LOW signals, or any clock signal, which shows me the hardware line is clear. Indeed in labview, I added an indicator and a timer controller for checking if I send the true value from software and it also shows me everything is all right. I add a picture of some "other" configuration, which I know it consist of unnecessary things, but for just test purpose.

I tried to use "for loop" configuration first, instead of "while loop", but my control signals which is mentioned above are not worked properly for "for loop" configuration. Because of this, I changed it to a "while loop".

I chose "Rotate Left with Carry" function, since it gives me the MSB, but Ian you wrote that "You could use the rotate function instead, then you'll have to pull out the MSB value still.". That function initially does not have any carry out the MSB as you mentioned also, or am I missing something, how could I pull out MSB with this function?

Thank you for your help again,

Best Regards

ONUR YILDIZ

byte to BIT.png

0 Kudos
Message 4 of 6
(3,607 Views)

Hi Ian,

 

Your suggestion about using "Number to Boolean Array" has solved my probelem. However, I could not understand why I could not observe any meaningful signal (i.e. other than white noise) with "Rotate Left with Carry" function, but it is no matter for me which solution does the work.

 

Thank you very much for your help sir,

Best Regard

 

ONUR YILDIZ

0 Kudos
Message 5 of 6
(3,590 Views)

@onrep wrote:

Hi Ian,

 

Your suggestion about using "Number to Boolean Array" has solved my probelem. However, I could not understand why I could not observe any meaningful signal (i.e. other than white noise) with "Rotate Left with Carry" function, but it is no matter for me which solution does the work.

 

Thank you very much for your help sir,

Best Regard

 

ONUR YILDIZ


Let me shed just a bit of light on that. Is it possibly be because you wired the Rotate Left with Carry to a I32 and the 24 MSBs were all Zeros?

 

Frankly I prefer something a bit more scaleable

Capture.png

 

Did you also need me to point out the case structure where the True and False cases differ only by the value of a boolean constant?  (And yes, go look at that again a "T" constant in the True case and (you gussed it) an "F" constant in the False caseSmiley LOL


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 6
(3,562 Views)