Announcement

Collapse
No announcement yet.

MakeCode Unreliable?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • MakeCode Unreliable?

    My team and I had a frustrating meeting today. Most of it had to do with our programs not running consistently. There were several problems that I blame on MakeCode, but I would like to discuss and find out if maybe we did something wrong or didn't do something that could have fixed those issues.

    First, the color sensors keep blinking off and on while the program is running. We watched and the red light on the table was flashing like a railroad crossing light. This only affected one of the 2 color sensors, and stopped when we switched ports. This happened to 2 of our robots (identical robots running different MakeCode programs).

    Second, and more critical in my mind, is that the robot, starting the same code from the same place and in the same manner, does very different things. I recorded the robot running the same program, from launch to the elevator, three times. ***Spoiler alert: You will see how my team plans to get the elevator. Fortunately, it doesn't work in the video, so no harm no foul.*** I don't have a copy of their code available, but I can get it later if anyone wants to check it. https://youtu.be/Nx6_3wV2Xhw

    After watching this, and after spending LOTS of time trying to figure out how to get MakeCode to work since we're using Chromebooks, my team voted to go back to using our turn of the century laptops that take 10 minutes to boot up and MUST stay plugged in while we use them and use the EV3 Mindstorms program.

    So, did we code something wrong? Is there something that we should have done differently? Or is MakeCode just not ready?

  • #2
    If you could share your code, I can take a peek. (Hit the share button and copy link here)

    Comment


    • #3
      The sensors may be blinking because they are switching modes - like reading reflected light then reading color in a loop. Seeing the code would be helpful.

      Comment


      • #4
        Why would changing ports make blinking go away? One reason would be if your program thought it was accessing reflected light from once sensor and color from the other, but you incorrectly specified the same port for both. When you changed the sensor port for the blinking reflected light sensor block you inadvertently corrected the error.

        This is how you debug. Look at what is happening and form a hypothesis. "What could possibly be causing this behavior?" Come up with a list of reasons. Then you design an experiment to test your hypothesis. "If the problem is two blocks are reading the same sensor, one as color and the other as reflected light, stopping the code that reads color should make the red light stay on". The you modify the program and perform the experiment. If the red light stays on you have not proven that the port selection is the cause, but you have supporting evidence.

        Comment


        • #5
          Every instance of the sensor being checked was looking for reflected light. There were no port conflicts that I am aware of and we checked carefully. MakeCode also notifies you when you try to put two things in the same port, and there were no error messages. I will upload the code once I get it, so we can take a closer look. I thought maybe the wire was loose, but that didn't track with the light blinking. Maybe it had to do with the sensor being checked as a condition in the loop, but I don't see why that would cause it to turn off and on...

          Comment


          • #6
            You can send me the code at [email protected] if you do not wish to leak it on the forum.

            Comment


            • #7
              I see this in EV3 occasionally and it usually is a loop or a wait. Was a big problem using the Gyro sensor in Rate + Angle mode (for self balancing robots and the like, or PD type control). If you use a wait angle or loop rate it would do a mode change and that would reset the sensor (early versions of gyro sensors).

              How can makecode check for this problem? I can write makecode where the sensor mode indeterminant until the program runs and can change from run to run. Use the light sensor in reflected light mode in a loop that begins with the start of a program. Have another chunk of code that reads a color sensor using the same port after I press a button. Have a third chunk of code that reads ambient light that is triggered by an event. Does it just pop up a message that says "Umm, you were using the color sensor in reflected light mode, are you sure you want to use it in color mode now?" I've never tried that and don't have access to try it now.

              Comment


              • #8
                We could detect that you are changing mode too fast - say > 1 per sec and surface a runtime warning. It is quite easy to make that mistake indeed.

                Comment


                • #9
                  https://makecode.com/_JkuMC9CW9Ud0

                  Here is the link to the kids' code. Happy to hear any suggestions that might help. I'd really like to understand what was going on. Thanks.

                  Comment


                  • #10
                    nothing shocking in there. The first step in this kind of situation is to be able to “see” what happens so that you can check that it matches what you expected. This is where “control.log” comes in. Add logging messages all over the code and run it. Then plug in the robot again and look for the dmesg.txt to see the output. Maybe you see something not going right or you are able to diagnose the incorrect code.

                    Comment


                    • #11
                      You probably want to set ready to false outside of run in background. Logging will help you find races.

                      Comment


                      • #12
                        From the code, can you tell why the color sensor was blinking?

                        Comment


                        • #13
                          No obvious reason. Which ports failed and which ones worked? I will try to repro this on my brick next week.

                          Comment


                          • #14
                            You're totally sane. I can see the color sensor blinking. Investigating...

                            Comment


                            • #15
                              It was port 1.

                              Comment

                              Working...
                              X