Quote:
Originally Posted by RyanN
There are several mistakes that I see. From what I can tell (and would have been important to mention) is that you're trying to create an interrupt for your gyro.
1) The Interrupt Wait block will wait indefinitely for an interrupt. The timeout is disabled by default, and you do not have a non-default value going into it. So once your interrupt hits, it will return 'false' on the Wait block, no matter what (since the timeout is disabled). So it will always output 'false' to the "Timed Out" indicator.
2) You should not have any sleep timers in an interrupt able loop. That sort of defeats the purpose of an interrupt (meaning to do something immediately). If your gyro is creating an interrupt 1000 times per second, it will still only read it 5 times per second because of that 200ms wait.
3) You mention that there is a square wave. Is that a constant square wave, or just one transition, from say, low to high. Keep in mind that the all of the DIO ports are pulled-up internally to 3.3V on the RoboRIO using a 40k resistor. Did you measure that while it was connected to the RoboRIO? I have a feeling that the gyro might pull-down when not asserting the interrupt, and pushing high when asserting the interrupt. That won't work with the RoboRIO. You'll have to create invert that signal going in.
Lucky for you, I can barely make out that you have an IMU 16448, which I think means you have an Analog Devices ADIS16448. Take a look at Page 20 in the datasheet. The Data Ready indicator (aka your interrupt) can be inverted by setting MSC_CTL[2:0] to 100 or 101, depending on which ADIS DIO port you're using (DIO2 = 101, DIO1 = 100).
Let me know if that helps.
|
Hi Ryan, thanks for the feedback! I don't have my RoboRIO with me to test the code, so I'll have to let you know the results tomorrow morning.
1) I assumed that the Interrupt block's default was -1, not 0. I've added a -1 to the timeout input to hopefully fix this issue.
2) I'm not sure I agree. An interrupt (in the embedded world) means "stop what you're doing, do this other thing, and return to what you were doing". In this case, I'm trying to improve the 448 sampling by only reading data from the sensor when it outputs valid data (~100 Hz) instead of polling the sensor and hopefully catching valid data. For this specific example however, I'm just trying to understand what the interrupts actually do on the RoboRIO.
3) There is a data ready signal being output from the sensor to MXP DIO0. I have verified that the signal looks as it should (data valid = high) using an oscilloscope connected to MXP DIO0. I hadn't taken into account the pull-up resistor, but do I need to? Even though there is a pull-up resistor on the DIO, as long as I configure the interrupt to trigger off the proper edge it shouldn't matter. The sensor should pull the pin low however I configure it since it doesn't high-z when inactive.
I've made the changes to the code using your feedback below:
