Announcement

Collapse
No announcement yet.

Problems when reading status of WINBUTTON

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

  • Problems when reading status of WINBUTTON

    Greetings All,

    Now that I am able to write/control the values of LEDDIGITS, THERMOMETER, GAUGE and WINBUTTON I have now begun the process of attempting to read values from widgets such as WINBUTTON which I've seem to encounter some problems.

    Button Configuration:
    WINBUTTON:
    Index=1
    Momentary=No

    My options:
    It appears that I have three options to determine if the button has been "pressed"

    x00-Read Object Status (which seems to make the most sense to me)

    x05-Report Object Status (but why do we set the MSB and LSB for something that I'm trying to read)

    x07-Report Message Event (is the value of the widget stored until the uProcessor issues this command)

    What I tried:

    I went with sending x00 route using the following command:
    HTML Code:
    HSEROUT [$00,$06,$01,$07]
    
    
    I receive a NAK error when the above command is sent even though I verified the commands that should be sent using the GTX Utililty (see below for output):
    
    Request Winbutton Value 07:32:02.751 [00 06 01 07]
    
    Winbutton Value 07:32:02.791 [05 06 01 00 00 02] 
    
    So I tried the x05 route using the following command:
     LCD_COMMAND=$06
     LCD_OPERATION=RD
     LCD_NUMBER=$01
     LCD_MSB=$00
     LCD_LSB=$01
    
    
     LCD_CHECKSUM=$05^$06^LCD_NUMBER^LCD_MSB^LCD_LSB
     SEROUT S_OUT,I9600,[Send Query to LCD,13]
     HSEROUT [$05,LCD_COMMAND,LCD_NUMBER,LCD_MSB,LCD_LSB,LCD_CHECKSUM]
    I still receive an NAK with the above example also.

    Sorry if I'm missing something here but any help/insight would be great as I'm in the process of building a "library" for us PBASIC/BASIC users

    Thanks-Brian

    PS: I can send commands to turn the status of the WINBUTTON on and off.

  • #2


    0x05 is what comes back from the display in response to you sending 0x00

    Are you looking at the Genie reference manual section 2.1 (which is much more detailed), or the Genie user guide Section 8 (which is only an overview)?

    Could the NAK be coming back because of something previously sent that was invalid (remember, to the display you are only sending a stream of data where one command ends and another one starts is only related to the valid length of the previous command)?
    Mark

    Comment


    • #3


      Thanks for the explanation Mark between x00 and x05; that "makes" sense now.

      But the problem is that I am getting a NAK error right after I am sending the x00 (so I can't even get to reading the results of x05). Any suggestions (as I've already added delays and I even moved the x00 command to read the status of the button right after a LCD Reset)?

      All of the the previous "write" commands all have a ACK so things should be fine there...I already have moved code around and no matter what I still am receiving a NAK error. I have also

      BTW:
      1) I configured a Baud Rate is 38400 (which has been working fine until I tried reading the status of the WINBUTTON)
      2) I configured a delay of 25ms for the Serial (as well as a 38400) but I don't that that would affect this
      3) 4D Workshop is version 4.1.0.14


      Answer to your question:
      Yes I have been using the Reference Manual (V1.06) as that as how I have been able to get this far Honestly what has helped me the most is the GTX Utility which shows me the info that I must send vs. receive.

      ; *** Example code to connect a Basic Micro Nano-18 to a 24PTU using Visi Genie ***


      SEROUT S_OUT,I9600,[0,Program starting...,13]

      PAUSE 500

      LCD_RST CON P3

      RD CON 0
      WR CON 1
      REPORT CON 5

      DIPSWITCH CON $00
      KNOB CON $01
      ROCKERSWITCH CON $02
      ROTARYSWITCH CON $03
      SLIDER CON $04
      TRACKBAR CON $05
      WINBUTTON CON $06
      ANGULARMETER CON $07
      COOLGAUGE CON $08
      CUSTOMDIGITS CON $09
      GAUGE CON $0B
      LED CON $0E
      LEDDIGITS CON $0F
      METER CON $10
      THERMOMETER CON $12

      LCD_COMMAND VAR BYTE
      LCD_OPERATION VAR BYTE
      LCD_NUMBER VAR BYTE
      LCD_MSB VAR BYTE
      LCD_LSB VAR BYTE
      LCD_CHECKSUM VAR BYTE
      LCD_STATUS VAR BYTE
      LCD_IGNORE VAR BYTE

      LCD_QUERY VAR BYTE


      ; **************** Beginning of acutal program ***********************


      CLEAR

      GOSUB HSERIAL_SETUP ;Setup the HSEROUT/HSERIN Baud Rates

      GOSUB LCD_RESET ;Reset the LCD Display

      PAUSE 1000
      LCD_COMMAND=LEDDIGITS
      LCD_OPERATION=WR
      LCD_NUMBER=$00
      LCD_MSB=$00
      LCD_LSB=99

      GOSUB LCD_SEND

      PAUSE 1000
      LCD_COMMAND=LEDDIGITS
      LCD_OPERATION=WR
      LCD_NUMBER=$00
      LCD_MSB=$00
      LCD_LSB=15

      GOSUB LCD_SEND

      PAUSE 1000
      LCD_COMMAND=WINBUTTON
      LCD_OPERATION=WR
      LCD_NUMBER=$01
      LCD_MSB=$00
      LCD_LSB=$01

      GOSUB LCD_SEND

      PAUSE 1000
      LCD_COMMAND=WINBUTTON
      LCD_OPERATION=WR
      LCD_NUMBER=$01
      LCD_MSB=$00
      LCD_LSB=$00

      GOSUB LCD_SEND

      MAIN

      GOSUB LCD_READ

      GOTO MAIN

      END


      ; *********************** Subroutine to send commands to the LCD ****************************

      LCD_SEND

      LCD_CHECKSUM=LCD_OPERATION^LCD_COMMAND^LCD_NUMBER^LCD_MSB^LCD_LSB
      SEROUT S_OUT,I9600,[Writing to object:,13]
      HSEROUT [LCD_OPERATION,LCD_COMMAND,LCD_NUMBER,LCD_MSB,LCD_LSB,LCD_CHECKSUM]

      GOSUB NAK

      RETURN

      ; *************************************************************************************************


      ; *********************** Subroutine to read commands from the LCD ****************************

      LCD_READ
      PAUSE 500
      LCD_CHECKSUM=$05^LCD_OPERATION^LCD_COMMAND^LCD_NUMBER^LCD_MSB^LCD_LSB
      SEROUT S_OUT,I9600,[Send Query to LCD,13]
      HSEROUT [$00,$06,$01,$07]
      ;PAUSE 20
      GOSUB NAK

      HSERIN [LCD_IGNORE,LCD_IGNORE,LCD_IGNORE,LCD_IGNORE,LCD_QUERY,LCD_IGNORE]

      SEROUT S_OUT,I9600,[Waiting on results of Query from LCD:,DEC LCD_QUERY,13]
      GOSUB NAK

      RETURN

      ; *************************************************************************************************


      ; *********************** Configure the Baud Rate for Hardware Serial ****************************
      HSERIAL_SETUP

      SETHSERIAL1 H38400 ;Maximun baud rate for a standard Nano?

      RETURN

      ; *************************************************************************************************


      ; ****** RESET THE 4D SYSTEMS DISPLAY ******

      LCD_RESET

      SEROUT S_OUT,I9600,[0,Resetting the LCD,13]

      HIGH LCD_RST
      PAUSE 250
      LOW LCD_RST
      PAUSE 100
      HIGH LCD_RST
      PAUSE 3000

      RETURN

      ; *************************************************************************************************


      ; ******************** Subroutine to check for communication from the LCD *************************

      NAK
      HSERIN [LCD_STATUS]

      IF LCD_STATUS=$06 THEN
      SEROUT S_OUT,I9600,[LCD COM OK:,HEX LCD_STATUS,13]
      ELSE
      SEROUT S_OUT,I9600,[LCD COM Error:,HEX LCD_STATUS,13]
      ENDIF

      ;PAUSE 250
      RETURN

      ; *************************************************************************************************

      Comment


      • #4


        Use the programming cable as a monitor to see what your controller is 'really' sending to the display.

        Connect RX of the programming cable to TX from your controller and use the terminal program to monitor what is being sent.

        The 25ms will just delay the sending of the ACK/NAK back to your controller, if you can see a NAK turning up then the 25ms is definitely enough.
        Mark

        Comment


        • #5


          Hi again Mark,

          Just to clarify:

          1) Programming Cable=uUSB-PA5?
          2) Terminal Program=Terra Term/Hyper Terminal or the GTX Utility?

          Again to clarify that the 25ms delay is configured on the Serial Environment Tab (as well as an option for setting the the baud rate); would changing the delay really affect anything when using VISI-GENIE?

          Thanks-Brian

          Comment


          • #6


            1. Yep
            2. The Terminal program that comes with workshop, it's different to GTX.

            Sorry, the delay is for Serial only, it is not applicable to Genie
            Mark

            Comment


            • #7


              OK...from what I can tell everything looks OK; see graphic below to verify:




              So I'm going to guess I that I found a bug

              Just as a FYI I have been able to read and write to the 24PUT when it was programmed for Serial Operation so based on that outcome I would assume from an electrical/timing perspective that the only "thing" that has changed is switching the firmware from serial to Visi-Genie.

              Hope we can get this resolved so let me know what you would like me to do next.

              Thanks for the assistance Mark.

              Comment


              • #8


                So where'd the 06 06 come from in that log?

                And what came before the '00 06 01 07', or was that the first thing after the display was reset?

                If you can show everything before that might help

                If it was the first thing after a reset can you try waiting longer?
                Mark

                Comment


                • #9


                  The 06 06 is what I had to send back to my program in order for the next line to continue (I pressed Send Hex button and then entered 06).

                  I have sent the 00 06 01 07' bytes being sent right after a reset (which is already 3 seconds long) as well as after sending other commands.

                  This is what I am going to do as I need to get the project going (again I had no problem sending/receiving data from the LCD in serial mode):

                  This is what I will do in an attempt to resolve this issue:
                  1) lower the baud rate
                  2) see if I can read the status of another object
                  3) post a full exchange of commands between the terminal and the processor per your request
                  4) as a last resort give up on VISI-GENIE and go back to the serial firmware

                  Thanks-Brian

                  PS: May be insightful if you guys purchased a Basic Nano-18 and a programmer to test my code (it would be less than $30 dollars) to see what the error is (still not ruling out an error on my part). At least then you may be able to post come code examples for us BASIC users

                  Comment


                  • #10


                    Err, after you send '00 06 01 07' you call NAK.

                    The response back from the Display will be '05 06 01 00 00 02' (for example), but NAK simply checks the first byte for 06, it doesn't have the smarts to read a full response from the display.
                    Mark

                    Comment


                    • #11


                      Greetings Mark,

                      Problem Solved!

                      After reading your last post and rechecking the docs for 150th time it finally dawned on me that you don't receive a ACK for this command; only a 6 byte return message (or NAK if an error occurs)

                      I DO want to extend a big "thank you" in your assistance in resolving my problem.

                      But...if you reviewed my code that I posted it would of been plain to see that I totally missed the whole concept that the "standard ACK" response was replaced by a 6-byte response (in all honesty I did note this change when reviewing the Visi-Genie documents a few weeks ago...just plain forgot about it).

                      Again just my two cents but I really have enjoyed the Visi-Genie option (vs. the much more labor intensive serial option) but what helps me is seeing the "byte examples" of how send commands and the bytes returned (I know, mostly ACKs) that are posted in the App Notes. I hope that you would consider forwarding my request to the documentation department to see if that info could be included in the reference manual?

                      Thanks again for you help Mark and enjoy the Holiday Season!

                      Regards-Brian.

                      Comment

                      Working...
                      X