Announcement

Collapse
No announcement yet.

New here with a couple of questions

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

  • huy373
    replied
    Hello,
    II need help, please. I cannot build my visi project as picture.
    Thank you so much.
    Huy
    Attached Files

    Leave a comment:


  • ESPsupport
    replied
    The first bit was just and example to show how the architecture addresses words not bytes.

    The second example shows the use of string pointer functions to reference the memory bytewise, this is the proper way to handle strings.

    Sorry, nibble has been replaced, no idea why I typed that.

    Leave a comment:


  • wanderer
    replied
    OK. That helped me out. Its still a rather confusing round-about way of doing things.

    If I write :

    mystring[2] := 0x324F ;
    print([STR] mystring, "\n") ;

    i have to remember that the the "2" and the "O" are backwards and I cant just modify the single position I want without knowing what the previous (next??) position contains.


    But if I write:

    i := str_Ptr(mystring) ;
    str_PutByte(i+5, '2') ;
    print([STR] mystring, "\n") ;

    then its not backwards. Why is that? And what is a nibble? I always thought a nibble was 4 bits.

    Thanks
    Tony

    Leave a comment:


  • ESPsupport
    replied
    Maybe it's because the underlying architecture is word sized rather than byte sized, this is fairly common these days, but obviously the first time you come across it it can be rather confusing.

    You can read about it in appnotes http://www.4dsystems.com.au/appnote/4D-AN-00047/ and http://www.4dsystems.com.au/appnote/4D-AN-00056/

    Here's some code to answer your question, or course there are other ways to do the same thing, you might like to try a few after you've read the app notes

    Code:
    #platform "uLCD-32PTU"
    
    #inherit "4DGL_16bitColours.fnc"
    
    func main()
        var mystring[10] ;          // enough to hold a string of 19 characters plust space fo the trailing 0
        var i, j ;
    
        to(mystring) ;              // write to my string and not the screen
        print("HELLO1") ;
        // could continue adding to mystring with to(APPEND) ;
        print([STR] mystring, "\n") ;
    
        // since variables are words and little endian, the 1 will be in the high byte of the 2nd word
        print([HEX4] mystring[2],"\n") ;    // 0x31 is ascii for 1
    
        // so we can change it by simply changing that word
        mystring[2] := 0x324F ;
        print([STR] mystring, "\n") ;
    
        // but that's really cheating, so lets do it a longer way
        i := str_Ptr(mystring) ;             // we need to work with string pointers
        j := str_Find(&i, "2");              // since we have previously changed the 1 to a 2
        if (!j)                              // j is a string pointer to the found string, or null if not found
            print("2 not found in string!" ) ;
            repeat forever
        endif
        print("2 found in position ", j-i+1, "\n") ;
    
        str_PutByte(j, '3') ;               // since we just want to change a single character we can simply do this
        print([STR] mystring, "\n") ;
    
        repeat
        forever
    
    endfunc

    Leave a comment:


  • wanderer
    replied
    Well you made it look easy. Very clever. Both of those code snippets work well and will be quite useful to me. I could never have figured it out.

    I have to say. I like your product very much but for me it has a steep learning curve. Things I expect to be difficult end up being quite simple for me to do, but things I expect to be simple end up being difficult. I picked right up on anything to do with graphics and the Touch functions. Likewise using Designer, I wrote some serial code to communicate with a controller board (of our own design) and it was a breeze for me. Its the string stuff that I just cant seem to grasp no matter how hard I try.

    The first code snippet you wrote, I almost completely understand. In the second code you wrote, I fully understand the first 5 lines but the last 5 lines have me completely baffled. Looks like Chinese. Once I figure it out and understand it I'll probably be in a much better position.

    This may seem like a dumb question but it will go a long way towards getting me to understand. Lets say I have a variable called mystring. I want to make mystring ="HELLO1" and print it. Whats the proper code? Then I want to replace just the "1" in "HELLO1" to a "2". Whats the proper code?

    Thanks for everything

    Leave a comment:


  • ESPsupport
    replied
    The way I was thinking of doing it was like this

    Code:
    #platform "uLCD-32PTU"
    
    #inherit "4DGL_16bitColours.fnc"
    
    func domath(var win)
        var r32[2] ;
        umul_1616(r32, win, 2000);
        return r32[1] ;
    endfunc
    
    func domath1d(var win)
        var r32[2] ;
        umul_1616(r32, win, 20000);
        return r32[1] ;
    endfunc
    
    func main()
        var res ;
        print([DEC3ZB] domath(32767), " ") ;
        res := domath1d(32767) ;
        print([DEC3ZB] res / 10, ".", res % 10, "\n") ;
    
        repeat                      // maybe replace
        forever                     // this as well
    
    endfunc
    This doesn't quite work for -ve numbers, but you should get the idea, I only use the high word of the result and not the full 32bits.

    For the full 32 bit number you could do something like

    Code:
        var i, x[2], str[20], strd[20], strf[20] ;
        i := str_Ptr(x) ;
        x[0] := 2 ;
        x[1] := 21 ;                                    // ultimately 1376258
        to(str) ;                                       // next print goes to string
        str_Printf(&i, "%10lu");                        // print as 10 digits
        print([STR] str, "\n");                         // print asis
        str_CopyN(str_Ptr(strd), str_Ptr(str), 5);      // send first 5 to decimal part
        str_Copy(str_Ptr(strf), str_Ptr(str)+5);        // send rest to fractional part
        print([STR] strd, ".", [STR] strf);             // now print decimal . fraction

    Leave a comment:


  • wanderer
    replied
    I used 1000lb load cell as an example. Sometimes we use 100lb load cell or 50 gram load cell so displaying to 2 decimal points is not unreasonable.. Any way I have been playing around with your method and it would work in some cases. Problem is I can't figure out for the life of me how to format and display the result of umul_1616. You have to jump through hoops to work with 16 bit numbers/strings with picasso and 4dgl. Using 32 bit numbers seems nearly impossible. Please tell me how to print/format the result of umul_1616 with a decimal point. I could do it with my eyes closed in visual basic or C or even in 8051 assembler.

    Leave a comment:


  • ESPsupport
    replied
    Also have a read of this thread http://forum.4dsystems.com.au/forum/...=1410301570805 It shows why you can't use 2 decimals, regardless of the accuracy of your sensor

    Leave a comment:


  • ESPsupport
    replied
    The resolution of '1' from your 'load cell' is 0.0305... so you cannot display a calculation accurate to 2 decimal places.

    I also suspect that the total accuracy is unlikely to be accurate to even 1 decimal place given the large range measurable.

    'It does not fit', as you put it, is a fact, there is no room to add floating point math to the Picaso processor.

    Also, there is something here that you might like to have a look at http://forum.4dsystems.com.au/forum/...-point-in-4dgl

    Leave a comment:


  • wanderer
    replied
    Oh well. As I figured there's no easy way around it. The only thing I can think of is a massive lookup table. I realize these display modules are not really meant to be used as stand alone systems but the possibility is there. The lack of floating point and the reason "It does not fit" does not hold water.As I said in my first post just about any high level compiler going back to the early days of CPU's, MPU's and MCU's had support for floating point. Granted it was not hardware based but in most cases it was quite useable, fairly fast and easy to use. Even some assemblers had floating point support - though they were klunky and cumbersome but useable. The person(s) who designed 4DGL should certainly be able to add a floating point variable type (in addition to others that are lacking in 4DGL) . I could probably do it if I had the incentive.

    Tony

    Leave a comment:


  • ESPsupport
    replied
    So if you multiplied the number by 2,000 using umul_1616, the high word will contain the number to 0 decimal places.

    Similarly if you multiplied by 20,000 the high word would contain the number *10 (i.e. to 1 decimal place)

    Unfortunate 1 you won't be able to get 2 decimals using this method (well, you can for less than 327.68 pounds with a lot of playing)

    Unfortunate 2 you will need to play with it a bit to get -ve numbers to work properly.

    Leave a comment:


  • wanderer
    replied
    As far as the calculation, I don't expect anyone to do my work for me but maybe you can point me in the right direction. I am "Bit-Banging" a 16 Bit serial analog to digital converter using the GPIO pins. The input to the AD converter is a 1000 Pound load cell. The output of the AD will be -32768 for -1000 pounds, 0 for 0 Pounds and 32767 for +1000 Pounds. Therefore each LSB of the output code represents 1000/32767 or .030518 Pounds. So if my AD converter was reading say 1250 my calculation would be 1250 * .030518 = 38.14813 Pounds which I would like to display to 2 decimal places, 38.15. Pounds.

    Thanks
    Tony

    Leave a comment:


  • ESPsupport
    replied
    Sounds like some sort of weird memory corruption, maybe.

    Can you use zip project and send it to mark at 4dsystems dot com dot au?

    We only make the larger displays with Diablo. If you are a volume customer you can order the OGM module which can have the smaller displays attached to it.

    Any chance of sharing the calculation?

    Leave a comment:


  • wanderer
    replied
    I am using 24PTU. Sometimes the form can be shifted as soon as I start Workshop. Other times it happens after I have added a few widgets. There's no rhyme or reason to it. One time the form appeared almost completely outside the display outline in the lower right corner

    You Mention Diablo.. Most of your application notes mention ULCD-28DT, uLCD-32DT and ULCD-70DT. What happened to ULCD-28DT. It does not appear on your products page?
    Thanks
    Tony

    Leave a comment:


  • ESPsupport
    replied
    Hmm, I can't seem to recreate this. What display are you using (looks like a 28-PTU), when does it happen?

    Picaso does not have Floating point and it cannot be added. Diablo OTOH does have floating point.

    What is the complete calculation you need to do? (include the valid ranges of the variables)

    ​I'll see if I can get it to work with integers.

    Leave a comment:

Working...
X