Results 1 to 6 of 6

Thread: Displaying and storing the ADC value obtained over serial port

  1. #1
    Join Date
    Aug 2010
    Posts
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Displaying and storing the ADC value obtained over serial port

    Hi guys


    I have wrote an user interface for interaction with the serial port and to display it's contents over the LCD display widget.

    Currently I am just sending a character and receiving a character in return.

    But now I want to add some extra functionalities to my user interface in which I want to let my user interface keep showing the changing ADC value of my microcontroller and also to store the first hundred readings of the ADC in
    a temporary buffer and than when user ask to save it than this data gets stored in a file like notepad.

    So can you people guide me the flow which I should follow and also which Qt classes will be most appropriate to me for my this task.

    Also I don't know that how to manage the buffer in the Qt.

    i.e. to store large amount of data and to store them on the harddrive and also to read them and to display on the display widget of the Qt.

    right now I just want to read the data coming from the ADC of my microcontroller over the serial port and than
    displaying it on the LCD widget of my User interface and than storing the first 100 values to a file when user ask
    to do so.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Displaying and storing the ADC value obtained over serial port

    If you want to store in memory, you can use QBuffer.
    But you could also just write into a QFile in all cases and just delete it if it is not "saved".
    Or write into a QTemporaryFile and copy/rename to the save file name on save.

    Cheers,
    _

  3. #3
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Displaying and storing the ADC value obtained over serial port

    Remeber that "serial port" is ordinary stream of bytes. The protocol defines how to interpret it. You must implement "protocol of the ADC" on receiver (application) side.

  4. #4
    Join Date
    Aug 2010
    Posts
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Displaying and storing the ADC value obtained over serial port

    Thanks anda skoa for your reply and suggestions

    Quote Originally Posted by Lesiok View Post
    Remeber that "serial port" is ordinary stream of bytes. The protocol defines how to interpret it. You must implement "protocol of the ADC" on receiver (application) side.
    lesiok I didn't get your point can you describe me your concern a little bit more clearly.


    Thanks

  5. #5
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Displaying and storing the ADC value obtained over serial port

    How this ADC sends data ? As single bytes or or any value is a few bytes. If this second how do you know when it begins a new value ? All of this is a protocol.

  6. #6
    Join Date
    Jun 2013
    Posts
    20
    Thanks
    8
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Displaying and storing the ADC value obtained over serial port

    to put it in a different way: Decide upon a way to send data. Most muC have either 8-bit or 16-bit ADCs. If you use an 8 bit adc it can be very easy as a serial port in general works on bytes. So each value that you receive on the the ComPort / serialPort on your PC is one value, that you can take, display and save directly (by using any kind of container, a ring buffer would be a good idea in your case). a 16 bit ADC needs you to combine 2 consecutive bytes. Demands a bit of logic but is essentially the same. Though very simple this is already a protocol. You can also think of a more complicated way to communicate between muC and PC depending on what you want to achive beyond just a few ADC values. You could for example use a char to indicate whether a value was send or a command, or any other information.

    Though unlikely you should always consider that your muC can be faster than your program, depending on the speed of your ADC, the things you do in your program and the general load on your Computer.

Similar Threads

  1. Serial read misses to read data from the serial port
    By mania in forum Qt for Embedded and Mobile
    Replies: 11
    Last Post: 18th August 2014, 09:49
  2. qt serial port
    By saman_artorious in forum Newbie
    Replies: 9
    Last Post: 24th April 2013, 17:19
  3. win32 API serial port in Qt4
    By jakr13 in forum Newbie
    Replies: 5
    Last Post: 15th February 2013, 10:33
  4. Serial port performance
    By marcvanriet in forum General Programming
    Replies: 1
    Last Post: 2nd January 2012, 13:40
  5. Serial Port
    By b1 in forum Qt Programming
    Replies: 2
    Last Post: 18th January 2007, 03:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.