1. Alasttt

    Thread Starter Member

    May 13, 2015
    68
    0
    Hi,

    I have some data that I want to transmit to a PC. I've been using a microcontroller writing c etc. However I was wondering does anybody know if there is such a chip that exists that would do this for me ?.
    i.e take pulses and transmit to the pc
     
  2. JohnInTX

    Moderator

    Jun 26, 2012
    2,342
    1,024
    Which microcontroller? Does it have a UART built in? Most applications like this use a uC with a UART on board. The UART signals interface to a PC's RS232 port using something like a MAX232 to do the level shifting.

    You could also use a microcontroller with built in USB capability or use something like an FTDI USB-UART interface chip to interface the uC's UART with USB.
     
    Last edited: Feb 10, 2016
  3. Papabravo

    Expert

    Feb 24, 2006
    10,138
    1,787
    What kind of pulses did you have in mind? Sorry my crystal ball is in the shop for repairs.
     
  4. Alasttt

    Thread Starter Member

    May 13, 2015
    68
    0
    A stream of 1s and 0s, 20khz freqeuncy, 0-5v I want to transmit the 1s and 0s to a PC. Is there a chip that could do this for me or do I have to program my atmega328
     
  5. Alasttt

    Thread Starter Member

    May 13, 2015
    68
    0
    I'm using an atmega328.
    It does have uart but I have to program it etc and its proving difficult. I was looking for a chip that does something along the lines of input my data into one pin and connect a uart to usb cabel on another pin and the data should flow to the USB pprt
     
  6. JohnInTX

    Moderator

    Jun 26, 2012
    2,342
    1,024
    Ah.. the magic chip - in the DIP package made of unobtainium. I don't know any of those. But, having problems with the UART on board the '328 shouldn't be a deterrent. Everyone here finishes all kinds of things that they didn't understand when they started them.

    What is the data you want to send to the PC? I assume the Atmega 328 is collecting it from something.

    Since you want USB and this chip does not have USB you will wind up doing something with the UART. If you had an external UART, you would still have to send data to that so why not use the one on board? Sure! Let's do that.

    The onboard UART will transmit data byte by byte in asynchronous format. To make that go into a PC with a USB port you need either:
    A MAX232 to generate RS232 voltage levels AND a USB->RS232 cable
    OR
    The FDTI chip which interfaces directly with the Atmega UART and makes USB happen. You can either buy the chip directly OR get one all ready to go from outfits like Sparkfun.

    If your PC does not have the old serial port with the DB-9 connector, I would use the FDTI/Sparkfun setup.

    EDIT: you'll have to show us what the stream of 1 and 0 looks like.
     
    Last edited: Feb 10, 2016
  7. Papabravo

    Expert

    Feb 24, 2006
    10,138
    1,787
    Believe me when I tell you that bit-baning 1's and 0' correctly framed for reception by a PC will drive you bats. Aside from the problem that PC's dont have ANY inputs that are compatible with 0-5V any more, I think you need to pay attention to JohnInTX. There used to be bi-directional parallel printer ports that people used, but they've been gone for almost a decade. You might be able to encode your data and send it in through the sound card but that would require some analog hardware work and more complicated programming so I would go with the on board UART in the ATMega328. You configure the UART, send the bytes one at a time, and you are done.

    How can we help?

    Example:
    The closest standard datarate to 20 kHz. that you can use to send data to a PC is 19,200 bits per second. Normally a UART wants to have a clock that runs 16 times faster than the datarate. OK swell -- 19,200 x 16 = 307,200. Now here is where things get tricky. You have a crystal running your processor and you need to divide it down to get something close to 307,200. How close? And how are you going to do that? Answer is that you need to be within 2% for reliable data transfer. First you divide your oscillator frequency by 307,200 and see how small the remainder is. If it is too big you can try a smaller datarate of you can "cook" your oscillator to be a multiple of -- you guessed it 307,200. The second answer is that you pour over it again and again until you grok the UART. That is all there is to it!

    In all my ATMega products I had two serial ports running, and I ran the processor at 7.3728 MHz. Can you tell me two reasons why I might have made that choice?
     
    Last edited: Feb 10, 2016
    JohnInTX likes this.
  8. NorthGuy

    Active Member

    Jun 28, 2014
    603
    121
    UART (most likely through UART-to-USB converter) is about as easy as it gets. Anything else will be much harder.
     
  9. hp1729

    Well-Known Member

    Nov 23, 2015
    1,948
    219
    Something as simple as a shift register? Synchronous or asynchronous? Byte at a time? 20 KHz? 19,200 is a standard baud rate for asynchronous UARTs. Would that do?
     
    Last edited: Feb 12, 2016
  10. ScottWang

    Moderator

    Aug 23, 2012
    4,853
    767
Loading...