Shop OBEX P1 Docs P2 Docs Learn Events
how to interface — Parallax Forums

how to interface

BebopALotBebopALot Posts: 79
edited 2006-03-11 21:52 in General Discussion
Hi folks,

I have recently constructed a measurement instrument with the SX and I need to evaluate the data that the SX is storing. Preferably I'd like to see it in my PC. Anyone have any ideas on what I should do to read the chip output to my PC? I need to transfer 12 bits from the SX every 10ms and go over the results later (such as a time interval of 1 second = 100 data points, not real time).

I am sure the tech boys have something for this?

Thanks in advance,

BBAL

Comments

  • David BDavid B Posts: 592
    edited 2006-03-09 16:11
    Part of the problem will be how hard is it to take your existing design and add communication to it.

    RS232 serial is often a good way to go because so many PC programs already are able to receive it. But adding it to an existing project may be hard because of the need to precisely time the serial bits.

    One way to send RS232 is to add a virtual periferal with an interrupt sending bits at the right time. If your design will not allow that, and if your project can spare the cycles, you could send RS232 from a separate function that sends bits with internal time delays. It kind of depends on what your existing project will allow.

    Would there be any harm to your project if occasional data bytes were lost? If not then maybe your SX could simply send a steady stream of bytes. If so then you might need to design a handshaking protocol of some sort.

    David
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-03-09 16:30
    If you are really tight on program space or cannot fit the RS-232 into a properly timed ISR thread, you might just use an outboard UART [noparse][[/noparse]another SX28] and move data to it in 8 parallel bits.

    Then the UART could stream the data to the PC.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)

    ······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2006-03-09 17:12
    Well, let's do some maths...

    100 data points / second with 12 bits resolution.

    Using RS232 means 10 bits to be sent serially per data byte, (one start - eight data - one stop bit). So for 100 data points, the speed is 2000 Bits/second (as you need to send two bytes for 12 bits) which is pretty low. The next faster standard baud rate is 2400 Baud. The SX can easily handle higher Baud rates than this. When you clock the SX at 50 MHz, 9600 Baud is still pretty slow (from the SX POV) but more than fast enough to handle your data throughput. So, I don't see the need for any additional hardware UART.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • BebopALotBebopALot Posts: 79
    edited 2006-03-09 19:05
    So Guenther I take it I can use the same SX that is doing the measurements to also serially transfer the results? Or would you use a second SX as mentioned tot ake the bits from the first SX and serve as a modem?

    Ok, so could I take this adapter[noparse]:([/noparse] www.awce.com/rs1.htm )to my breadboard and program the SX to talk to it and it to my computer?

    Post Edited (BebopALot) : 3/9/2006 8:03:02 PM GMT
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2006-03-09 22:18
    Usually, on the SX, a serial asynchronous transmitter is realized as Virtual Peripheral by software within an interrupt service routine. In case you have my book, you can find an example there - if not, please let me know, and I'll provide you with a link to the source code. I don't know the details about the acquisition of your data but I'm quite sure that the same SX can handle both, i.e. acquiring the data plus handling the serial communication to the PC.

    An adapter to shift the SXes 0/5V level to the -12/+12V RS-232 levels would be nice but not really necessary. You can find exsamples for alternative interfaces here in this forum.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • BebopALotBebopALot Posts: 79
    edited 2006-03-10 04:53
    Thanks Guenther, and I do have your book.

    Here is a great how to schematic : (go to page 4) www.parallax.com/dl/docs/cols/nv/vol6/col/nv125.pdf with the SX28.

    And if you don't want to buy the pieces individually, this URL has them pre-made to snap right into your board -www.awce.com/rs1.htm.

    On the PC side of it would you use hyperterminal , c or Java - which would you use?
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-03-10 06:50
    Modem? Modem! ! !

    I said UART, not modem.
    But, according to the Virtual Peripherals you could do a modem directly from an SX. It would take some more software of a different kind.

    I believe the technical challenge is to get the sound reproduced in good enough quality for the telephone.

    It certainly opens a different possiblity. Data sampling directly into a telephone line [noparse][[/noparse]and all in one chip].

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)

    ······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2006-03-10 16:47
    BebopALot said...
    Thanks Guenther, and I do have your book.

    Here is a great how to schematic : (go to page 4) www.parallax.com/dl/docs/cols/nv/vol6/col/nv125.pdf with the SX28.

    And if you don't want to buy the pieces individually, this URL has them pre-made to snap right into your board -www.awce.com/rs1.htm.

    On the PC side of it would you use hyperterminal , c or Java - which would you use?

    Here is another one w/o the need for a MAX-232: www.parallax.com/dl/docs/prod/schem/bs2revf.pdf.

    Which program to be used on the PC side mostly depends on the format you are sending the data points. When you send pure binary values from 00000000 00000000 up to 00000011 11111111, most terminal programs will have trouble as they interpret incoming data as coded characters, e.g. ASCII chars. You might use a terminal program to capture the incoming data into a file that you can read and interpret later with a program you would have to write. Maybe, you use VB to write an application that also handles capturing the incoming data because the MSComm object that comes with VB is pretty nice to handle.

    All what I'm saying here is kinda guesswork because you did not post any information about the format of the data points you are going to handle - this makes it difficult to give you a good hint.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • BebopALotBebopALot Posts: 79
    edited 2006-03-11 21:52
    Thanks Guenther. I'll repost if I need help troubleshooting the circuit. Once I have the adapter set up, I'll try and write an SX program for it. The I'll go to the other end try to write an interpreter.

    Kramer - you are a funny dude. I guess I did say "modem" which is technically that which you would use for a telephone. I know you will be really surprised to hear I really don't plan to do that, so I must admit my error in imprecise language!

    BBAL
Sign In or Register to comment.