Announcement

Collapse
No announcement yet.

Writing Messages Directly in code for Diablo16

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

  • Writing Messages Directly in code for Diablo16


    Hi

    The app notes make reference to communicating to the display via third party hardware such as arduino so that the messages are built in arduino scriupt and then sent to the dispaly via comms

    Is it possible to have messages dynamically created / written within the script resident on the Diablo16 without needing to have them created on an external MPU like an arduino

    examples

    using an if statement have the code write and execute a message if a condition was met, whether the values tested in the if statement are calculated within the script or received as raw data (non message formatted) from an external source



  • #2
    Hi Claude,

    Sorry what Appnote are you referring to?
    I cant quite follow what you are asking, sorry. Script?
    Can you elaborate with more specifics ?

    Regards
    James

    Comment


    • #3
      Hi James i am using the magic code widget ( if that's the right term)

      I am not at the stage of being able to display the dynamic data on to the display

      i appreciate the need to build the customer messages that tell the diablo16 what to do and where to place the data / values

      i see from the notes sending serial data using Arduino the process of building the message in Arduino and then sending the message to the display via serial comms

      https://docs.4dsystems.com.au/app-no...0015_R_1_1.pdf

      The above app notes demonstrate how to send the data / message from the Arduino host to the display over serial comms

      What i am trying to understand is how can i create the messages in the code in the .inc file itself so that i do not need to use an arduino to create and send the code instead have the message code created in the code written within the .inc file

      i want to be able to send raw data sent from an external host eg a value sent as "spd100" to mean speed = 100 and then have the code residing inside the inc file to build the diablo16 message

      0x01 0x2F 0x01 0x00 0x64 0x4B

      to allow the value to appear on the screen where i require it, removing Arduino totally from the solution.

      i hope this clarifies what i am trying to explain




      Comment


      • #4
        Hi Claude,

        I'm still a bit confused by what you want to accomplish so I'll try to reply based on what I understand. Please let me know if my assessment of your inquiry is wrong.

        I think you want to send data containing a coded message and let the display extract the message and act on it.

        If that is the case, it is entirely possible with a MagicObject. However, I would advise you to refrain from sending strings. The main reason is that it is often inefficient to do so.

        Instead you might want to do one of the following implementations:
        1. Send a GENIE_WRITE_OBJ to separate MagicObjects with separate tasks
        2. Send a GENIEM_WRITE_BYTES to a MagicObject containing a command byte followed by the 2-byte value (-32767 to 32767).
        With option 1, you simply have to send a write object command to separate objects that will perform different tasks. For example, MagicObject0 can be for speed while MagicObject1 can be for brightness. The value can simply be used directly in the 4DGL code as an 16-bit integer (-32767 to 32767).

        With option 2, you are sending 3-bytes compared to 6-bytes from "spd100". Furthermore, it would be easier for the 4DGL code to handle the processing of the coded messages since it is byte-coded. This option if often unnecessary if you only plan to send 16-bit values or less in which case, option 1 would suffice. However, this option can be customized to user's needs.

        I attached example ViSi Genie projects showing the 2 options which basically does the same thing.

        I hope this helps

        Best Regards,
        Attached Files
        Juniel Cruz

        Comment


        • #5
          Hopefully the following will shed more light

          I have data coming from several api’s which my
          gps tracking device is able to query and have the values from the api outputted from the tracking device as rs232 output. I have a 4dsystems rs232 adaptor attached fo my display to receive the data outputted from rut tracking device

          2 examples of the information being outputted in rs232 via the tracking device include

          - outside temperature
          - vehicle heading as in (0-359 degrees ) vehicle heading

          the above info displayed needs to be updated in real time which it will receive from the rs232 output of the tracking device at 2-4 second intervals

          I also plan to have engine data being displayed, that data comes from the CAN bus of the vehicle I am using the 4Dsystems CAN adaptor to receive the hi / low CAN signals from the vehicle CAN bus.

          The chosen data from the vehicle CAN such as

          Current vehicle speed
          current fuel consumption
          current engine water temp

          also need to be received and displayed in real time at 2-3 second intervals.

          As I am using the rs232 for the serial data being sent from the tracking device and the vehicle data sent via the CAN adaptor I am wanting to be able to achieve the above without needing to add an Arduino board


          i trust the above further clarifies what I am trying to achieve

          I thank you in advance for your assistance.

          Comment


          • #6
            Hi Claude,

            As far as I understand, your setup includes the following:
            • 4.3-inch Diablo16 display module
            • MOTG-AC4
            • MOTG-RS232
            • MOTG-CAN
            • GPS Tracking device connected via RS232
            • Vehicle CAN bus
            • A ViSi Genie External Host Controller (please confirm)
            Based on the application note you were browsing, I assumed you were using ViSi Genie protocol to receive the coded message. But based on your last reply, I assume that's not the case.

            Regarding the GPS Tracking device, it seems to me that you can program it to send a custom coded message.If that is the case, Some parts of Option 2 from my previous reply would still be ideal. I would still recommend sending them as a byte-coded message since it will still be more efficient. As per your examples, I would suggest sending the coded message like this:

            Click image for larger version

Name:	sample.png
Views:	48
Size:	2.2 KB
ID:	73425

            The above example can then be further expanded for more commands from the RS232. Notice that the coded message is always 5-byte long. Each command can send a 4-byte value [2 16-bit integers, a 32-bit integer or a 32-bit float].

            As for the Vehicle CAN bus, as far as I know, it follows the ODB-II PIDs which you'd need to check at some point for your CAN development. Interestingly, the protocol is somewhat similar to my suggestion above in a way that the data transmission is started using an ID and the value is sent as data bytes.

            The information above should cover the suggested format for the coded message to be received. As for processing the data bytes, assuming you've already setup the MOTG-RS232 completely, you only need to add a MagicCode set to Main Loop:

            Code:
            var cmd232, intVal, fltVal[2], lngVal[2];
            if (com1_Count() >= 5) // check if we alread received a complete packet
                cmd232 := serin1();
                if (cmd232 == 0x00) // Expecting Temperature in Float
                    // Receive High Word of 32-bit float
                    fltVal[1] := serin1() << 8;
                    fltVal[1] |= serin1();
                    // Receive Low Word of 32-bit float
                    fltVal[0] := serin1() << 8;
                    fltVal[0] |= serin1();
                    // You can use float functions here to further process the value
                endif
                if (cmd232 == 0x01) // Expecting Vehicle Heading as 16-bit integer
                    // Receive 16-bit integer
                    intVal := serin1() << 8;
                    intVal |= serin1();
                    // Ignore the next 2 bytes
                    serin1();
                    serin1();
                    // You can process the 16-bit integer here
                endif
                if (cmd232 == 0x02) // Sample 32-bit integer Value
                    // Receive High Word of 32-bit integer
                    lngVal[1] := serin1() << 8;
                    lngVal[1] |= serin1();
                    // Receive Low Word of 32-bit integer
                    lngVal[0] := serin1() << 8;
                    lngVal[0] |= serin1();
                    // You can use 32-bit integer functions here to further process the value
                endif
            endif
            After receiving the data, you can do as you please with it: print it on the screen, convert the float value to integer or use the value to update a widget using the ViSi Genie function WriteObject.

            I hope this helps.

            Best Regards,
            Juniel Cruz

            Comment


            • #7
              Hi sorry your list is correct other than
              • A ViSi Genie External Host Controller (please confirm
              I have no idea what this is

              The rs232 data I am able to customise the output to be in the display message format ( not sure if this helps re not needing a host controller )

              Comment


              • Juniel Cruz
                Juniel Cruz commented
                Editing a comment
                I was referring to an external host microcontroller that controls the display via ViSi Genie commands.

                As you might already know, ViSi Genie is primarily designed to work with another host controller. The most common example as you've seen in the application notes, is an Arduino.

                I also read that you are programming the GPS Tracking device and previously assumed you are using ViSi Genie via RS232. That's exactly why I sent my first reply.

              • Juniel Cruz
                Juniel Cruz commented
                Editing a comment
                I'm still a bit confuse really. I saw one of your post about sending a ViSi Genie command (extracted from a string) using python. I thought you are sending ViSi Genie commands from the GPS Tracking device to control the display.

            • #8
              Thanks Juniel

              I have added the above code to the magic code set to main loop and uploaded to display

              i will now set about analysing what the code does and working through step by step as i do

              will update you on the results

              Comment


              • #9
                Hi I am sending formatted code to the display via the rs-232 adaptor eg 0x01 0x01 0x00 0x00 0x00 to represent command vehicle heading and passing a integer value of 100

                i have added some test cost to first determine if the rs-232 is actually receiving any data and if it having the display load form (1) instead of form(0)

                if com1_Count() > 0)
                ActivateForm(1);
                endif

                form 1 does not display when i send the data indicating that the dispaly is not processing data

                the rs-232 has a power and grnd do i need to pass the 5v and gnd to the rs232 adaptor or will it be powered via the usb upa connection ?? or does the rs-232 need to be powered via its own 5v and grnd pins and if so when programming the display can i also have the upa connected hence giving the display 2 sources of 5v power or should i disconnect rs232 adaptor when programming using upa and then disconnect usb upa when connecting the rs232 with its own 5v / gnd

                Comment


                • Juniel Cruz
                  Juniel Cruz commented
                  Editing a comment
                  Quick Question: Can you confirm if you are trying to use the GPS Tracking Device to control the active form and value of the widgets?

              • #10
                yes the gps tracking device has rs232 serial output so i am able to build custom output thats sent out from the tracking device via rs232 port so the output i was sending from the tracking device rs232 port connected to the rs232 adaptor was 0x01 0x01 0x00 0x00 0x00 in this test example

                so my first test is to determine if the rs-232 is receiving the data being sent from the tracking device so i was measuring the length of the data on com1 to determine if its actually being received

                process of elimination mind set

                Comment


                • Juniel Cruz
                  Juniel Cruz commented
                  Editing a comment
                  Have you tried using the GPS Tracking device as an external host controller to write a value to a widget or change forms? I was under the impression that you did already.

                  So I was wondering if my very first reply #4 is actually the best option for you.

              • #11

                Originally posted by SpeedlessAustralia View Post
                I am sending formatted code to the display via the rs-232 adaptor eg 0x01 0x01 0x00 0x00 0x00 to represent command vehicle heading and passing a integer value of 100
                Are you following the same format I used as an example? If yes, then the command for sending 100 should be [0x01 0x00 0x64 0x00 0x00] since the values are written in HEX.

                Originally posted by SpeedlessAustralia View Post
                i have added some test cost to first determine if the rs-232 is actually receiving any data and if it having the display load form (1) instead of form(0)

                if com1_Count() > 0)
                ActivateForm(1);
                endif

                form 1 does not display when i send the data indicating that the dispaly is not processing data

                the rs-232 has a power and grnd do i need to pass the 5v and gnd to the rs232 adaptor or will it be powered via the usb upa connection ?? or does the rs-232 need to be powered via its own 5v and grnd pins and if so when programming the display can i also have the upa connected hence giving the display 2 sources of 5v power or should i disconnect rs232 adaptor when programming using upa and then disconnect usb upa when connecting the rs232 with its own 5v / gnd
                Have you completely setup the COM1? As mentioned earlier, the code will only work assuming you've setup everything required.

                In Diablo16 displays, you need to assign the appropriate pins to use as RX and TX. You can check the MOTG Datasheets to know which pins are connected if you haven't already. You also need to setup an RX buffer to contain the messages received and for com1_Count to work properly.

                ---------------------------------

                Can you confirm if you are using the GPS Tracking device as an external host for the display? What I mean is if you are using the GPS Tracking Device to send and receive ViSi Genie commands to and from the display.
                Juniel Cruz

                Comment


                • #12
                  ok from my reading as at the moment i only have one of the adaptors connected to the board i have left the solder points on the A4 untouched i know i need to work on them if i have 2 of the adaptors attached at the same time

                  regarding setting up the comms i have selected comm1 as pic screen shot attached thats all i have done

                  to try and explain in more details to assist

                  hardware
                  • 4.3-inch Diablo16 display module
                  • MOTG-AC4
                  • MOTG-RS232
                  • GPS Tracking device connected via RS232
                  • MOTG-CAN (not attached lets get rs232 data working first)
                  • Vehicle CAN bus
                  • A ViSi Genie External Host Controller (please confirm) ???????

                  all data sent to the display via rs232 comes from the trackers rs-232 port
                  the tracker itself sends and receives data via grps socket connection from a web hosted server with the tracking server software is written in python
                  the python code on the server connects to api's and gather than processes data and then returns relevant data back to the tracker via the socket connection
                  the server can customise the format of the data being sent back to the tracker whether it be in diable message format or purse ascii text data
                  the data that is sent back to the tracker from the server is then outputted from the tracker via the rs232 port connected to the rs232 port on the display

                  i hope the info above clarifies any confusion

                  i am happy to have a voice / skype real time chat if its easier so that questions can be asked and addressed in real time rather than taking up your valuable time with all these back and forth posts




                  Attached Files

                  Comment


                  • #13
                    Originally posted by SpeedlessAustralia View Post
                    yes the gps tracking device has rs232 serial output so i am able to build custom output thats sent out from the tracking device via rs232 port so the output i was sending from the tracking device rs232 port connected to the rs232 adaptor was 0x01 0x01 0x00 0x00 0x00 in this test example

                    so my first test is to determine if the rs-232 is receiving the data being sent from the tracking device so i was measuring the length of the data on com1 to determine if its actually being received

                    process of elimination mind set
                    No I do not understand what you mean about using the tracking device as an external host controller. The step i am upto now is connecting the rs232 port of the tracker to the rs232 port adaptor and trying to confirm that the display is receiving the packet data being sent to it hence my using the code mentioned ealier in the if statement to test the condition if it detects the data being recieved. If this action is using the tracker as an external host controller or not sorry i do not know as i am not familiar with the term.

                    if you have not yet realised i am a total newbie to using this type of hardware and projects i am learning one step at a time

                    Comment


                    • #14
                      QUOTE: Are you following the same format I used as an example? If yes, then the command for sending 100 should be [0x01 0x00 0x64 0x00 0x00] since the values are written in HEX.

                      yes i concede i stuffed up with the hex packet, HOWEVER even doing so it still should have generated a result form testing for the presence of data coming form the com1port with the if statement i was using yet it did not indicated detecting any data

                      Comment


                      • Juniel Cruz
                        Juniel Cruz commented
                        Editing a comment
                        My apologies. I was sure it has nothing to do with your primary issue but I decided to comment on your message from top to bottom.

                        Hopefully, my the rest of my comment was a bit more useful.

                    • #15
                      Originally posted by SpeedlessAustralia View Post
                      i am happy to have a voice / skype real time chat if its easier so that questions can be asked and addressed in real time rather than taking up your valuable time with all these back and forth posts
                      We discussed among ourselves and Paul will be contacting you soon.
                      Juniel Cruz

                      Comment

                      Working...
                      X