Announcement

Collapse
No announcement yet.

From PIC to VISI Genie and 32DT

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

  • From PIC to VISI Genie and 32DT

    Dear 4D System team,

    Up to now i was using only serial enviroment and sent the vars on the 4D systems display.

    These days i would like to try Visi Genie, and external host from microchip a PIC18F26K22.

    i have built a nice small enviroment with Visi Genie, and at the moment the forms works as expected.

    Now i would like to send some variable values like Temp values from the PIC (host) to the 32DT.

    i have seen that document but it is for arduino (https://docs.4dsystems.com.au/app-no...0015_R_1_1.pdf). I guess they are using a library.

    May i have your help in order to understand exactly which set of command to follow?

    Many thanks in advance.

  • #2
    Hi,

    The Visi Genie Reference manual would be a good place to start,

    https://4dsystems.com.au/mwdownloads...ad/link/id/27/

    It explains the Visi Genie commands via serial and you can then write your PIC code following the described protocol.

    The GTX Tool under the Tools tab in Workshop can also be helpful as you can see the serial data sent to change an objects status on the display.

    If you are using C to program the PIC then you may be able to use the Visi Geine C library which you can download from here,

    https://github.com/4dsystems/ViSi-Genie-C-Library

    I hope this helps

    Best regards

    Paul

    Comment


    • #3
      Hi Paul,

      thanks a lot for your kind reply.

      I'm not using C, but PICBasicPro.

      GTX is a great tool and have used it in order to gather information regarding the serial data send for each Form.

      The only thing i want is to write the value of the Temp on specific area, like i do when i used SPE.

      I will follow the Visi Genie Reference manual and will try to see what is the command for my application.

      Thanks.

      Comment


      • #4
        Paul, i need your help.

        Using only serial command i was able to send viariable so simple like the following:

        temperature and remainder are both variable values from Sensor.

        Code:
        hserout [$73,$00,$02,$12,$00,$ff,"TEMP =", Sign,dec2 temperature,".",dec2 remainder,"*C",00]
        Hserin timeout,error,[wait(6)]
        I know that with Visi Genie might be even easier, but i would like to have a simple example if possible, because i'm a bit lost.

        I have 4 Forms, the Form 0 has 3 buttons that are connected to the Form1, Form2, Form3 respectively. I have gathered the information needed from a report message when the Form1 is active.

        In my speudo code i will say that:

        When Form1 is active then jump to Temp Display:

        TempDisplay:

        Code:
        hserout [$73,$00,$02,$12,$00,$ff,"TEMP =", Sign,dec2 temperature,".",dec2 remainder,"*C",00]
        Hserin timeout,error,[wait(6)]
        In the Visi Genie Manual there are protoco definitions, and really i cant undersntad which is the right one for my need.

        I dont mind to go to Pro version if required, but i would like your help in order to choose the right command.

        Click image for larger version  Name:	VG protocol.png Views:	2 Size:	78.4 KB ID:	73748
        Last edited by astasuleo; 22 September 2020, 06:41 PM.

        Comment


        • #5
          I would like to send the result of the temp var as shown below: marked in yellow.
          Attached Files

          Comment


          • #6
            Hi,

            That looks great.

            I don't have a ready made example for doing this and it is a little different to the Serial control you've been using before as it has a calculated checksum to send as the 6th byte of the genie message.

            I would guess that you are using a Strings object for the Ambient and Body temperatures so they would be Strings0 and Strings1

            So say for Strings0 you would be sending

            0x02, 0x01, 0x07, "22.7 C", 0x00 followed by a checksum of all of the previous values XOR'd together

            I looked at the MikroBasic manual and you have the 'xor' bitwise operator so you need to create a checksum using the above line of data for each individual character.

            Not sure how you would deal with the string in basic but it would be

            dim checksum as byte
            checksum = 0x02 xor 0x01 xor 0x07 xor '2' xor '2' xor '.' xor '7' xor ' ' xor 'C' xor 0x00

            You may need to check on this as I'm not sure if '2' would be the ASCII equivelant of character 2

            Ideally you would need to automate this process and determine the string length and the ASCII value of each character of the string

            Best regards

            Paul

            Comment


            • #7
              Hi Paul,

              thanks for the prompt reply. (i will do also the calculations with xor)

              I would guess that you are using a Strings object for the Ambient and Body temperatures so they would be Strings0 and Strings1
              no i'm using static text for Ambient and body. So in order to send those vars we need to use Strings objects?

              actually in place of the "22.7" will be a var value that is changing acording to the sensor. I have done all the calculations and seperated the 1st 2 places with the variable: temperature

              and the second two places after the "." with the variable: remainder

              Code:
              0x02, 0x01, 0x07, "22.7 C", 0x00
              So lets say i will use the string command in place of the "22.7" will be :

              0x02, 0x01, 0x07, dec 2 temperature".", dec2 remainder, "C", 0x00

              Have you any idea if Visi Genie command for the above string accepts vars?

              I thought that would be much easier to send variable values from PIC to screen via Visi Genie.
              Last edited by astasuleo; 4 weeks ago.

              Comment


              • #8
                Hi,

                It is supported in the genieArduino library as it will take variable and convert it into a string but as you can't use the library you will have to convert the variable into a string so that you can find the ASCII value of each character that you are sending to calculate the checksum.

                I will do more research into how this can be done in MkiroBasic

                Best regards

                Paul

                Comment


                • #9
                  Hi Paul,

                  thanks for the interest.

                  I will also try to do some research on it in the PBP3.

                  4D Systems have done so much work, and it is obvious that cannot cover all the customer's needs.

                  My request on this, is that this specific problem should be easier to handle, because most of the users that would like to use an external MCU, they have already done most of the code in there.

                  For me i use the screen because it helps me to use in no time, pictures, videos, sounds, touch buttons, forms, etc. Then i send vars to the screen from the pic.

                  This is in my opinion the most common application for many users.

                  If there is time for 4D Systems engineers and developers to add a simplest feature in Visi Genie in order to any user to be able to just send directly vars that would be great.

                  This is the form that would much for anyone.

                  via serial interface:

                  Code:
                  command : for the specific action
                  x               : position on the screen
                  y               : position on the screen
                  color         : color of the font
                  font           : use of any Windows font
                  var            : variable, that could be ,bit, byte or word or long
                  
                  and a sytax like you are always do:
                  
                  command,x,y,color,font,var
                  Then you will notice that will be a major solution for many programmers.

                  I know that this might take long time or it may not be possible to be done, but it is just a request.

                  Thanks once again.

                  Comment


                  • #10
                    Hi,

                    We do try to cover every customer needs and we have many environments to try to at least provide an alternative method where MCU's and programming languages are a bit unique or not as widely used.

                    On saying that. I very much like the MikroBasic and at the end of this, getting a method to work with genie will be great.

                    Visie-Genie writes to pre-defined objects so in this case it is a pre-defined string object so all we have to do is convert what we need to send to a string, calculate a checksum and send. This is where Genie differs from Serial as in the Serial mode you are sending a serial command to the display which is translated to a command to do a supported function on the display.

                    We already have the solution for programmers to do this in Genie. If you have the Pro version of Workshop, you can do exactly what you want essentially creating a method to send command, x, y, color, font, var using Magic bytes. This would still be as complex to achieve and would need some code to be written in Genie to handle the command sent which Pro allows you to do. This is easier to do with a supporting library on the MCU side but is also possible without a library just needs extra work.

                    Best regards

                    Paul

                    Comment


                    • #11
                      The only solution i see right now is to try to see how this could be done from host to visi genie.

                      Otherwise i need to wait for a simplest upgrade solution from 4D Systems. Hopefully in the near future will have this addon feature.

                      I understand that there is a solution via magic bytes, but still you need to use the ide and write a code in there as well.

                      Comment


                      • #12
                        wish there will be a library for picbasic pro, pbp3 people.

                        https://forum.4dsystems.com.au/node/72905

                        I know that most of the users goes to arduino or C, but there are many would like to have this addon library for pbp3.

                        Comment


                        • #13
                          i'm trying step by step to figure out how could i send command to the display.

                          The following is for people that would like PBP3 from melabs. PIC to 4D Systems display using Visi Genie.

                          Only one command is being used and CS is calculated very simple. Honestly i do not have much time this week but i will do my best to find a solution and send variables to the display.

                          The only thing i need is a pseudo style code from 4D systems in order to understand what it is needed to use in order to being able to send variables like TEMP values to the specific area on the display with a specific Font.

                          Thanks.

                          Code:
                           '*****************************************
                          '* Name : PIC18F26K22HM.BAS *
                          '* Author : LB                    *
                          '* Notice : Copyright (c) 2018 by L.B. *
                          '* : All Rights Reserved *
                          '* Date : 17/May/2020 *
                          '* Version : 1.0 *
                          '* Notes : PIC to 4D ulcd -               *
                          '*****************************************
                          
                          #IF __PROCESSOR__ = "18F26k22"
                          
                          @ ERRORLEVEL -306 ; this command prevents the compiler to give you a notice of *
                          ; crossing page boundary - make sure bits are set *
                          '*********************************************************************************
                          
                          #CONFIG ; The PBP configuration for the PIC18F26K22 is:
                          ; CONFIG FOSC = RCIO6 ; External RC oscillator
                          CONFIG FOSC = HSHP ; HS oscillator (high power > 16 MHz)
                          
                          
                          ;*---------------------------------4x PLL ENABLE--------------------------------------*|
                          ;* 4X PLL Enable *|
                          ; CONFIG PLLCFG = OFF ;Oscillator used directly *|
                          CONFIG PLLCFG = ON ;Oscillator multiplied by 4 *|
                          ;*------------------------------------------------------------------------------------*|
                          ;
                          ; Primary clock enable bit
                          ; CONFIG PRICLKEN = OFF ;Primary clock can be disabled by software
                          CONFIG PRICLKEN = ON ;Primary clock enabled
                          ;
                          ; Fail-Safe Clock Monitor Enable bit
                          CONFIG FCMEN = OFF ;Fail-Safe Clock Monitor disabled
                          ; CONFIG FCMEN = ON ;Fail-Safe Clock Monitor enabled
                          ;
                          ; Internal/External Oscillator Switchover bit
                          CONFIG IESO = OFF ;Oscillator Switchover mode disabled
                          ; CONFIG IESO = ON ;Oscillator Switchover mode enabled
                          
                          CONFIG BOREN = SBORDIS ; Brown-out Reset enabled in hardware only (SBOREN is disabled)
                          
                          ;*--------------------------------------------------------------------------------------------------------;|
                          CONFIG WDTEN = ON ; WDT is always enabled. SWDTEN bit has no effect ;|
                          CONFIG WDTPS = 32768 ; 1:32768 ---> HERE enable the watchdog timer with a 1:32768 postscale;|
                          ;*--------------------------------------------------------------------------------------------------------;|
                          
                          CONFIG PWRTEN = ON
                          CONFIG HFOFST = ON ; HFINTOSC output and ready status are not delayed by the oscillator stable status
                          CONFIG MCLRE = EXTMCLR ; MCLR pin enabled, RE3 input pin disabled
                          CONFIG LVP = OFF ; Single-Supply ICSP disabled
                          CONFIG XINST = OFF ; Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
                          CONFIG DEBUG = OFF ; Disabled
                          
                          ;*--------------------------------------------------------------------------------------------------------|
                          ;* | -------------------------- | |
                          ;* ----------------------------- | [PROTECTED OPTION FUSES] | ------------------------------------ |
                          ;* | -------------------------- | |
                          ;*--------------------------------------------------------------------------------------------------------|
                          
                          CONFIG CP0 = OFF ; Block 0 (000800-003FFFh) not code-protected
                          CONFIG CP1 = OFF ; Block 1 (004000-007FFFh) not code-protected
                          CONFIG CP2 = OFF ; Block 2 (008000-00BFFFh) not code-protected
                          CONFIG CP3 = OFF ; Block 3 (00C000-00FFFFh) not code-protected
                          CONFIG CPB = OFF ; Boot block (000000-0007FFh) not code-protected
                          CONFIG CPD = OFF ; Data EEPROM not code-protected
                          CONFIG WRT0 = OFF ; Block 0 (000800-003FFFh) not write-protected
                          CONFIG WRT1 = OFF ; Block 1 (004000-007FFFh) not write-protected
                          CONFIG WRT2 = OFF ; Block 2 (008000-00BFFFh) not write-protected
                          CONFIG WRT3 = OFF ; Block 3 (00C000-00FFFFh) not write-protected
                          CONFIG WRTC = OFF ; Configuration registers (300000-3000FFh) not write-protected
                          CONFIG WRTB = OFF ; Boot Block (000000-0007FFh) not write-protected
                          CONFIG WRTD = OFF ; Data EEPROM not write-protected
                          CONFIG EBTR0 = OFF ; Block 0 (000800-003FFFh) not protected from table reads executed in other blocks
                          CONFIG EBTR1 = OFF ; Block 1 (004000-007FFFh) not protected from table reads executed in other blocks
                          CONFIG EBTR2 = OFF ; Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks
                          CONFIG EBTR3 = OFF ; Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks
                          CONFIG EBTRB = OFF ; Boot Block (000000-0007FFh) not protected from table reads executed in other blocks
                          
                          #ENDCONFIG
                          
                          #ELSE
                          #MSG "Wrong Processor selected!"
                          #ENDIF
                          
                          ;*---------------------------------------------------------------------------------------------------------|
                          ;*---------------------------------------------------------------------------------------------------------|
                          define OSC 64
                          '#DEFINE MY_OSC 64
                          '#DEFINE ENABLE_SENSOR_1 ' Enable Sensor #1
                          'DHT_Sensor_1 var PORTC.2 ' Assign Sensor #1 Alias
                          '#IFDEF ENABLE_SENSOR_1
                          '#ENDIF
                          INCLUDE "modedefs.bas"
                          INCLUDE "ALLDIGITAL.pbp"
                          ' include "PBP3_DHT_LIB.BAS"
                          OSCCON = %01110000 ; 16Mhz
                          OSCTUNE.6 = 1 ; Enable 4x PLL
                          
                          while ! osccon2.7 :WEND ; to make sure the pll has stabilised before you run any other code
                          
                          '------------------------------------------------------------------------------|
                          ' INITIALIZE RAM |
                          '------------------------------------------------------------------------------|
                          initialize:
                          CLEAR
                          '-------------------------------------------------------------------------------------------------------------------------------------------------------------
                          
                          TRISA = %00000000 'use TRISA to specify which pin is (1 = input) and which (0 = output) (ALL pins are output)
                          TRISB = %00000000 'use TRISB to specify which pin is (1 = input) and which (0 = output) (ALL pins are output)
                          TRISC = %10000110 'use TRISC to specify which pin is (1 = input) and which (0 = output)
                          
                          '------------------------------------------------------------------------|
                          '----------------------- At start all PORTS LOW -------------------------|
                          '------------------------------------------------------------------------|
                          PORTA = 0 'make low all ports at A range |
                          PORTB = 0 'make low all ports at B range |
                          PORTC = 0 'make low all ports at C range |
                          '------------------------------------------------------------------------|
                          
                          '------------------------------------------------------------------------|
                          '-------------------------- COMPARATORS OFF -----------------------------|
                          '------------------------------------------------------------------------|
                          CM1CON0.7 = 0 'Disable comparator1 |
                          CM2CON0.7 = 0 'Disable comparator2 |
                          '------------------------------------------------------------------------|
                          
                          '*-----------------------------------------------------------------------------|
                          '*-----------------------------------------------------------------------------|
                          Timeout CON 2000
                          
                          Green var LATC.3
                          Red var LATC.4
                          
                          command var byte
                          contrast var byte
                          CS var byte
                          '*-----------------------------------------------------------------------------|
                          '* | --------------------- | |
                          '*----------------------- | EUART 1 Configuration | --------------------------|
                          '* | --------------------- | |
                          '*-----------------------------------------------------------------------------|
                          
                          DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
                          DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
                          DEFINE HSER_CLROERR 1 ' Clear overflow automatically
                          DEFINE HSER_SPBRG 160 ' 38400 Baud @ 64MHz, -0.08%
                          SPBRGH = 1
                          BAUDCON.3 = 1 ' Enable 16 bit baudrate generator
                          
                          '*-----------------------------------------------------------------------------|
                          '*-----------------------------------------------------------------------------
                          gosub lcdinit
                          main:
                          high red
                          pause 100
                          low red
                          pause 100
                          
                          goto main
                          
                          ' -----------------------------------------------------------------------------|
                          ' [ LCD Initialization ] |
                          '------------------------------------------------------------------------------|
                          ' FIRST TIME BOOTUP: We give plenty of time for tbe LCD '
                          lcdinit:
                          pause 2000
                          command = $04
                          contrast = $06
                          gosub checksum
                          hserout [command,contrast,CS]
                          hserin [wait(6)]
                          pause 100
                          
                          
                          high green
                          return
                          
                          '------------------------------------------------------------------------------|
                          ' CHECKSUM |
                          '------------------------------------------------------------------------------|
                          checksum:
                          cs = 0
                          cs = cs ^command
                          cs = cs ^ contrast
                          return
                          '------------------------------------------------------------------------------|
                          ' return to error |
                          '------------------------------------------------------------------------------|
                          error:
                          high red
                          PAUSE 10
                          return
                          
                          end

                          Comment


                          • #14
                            Hi,

                            I found information on page 525 of the manual http://www.farnell.com/datasheets/1681392.pdf about the conversions library and there is the FloatToStr routine which would convert the temperature as a float into a string.

                            So if you converted the temperature to a string like this

                            dim txt as string[22]
                            dim l as word
                            FloatToStr(temperature, txt)
                            l = strlen(txt)

                            Then you could access the individual characters by finding the value of the character in the string

                            schar = txt[0]

                            Comment


                            • #15
                              Originally posted by pauleilio View Post
                              Hi,

                              I found information on page 525 of the manual http://www.farnell.com/datasheets/1681392.pdf about the conversions library and there is the FloatToStr routine which would convert the temperature as a float into a string.

                              So if you converted the temperature to a string like this

                              dim txt as string[22]
                              dim l as word
                              FloatToStr(temperature, txt)
                              l = strlen(txt)

                              Then you could access the individual characters by finding the value of the character in the string

                              schar = txt[0]
                              Thanks Paul,

                              thats micro Basic from Mikroelektronika and not PBP3 from melabs.

                              micro basics has the feature to convert float to strings. I will check as well what is the method from melabs PBP3 to do that.

                              PBP3 doesnt have floats. So in order to use floating numbers we manage it as a word variable and then seperate this word to bytes. Calculations is being a bit strange but works.

                              Comment

                              Working...
                              X