Communication options

Discussion in 'Embedded Systems and Microcontrollers' started by geoffers, Aug 18, 2011.

  1. geoffers

    Thread Starter Active Member

    Oct 25, 2010
    239
    6
    Hi all,
    I would like some advice on comunicating between a PIC and pc. I've not attempted this yet so my questions maybe basic. The outline of my project is a reader I've made to read ISO 11784/11785 tags. My latest version uses a PIC18f2523 with a 24lc512 serial eeprom added. This gives me capability to store up to 10,000 tags. I would like to be able to transfer the tag numbers to a pc, idealy to a spreadsheet. I'd like to know what my best options are? I see microchip do a chip to set up a usb port? However I've heard of people using the on-board UART and hyperterminal? Software advice at the pc end would be good to? Is there a simple way of getting my data into a spreadsheet? The tag number is stored in 6 bytes, one of which has to be separeted to interprate to give one two byte number and another 5 byte number. Would I have to send out 6 bytes or change the number into assci characters and send it as a 'decimal' number? Its easier for me to make changes to the pic as I kind of understand them! I programme in mpasm.
    Sorry for the rambling post, any advice would be welcome.
    Thanks Geoff
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,449
    3,365
    There are many options. The simplest that comes to mind is:
    if your PIC does not have USB, then use the UART output and convert to RS-232 interface.
    Connect directly to a COM port on your PC. If none is available, get a RS-232 to USB converter cable.

    To test the connection, use Hyperterminal.
    Convert all output into decimal strings.
    You can use Hyperterminal to Capture Text and save to a text file which you can read into your spreadsheet.

    Later you can use a utility which will allow the spreadsheet to read the COM port directly.
     
  3. geoffers

    Thread Starter Active Member

    Oct 25, 2010
    239
    6
    Thanks for that, been doing a bit of digging, microchips an774 would seem to go in the right direction, I already have the usb to serial adaptor for my picstart plus programmer. The max232cpe looks like a suitable chip to use for conversion to rs232 signals? Any thoughts or advice on using that setup would be welcome.
    Thanks Geoff
     
  4. kubeek

    AAC Fanatic!

    Sep 20, 2005
    4,670
    804
    Maybe you could avoid the double conversion to RS232 and back if you tap inside the the adaptor. The adaptor will likely have one chip that converts USB to UART and then another that converts UART to RS232, so it could be easier to tap in the uart than setting up a max232.
     
  5. geoffers

    Thread Starter Active Member

    Oct 25, 2010
    239
    6
    Hi,
    Thats a interesting idea, just popped the serial addaptor open and there are indeed two chips in there, tapping into them looks quite tricky though, lots of pins very close together, I've got a max3232cpe now so I think I'm going to tackle it that way.
    Cheers Geoff
     
  6. geoffers

    Thread Starter Active Member

    Oct 25, 2010
    239
    6
    Hi all,
    Now have the max3232cpe wired up to a 18f2523, I've configerd the usart according to microchips an 774 and wrote a programe to output a incrementing 8 bit number. The baud rate is set at 9600 in the code. At the moment I'm running the int osc at 4mhz. With my scope I can see the signal coming out of the max, its 15v peak to peak. Unfortunatly I'm getting nothing out of hyperterminal. When I connect up the serial lead to the max my nice clean looking signal turns into a messy looking thing. I've got the output of the max connected to pin2 on a nine pin rs232 to usb addapter, should the signal stay clean looking or is it normal to go all rough looking and I have a problem elsewhere?

    Thanks Geoff
     
  7. kubeek

    AAC Fanatic!

    Sep 20, 2005
    4,670
    804
    If you can, toggle another pin active when you send the char to trigger a stable trace on the scope, keep sending the same byte and see what it changes to when you connect the max3232.

    Also, do you have the signal levels and supply voltages right? Can you post a schematic?
     
  8. MrChips

    Moderator

    Oct 2, 2009
    12,449
    3,365
    When you are testing serial output for the first time, send binary 01010101 followed by a long pause such as 20ms and observe on the scope.
    Measure the single bit width to confirm correct baud, number of bits, start and stop bits, and voltage polarity.
     
  9. geoffers

    Thread Starter Active Member

    Oct 25, 2010
    239
    6
    Hi everyone,
    Thanks for the swift replies, been tinkering about with it, I got the 18f2523 to output 01010101, then changed it to 10101010, the bit length is 1.05-4 which by my sums is pretty close to 1/9600. It would appear I have one start bit high and a stop bit low? Is this right for rs232, I thought it should be start bit low stop bit high but I may have dreamt it?
    I might not have made it clear in my last post, The signal comes out of the max just fine, its when I connect up the rs232 to usb lead its goes fuzzy? The output from the max is roughly +/-8v or 16v peak to peak which I think is about right?
    Thanks Geoff
     
  10. kubeek

    AAC Fanatic!

    Sep 20, 2005
    4,670
    804
  11. kubeek

    AAC Fanatic!

    Sep 20, 2005
    4,670
    804
    Can you elaborate on the fuzziness? And please draw some schematic of how you have all the chips connected and powered, you could be having problems with ground loops.
     
  12. geoffers

    Thread Starter Active Member

    Oct 25, 2010
    239
    6
    Hopefully there should be a pdf attached with a basic schematic, I've left off the four capacitors for the max's charge pump, I've check their values and they seem to be right. By fuzziness I mean the nice square signal without the lead connected goes all spikey on the top of the positive side, the negative remains clean? If I dissconnect gnd(pin5 of the 9pin connector it cleans up again?)
    Thanks Geoff
     
  13. kubeek

    AAC Fanatic!

    Sep 20, 2005
    4,670
    804
    Have you tried it with just the gnd connected and not the data pin?
    Also check how does the 5V rail look like with and without the connections.
     
  14. geoffers

    Thread Starter Active Member

    Oct 25, 2010
    239
    6
    Hi,
    I get the same result by disconecting the rxd pin, fuzzy bit goes. Seems to only be there when its connected up. Just to check, I should have the output of the max connected to pin2 (rxd) of the rs232? The 5v rail is quite busy, theres a lcd and two transponder reader ics (they are both asleep when I test the usart though. Is there a easy way to check hyperterminal is working ok? The usb to 232 addaptor is working fine when I use it for my picstart plus, so I also know I'm checking the right com port.
    Thanks Geoff
     
  15. kubeek

    AAC Fanatic!

    Sep 20, 2005
    4,670
    804
    Yes you should have connected tx from max connected to rx on rs232.
    So is the 5v supply reasonably clean, and doesn´t change when you connect the rx?
     
  16. geoffers

    Thread Starter Active Member

    Oct 25, 2010
    239
    6
    Just put the scope on it and the 5v line stays nice and steady. However I have just found another usb/serial adaptor and that one doesn't affect my signal! But when I try to connect to com4 its not shown, begs the question as to which adaptors not working right?
    Thanks Geoff
     
  17. geoffers

    Thread Starter Active Member

    Oct 25, 2010
    239
    6
    Hi all,
    Not sure what my problem with the MAX3232cpe was. I've now got hold of a USB>TTL cable from rs in the uk. It works a treat, you can connect it right up to the pic's uart and the pc see's it as a comm port. For anyone like me (a bit simple?) its a easy way to do pc<>pic comms.
    Thanks for all your advice,
    Geoff
     
Loading...