Announcement

Collapse
No announcement yet.

Recover from Serial 4D Library reports error

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

  • Recover from Serial 4D Library reports error

    I am periodically getting a "Serial 4D Library reports error NAK returned data =21". If I remove the while(1) line int the error callback the code continues to execute but the display quits working. What causes this error and what can I do to recover ?

  • #2
    can you post your sketch so we can take a look
    thanks

    Tony

    Comment


    • #3
      Dear dskogman,

      This means the 4D display is not receiving the proper data. 21 is decimal for 0x15 which is NAK. Please make sure you send the proper command or packet to the 4D LCD. This means
      the command, parameter and checksum must be correct.
      Best regards,

      Comment


      • #4
        I should have been been more clear on the failure. It runs fine for a period of time (2-10 minutes) then fails with the error 21 and never recovers until I do a hard reset. The sketch continues to run (once I removed the while(1) ) but the screen stops updating. It appears to be load related in that if I slow down screen updates it runs longer before failure but still fails. The output to the screen is very simple. It's three numbers using the txt_MoveCursor and print functions from the Arduino Picaso Serial library. I'll post the sketch later but it has the following:
        Input:
        4 Buttons - digital input
        2 Potentiometers - analog Input
        1 Serial input from a scale - Software Serial, 10 times/second
        Output:
        2 Servos - Servo shield
        1 Stepper Motor - Motor Shield
        2 DC motors - Motor Shield

        Comment


        • #5
          Sketch attached
          Attached Files

          Comment


          • #6
            Dear dskogman,

            Can you try this protection circuit to isolate the Arduino and 4D LCD from the noise generated by the 3 type of motors you are using? The motors generate noise which can
            affect the Arduino and 4D LCD and will cause the power supply used to drop when it starts and when the load is heavy. If possible, please use separate supply for the motors
            aside from the one used by the Arduino and 4D LCD.
            Attached Files

            Comment


            • #7
              I cannot read the attached file. Is the link working?

              Comment


              • #8
                Dear dskogman,

                Please try this link:--> https://www.dropbox.com/s/fryqqrscpf...ction.pdf?dl=0

                Best regards,

                Comment


                • #9
                  The power protection circuit is not really practical (12v battery?)
                  I did try a separate power supply for the motor shields and the 4Duino and reduced the print frequency where possible. It does not seem to lock up the display any more but still starts generating errors after about 3-5 minutes very repeatably. If it was a power issue it should happen immediately I would think. Sounds more like a memory leak or something.

                  Comment


                  • #10
                    Dear dskogman,

                    Could you please try running your setup with out the 3 types of motors? Often, CMOS suffers from parasitic latch up when
                    there is an inductive load which causes some glitch which is higher than the supply or lower (negative) than ground.

                    Can you please post a picture of your setup, and explain the power supply system a little more. What is supplying the 5V to the display, and what else is on this 5V rail.

                    Best regards,

                    Comment


                    • #11
                      I ran it without the shields and of course it ran OK but is not really useful. The shields are the Adafruit motor and servo shields.
                      Motor Shield https://www.adafruit.com/products/1438
                      Servo Shield https://www.adafruit.com/products/1411
                      They use I2C to communicate to the 4duino and the power supply can be independent as well ( https://learn.adafruit.com/adafruit-...owering-motors ). I have a separate power supply for the motor and servo shields and the 4duino

                      Comment


                      • #12
                        I did some more testing and ran with the shields but no power to the motors. The only thing running was the scale sending data ( 17 bytes of data 10 times per second ) to the software serial port. It would run for between 5 and 10 minutes before the display started generating the following errors:

                        Serial 4D Library reports error NAK returned data= 0
                        Serial 4D Library reports error NAK returned data= 0
                        Serial 4D Library reports error NAK returned data= 21
                        Serial 4D Library reports error NAK returned data= 21
                        Serial 4D Library reports error NAK returned data= 21
                        .
                        .
                        .
                        Serial 4D Library reports error NAK returned data= 21
                        Serial 4D Library reports error NAK returned data= 21
                        Serial 4D Library reports error NAK returned data= 21
                        Serial 4D Library reports error NAK returned data= 0
                        Serial 4D Library reports error NAK returned data= 0
                        Serial 4D Library reports error NAK returned data= 7
                        Serial 4D Library reports error NAK returned data= 0
                        Serial 4D Library reports error NAK returned data= 3
                        Serial 4D Library reports error NAK returned data= 0
                        Serial 4D Library reports error NAK returned data= 9
                        Serial 4D Library reports error NAK returned data= 0
                        Serial 4D Library reports error NAK returned data= 0
                        Serial 4D Library reports error NAK returned data= 3
                        Serial 4D Library reports error NAK returned data= 0
                        Serial 4D Library reports error NAK returned data= 9
                        Serial 4D Library reports error NAK returned data= 0
                        Serial 4D Library reports error NAK returned data= 0
                        Serial 4D Library reports error NAK returned data= 3
                        .
                        .
                        .

                        Comment


                        • #13
                          Screen shots of the normal screen (white background)
                          and two after running for a while with errors. Click image for larger version

Name:	IMG_6013.JPG
Views:	1
Size:	917.2 KB
ID:	56765Click image for larger version

Name:	IMG_6011.JPG
Views:	1
Size:	874.3 KB
ID:	56766Click image for larger version

Name:	IMG_6014.JPG
Views:	3
Size:	3.75 MB
ID:	56768
                          Attached Files

                          Comment


                          • #14
                            Dear dskogman,

                            I tried running your sketch and it ran for many hours with no error messages although only the 4duino since I do not have the shields. However, can you lower the baud rate of the Picaso display and see if the error still persist?. In 4D Workshop Click on File-->Click on Options-->Click on Serial-->Choose the Serial Environment Baud Rate to 57600. In 4D Workshop click on File-->New-->Choose Arduino-->4duino-->Extended Graphics-->Tools-->SPE Load. Please choose the Serial port of the 4Duino connected through the uUSB-PA5 of the Picaso Programming Header. In your code also change the the code DisplaySerial.begin(200000); to DisplaySerial.begin(57600) ; Please make sure that the 5V power supply of the 4Duino is regulated and capable of delivering more than 320 milli amperes. If not, the output voltage may drop when it enters the current limit and will cause the 4Duino to behave erratically. If the shields draw power from the 4duino
                            headers, you will need more the 320 milli ampere. If you are using the USB port to power the 4duino, you may need a self powered hub since most USB ports can only deliver 500 milli amperes.
                            Best regards,

                            Comment


                            • #15
                              Dear dskogman,

                              Our Senior Software Engineer suggested to use a baud rate of 56000 with an error rate of 0.45%. However, could you please
                              provide photos of your setup so we can have an idea if lowering the baud rate will be worthwhile.

                              Best regards,

                              Comment

                              Working...
                              X