Sensor Issue

We are trying to program a LV-MaxSonar-EZ1 sensor for distance measurements. We have copied the template and when deployed alone it works fine but when we try to run it with the rest of our code it does not give us any feedback as to if it is working or not. We have an icon on our dashboard that is suppose to move with the distance but shows nothing. Any help would be greatly appreciated!

Did you copy the code by re-making exactly it in your project exactly how you saw it or did you simply CTR-C, CTR-V? If you CTR-C’d it, try remaking it just how you see it in the example, this will add the needed dependency files to your robot project, rather than just those copied from the other vi.

Also, posting a picture of your code can be very helpful!

We had this exact problem with the accelerometer vi, make sure it is checking the correct DIO module. It had defaulted to Breakout 2, which was not physically present on our robot. Also, make sure that there are no conflicting functions, such as the one that connects to the dashboard, which are often in the example code. I would recommend simply transplanting the sub-programs within the examples, such as the load and read functions within the main example loop. if you continue having issues, post your code; I would be happy to look over it.

Here is the code that I tried.





When you copied the front panel controls to teleop, did you make sure the values stayed the same?

Yes. All values are the same.

Here is a pic of the front panel…I am unsure if there are any other VIs I need to add a front panel to other than teleop…





We had this issue when we tried using the “Digital”, or “PWM”, output. We ended up just choosing to use analog, as you did here.
The one thing to remember about this sensor is, it only samples at a 10Hz rate. Anything beyond that is not getting you any additional data, and may be corrupting your readings…
With the default config, you are sampling it at 1KHz.
Try setting the sample rate down to 10Hz and see how it works.

(We ended up re-building the digital interface and it worked like a charm. I have NO CLUE why it failed previously!)

I edited the code, but its still not functioning





Dividing the value by 9.8 is only off by a factor of 1000.
It should be .0098.

I changed the scaling but it still does not show its working…is there specific numbers for the AverageBits and OversampleBits?