It is currently 19 Nov 2018 14:52

All times are UTC + 1 hour




Post new topic Reply to topic  [ 729 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 49  Next
Author Message
 Post subject:
PostPosted: 29 Sep 2008 13:21 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3765
Location: Nieuwpoort, Belgium
Hi all,
A new unit has been added: the USB_HID_library.
See section "Units" on the website http://www.rosseeld.be/DRO/PIC/index.htm. The interface is somewhat different than the one of mE.
The "Descriptor" part of the "HID Terminal" tool is not used any more. In stead the descriptors are embedded in the library and adapted according the values set in the file "USB_HID_ProjectItems.ppas" (see further).

The main part of the unit's interface is:
{ ---------------------------- USB_HID Library Interface -----------------------

procedure InitUsb;
// Initializes USB HID and starts the uSB enumeration process.

function ConfiguredUsb: boolean;
// Returns true if the USB enumeration process was completed and successful.

function USB_HID_Read(DstPtr: ^byte; MaxLen: byte): boolean;
// Returns true if some data has arrived, false means: no data arrived.
// The arguments are:
//   DstPtr:  the address of the user defined receive buffer.
//   MaxLen:  the actual number of received bytes to be copied into the user defined receive buffer
//            (can be less than or equal to the size of the user defined receive buffer).

function USB_HID_Write(SrcPtr: ^byte; ByteCount: byte): boolean;
// Returns success as true, false means: try later again (USB sendbuffer was still busy).
// The arguments are:
//   SrcPtr:  the address of the user defined send buffer.
//   ByteCount:  the actual number of bytes to be sent
//              (can be less than or equal to the size of the user defined send buffer).

procedure DeInitUsb;
// Stops and disables USB HID.

procedure SoftDetachUsb;
// Disconnects USB from the "host" and connects it again,
// restarting the USB enumeration process.

As also mentioned on the web the following holds:
Quote:
Intended for the PIC18F2455/2550/4455 and 4550 PIC's or PICs with the same USB SIE.
Derived from the "TB054" publication of Microchip. No knowledge of USB "descriptors" required.
Warning: before usage one should delete "USBGenHID" from both the files "P18Fxxxx.mlk" and "P18Fxxxxdef.ppas"
in "C:\Program Files\MikroElektronika\mikroPascal\defs". Once deleted, a restart of mikroPascal is needed.
Example project: http://www.rosseeld.be/DRO/PIC/USB_Demo.ppas: the main (demo) project, and http://www.rosseeld.be/DRO/PIC/USB_Demo.ppp, the ppp file (8 Mhz crystal used).
Important: For each project using the library, a separate version of "USB_HID_ProjectItems.ppas" should be available (it is "used" by the library), residing the the project's directory itself. The libary itself ("USB_HID_Library.ppas") can reside in a common directory.

An example of usage:
program xxx;

uses USB_HID_Library;

var I: byte;
    ReceiveBuffer: array[5] of byte;
    SendBuffer:    array[5] of byte;
...

procedure InitMain;
...
end;

procedure interrupt;
begin
  USB_Interrupt; // <--- necessary call to the library
end;

begin // main
  InitMain;
 
  InitUsb; // Init Usb and start enumeration process
  repeat until ConfiguredUsb; // wait for the completion of the USB enumeration

  while true do // main loop
  begin
    // read data from the USB-HID interface and echo it
    if USB_HID_Read(@ReceiveBuffer, SizeOf(ReceiveBuffer)) then // USB data came in
    begin
      for I := 0 to SizeOf(SendBuffer) - 1
      do SendBuffer[i] := ReceiveBuffer[i]; // simply echo
      repeat until USB_HID_Write(@SendBuffer, SizeOf(SendBuffer)); // send
    end;
  end;
end.

The source code is published, so feel free to debug and enhance it!

Have fun. :D

_________________
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)


Last edited by Dany on 27 Oct 2010 09:53, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: 05 Oct 2008 09:07 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3765
Location: Nieuwpoort, Belgium
Hi, the "USB_HID_Library" has been updated:
- the strings identifying manufacturer, product and productversion have been moved to constant memory (defined now in "USB_HID_ProjectItems.ppas"), just like the ID's for vendor and product already were.
- The endpoint receiving data from the host is used now (EP1Out) in stead of the "set report" feature. The host will wait now until the out buffer has been read by the PIC's software.

Have fun! :D

_________________
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)


