PIC Microcontroller selection help?

Discussion in 'Embedded Systems and Microcontrollers' started by twentyfour, Feb 21, 2012.

  1. twentyfour

    Thread Starter New Member

    Feb 21, 2012
    7
    0
    Hey guys,
    Ive been part of a forum before though (mechanical related) learned alot from posting and reading, I hope the same will come here.

    I'm working on putting together a project and all I have used in the past was PIC's 18f2420 8 bit MCU. I'm pretty familiar with this device and have yet to venture off into using any other MCU.

    The goal is to develop a device that will communicate with my computer information relating to the rpm/temp/(to be expanded) of an engine. I can interface sensors without help but but when it comes to usb/computer interfacing I need guidance. I have done rs232 to hyperterminal before but I would rather talk to a VB GUI or something so I can use the numbers in a spread sheet later on or display the information cleanly. I have made a couple forms in VB and am "ok" at it, not the greatest but I can eventually figure things out.

    To get started I purchased

    http://www.ebay.com/itm/150689787403?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649

    this guy hoping I could connect the UART of the PIC to it for $3 I didn't see how I could go wrong. As for communication, is everything transferred in 8 bit chunks or does it differ? Ive watched a tutorial of someone interfacing a device to a computer and they needed to set up some sort of parameters so windows knew what it was (kinda like that installing new hardware icon that pops up) along with addressing the correct software port in the computer? To be honest I don't know that much about talking to computers, when its mcu-mcu/or other IC's through spi/uart I'm ok with that.


    I was also looking at spi/uart wifi/bluetooth modules for later on after I figure out the usb thing and I begin to question weather my 8bit pic will do. Should I finally move up to 16 or 32 bit. I have done mcu-Xbee-Xbee-mcu but none of that requires talking to a computer like with the wifi module which I would like to eventually figure out for future projects.

    I have the pic kit 2 currently for debugging and I use MPlab with there C18 compiler.

    If there is any other easy to follow tutorials relating interfacing with a computer please let me know, also any other free software GUI's better then VB? I'm sure there is I'm just new to this industry so I don't really know where to look just yet.

    Thanks
     
  2. Felo

    Member

    Feb 20, 2012
    91
    13
    Hi, I have used VB with serial port extensively in PIC mcu, so you are well on your way, for your engine interface, I think that even a 16F family of PIC is well up to the task, a 18F is great, but upper families seem like an overkill. But, that is just my opinion. use what you are most comfortable with.

    Just dive into it and ask for help when you fin a tight spot, there are many talented people here willing to help
     
  3. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
    First thing is to assess what you have on the PC. Do you have a 9-pin COM port or only USB?
    It has been a while since I have used VB. Which version do you have? Does your VB have a COMM object?

    Serial from the MCU is the easy part. Any MCU will do the trick. Once we figure out what you have on the PC you're on your way.
     
  4. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,387
    1,605
    VB is probably still easier to use then VC, but they sure are making it harder. I sure do miss VB6

    The device you bought off EBay (how the heck do they even get the parts for that cheap?) should come with a driver that creates a "virtual COM port," meaning VB can talk to it like any other serial port on the system. Handy when your system doesn't have a serial port.

    While the PIC18F2420 doesn't have a USB module many PICs do, and you could save a few parts going direct from your PIC to your PC. Microchip has library code & examples to do just that.

    Finally, I sure do hope this engine is on a lawnmower or such as automotive modifications are not discussed here.
     
  5. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
  6. twentyfour

    Thread Starter New Member

    Feb 21, 2012
    7
    0
    Thanks for the input.

    As for the application, I hope to use this on my dirtbike (non street legal) they don't have instruments from the factory. Sure I could buy something but id rather make it and use it for my degree project next year.

    My PC does have the male DB9 output but I was hoping to go usb. As for OS I'm using win7, with 2010 Visual Studio (I earlier said VB, not sure if these are the same but I think they are similar).

    I browsed through the tool box in VS and I saw that it offers a serial port component. After I pull it into the form the properties given are

    name * (what you use to make use of it in the form)
    baud rate *
    data bits * (assuming this means the useable info in each frame) 8
    discard null
    dtr enable
    generate member
    handshake
    modifiers
    parity*
    parity replace
    port name* (address within computer assigned to software i think) COM1 in this case

    read buffer size
    read time out
    received bytes threshold
    rts enable (i dont think there is an individual RTS line so i left this disabled)
    stop bits * (i set it to one)
    write buffersize
    write timeout

    How I've set things up in the past..
    idle line is high, startbit is low,then lsb-msb(8 data bits),followed by pulling the line back high fairly standard. I haven't made use of the parity in the past because with the (mcu-mcu) communication I would just add in a check sum to the message for example
    [header][device id][lenght][ payload...][checksum] would be the setup of the string to send info.

    Can I use a similar approach to talking to the computer? I'm only familiar with the * marked listed properties or so I think ;). Not too sure what the other are for/if they are needed.

    To get started I was hoping to have a radio button when selected it would listen and display in a text box whats been received. I don't know what needs to be referenced to get a hold of the received info once I have the properties set up correctly. I'm assuming you need to use the name of the serial port tool.

    I have seen the usb PIC's but I have yet to get my hands on one also haven't used library's much because our prof made us read the data sheet and write everything which sucked but it was helpful in the long run.
     
  7. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
    Good to know that you still have a DB-9 COM port. Now you have a choice between RS-232 or USB. In either case you will need an adapter.

    If you go with RS-232, you will need a TTL-to-RS232 receiver/driver such as a MAX232.
    If you want to use the USB, a simple solution is to use that USB-to-TTL converter posted above.

    In either case, there should be no difference to VB. VB will treat either as a COMM object.

    The first step is to write a simple program on the MCU to send single characters. This can be tested on the PC using Hyperterm.
     
  8. twentyfour

    Thread Starter New Member

    Feb 21, 2012
    7
    0
    I've done hyperterminal-PIC through this com port in the past with MAX 232 which wasn't too bad. I was hoping to go USB just because its everywhere. I ordered the usb-ttl device so I'm just waiting on it to show up (snail mail, might be a while). I'm hoping to have the same results with the usb-VB form like I did with the db9-hyperterminal.
     
  9. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    I'd disable all of these, I don't know what all of them are, but dtr enable and handshake will either cause problems or be unnecessary.
    I'd be tempted to go for 2 stop bits - I think it gives a better chance of synchronisation between the devices if their frequencies happen to be a bit off.
     
  10. panic mode

    Senior Member

    Oct 10, 2011
    1,320
    304
    i was making terminals in VB6 and later VB.NET. there are plenty of code samples on the web but make sure that "received bytes threshold" is 1
     
  11. twentyfour

    Thread Starter New Member

    Feb 21, 2012
    7
    0
    ok sounds good, thanks again
     
Loading...