LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can i multiplex sensors using the FPGA

Solved!
Go to solution

Hi,

Im using a Robotics starter kit, and the FPGA chip is too small for the code i try to put in there, so i am trying to make several functions smaller.

I am using 8 identical sensors and i have a subVI which returns the distance measured and wheather the sensor timed out or not, but i dont know how to re-use the same function for every sensor.

Can somebody help me?

 

Multiplex help

0 Kudos
Message 1 of 14
(4,129 Views)

not enough information to help you yet.  what is the code within the measurement function?

if it has memory like a shift register, you either need to code it as an array or use memory to implement a piece of code that be iterated on within a loop.

 

Stu
0 Kudos
Message 2 of 14
(4,126 Views)

Thats a good point. I added the entire code, so maybe you can take a look?

I cant seem to put the IOadresses into an array... Maybe it is possible and maybe its the solution to my problem 🙂

 

tnx in advance

0 Kudos
Message 3 of 14
(4,121 Views)

Maybe this will help 🙂

 

Total subVI:

multiplex2.JPG

 

 

Pieces of the subVI(enlarged):

multiplex2a.JPGmultiplex2b.JPGmultiplex2c.JPG

 

 

0 Kudos
Message 4 of 14
(4,113 Views)

I tried to make an array of the 8 IOpins, but when I try to make a for-loop to use them all i get multiple error messages:

"Possibility of Dynamic Refnum not supported for current target"

 

When I make it a fixed-array I get the same error message Smiley Mad

0 Kudos
Message 5 of 14
(4,100 Views)

The best solution would be to create a separate while loop for each of the sensors (see attached image).  I tried this with the sensor loop, and it compiled fine for an sbRIO-9631.

8sensors.png

 

You should avoid calling the Measure Distance sub VI sequentially in a For Loop because the VI takes up to ~20 ms to run.  This is how long it takes for the ultrasonic sensor to receive a response pulse at maximum range.  Running the VI in an 8-iteration For Loop would result in 1/8th the sensor frequency for each sensor.  Using parallel loops will avoid this problem.

 

Chris M

0 Kudos
Message 6 of 14
(4,078 Views)

are all of these events synchronized?  as in they are all initiated at the same time and should complete within the same timeout?

How often is the sequence repeated?

 

I understand that you are trying to fit onto the FPGA and are looking to reduce the code footprint by multiplexing the code.  I also assume that you need the digital input response to be as fast as possible to provide the best resolution.

Stu
0 Kudos
Message 7 of 14
(4,074 Views)

For some reason I can only fit 2 sensors into my FPGA module...

I need a minimum of 4 sensors...

0 Kudos
Message 8 of 14
(4,041 Views)

 


@milo_unlimited wrote:

For some reason I can only fit 2 sensors into my FPGA module...

I need a minimum of 4 sensors...


 

Have you made any other modifications to the FPGA code, other than adding extra sensor loops?  Can you attach the modified example you are trying to compile?

 

Chris M

0 Kudos
Message 9 of 14
(4,035 Views)

The project contains 2x  dualmotordrive units, 8 simple digital sensor connectors, SPI-communication, a custom serial comunication for a linescan module and hopefully 4 ultrasonic sensors

 

Attached the entire project(.7z file in a .zip file because 7z is not supported on this forum). Hope somebody can help :-S

0 Kudos
Message 10 of 14
(4,027 Views)