Announcement

Collapse
No announcement yet.

Getting started with 4Discovery-50 and RS485

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

  • Getting started with 4Discovery-50 and RS485

    Hello!

    I've just started dabbling with a 4Discovery-50 and Workshop4.

    I'm designing a system that will consist of a 4Discovery-50 communicating with a Raspberry Pi over RS485. Think simple IOT functions such as dimming a light, choosing an RGB color, and other binary functions.

    I'd like to use Smart Widgets and I guess Genie Magic to simplify the creating of controls?

    However I can't seem to find some sample code to get me started on the RS485 communication to other devices. Is there documentation, or preferably examples I can study?

    Also, considering my system is quite simple, could I use the RS485 programmer connected to the Raspberry Pi as the interface for final deployment and ongoing use?

    Thanks!
    Phil
    Last edited by Phil_l; 1 week ago.

  • #2
    Good day!

    If you plan to connect the 4Discovery-50 to Raspberry Pi using the uUSB-485 Adaptor, you can simply use it as a simple Serial device.

    I would recommend using ViSi Genie to design your UI without coding required. We have a ViSi Genie Raspberry Pi library that you can use. There are some examples provided which will require minor modifications such as:
    • Changing the target display of the ViSi Genie project
    • Changing the UART port used in Raspberry Pi
    Smart Widgets provide a lot of customization for your custom widgets if you really have to but is often not required since we have several widgets available that has a predesigned layout.

    Another option is Serial (SPE) environment, due to the nature of the RS485 chip, this might be a better choice. SPE does not use events and therefore, the Serial communication is always half duplex.

    Here are some relevant libraries:
    Originally posted by Phil_l View Post
    Also, considering my system is quite simple, could I use the RS485 programmer connected to the Raspberry Pi as the interface for final deployment and ongoing use?
    Yes, you should be able to use the programmer. One thing you might want to check is whether the Raspberry Pi USB ports can supply the display with enough power.

    I hope this helps.

    Best Regards



    Juniel Cruz

    Comment


    • Phil_l
      Phil_l commented
      Editing a comment
      Thank you for the quick and thorough response Juniel.

      My Raspberry Pi program is running in Python, so I'm not sure I can use any C libraries, unless there is a way to bridge them?

      I will definitely be designing my own Smart Widgets, I need custom UI. I would like to design my UI elements in a GUI like Workshop4 Smart Widgets. However my functionality doesn't need to be complex. I need to make some sliders, binary switches, and maybe a colour picker control, and relay to the Pi which selections have been made, and ideally be able to change their state from the Pi in return.

      I need RS485, to ensure reliable signalling at a long range from 4Discovery-50. When you say "using the uUSB-485 Adaptor, you can use it as a simple Serial device" do you mean I would be using the RS485 programmer from the kit, and RS485 connection, but using it as a passthrough for regular serial commands?

      Phil

  • #3
    Hi Phil,

    My Raspberry Pi program is running in Python, so I'm not sure I can use any C libraries, unless there is a way to bridge them?
    You could try using ctypes which can be used to wrap compiled libraries in python. I haven't tried this before but it might be worth looking into.

    There is of course an option of simply writing your commands in your own python library. The ViSi Genie Reference Manual and Serial Command Reference Manuals should be enough to build one.

    I need RS485, to ensure reliable signalling at a long range from 4Discovery-50. When you say "using the uUSB-485 Adaptor, you can use it as a simple Serial device" do you mean I would be using the RS485 programmer from the kit, and RS485 connection, but using it as a passthrough for regular serial commands?
    Yes. That should work just fine. Physically, they are connected using RS485. But software-wise it would seem that you are only sending regular serial commands.

    Of course, this is only an option if you only plan to connect to the display.

    Best Regards

    Juniel Cruz

    Comment


    • #4
      Originally posted by Juniel Cruz View Post
      Of course, this is only an option if you only plan to connect to the display.
      Can you be more specific what you mean by this?

      The Raspberry Pi will always be directly wired to the 4Discovery-50, and it could use the uUSB-485 Adaptor permanently.

      Would I be able to use ViSi Genie and Smart Widgets to create a UI in Workshop4 Pro, then using simple serial commands, send my values back and forth from the 4Discovery-50 to my python program?

      I don't want to be drawing the UI from scratch from the Pi, and I only need to communicate the state of buttons and values back and forth.

      Phil

      Comment


      • #5
        Hi Phil,

        I mean exactly what I said.

        If the 4Discovery is the only device you plan to connect via RS485, then you can simply use is at simple serial device. But if you plan to add another device in the RS485 line, in multi slave setup, this further complicates things and would require additional programming. It looks to me that this is not the case in your project.

        Would I be able to use ViSi Genie and Smart Widgets to create a UI in Workshop4 Pro, then using simple serial commands, send my values back and forth from the 4Discovery-50 to my python program?
        Yes, you can do that. I recommend looking into GENIE_WRITE_OBJ and GENIE_READ_OBJ commands in the ViSi Genie Reference Manual.

        I don't want to be drawing the UI from scratch from the Pi, and I only need to communicate the state of buttons and values back and forth.
        You don't have to and we don't recommend you to do that either. I am not quite sure how you came to thinking you might need to do this but if this is because I mentioned Serial SPE, you can also design your interface in ViSi Genie and still use Serial SPE.

        I hope this helps.

        Best Regards
        Juniel Cruz

        Comment

        Working...
        X