04-10-2011 02:36 PM
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?
Solved! Go to Solution.
04-10-2011 07:58 PM
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.
04-11-2011 02:10 AM
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
04-11-2011 07:46 AM - edited 04-11-2011 07:54 AM
Maybe this will help 🙂
Total subVI:
Pieces of the subVI(enlarged):
04-11-2011 09:32 AM
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
04-13-2011 02:39 PM
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.
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
04-13-2011 02:51 PM
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.
04-21-2011 01:02 PM
For some reason I can only fit 2 sensors into my FPGA module...
I need a minimum of 4 sensors...
04-21-2011 01:43 PM
@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
04-22-2011 07:06 AM - edited 04-22-2011 07:06 AM
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