USB x RS232

General discussion on mikroPascal.
Author
Message
joseLB
Posts: 444
Joined: 02 Apr 2006 05:56
Location: Riode Janeiro, Brasil

USB x RS232

#1 Post by joseLB » 05 Oct 2006 00:13

I have a MP program that works well sending/receiving USART / RS232 data to a PC.
Any suggestion on how to convert it to USB, I mean, there is a simple way to simulate a serial rs232 port thu USB?
Last edited by joseLB on 11 Oct 2006 23:02, edited 2 times in total.

idakota
Posts: 334
Joined: 27 Sep 2006 08:07
Location: Pretoria/South Africa
Contact:

#2 Post by idakota » 05 Oct 2006 13:28

Good luck getting anybody to answer you joseLB....

These guys don't seem to care about their customers

jpc
Posts: 1986
Joined: 22 Apr 2005 17:40
Location: France 87

#3 Post by jpc » 05 Oct 2006 13:43

Hi joseLB,

what exactly would you like to do , if you use a PIC with USB interface you can convert serial to USB and the other way around , mPascal however does not deal with the PC-side software , for that you will have to build your own. You can however test it with the provided HID terminal. If you need a virtual comport implemented on USB this has nothing to do with programming the PIC.

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

#4 Post by zristic » 05 Oct 2006 14:30

idakota wrote:These guys don't seem to care about their customers
Please explain.

joseLB
Posts: 444
Joined: 02 Apr 2006 05:56
Location: Riode Janeiro, Brasil

#5 Post by joseLB » 05 Oct 2006 14:39

thanks jpc
Being more specific:
1- if I use HID routines provided with MP, I imagine that at the PC side things will be more complex, as I will have probably to develop some very specific interface USB /HID. I have no idea on how to deal with that. So, my question 1: Do you ave any tip or where I can find something about USB/HID/drivers, etc. at PC side? No matter the language.
2- on other hand, if I simulate on PIC serial rsr232 via USB, on PC side I guess I will have only to create a virtual com port, so, I will not need to develop anything else? So, my question 2: do you know how to do RSR232 thru USB simulation on PIC/MP?
3- today I have working a PIC/MP with real RS232 conected to a PC where I did a program to comunicate via RS232 and would like to do it thru USB. My question 3: is better to use HID (simpler PIC changes? / big PC changes?) ou RSR232 simulation (big PIC changes? / low PC changes?). That's the real question. As I have no idea of the dificultie to do rs232 simulation at PIC/MP neither the dificultie of doing HID at PC, I need all your help
Of course, i could use a USB x serial converter board, but that's the last solution, only if things start to become complex.
Thanks Jose
jose

joseLB
Posts: 444
Joined: 02 Apr 2006 05:56
Location: Riode Janeiro, Brasil

#6 Post by joseLB » 08 Oct 2006 00:09

Hi zristic
Do you have an working example on how at the PC side to acess a HID terminal? Could you put in this forum at least the part of the HID terminal code where the access to the USB is done?
Thanks, Jose

davekill
Posts: 52
Joined: 17 Sep 2005 22:13
Location: Preston, UK

#7 Post by davekill » 09 Oct 2006 12:59

Hi Jose,

I can send you my test application that I use to send messages to the PIC and retreive my software debug information.

The code is not very tidy, but I will help if you have any questions.

You will need the HID components that are part of the JEDI Delphi library.

Dave.

drdelphi
Posts: 19
Joined: 09 Oct 2006 08:33
Location: Romania
Contact:

#8 Post by drdelphi » 09 Oct 2006 13:35

There is a software from "mecanique" called "EasyHID" which you can use to generate Delphi / VB / VC++ code for handling HIDs.
h**p://www.mecanique.co.uk/software/EasyHID.zip

Good luck.
There are 10 types of people in the world. Those who can read binary and those who can't.

joseLB
Posts: 444
Joined: 02 Apr 2006 05:56
Location: Riode Janeiro, Brasil

#9 Post by joseLB » 10 Oct 2006 13:01

