Announcement

Collapse
No announcement yet.

Changing BaudRate causes display to freeze

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

  • Changing BaudRate causes display to freeze

    Hi

    I'm using Matlab to control a 96-G2 Goldelox display. Whenever I change the BaudRate I'm unable to clear the screen and display things - all I get is the splash screen (not scrolling).

    Here's the code, I just want to change the BaudRate and draw a circle but I can't do it.

    HTML Code:
    clear alldelete(instrfind)oled = serial('com8');set(oled, 'BaudRate', 115200);fopen(oled);fwrite(oled, hex2dec('00')); % Disable scrollingfwrite(oled, hex2dec('0C'));fwrite(oled, hex2dec('00'));fwrite(oled, hex2dec('00')); fwrite(oled, hex2dec('FF')); % Clear displayfwrite(oled, hex2dec('D7')); fwrite(oled, hex2dec('FF')); % Shape: filled circlefwrite(oled, hex2dec('CC'));fwrite(oled, 0)fwrite(oled, 30) % xfwrite(oled, 0)fwrite(oled, 30) % yfwrite(oled, 0)fwrite(oled, 5) % radiusfwrite(oled, 123)fwrite(oled, 123) % colorpause(5)fclose(oled)
    Any ideas?

    Many thanks
    Chris

  • #2


    You need to wait for the ACKs before sending the next command, failure to do so will result in the problems you are having.

    How are you changing the baud rate on the display?
    Mark

    Comment


    • #3


      In the code above I'm trying to change the BaudRate with

      HTML Code:
      set(oled, 'BaudRate', 115200);
      
      I've also tried to send hex, e.g.
      
       fwrite(oled, hex2dec('00')) % Change BaudRatefwrite(oled, hex2dec('0B')) fwrite(oled, hex2dec('00'))fwrite(oled, hex2dec('CF'))
      In the former case the BaudRate of the display object changes to whatever it should but I'm unable to display anything, as described above and there is no ack.

      In the latter case the BaudRate does not change, ack is 227, and I'm again unable to display anything.

      I appreciate your help.

      Comment


      • #4


        chrisharris wrote: In the code above I'm trying to change the BaudRate with

        HTML Code:
        set(oled, 'BaudRate', 115200);
        
        I've also tried to send hex, e.g.
        
         fwrite(oled, hex2dec('00'))fwrite(oled, hex2dec('0B')) fwrite(oled, hex2dec('00'))fwrite(oled, hex2dec('CF'))
        In the former case the BaudRate of the display object changes to whatever it should but I'm unable to display anything, as described above and there is no ack.

        In the latter case the BaudRate does not change, ack is 227, and I'm again unable to display anything.

        I appreciate your help.

        Comment


        • #5


          chrisharris wrote:
          Originally posted by chrisharris
          In the code above I'm trying to change the BaudRate with

          HTML Code:
          set(oled, 'BaudRate', 115200);
          
          I've also tried to send hex, e.g.
          
           fwrite(oled, hex2dec('00'))fwrite(oled, hex2dec('0B')) fwrite(oled, hex2dec('00'))fwrite(oled, hex2dec('CF'))
          In the former case the BaudRate of the display object changes to whatever it should but I'm unable to display anything new, as described above, and there is no ack.

          In the latter case the BaudRate does not change, ack is 227, and I'm again unable to display anything.

          I appreciate your help.

          Comment


          • #6


            You need to send the change baud rate command first, you then need to ensure the command has been fully flushed, then you need to change the baud rate on your controlling system, and finally you need to wait for the ACK (which comes back at the new baud rate)
            Mark

            Comment


            • #7


              How do I "ensure the command has been fully flushed"?

              Comment


              • #8


                In Windows there's FlushFileBuffers(handle), but that seems to only ensure the data is flushed to the com port driver, so you also need a small delay to ensure that has had time to write out the characters (say 10 ms)
                Mark

                Comment

                Working...
                X