LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read/Write Function reads wrong value?

Solved!
Go to solution

Hy,

im using the NI Quadrature Encoder on my FPGA.

(http://www.ni.com/white-paper/6608/en/)

I add some inputs, so that its possible to set an offset value.

vi_encoder.png

All in all the VI on the FPGA works fine with my encoder.

If i start the VI on my FPGA, the position value is 0, due to the "First run?" Element.

 

Now i used the Read/Write Control in a while loop on my Host VI to get the current value of the encoder.

After i start my host vi the position indicater shows allways the value "2".

If i use the highlight function, the value stays at "0".

 

Thats a really strange behavior, i dont know what can be the source of that problem.

All positionsoffset values are 0 and the encoder inputs on my 9401 module are connected with ground.

The position value is only written on the fpga, nowhere else.

 

Anyone got an idea for that?

 

Thanks a lot.

Untitled.png

 

 

 

0 Kudos
Message 1 of 12
(3,042 Views)

Without having looked at your problem too much I can see a race condition with your 'A Register' and 'B register' local variables. You don't know if the local variables will contain the value that the indicators have before or after receiving the 'Signal A' and 'Signal B' values. Highlighting may very well change that order.

 

Fast and easy way to check this is to put 'A Register' and 'B Register' indicators in a single frame sequence structure and wire the output of your topmost OR operator to its frame.



CLA
www.dvel.se
0 Kudos
Message 2 of 12
(3,030 Views)

Hi,

 

"feedback nodes!" came to my mind when looking at the FPGA code...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 12
(3,024 Views)

I will have a try with the feedback nodes.

 

 

0 Kudos
Message 4 of 12
(3,010 Views)

Below is my whole code.

On FPGA Level erverything still works fine and the position is "0".

 

On Host i still get the position value "2".

 

 

New Sub VI on FPGA:

 

vi_encoder.png

 

FPGA Top Level:

 

FPag.png

 

Host VI (new one for testing):

 

Untitled.png

0 Kudos
Message 5 of 12
(3,000 Views)

Hi B.,

 

can you verify the FPGA VI is running - maybe by wiring the loop iterator to an indicator?

Or by combining the boolean inputs to an U8 indicator, which you can read to check the correct parameter transfer?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 12
(2,993 Views)

Hy,

FPGA is running the Indicater increases rapidly.

 

And also i tried the U8 Indicator, looks also fine.

 

I can't recognize any problem with that. But i still get no "0" as position value at the beginning.

 

 

0 Kudos
Message 7 of 12
(2,980 Views)

Hi B.,

 

what signal level to EncoderA&B do have? Are the levels stable regarding to TTL specs?

Does it have any influence on your decoder logic?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 12
(2,966 Views)

Well,

i connect both encoder input pins on crio side to ground.

So the signal level should be on a defined "0" level.

 

The Encoder signal follows the TTL spec.

0 Kudos
Message 9 of 12
(2,935 Views)

Mh, i found a new strange behavior.

 

I modified my FPGA VI as below.

 

Untitled.png

 

If i set the "Input Enable" to false, the "false" value is given to the Sub VI with the encoder code.

On Host VI my position stays after running the VI at "0".

 

If I set the "Input Enable" to True, I read in the real Inputs to the Sub VI.

(But I connected them to ground!, so they should be also recognize as "false")

On Host VI the position switch to "2" after i start it.

 

Ok, next step was that i take a look on the host vi.

The FPGA use the real inputs, "Input Enable" is True.

If the loop counter reaches e.g. "7" the positions value changes to "2".

 

ddd.png

 

 

0 Kudos
Message 10 of 12
(2,914 Views)