Announcement

Collapse
No announcement yet.

Keyboard Object Question

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

  • Bigtim
    replied
    Hi Eran, the magic bytes method, looks very promising because:

    a) it uses the genie Arduino library which solves my first problem I think.
    b) Hopefully it will not suffer the same 'drop out' problem even though I am hooked up to com0 because it is using the displays internal routines to handle the COMMS.

    I am struggling a little to get my head around the example. Do you think it would be possible for you to build me a small demo that sends the message "Hello Arduino" when a button is pressed on the delay, receive this in the Arduino and have the Arduino send back a string (via magic bytes) to the display saying "Hi Display"

    I think if I can get those basics down, this might be the way to go.

    Thanks again for the help

    Tim

    Leave a comment:


  • Eran
    replied
    Hi Tim, those photos look promising!

    If you still need additional sample codes for the magic object, you can also take a glimpse of the sample under File>Samples>ViSi Genie Magic (Picaso/Diablo)>FileAccess.

    I'll wait for the results of your implementation with Magic Handler. Don’t hesitate to ask in case you encounter problems.

    Best Regards,
    Eran

    Leave a comment:


  • Bigtim
    replied
    Hi Eran, I'll take a look at the MagicHandler option. Do you think that because this uses the integrated display functions that fewer bytes will get 'lost/missed'?
    I think I noticed that the example that in the Arduino sketch the author is using a software serial out, do you know if in this project the software serial out was connected to Com0 or Com1 on the display? In the display code the author uses seroutCS is this a picaso command, I couldn't find it in the diablo reference?

    The good news is that whilst in version 1 of my device I don't have a access to a spare com port (either hardware or software) a) in future production runs I could b) In normal running mode there is not heavy traffic between the two devices, its only on start up and when the user is programming the controller that we need to be able to communicate.

    Just out of interest, I have attached a couple of photos of what we are building. As you can see we should have researched a software com port because now we committed this PCB adding one would be a pain



    Click image for larger version  Name:	20180208_145750.jpg Views:	4 Size:	2.51 MB ID:	63254 Click image for larger version  Name:	IMG_7485.JPG Views:	3 Size:	2.19 MB ID:	63255


    Last edited by Bigtim; 4th May 2018, 08:05 PM.

    Leave a comment:


  • Eran
    replied
    Hi Tim,

    A very useful example from this post can help you to make Magic object work. It uses a MagicHandler function on the Arduino side.

    https://forum.4dsystems.com.au/forum...er-application

    To communicate properly, the Arduino and the Display should run simultaneously and in sync with each other. This means that any delay or unrelated routines from either side may cause an unusual behavior to the other.

    You mentioned that the characters are missed when the display is not “looking” at the messages from the Arduino, and that is normal. The display won’t be “seeing” those messages for it is “looking away” while a message is being sent. By default, the Visi-Genie program uses COM0 for other things to communicate with the Arduino, so it is not really advisable to use the default Serial port of the display in this case. When the display is “looking away”, it is actually still communicating with the Arduino but doing things other than what you want it to look at. This means that when the display returns to looking at your messages again, one or two characters have already been sent but not noticed by the display. I hope you’re getting the picture, Tim.

    You can review the Magic code that I just sent you to know how to configure a serial port on the display side other than the default one.

    You can post your code (both sides) so I can simulate and help you debug for errors. Of course, that’s after you read the link that I just mentioned and decide on which course to take.

    Best Regards,
    Eran

    Leave a comment:


  • Bigtim
    replied
    Well I have made some progress today thanks to the links you sent me Eran, thanks for that

    Still two issues:

    1) the issue of whether I can use genie Arduino AND my own messages through the same com port.
    2) I have an issue with occasionally missing characters that are being sent.

    This is the code I am using to read the serial port:

    Code:
    if (serialStatus == 1)
    
       //repeat
    
        while (com_Count())
                inputCh:= serin();
                str_PutByte(comHoldingBufferPointer + inputCount ,inputCh);
                inputCount++;
        wend
    
        if (inputCh ==32)
            str_PutByte(comHoldingBufferPointer + inputCount ,3);
            //print ([STR]comHoldingBuffer);
            ANSI2Uni(str_Ptr(comHoldingBuffer),outBuffer) ;
            PrintStrings(1,outBuffer,1);
            inputCount:=0;
            inputCh:=0;
        endif
    
       //forever
    
    endif
    For now I am just using a <SPACE> character to terminate my message

    The above code is positioned in my main loop and it works, but every third or fourth message a character is being missed. I have a buffer set up in my post_gene_init insert point

    Code:
    com_Init(comBuffer, 128, 0);                                         // Setup COM0
    com_SetBaud(COM0, 960);
    If I uncomment the repeat forever lines in the code above then everyting is very stable. But of course nothing else in the project works (I'm stuck on this screen)

    It appears as if when I don't force the programme to stay permanently looking at the com port then the display misses inputs at the comm port when it is off doing other things? At first I thought it was the size of my project (lots of other forms and buttons) but even if I strip the project back to this form alone, then I get the same problem.

    I thought that using buffered comms would avoid this?

    Is there a way around the issue? or a way to improve my code or locate it somewhere different such that I stop dropping these crucial parts of my message?

    Leave a comment:


  • Bigtim
    replied
    Eran, whilst we are both awake

    Is there something fundamentally wrong with this:


    if (serialStatus == 1)


    inputCount:=0;

    while (com_Count())
    str_PutByte(comHoldingBufferPointer + inputCount ,serin());
    inputCount++;
    wend

    if (inputCount>0)
    print ([STR]comHoldingBuffer);
    inputCount:=0;
    endif

    endif

    Its almost working but when I send a string of say 4 characters, its very hit and miss as to the results that get printed. One in 10 times it gets the right 4 characters, most of the time it gets 2 or 3

    Leave a comment:


  • Bigtim
    replied
    My main problem is that I have built a bespoke PCB (with a deconstructed Arduino on it) and at this point I don't have access (headers) to any other Arduino pins. For production run 2 I might be advised to make another serial port available and use the software serial library.

    For now though I am stuck with the one. Is there any way I can format my messages from the Arduino such that the display will 'ignore them' and continue to handle standard genie library function messages?

    Leave a comment:


  • Eran
    replied
    Hi Tim,

    No Worries!
    You can use the digital pins to configure an additional software serial port other than the four hardware serial ports using the Software Serial library. Please see the sample code that I've just uploaded.

    Best Regards,
    Eran

    Leave a comment:


  • Bigtim
    replied
    I'm really intrigued about the magic object thing, thank you so much for the offer of help

    Leave a comment:


  • Bigtim
    replied
    Hi Eran, Two serial ports is a problem (I am using all four on the Arduino Mega) so I am stuck with only being able to use one port on the display Its not a show stopper but it would be quite nice if I could continue to use the genie Arduino functions along side my own messages down the same serial port. Do you think this will be possible?

    Thanks for the additional information I'll take a good look through all of that today to see if I can get the basic receiving of a message working properly

    Leave a comment:


  • Eran
    replied

    Hi Tim,
    The sample code that I sent you can only handle one digit at a time. When you want to make it handle more than one digit/character, you need to make a routine that would append the second buffered digit to the first stored digit.

    I suppose you already know how to do this in Arduino, but just in case you still need some backup information, you can read this: https://www.arduino.cc/en/Tutorial/StringAppendOperator or you can also use an array and convert it to an integer using the atoi() function if your buffered inputs only include numbers, that is.
    On the buffer of the display side, you can read these forum threads:
    https://forum.4dsystems.com.au/forum...es-with-serout
    https://forum.4dsystems.com.au/forum...uding-decimals

    As you can see in the latest sample code that I sent you, there’s a library Software Serial that lets you utilize other pins as your Serial ports (RX and TX). On the display side, it can also be implemented (Please review the code) using another serial (i.e. COM1) other than COM0 for COM0 is being used by default.

    Using the example that I sent you which utilizes a COM1 communication, the connection would be Arduino’s digital pin 6 to gen4 PA’s GPIO 6 and Arduino’s digital pin5 to gen4 PA’s GPIO 5.

    Regarding the Magic object object, yes. You can use it to send strings to your display and even make your own protocol in order to update your dynamic string. If you have already read much about this object, then it would be really beneficial to your project for it won’t need an additional serial port anymore.

    I’ll try making an example for you.


    I have attached a modified example that allows you to make use of two Serial ports. Don’t hesitate to ask for clarifications.

    Best Regards,
    Eran
    Attached Files

    Leave a comment:


  • Bigtim
    replied
    I have a feeling the first issue is something to do with the 2 byte word within the diablo, when I send 4 characters, I seem only to be adding 2 of them to the string! lol this is driving me nuts is there a neat way of handling this 2 byte word thing that I am missing?
    Last edited by Bigtim; 3rd May 2018, 06:42 PM.

    Leave a comment:


  • Bigtim
    replied
    Hi Eran, thanks for the help on the comms.

    I have managed to get a little further today but have 2 issues.

    I have adapted the code you sent to try and receive some data from the Arduino which is almost working. I am taking the data received and writing it to a string object. I am trying to use a buffered serial input on com0 of the display. When the count gets to double digits however, I am losing the second digit.

    I have attached the files and wonder if you could see what it is I am doing wrong as I am making no progress sorting it this afternoon.

    NB in the programme provided there is a toggle switch that needs to be turned on to enable my serial decoder (I added this due to the second question below)


    The second thing I have come up against today is what appears to be a conflict if I try and use the gernie aruduino functions such as genie.WriteStr( 0, input); alongside my own messages (like the counter in question 1. What I hoped to be able to do was mix my own messages in amongst genie Arduino messages which I already use quite extensively in a hack version of the product .

    You might notice in the Arduino script I am trying to send alternating messages using the genie Arduino function and a basic home made serial message via the same port (I only have one spare serial port on the Arduino) the two methods work fine when the other is commented out but if I try to use both then the process that is handling the genie Arduino stuff seems to grind to a halt.

    Since I can't see how the display is handling these messages, I'm guessing there is some code somewhere handling the genie library message that I am messing up by sending to or reading from COM0?

    Is there a way around this? Can I structure my messages such that I do not interrupt the genie library functions or will I have to choose one or the other method?

    I was reading a little today about the magic object object, can I use this to help me handle incoming serial message (hopefully without disrupting the genie Arduino messages?) the messages I will need to send and receive will range from simple 'command type messages' to quite long lists that I will need to receive/store and edit (eg to populate my list boxes)

    Hope that all makes sense and apologies again for the dumb questions.
    Attached Files

    Leave a comment:


  • Eran
    replied
    No worries Tim!

    You can read https://forum.4dsystems.com.au/forum/forum-aa/4d-systems-hardware/4d-intelligent-display-modules-diablo16/40191-serial-comunication-from-arduino-to-display-ulcd-70-dt to learn about the Communications between the Display and the Arduino.

    There is also a project in this section where Communications between the Display and the Arduino was needed: https://www.4dmakers.net/projects/de...evel-indicator.

    Attached is a working example.

    Best Regards,
    Eran
    Attached Files

    Leave a comment:


  • Bigtim
    replied
    Thanks for these examples Eran, you are very kind putting your time into providing these very comprehensive and practical answers to my questions. Thank you

    The last (hopefully ) piece of the jigsaw for my project is for me to start talking to my Arduino host. I can already use the gene library to select forms and update string objects etc, ie some basic interaction with the screen. My next challenge will be to set up some communication that will allow the Arduino to send the display a 'string' of data (to populate my list box) and for the display to at a later time send back the same or similar strings of data to the Arduino.

    Is there an app note that you could recommend to help with this? Would the best method be to use "ViSi-Genie Magic How to Read a File Arduino" as a guide?

    Thanks again

    Tim

    Leave a comment:

Working...
X