davekill wrote:Hi Jose,

I can send you my test application that I use to send messages to the PIC and retreive my software debug information. The code is not very tidy, but I will help if you have any questions. You will need the HID components that are part of the JEDI Delphi library.
Dave.
Thanks dave, I would apreciate very much your help, if you can send it. While Delphy is not my target (I'm using AutoIt at PC side), I think it can help. It can be sent at " joselb AT globo.com "
Jose
I'm seeing that to write USB code is a kind of very complex thing, even to get information. Good times the RS232 ones....
I can't believe that there is not a thing like command line programs, or even the code of part of the code From MikroE's HID TERMINAL...

joseLB
Posts: 444
Joined: 02 Apr 2006 05:56
Location: Riode Janeiro, Brasil

#10 Post by joseLB » 10 Oct 2006 13:04

drdelphi wrote:There is a software from "mecanique" called "EasyHID" which you can use to generate Delphi / VB / VC++ code for handling HIDs. h**p://www.mecanique.co.uk/software/EasyHID.zip
Good luck.
Thanks drdelphi, I downloaded the code, but as it's a instalable program and as i'm somewhat paranoic int install programs in my PC, do you have any documentation on this program?

drdelphi
Posts: 19
Joined: 09 Oct 2006 08:33
Location: Romania
Contact:

#11 Post by drdelphi » 10 Oct 2006 13:18

I took my chances and I installed it. With slight modifications I made it work with the demo of HID for 18f4550 that comes with mP. If you want I can mail you the source code in Delphi or give you the compiled version.
There are 10 types of people in the world. Those who can read binary and those who can't.

joseLB
Posts: 444
Joined: 02 Apr 2006 05:56
Location: Riode Janeiro, Brasil

#12 Post by joseLB » 10 Oct 2006 13:53

drdelphi wrote:I took my chances and I installed it. With slight modifications I made it work with the demo of HID for 18f4550 that comes with mP. If you want I can mail you the source code in Delphi or give you the compiled version.
I would apreciate very much if you could email me the source in delphi. joselb AT globo.com

drdelphi
Posts: 19
Joined: 09 Oct 2006 08:33
Location: Romania
Contact:

#13 Post by drdelphi » 10 Oct 2006 14:06

sent. everything you type in Edit1 will be forwarded back by the pic to Memo1.
There are 10 types of people in the world. Those who can read binary and those who can't.

joseLB
Posts: 444
Joined: 02 Apr 2006 05:56
Location: Riode Janeiro, Brasil

#14 Post by joseLB » 10 Oct 2006 18:41

drdelphi wrote:sent. everything you type in Edit1 will be forwarded back by the pic to Memo1.
Thanks, drdelphi, I received your zip. Now, of course, the doubs; :?: :roll:
1- mcHID.dll : this dll is a standard windows dll, or where I can get it?
2- the main form is atctivated when an USB event ocurrs?
3- the efective reading or writing is very simple, once your get the DevHandle of the device. An to get it seems to be very simple also

drdelphi
Posts: 19
Joined: 09 Oct 2006 08:33
Location: Romania
Contact:

#15 Post by drdelphi » 10 Oct 2006 19:15

Sorry, I've just noticed that mcHID.dll was missing. I found it in c:\program files\mecanique\easyhid\mchid.dll , but since you don't want to install easyhid yourself, then I'll send you the dll by mail.

As for the 2nd point, not the main form is activated when an usb event occur, but :
- first you hook the function USBEvent, which will receive all the system messages
- the USBEvent function will be called each time a system message occurs, and it will filter the messages, looking for USB HID messages
- then it will look if it's a "plug" message or "unplug"
- in the end, it will check if the device generating the event is the one it's looking for. To do that, it compares the VendorID and ProductID

You can change the values of the constants VENDOR_ID and PRODUCT_ID in the "const" section of FormMain.pas, but don't forget to also change these values for the pic side.

good luck
There are 10 types of people in the world. Those who can read binary and those who can't.

Post Reply

Return to “mikroPascal General”