Announcement

Collapse
No announcement yet.

Best application architecture with 4D displays

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

  • Best application architecture with 4D displays

    I've been using the 4D displays with an Arduino for a while now starting with the 4Duino, then a 3.5" CT Diablo connected to a Mega and now a 5" CT Diablo connected to a 32 bit Due. I now have two stepper motors, two small DC motors, one servo motor, one serial input, a couple of digital I/O's and a serial I/O to the Diablo. I have been using the standard Workshop Arduino projects with fairly good results but there are a couple of issues:
    1. The polling architecture of the diablo interface requires dropping in event checks for button pushes all over the code if you want to be able to change things on the fly.
    2. If I use a stepper/motor/servo driver that uses PWM I/O pins for control, the display or motor will hang up at some point. If I use I2C drivers for the motors it never seems to hang. The I2C drivers are not very common (Adafruit has the only ones I know of) and are much more expensive.
    So is there a better way to do this by moving the display processing code to the Diablo itself with an event driven handler on the Arduino side using Visi, Visi Genie or something else like I2C ? If so is there a way to convert the Arduino C code to 4DGL easily? Would this eliminate interference with the PWM I/O?

    Click image for larger version

Name:	loader screen.jpg
Views:	1
Size:	1.45 MB
ID:	64029

  • #2
    Hello,

    You can move display processing to the display and program the display in Visi, converting from the Arduino to 4DGL is quite straight forward as 4DGL is like a mixture of C, Basic and Pascal and the graphics code can be generated easily by clicking the paste code button. The Arduino can then be responsible for handling your stepper/motor/servo and the display left to process graphics. You will have to create a serial routine to pass data back and forth to the Arduino but you can make this as simple as you need. You can even use I2C or SPI as a master on the display as long as the Arduino will accept this as a slave device

    The Diablo internal functions manual will help https://www.4dsystems.com.au/product...ions_R_2_0.pdf

    I hope this helps

    Best regards

    Paul

    Comment


    • #3
      Thanks for the info. I looked at the documentation and played around in the editor and the code is pretty similar although I'm not sure why you didn't pick one syntax (C, Basic or Pascal ). A simple serial interface would be the easiest as long as it did not have the same issue of periodically hanging up the display or PWM (# 2 above).

      Comment


      • #4
        Hi,

        It's not normal behaviour for the display to hang using when using a microntroller with PWM so there will be something causing this problem. Firstly it needs to be established which is failing. The display is not known to hang so it could likely be a problem on the Arduino. If you would like to send us your Arduino code we could examine it to see where the problem may be.

        Best regards

        Paul

        Comment


        • #5
          It doesn't happen often but when it does the Arduino continues working but the screen stops sending touch inputs or the Arduino misses them if it does. The code is over 1K lines so is probably too much to review. I will experiment with splitting the UI code out and loading on the display and see how that goes.

          Comment


          • #6
            I put together a prototype splitting the UI (Diablo) and application (Arduino) with a serial interface sending messages back and forth. It works well and the UI is much more responsive to touch inputs and the serial interface can easily handle the data back and forth (using buffered I/O). The only issues are I have a lot of code to convert (moving back and forth between 'C' and 4DGL syntax is a pain) and lack of a byte/char data type. It's been 20+years since I had to pack chars into words and vice versa. I can live without floats but no bytes?

            Comment


            • #7
              Hi dskogman,

              Using a single variable type makes it easier for beginners in programming to adapt easily without having to think about multiple data types. Type casting or conversion between data types can be achieved using additional routines, as you might have already done in your implementation. For handling strings, you might want to check the strings class functions under section 2.16 of the Diablo16 Internal Functions manual. These functions allow you to manage strings easily, without having to worry about converting between words and bytes.

              A number of Appnotes from this link can also help you through each process: https://www.4dsystems.com.au/appnotes

              Additionally, we also have built in ViSi examples in Workshop4 under File > Samples > Picaso ViSi

              There are forum posts as well that can help you in learning 4DGL or you can start a post so we can help you with the things that you’re having a hard time on. We’re always here to guide you in achieving your projects.

              Hope this helps and Best Regards,
              Eran

              Comment


              • #8
                The best architecture I've found is the diablo , on it's own with visi.

                Weve been using AVR's for years and my first use of the 4d stuff was with Visie Genie. we still make a metering device thats used the same visie genie program for years.

                Moving onto Visi seems , for me to be the best of both worlds , creating the graphics is easy and once done I can do just about anything I need to."so far", and the more I use it the more I can find I can do.

                I have project on my bench now thats controlling servos using the PCA9685 over I2C , as used on the adfruit module , bought on ebay for about 4 pounds.
                it's reading temperature from a Pt00 using a MAX3186 module over SPI and running a stepper via a microstep driver all at the same time with just the Gen 4 43 DT.

                It's a work in progress granted.

                The advantage for me is I only have to write one lot of code and don't have to bother with comms between screen and avr.

                Although , obviously there is no one answer , I found it worth the time and effort and the 4d staff have always been very helpful on the forum.

                You do have access to floats and bytes , (use the HiByte , LoByte functions. )

                Garry






                Comment


                • #9
                  After having moved a substantial amount of code to the Diablo using the Visi environment I will say you are right that there is a lot you can do on it directly. It is a capable processor in its own right. The response to touch input is much faster when done locally. The serial interface to the Arduino works well and has more than enough bandwidth.

                  The biggest impediment to productivity is the Frankenstein language syntax and lack of even a byte data type much less a string or float. It makes things much more complicated then they should be. Yes there are lots of functions to work around the limitations but it would make it much easier on the user if you didn't have to. A good example is the communication interface between the diablo and arduino. Communications interfaces (serial, ethernet, etc) are byte data streams. The code required on the arduino side is smaller and less complex than on the diablo side. Also, data on a display is a combination of strings, numbers and graphics. The arduino code to drive the diablo remotely is less complicated then doing it on the diablo directly.

                  I think more people would be willing to use the graphics processor directly if it used a standard language like the arduino.

                  Comment

                  Working...
                  X