Go Down

Topic: Need help troubleshooting variable not getting set by interrupt (Read 1 time) previous topic - next topic

MatCat

Yeah if I cant figure it out with my current method I will end up using the software serial, I also found a special ISP for the tiny (based on arduino ISP) that uses the MISO pin to relay serial via the arduino to serial which I may try.

DuaneB

Hi,
   I have just had an idea of what your problem might be, when one channel falls, the other rises simultaneously - the logic of figuring out which pin is doing what inside the library might not be written for this situation of simultaneous pin changes.

Do you have a link to the source code of the library ?

Duane B


DuaneB

From a quick look at the code, I can't see anything that would lead to one of the interrupts being dropped, but it sounds like this could be your problem. Off to the airport now, but this is what I would investigate.

Duane B

MatCat

Success!  After using my debugger code, which BTW had errors posted above, but I changed it to show working code.  Basically it boiled down to variable decelerations!  In one case an int was being put into a byte so that was screwing up that value, then in a few places I had unsigned int's being put into signed int's as well.  After finding those bugs and fixing all works as well as should be, and BTW the timing is quite accurate, using the scope I can easily measure the width of the PWM outputs, and compared to the measurements my interrupts are measuring it is pretty much spot on and the action is quite smooth as can be seen in the video below.

https://www.youtube.com/watch?v=LenmLVkkPis

Pictured below are screenshots from the scope showing the frameTime variable which is a calculation of the width of the pulse from the RX, normally 1000us is the lowest, and 2000us is the highest, the first is the throttle stick all the way down and reads 1116us which is within normal limits and indeed matches the width from the RX quite damn closely as measured with the scope.  The second picture is with throttle stick at 50% and reads 1525us, and the final picture is with the throttle at 100% and the reading being 1927.  all measurements are very consistent, I am quite happy now!

Go Up