Reading the timer and another sensor after each other has invalid behavior


#1

Hi,

When using the timer together with another input, results in invalid behavior. With this simple program, my sprite actually says the timer value instead of the joystick X-axis value most of the time. Also the 7-segment display after a while starts showing incorrect behavior (timer not displayed anymore, and some random blinking segments). When not using the timer, both the segment display and the joystick work as expected.

I’m using the latest stable mBlocks version, with the latest firmware uploaded to the orion board. Everything else seems to work fine, it’s only when using the timer that things go wrong.
It looks like there’s something wrong with the ID’s used to do the non-blocking reads, but I haven’t been able to figure out exactly why or how to fix it.

Has anyone else seen this, and is there a fix?

Thanks,
Kester


#2

@kester,

I’m not sure how you got this to work. I could not even get it to upload.

Mike


#3

@mddickey,

I run it from mBlock, not uploading it to the Arduino. I’m sure that when uploading such (without the say block) it works fine. The issue is when you run it from mBlock. So when you double click on Orion Program, it’s running from mBlock, and gives incorrect results…

Regards,
Kester


#4

The SAY command will only work in Scratch mode - the animal in on the screen will then say the text.

You need to delete that command when you upload the code to the board.


#5

Yep, I forgot about the double click. I usually write programs to upload.

Anyway, if you switch the order of the 7-segment and the SAY, it seems to work correctly. Also, if you put a .2 Sec WAIT between the SAY and the 7-segment, it works too. I have no idea why it acts this way.

Mike


#6

When switching the order of the lines, it works better for me, but still not correct though.
The underlying reason seems to be the asynchronous calls used from scratch: the response should use the correct ID, but that doesn’t seem to propagate correctly.
I’ve tried to put a wait statement, and indeed that’s similar to the change of order, ie it works better. What would be the correct approach to get this fixed?

-Kester


#7

When you find bugs, it is a good idea to let @tec_support know.

Mike