Announcement

Collapse
No announcement yet.

Simulate: sensor data through serial + use it in own code

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

  • Doff
    replied
    Hi Magor,

    Thanks that part works fine, I mean it's able to get those data and shoe it on the screen, as the xamp and yamp also.

    I'm just a bit confused about the timing. What is the recommended preparation (maybe: timer interrupt?) to get the most proper/exact data timing on the display?
    I'm not sure about what you mean by "to get the most proper/exact data timing on the display". You are already using a buffer for the received bytes. Are you still losing data? Also, how are you sending data to the display? Perhaps you could post the Designer project and also give more information on what you're trying to achieve with it so we can understand the code better.

    Regards.

    Leave a comment:


  • kmagor
    commented on 's reply
    Thanks that part works fine, I mean it's able to get those data and shoe it on the screen, as the xamp and yamp also.

    I'm just a bit confused about the timing. What is the recommended preparation (maybe: timer interrupt?) to get the most proper/exact data timing on the display?

    regards: Magor Árvid

  • ESPsupport
    replied
    It's odd that you check char[0] for a value and then try to action/use char[1]. Surely the code, the way it is, can never actually load anything into char[1]?

    Leave a comment:


  • kmagor
    replied
    According to #6 I'm on my way to write my own serial.

    While i was testing it with a tank, i met with a problem. Here is the code:

    Code:
    com_Init(comRX,1024,0);
    com_SetBaud(COM0,960);
    com_TXbuffer(comTX, 100, 0);
    
    var cmd, char[50], j, i, frame;
    // var InputCS := 0 ;
    
    repeat
        if (com_Count() != 0)
            i := serin() ;
            print("\n",i);
            // InputCS ^= i ; // update checksum
            char[cmd++] := i ;
            if(char[0]==0x01)
                j:= char[1];
                print("j:",j,"\n");
                print(cmd,"\n");
                cmd := 0 ; //?? ---POINT A
            endif
        endif
    
        frame :=j;
    
        img_SetWord(hndl, iAKo, IMAGE_INDEX, frame) ; // where frame is 0 to 100 (for a displayed 0 to 100)
        img_Show(hndl,iAKo) ;
    If i comment point Ait works fine with the terminal for the first time.
    but it seems like my buffer do not goes empty afterthat. cmd will be
    3,4 5,6 7,8 etc... So its not going to refresh.

    So let's make cmd:=0;

    than if cmd>1 its just not get in the tank refresher if loop.

    each time when i send hex through serial is like: 01XX (XX in ced between 0 and 100)


    If ican refresh the serial i can recieve a lot of different messages, so i will be able to use those for alerts, for the scope etc...

    I hope you can help me out of this.

    Leave a comment:


  • kmagor
    replied
    Thanks i m going to take a look.

    Leave a comment:


  • Doff
    replied
    Hi,

    There are scope demos that come with the Workshop 4 IDE. Kindly go to:

    File -> Samples -> Picaso ViSi -> Scope.4DViSi

    File -> Samples -> Diablo Designer -> Scope.4dg

    File -> Samples -> Diablo Designer -> Scope2.4dg

    The examples show you how the scope object and the gfx_Scope(...) function are used. You can also refer to the internal functions manual for a description of the function. There is a basic codebase example for the scope object pending to be released. If you are interested, here is a link to the "pre-release" version (post # 6):

    http://forum.4dsystems.com.au/forum/...cope-functions

    The above examples should be able to answer most, if not all, of your questions. For instance, you will see that gfx_Scope(...) automatically handles the "old" array and that you will only have to worry about the "new" array. The examples also show that the sizes of the arrays correspond to the width of the scope object, that the arrays are word (and not decimal) arrays, how to update the values of the array, etc.

    Regards.



    Leave a comment:


  • kmagor
    replied
    So if i just click /paste code/: there gonna be 2 buffer. as it writes.

    Are these 2 buffers simple arrays? like old[?] and new[?]

    Lets say i recieved the needed values in an array. recieved[1000]

    recieved[0]--goes->new[0] ... untill .... recieved[999]--->new[999]
    so the program gonna be able to put it on the scope
    ,
    but lets say the scope is just 500pixel width, so the other 500 (this was the 1.-500. value so it has gone through the scope, these values has displayed and has written to the old[ ] )

    Which format of the value should be in new[ ]; Decimal is good?
    How much data can be stored in old[ ]


    Do i have to write the function for copying the data from new[ ] to old[ ]?

    If i wanted to change Xstep and Yamp , where should these parameters been refreshed? and also how is the refresh about new[ x ] ?

    thx: Magor

    Leave a comment:


  • Doff
    replied
    Hi Magor,

    It seems that you are trying to create a ViSi project with a scope object in it. Then you want to drive that scope by sending to it messages, the format of which is the same with that of the WRITE_OBJ messages sent to a scope object in a ViSi-Genie application. It seems to me also that you saved a ViSi-Genie project as a ViSi project, and now you are trying to analyse the code such that you could modify it and use it for your own purposes. These are my conclusions after reading your posts several times, am I correct? If yes, then here is my answer.

    The ViSi-Genie environment is defined as

    An advanced environment that doesn't require any 4DGL coding at all, it is all
    done automatically for you. Simply lay the display out with the objects you want
    (similar to ViSi), set the events to drive them and the code is written for
    you automatically. ViSi-Genie provides the latest rapid development experience from
    4D Systems.
    As you may already know, a ViSi-Genie project uses the ViSi-Genie communications protocol to talk to an external host. The protocol is documented in the ViSi-Genie Reference Manual.

    http://www.4dsystems.com.au/product/..._IDE/downloads

    The protocol defines the format of the messages to be sent to and received from the display. For instance, if you want to set the value of a scope object on the display to "50", you send it a WRITE_OBJ message with the correct parameters. If you press one of the keys of a keyboard object on the display, the display will send back a REPORT_EVENT message to the host.

    Note that the source code of a ViSi-Genie program is not meant to be 'seen' by the user. The hidden source code includes the implementation of the ViSi-Genie communications protocol. Of course you can see the code if you save a ViSi-Genie project as a ViSi project, which I think is what you did. You may have observed that the source code is highly optimised. This is to ensure that the program makes very efficient use of the target processor's resources. Consequently, this makes the source code very complicated. Explaining it would be most difficult, since it is meant to be hidden in the first place.

    Now if you wish to do your project in ViSi, I suggest that you implement your own protocol. You could imitate the ViSi-Genie communications protocol, but the actual 4DGL implementation would be up to you. Creating your own protocol would require knowledge of how serial comms is implemented in 4DGL. To get started, please refer to the examples that come with the Workshop 4 IDE. Go to

    File Menu -> Samples -> Picaso Designer -> PICASO-SERIAL COMMS

    The Diablo16 Internal Functions Manual will also help you.

    Another introduction to 4DGL serial comms is the codebase example

    4D-CD-00045 Designer or ViSi Goldelox Serial Communication

    http://forum.4dsystems.com.au/forum/...-communication

    Although this codebase example was written for and tested on a Goldelox display, the concepts are applicable to Picaso and Diablo16 displays as well.
    When you have grasped the basics, you should now be able to create applications such as

    ViSi SOMO-II Multi Form Demo (this one implements a library/protocol for talking to a SOMO-II device)
    Designer uCAM-II Demo for Goldelox Displays (this one implements a library/protocol for talking to a uCAM-II device)

    You could then implement your own protocol. Note that the SOMO-II and uCAM-II devices in the app note examples above are slaves to a master display. In your case, I presume that the display would be a slave or an intelligent device talking to host. However, the app notes should be able to give you further insight into how serial comms is done in 4DGL.


    Hope the above helps and regards.

    Leave a comment:


  • kmagor
    replied
    Hi again!

    So as i tried to figure out all this, i got here:
    1. In nutshell:

      i do not understand clearly this: p[oScopen[j+scDataPoints]-1] := NewVal ;


      cmd[3] << 8 + cmd[4] this is also not clear how the serin value is manipulated. I guess this is the proper way how u have to handle the data here. something because hexadecimals.
    2. And in a most proper way:

    I'm working is visi so i saved "visigeniescope" as visi, as you recommended:
    • serin() gives me the exact serial recieving.
    • we are using this line to store the data: cmd[cmdi++]:=i //line 535
      • so it seems like we will have all of the recieved data as cmd[0], cmd[1], etc.. its clear.
    • if ( (cmd[0] == WRITE_OBJ) // 6 byte write command (gen option)
      && (cmdi == 6) )
      if (InputCS)
      nak0() ;
      else
      WriteObject(cmd[1], cmd[2], cmd[3] << 8 + cmd[4]) ;
      serout(ACK) ;
      endif
      • these type of if/else lines are for reading obj. and writing objects and etc..
        Its also clear. NAK part also.
        I need to write to the scope so I went a head and see that:
    • WriteObj put this cmd[3] << 8 + cmd[4] in doScope func and it became as a var NewVal, wich became the newValue of the scope wich going to be displayed as the fresh new value. Thats cool. I got it. Sooo where do we store exactly this NewVal?. Here in doScope func. aswell.
      • so the concluison was this: p[oScopen[j+scDataPoints]-1] := NewVal ;
        • Here p is a pointer oScopen means a lot of data (the parameters of the scope)
        • j is a variable supposed to help us to use the identified scope j := ObjectIdx * SCOPEENTS ; //i dont know this SCOPEENTS
        • I dont know where can I find the bond between oScopen data (I cannot even identify wich exatly what i need) and between SCOPEENTS and scDataPoints
      • As u can see this part is a bit messy, if I can guess. we gonna write the income serin data to the place where this p pointer guide us, i dont really know this proper place, but im sure its gonna be the scope what we need.
        • I'm also not sure about this: p := tnew[curtrace] ; .. i guess it means that we store the income serin data as the NewVal into tnew array on the needed trace. but thats all im lost here.
    I guess maybe in the oScopen part the data what we need gonna be refreshed and "up to moment" and we use that fresh data in drawscope and do scope and the needed functions.

    Waiting for your answer: Magor

    Leave a comment:


  • ESPsupport
    replied
    The three environments you have lumped together are all completely different. The Serial protocol is completely different to the Genie protocol, ViSi has no protocol, you need to do everything yourself.

    If you are using one environment you can issue commands designed for another.

    There are several examples using serial in the File, Samples, Picaso Designer folders.

    There is plenty of documentation in the manuals.

    Perhaps the easiest way to see a 'complex' example is to create a simple Genie project with a single button, compile it and then save it as a ViSi program

    Leave a comment:


  • kmagor
    commented on 's reply
    So based on this App-note: http://www.4dsystems.com.au/download...0149_R_1_0.pdf
    I think the best is to use 1st the uSD and than read from the uSD the data into the flashbank and than send it to the scope.
    I think its better than just send directly to the scope, because I have to make changes with that measured values.

    But the direct way is also interesting for me cuz both of them should appear on my scopescreen.

    Thank you for helping me. Magor

  • kmagor
    replied
    Allright let's focus on the target more properly: My display (70DT) going to get massages trough serial, from the connected device. I have to put that message on the scope item. I got a whole menu structure and etc. in Visi, so the rest is to solve this.
    When i used genie and used the scope i just set the value to lets say 80 and the GTX tool sent is as the following: 01 19 00 00 50 48 And there it is explained that the first 2 number means WRITE_OBJ, and the 2nd numberpair means the scope. and etc..

    So I tried to send this trough the serial and it does not work. i get back only this as red: 15 ... so no ACK or anything else.


    I wanted to use my scope, but my code now in Visi. I guess i have to use the serial environment also. But yet I can only use visigenie to use scope.
    • What kind of message should fit to my scope? I got controll about how i send the messages from the decive to the display.
      - If I knwo what kind of massage should i send: than i hope i can simulate it trough the terminal.
    • And I wanted to store the measured data. So if the message arrived I need to store them somewhere somehow if I wanted to look back in the time in my scope with scaling (every 10th data shown not every 2nd)? I guess i have to change: RefreshIncrement to manage this kind of scaling out or zoom out and zoom in the scope. I hope that the data is stored (buffered? sorry about my english) automatically.
    • I also have to send parameters to the device. So now I feel like im missing some kind of appnote, like how to set TX/RX pin. And how can i exactly send message. (AND if I have to code this in serial how can that fit to the visi part)



    Leave a comment:


  • ESPsupport
    replied
    I'm not sure I understand what you want exactly.

    When using the terminal you can send and receive messages. For manually sending lots of different messages I often use cells in Excel to store the messages and just copy and paste (Not that a copied excel cell has a Cr on the end). Is that what you meant?

    Messages received in terminal can be copied and pasted to other places

    What is the 'storplace'?

    You said you are using the serial environment. Have you used Serial Commander? You can copy received messages from there and the commands are easily generated

    Leave a comment:


  • kmagor
    started a topic Simulate: sensor data through serial + use it in own code

    Simulate: sensor data through serial + use it in own code

    Hello!
    I wanted to simulate and recieve and use serial messages.

    I am simulating a lot of messages: what is the best way to store them?
    Can i use the terminal for simulate that properly?

    What is the way of recieving a serial message?

    So I will be able to recieve and store the messages. How can I implement them from the storeplace?

    I would be really thankfull.

    //Magor
Working...
X