Top
 Profile  
 
 Post subject:
PostPosted: 11 Oct 2008 10:26 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3765
Location: Nieuwpoort, Belgium
Hi, the "USB_HID_Library" has again been updated (version 11-10-2008 now):
- some constant names have been changed to comply with those used by Microchip,
- the code for endpoint "GetStatus", "ClearFeature" and "SetFeature" has been corrected.

Have fun! :D

_________________
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)


Top
 Profile  
 
 Post subject:
PostPosted: 13 Oct 2008 20:53 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3765
Location: Nieuwpoort, Belgium
Hi all,
A new unit has been added: the "USB_CDC_Library".

See section "Units" on the website http://www.rosseeld.be/DRO/PIC/index.htm.

Please read the documentation present on the website.

On the website also the necessary PC software (including sources and executable) and the windows driver can be found.

Have fun!

_________________
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)


Last edited by Dany on 27 Oct 2010 09:54, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: 15 Oct 2008 15:23 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3765
Location: Nieuwpoort, Belgium
Hi all,
A small article has been added about the clock settings for USB PIC devices. This activity is not so easy if one has to do it for the first time (as I did a short while ago). :shock: I hope this article helps somewhat.
See section "Tips" on the website http://www.rosseeld.be/DRO/PIC/index.htm.

Have fun. :D

_________________
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)


Last edited by Dany on 27 Oct 2010 09:55, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: 16 Oct 2008 15:17 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3765
Location: Nieuwpoort, Belgium
Hi all,
A small article has been added about the usage of mE's USB HID library.
See section "Tips" on the website http://www.rosseeld.be/DRO/PIC/index.htm.

Have fun! :D

_________________
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)


Last edited by Dany on 27 Oct 2010 09:55, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: 17 Oct 2008 20:38 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3765
Location: Nieuwpoort, Belgium
Hi all,
The unit "StrngUtils" has been extended with these two:
procedure WordToHexStr(Val: word; var S: string[4]);
// Converts a word to its hexadecimal string representation

procedure LongintToHexStr(Val: longint; var S: string[8]);
// Converts a longint to its hexadecimal string representation


Have fun. :D

_________________
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)


Top
 Profile  
 
 Post subject:
PostPosted: 28 Oct 2008 13:05 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3765
Location: Nieuwpoort, Belgium
Hi all,

The "PC side software" for use with the "USB_CDC_Library" has been changed: the serial port "writetimeout" has been adapted (= not zero any more). Reason: better write synchronisation from PC to PIC.

The write speed (pure transfer speed with only a "read buffer" at the PIC side) to the PIC (with my PC anyway) is now about 250 kB/sec. I intend to (in the future) make a library that uses the so called ping pong buffer method, which should make the speed approximately twice as high.

Have fun! :D

_________________
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)


Top
 Profile  
 
 Post subject:
PostPosted: 04 Nov 2008 10:56 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3765
Location: Nieuwpoort, Belgium
Hi, I did correct a small string descriptor problem (only a potential problem, not an actual one yet) in both the USB (HID and CDC) libraries.

Have fun! :D

p.s. progress on the "CDC ping pong buffer" project (I get further in the enumeration procedure now) , but not working yet. :cry:

_________________
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)


Top
 Profile  
 
 Post subject: LCD1602 Lib
PostPosted: 09 Nov 2008 17:14 
Offline

Joined: 24 Sep 2008 14:43
Posts: 11
Location: Netherlands
Dany,

First of all .. many thanks for your nice libs ..
I started to use your libs one by one .. and leave the "blind" libs of mikroe more and more behind, because you made it open source .. and see what happens .. I now use your 1602 LCD lib and noticed that some HD44780 type controllers need the "set it in 4 bits interfacing mode with 2 lines" commands twice .. With your lib i was able to find the correct line .. and double it in your code .. and your lib works now fine with my type of display too ...

So .. tip for users of your lib that get only one line in their LCD.

