Digital to ASCII conversion

Author
gvecino
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2013/11/05 08:20:32
  • Location: 0
  • Status: offline
2013/11/05 09:28:16 (permalink)
0

Digital to ASCII conversion

Good morning.
I am implementing and application that needs to read information from a sensor and have been resaerching on how to do it. I understand that the PIC Microcontroller will read the analog signal and convert it to digital. Is this digital signal being sent to the computer through the USB port a digital signal and converted to ASCII with a program within the computer? Does PIC Microcontroller provides and interface to translate digital signals to ASCII?
I am confused because, we are retriving information from a GPS and it seems that the information comes through the port as an ASCII Sentence, or it is a digital signal converted within the computer to ASCI, whit a software component.
According to my understanding, in order for me to read incoming information through a port I need to parse an ASCII sentence: which device generates this ASCII sentence? 
I will appresiate your advise. Thank you.
#1

14 Replies Related Threads

    tom maier
    Super Member
    • Total Posts : 2116
    • Reward points : 0
    • Joined: 2013/08/22 15:27:12
    • Location: earth
    • Status: offline
    Re:Digital to ASCII conversion 2013/11/05 09:49:02 (permalink)
    +2 (1)
    gvecino

    I understand that the PIC Microcontroller will read the analog signal and convert it to digital. Is this digital signal being sent to the computer through the USB port a digital signal and converted to ASCII with a program within the computer? Does PIC Microcontroller provides and interface to translate digital signals to ASCII?
     

     
    You can program the pic to send data either way, as raw binary or you can convert it to an ASCII string. Depends on what you want.
     
    gvecino
     
    I am confused because, we are retriving information from a GPS and it seems that the information comes through the port as an ASCII Sentence, or it is a digital signal converted within the computer to ASCI, whit a software component.
    According to my understanding, in order for me to read incoming information through a port I need to parse an ASCII sentence: which device generates this ASCII sentence? 


     
    GPS modules normally contain an embedded chip that will communicate with you through ASCII strings. They have a ASCII command language that allows you to talk to them.
     
    Does that answer the questions? It seems to be two separate questions.
     
    #2
    Ian.M
    Super Member
    • Total Posts : 13079
    • Reward points : 0
    • Joined: 2009/07/23 07:02:40
    • Location: UK
    • Status: offline
    Re:Digital to ASCII conversion 2013/11/05 09:50:49 (permalink)
    +2 (1)
    Most GPSes output a digital serial data stream following the NMEA0183 standard consisting of ASCII 'sentences' starting with '$' and terminating with <CR><LF>.   ASCII is a representation, not a type of signal.   All signals transferred by USB are digital. 
     
    You get to choose (and have to write code for) where the data is converted to or from ASCII.   It is generally hard to use ASCII formatted numbers directly for anything other than displaying to people so it is usual to convert them into binary numbers before calculating with them.
    #3
    gvecino
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2013/11/05 08:20:32
    • Location: 0
    • Status: offline
    Re:Digital to ASCII conversion 2013/11/05 10:11:54 (permalink)
    0
    Thanks for your response, it was straightforward and helpfull.
    Which tool would you recommend me, from the Microchip Development Tools, for prototyping these processes? Is any of these tools compatible with .NET programing?
    Thanks again.
    #4
    tom maier
    Super Member
    • Total Posts : 2116
    • Reward points : 0
    • Joined: 2013/08/22 15:27:12
    • Location: earth
    • Status: offline
    Re:Digital to ASCII conversion 2013/11/05 10:16:21 (permalink)
    0
    Ian.M

      It is generally hard to use ASCII formatted numbers directly for anything other than displaying to people so it is usual to convert them into binary numbers before calculating with them.



    Yeah, using ASCII data transfer is the slow way to do it, because the embedded chip has to ASCII encode the data, send it, and then the recieving end is normally just going to convert it back anyway. But using the ASCII strings overcomes problems of little-endian, big-endian, and other binary number conversions so the customer ends up with fewer problems and you end up with fewer support calls on the device. Normally there are fewer compiler idiosyncrasies in converting an ASCII string than a 24 bit binary number from some device.
     
    Unless you need the speed of raw binary data transfer, it is best to offer a full ASCII interface to the customer.
     
    #5
    tom maier
    Super Member
    • Total Posts : 2116
    • Reward points : 0
    • Joined: 2013/08/22 15:27:12
    • Location: earth
    • Status: offline
    Re:Digital to ASCII conversion 2013/11/05 10:18:37 (permalink)
    0
    gvecino

    Thanks for your response, it was straightforward and helpfull.
    Which tool would you recommend me, from the Microchip Development Tools, for prototyping these processes? Is any of these tools compatible with .NET programing?
    Thanks again.


    Can you describe exactly what you want to do? You have a GPS module and then what?
     
    #6
    gvecino
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2013/11/05 08:20:32
    • Location: 0
    • Status: offline
    Re:Digital to ASCII conversion 2013/11/05 10:22:33 (permalink)
    0
    Thanks Ian.M
    I am writing code in the .NET environment and in order to parse the string, incoming from the microcontroller - in this case, I need to use text characteres. So, the PIC Microcontroller will give me the option to create an ASCII sentence that I can pick up with my code?
     
    Thanks,
    #7
    gvecino
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2013/11/05 08:20:32
    • Location: 0
    • Status: offline
    Re:Digital to ASCII conversion 2013/11/05 10:45:44 (permalink)
    0
    Tom
     
    The GPS module was just an example. Currently I just need to understand how the microcontroller picks up the analog signal and send it through the pc port as an ascii sentence. Say to pick up a current that varies from 0 to 5 volts.
     
    Thank you,
    #8
    tom maier
    Super Member
    • Total Posts : 2116
    • Reward points : 0
    • Joined: 2013/08/22 15:27:12
    • Location: earth
    • Status: offline
    Re:Digital to ASCII conversion 2013/11/05 10:49:26 (permalink)
    +2 (1)
     
    To communicate from a pic controller to a PC there are two ways to do it:
     
    1.)  Use a pic with USB port built-in, and do a direct link to the PC. The pic will have to be programmed with USB interface software, and I've heard this is tricky to do. Never had to do it myself and have been trying to avoid it, if possible. Using this method your .net code would address the usb port either through it's own usb drivers or by a third party driver. Has you ever done communication to any device through the usb port?
     
    2.)  Use the rs232 port of the pic and then go to a USB to UART converter. This is how I normally do it because it is easy and less likely to drive you crazy. Using this method your .net software will address the pic through the serial port interface, as if you were talking to a device on COM1 or COM2. Have you ever dome serial port work through .net?
     
    The second option is the easy path.
     
     
    post edited by tom maier - 2013/11/05 10:51:18
    #9
    gvecino
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2013/11/05 08:20:32
    • Location: 0
    • Status: offline
    Re:Digital to ASCII conversion 2013/11/05 11:15:30 (permalink)
    0
    Tom,
    Will the PIC 18 Development kit (Part Number DV164136) work? I mean, as a tools to play and understand. Dos this board has the RS 232 port?
    #10
    tom maier
    Super Member
    • Total Posts : 2116
    • Reward points : 0
    • Joined: 2013/08/22 15:27:12
    • Location: earth
    • Status: offline
    Re:Digital to ASCII conversion 2013/11/05 11:54:46 (permalink)
    +2 (1)
     
    It's a good development system for pic18 and has a serial port, but the kit is designed for people who already have an understanding of embedded development. You would get lost in it.
     
    What you need is a "Welcome to Embedded Development" kit. Many companies make those, but not from microchip. I don't think any microcontroller manufacturer makes tutorials that start from the ground up, they assume you are already trained and their kits are to demonstrate the latest product.
     
    So you need a tutorial and a board that matches the tutorial.
     
    Anybody got suggestions? There is the gooligum.com site, but they only do pic16, right?
     
     
     
    #11
    NKurzman
    A Guy on the Net
    • Total Posts : 14957
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re:Digital to ASCII conversion 2013/11/05 12:55:34 (permalink)
    0
    "So, the PIC Microcontroller will give me the option to create an ASCII sentence that I can pick up with my code? "
    No you have to get the USB stack write code in C to read the A/D then output it what ever form you like.  It is not a trivial task.  And No the PIC does not support .Net
     
    If all you need is to read an analog value a cheap Dataloger may be a better choice.
    Unless you want to learn how to program PICs.
    #12
    tom maier
    Super Member
    • Total Posts : 2116
    • Reward points : 0
    • Joined: 2013/08/22 15:27:12
    • Location: earth
    • Status: offline
    Re:Digital to ASCII conversion 2013/11/05 13:13:09 (permalink)
    +2 (1)
    NKurzman
     
    No the PIC does not support .Net
     

     
    My pics support java. wink  I use java now on the pc side of things, but I've used many languages for interface in the past. Java doesn't natively support rs232, so there is an unsupported add-on package called "RXTX" that somebody wrote.
     
    NKurzman
     
    If all you need is to read an analog value a cheap Dataloger may be a better choice.
    Unless you want to learn how to program PICs.


     
    Yeah, what is the underlying objective here? If it is just to gather analog data then you don't need to learn embedded programming. There are data loggers and some might have .net interface packages (haven't checked, but seems likely).
     
    I never got into the .net programming.
     
     
    #13
    gvecino
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2013/11/05 08:20:32
    • Location: 0
    • Status: offline
    Re:Digital to ASCII conversion 2013/11/06 06:16:21 (permalink)
    0
    Good morning,
    Thanks for your help, I will try to describe my need in general terms. I am receiving an analog signal from a sensor (0 to 10 volts) and I need to convert this signal to a stream of ascii sentences that will give one of the fallowing discrete readings {1.0, 1.5, 2.0, 2.5, 3.0, 3.5 ... 20}; when the sensor reading vary between 0 and 10 volts. If the microcontroller is to cumbersome to achieve this trivial requirement. Which will be the most simple approach? There is one or several components that I can assemble to get the result I need?
    Thanks again, 
    post edited by gvecino - 2013/11/06 06:17:57
    #14
    tom maier
    Super Member
    • Total Posts : 2116
    • Reward points : 0
    • Joined: 2013/08/22 15:27:12
    • Location: earth
    • Status: offline
    Re:Digital to ASCII conversion 2013/11/06 06:27:24 (permalink)
    +2 (1)
     
    Welcome back...
     
    Yeah, you are going down the wrong path. There are data loggers that will make this job easy.
     
    It depends on the speed that you need. I'm guessing this sensor is pretty slow, so something cheap and simple will do the job. High speed and high precision equipment can get to be thousands of dollars, but I think you can find something for less than 150 usd.
     
    There is a company that makes some pretty good data loggers called "the HOBO series". Search google for HOBO datalogger. They can also give you tips on how to address it through your .net software. The two options they will give you are direct USB interface or serial port access using the USB to UART converter (sold separately).
     
    You wouldn't want to bother with trying to learn microcontroller programming for this, it would take you four months of hard work to get something going. With a HOBO, you will be up and running in 2 days.
     
    #15
    Jump to:
    © 2017 APG vNext Commercial Version 4.5