double the line :
  Lcd1602Send(LCD_FUNCTION_SET + LCD_4BIT_INTERFACE + LCD_2LINES);  // 4 bits mode, 2 lines
  Lcd1602Send(LCD_FUNCTION_SET + LCD_4BIT_INTERFACE + LCD_2LINES);  // 4 bits mode, 2 lines

In the initialisation procedure.

Again .. many thanks .. Dany .. for sharing your nicely written and documented libs ..

Grx....

Eric


Top
 Profile  
 
 Post subject: Re: LCD1602 Lib
PostPosted: 10 Nov 2008 08:40 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3765
Location: Nieuwpoort, Belgium
velobyte wrote:
I now use your 1602 LCD lib and noticed that some HD44780 type controllers need the "set it in 4 bits interfacing mode with 2 lines" commands twice ..
Hi, thanks for the compliments. Do you have an idea why some controllers need the command twice?
Thanks in advance. :D

_________________
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)


Top
 Profile  
 
 Post subject:
PostPosted: 10 Nov 2008 09:30 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3765
Location: Nieuwpoort, Belgium
Hi, I did a change in the USB CDC library: made send (PIC -> PC) speed better.
The speeds are now (without additional data processing in PC or PIC):
from PC -> PIC: 250 KB/sec
from PIC -> PC: 270 KB/sec

Have fun. :D

_________________
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)


Top
 Profile  
 
 Post subject:
PostPosted: 11 Nov 2008 15:23 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3765
Location: Nieuwpoort, Belgium
Hi, a small change in the USB HID library: enumeration is much faster now. :D

_________________
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)


Top
 Profile  
 
 Post subject:
PostPosted: 12 Nov 2008 08:24 
Offline

Joined: 07 Dec 2006 11:00
Posts: 317
Location: Vienna, Austria
Dany wrote:
Hi, a small change in the USB HID library: enumeration is much faster now. :D


Hi, Dany!

Because Windows is not what I name an operating system, I use Linux. Did you ever test your library with Linux?
I know that many USB<->Serial converters are really PnP in Linux and are supported without any changes or additional setups in the OS. When plugged in, a new /dev/ttyUSBnn appears, that's all. This is what I am actually looking for since at least 1.5 years: A lib making a PIC appear as such a "serial port" when plugged in, so that I can talk to it.

Does this work? I have neither the right PIC here nor a board for testing (will have to build one), so my only option is to ask. If you confirm that it really works as I need, it is worth to build up a testing environment.


What I also would like to know:
Does your library work transparently in the background (means: interrupt controlled and giving me an Rx and Tx buffer to be read from/written to from my application), or must I run a daisy loop as fast as possible and repeatedly poll/execute a USB-procedure (makes programming more complicated)?
Please, be so kind and leave me some details.

Rainer


Top
 Profile  
 
 Post subject:
PostPosted: 12 Nov 2008 10:23 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3765
Location: Nieuwpoort, Belgium
rainer wrote:
Because Windows is not what I name an operating system, I use Linux. Did you ever test your library with Linux?

Hi Rainer,
No I did not test it on Linux (I do not have it available on my PC). :?

rainer wrote:
I know that many USB<->Serial converters are really PnP in Linux and are supported without any changes or additional setups in the OS. When plugged in, a new /dev/ttyUSBnn appears, that's all. This is what I am actually looking for since at least 1.5 years: A lib making a PIC appear as such a "serial port" when plugged in, so that I can talk to it.

Does this work? I have neither the right PIC here nor a board for testing (will have to build one), so my only option is to ask. If you confirm that it really works as I need, it is worth to build up a testing environment.
I will ask a test to someone using Linux. I let you know the result asap.

rainer wrote:
What I also would like to know:
Does your library work transparently in the background (means: interrupt controlled and giving me an Rx and Tx buffer to be read from/written to from my application), or must I run a daisy loop as fast as possible and repeatedly poll/execute a USB-procedure (makes programming more complicated)?
Please, be so kind and leave me some details.
It works as you say transparently in the background, acting like any ordinary serial port, you do not have to execute any USB related procedure. :D

_________________
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 729 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 49  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: