It is currently 26 Jun 2019 03:51

All times are UTC + 1 hour




Post new topic Reply to topic  [ 729 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8 ... 49  Next
Author Message
 Post subject:
PostPosted: 24 Dec 2008 13:03 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3779
Location: Nieuwpoort, Belgium
Hi,
A new library has been added to the website: the USB "HID" Joystick library, C version. The author is Fabio Silva (known as "Fabim" on this forum).
See the website, section "PIC Units".
Thanks Fabim! :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: 26 Dec 2008 11:17 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3779
Location: Nieuwpoort, Belgium
Hi All, the "BitUtils" library on the website has been updated with a few additional procedures, capable of manipulating "bit fields" (of more than 1 bit wide) within a byte: the "Bit Stuff" functions.
The interface of the unit is now:
    ------------ "Bit" functions ----------------
  // The two following functions translate a byte expression into a "bit" value (1 or 0).
  function Bit(B: byte)    : TBit;    // returns the "bit" value of B
  function NotBit(B: byte) : TBit;   // returns the inverted "bit" value of B


  ------------  Bit "Mask" functions ------------

  function BitMaskByte(Bitno: byte): byte;
  // Returns 2 to the power "Bitno": e.g. "BitMask[2]" equals "4".
  // Used to perform and and or functions to test, set or clear certain bits in a byte bits variable,
  // e.g. Var1 := Var1 or BitMaskByte(7); // set bit 7 in Var1
 
  function BitMaskWord(BitNo: byte): word;
  // Returns 2 to the power "Bitno": e.g. "BitMask[2]" equals "4".
  // Used to perform and and or functions to test, set or clear certain bits in a word variable,
  // e.g. Var1 := Var1 or BitMaskWord(12); // set bit 12 in Var1

  function BitMaskDWord(BitNo: byte): Dword;
  // Returns 2 to the power "Bitno": e.g. "BitMask[2]" equals "4".
  // Used to perform and and or functions to test, set or clear certain bits in a word variable,
  // e.g. Var1 := Var1 or BitMaskDword(20); // set bit 20 in Var1

  // The three following functions return the inverted value with respect to the three above
  function BitMaskByteNot(Bitno: byte): byte;
  function BitMaskWordNot(BitNo: byte): word;
  function BitMaskDWordNot(BitNo: byte): Dword;
 
 
  ------------  Bit "Stuff" functions ------------
  procedure StuffBits(var Bte: byte; Val, BitNr, Size: byte);
  // Sets the bits in "Bte", starting with "BitNr" and "Size" bits wide, to the value "Val"
 
  procedure ClearBits(var Bte: byte; BitNr, Size: byte);
  // Clears (set to 0) the bits in Bte, starting with "BitNr" and "Size bits wide.
 
  procedure SetBits  (var Bte: byte; BitNr, Size: byte);
  // Sets (set to 1) the bits in Bte, starting with "BitNr" and "Size bits wide.
 
  function GetBits   (Bte, BitNr, Size: byte): byte;
  // Returns the value of the bits in Bte, starting with "BitNr" and "Size bits wide.

All procedures manipulate (or get) the bitfield in byte "Bte". The bitfield starts with bit "BitNr" and is "Size" bits wide.
So a call like StuffBits(MyByte, 6, 2, 3) will set bits 2..4 in byte "MyByte" to the value 6. All other bits in Bte are unchanged.

The reason for making these functions is mainly the fact that e.g. PIC Option bytes or Timer registers make use of bitfields to identify their settings. The routines above make filling those fields more easy.

Have fun.! :D

p.s.: added on 2008-12-30: function "GetBits"

_________________
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 30 Dec 2008 12:56, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: 26 Dec 2008 23:33 
Offline

Joined: 26 Dec 2008 23:31
Posts: 25
Hi mate,

Just found this site of yours and just wanted to say thanks. :)

Merry xmas
Smurff (Danny)


Top
 Profile  
 
 Post subject:
PostPosted: 27 Dec 2008 00:58 
Offline

Joined: 25 Jun 2007 16:50
Posts: 47
Hi Dany,

I used many hours to do bulk test on your CDC USB Library. Yes, it is working. But the speed still the same (about 64KB/s).
Now, I really think something limited the speed (PC->PIC). But PIC->PC speed is ok (i don't test on bulk, but cdc speed over 300KB/s).
No idea how to fix it now. :(

-Tomy


Top
 Profile  
 
 Post subject:
PostPosted: 27 Dec 2008 10:13 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3779
Location: Nieuwpoort, Belgium
Hi all,
A small library has been added to the website: DS1820.ppas. It provides the basic functions for the DS1820 temperature sensor, including ready to display string output. The interface:
{ interface

  function DS1820_StartTempConversion(var Port_: byte; Bit_: byte; Wait: boolean): boolean;
  // Starts the temperature conversion of a DS1820 connected to Port "Port"."Bit".
  // If "Wait" is true, the function waits for 750 ms, the maximum conversion time.
  // Returns true if success.

  function DS1820_ReadTemperature(var Port_: byte; Bit_: byte): integer;
  // Reads the temperature out of the DS1820 connected to Port "Port"."Bit".
 
  function DS1820_StartTempConversionROM(var Port_: byte; Bit_: byte; Wait: boolean; var RomCode: array[8] of byte): boolean;
  // Starts the temperature conversion of the DS1820 connected to Port "Port"."Bit", which has ROM code "RomCode"
  // If "Wait" is true, the function waits for 750 ms, the maximum conversion time.
  // Returns true if success.

  function DS1820_ReadTemperatureROM(var Port_: byte; Bit_: byte; var RomCode: array[8] of byte): integer;
  // Reads the temperature out of the DS1820 connected to Port "Port"."Bit", which has ROM code "RomCode"

  function DS1820_CheckCRC: byte;
  // Returns 0 if the result of the last call of "DS1820_ReadTemp" gives a correct CRC.

  procedure DS1820_ReadROM(var Port_: byte; Bit_: byte; var RomCode: array[8] of byte);
  // Returns the ROM code of the single DS1820 device connected to Port "Port"."Bit" in array "RomCode".
  // Caution: only one DS1820 device should be connected to the one wire bus "Port"."Bit".

  function DS1820_CheckCRCRomCode(var RomCode: array[8] of byte): byte;
  // Returns 0 if the romcode in "RomCode" gives a correct CRC
 
  function DS1820_TempToString(Temp: integer; var S: string[5]; Sep: char);
  // Returns temperature "temp", read from an DS1820, as string in S
  // "Sep" is the decimal separation character
 
  procedure DS18B20_TempToString(Temp: integer; var S: string[5]; Sep: Char);
  // Returns temperature "temp", read from an DS18B20, as string in S
  // The resolution of the result is still 0.5 degree Celcius (1 digit after the decimal point).
  // The resolution the DS18B20 is put in does not matter.
  // "Sep" is the decimal separation character
}

The unit can be found in section "Units" on the website.

An example of how to use it can be found in the project "PIC Controlled Thermostat" in the "projects" section on the website.

Have fun! :D

Edited on 2008-12-28: the routines to address as specific DS1820 (with a certain ROM code) have been added. Also the "Read Romcode"and the CRC routine to check the RomCode have been added, see extended interface above.

Edited on 2008-12-28: the routine to convert a temperature value coming from a DS18B20 fas been added: DS18B20_TempToString.

_________________
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 30 Dec 2008 17:53, edited 7 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: 27 Dec 2008 10:15 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3779
Location: Nieuwpoort, Belgium
Tomy wrote:
Hi Dany,

I used many hours to do bulk test on your CDC USB Library. Yes, it is working. But the speed still the same (about 64KB/s).
Now, I really think something limited the speed (PC->PIC). But PIC->PC speed is ok (i don't test on bulk, but cdc speed over 300KB/s).
No idea how to fix it now. :(

-Tomy
I think the problem is most probably in the driver. As soon as possible I will investigate further. Sorry for the inconvenience. :oops:

_________________
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 Dec 2008 15:44 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3779
Location: Nieuwpoort, Belgium
Hi all,
In the library "DS1820" the routines to address a specific DS1820 (with a certain ROM code) have been added. Also the "Read Romcode"and the CRC check routines are added, see a few posts back for the interface..

An example of using more than one DS1820 on the same one wire interface can be found in http://www.rosseeld.be/DRO/PIC/OW.ppas (projectfile http://www.rosseeld.be/DRO/PIC/OW.ppp).

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:49, edited 3 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: 30 Dec 2008 17:58 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3779
Location: Nieuwpoort, Belgium
Hi all,
In the library "DS1820" the routines the routine to convert a temperature value coming from a DS18B20 has been added: DS18B20_TempToString.
See three posts back for the full interface of the routine. All other routines in the unit should work for both DS1820 and DS18B20.

Important: the string returned by the routine above has the same resolution as the one for the DS1820: 0.5 degree Celcius. The reason for this is that higher resolutions are rather useless: the DS18B20 accuracy is the same as that of the DS1820 (+/- 0.5 degree Celcius).

p.s. The following code has the same effect as the routine "DS18B20_TempToString":
   DS1820_TempToString(Temp shr 3, Sep);
but at the cost of higher code size.

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 Jan 2009 14:49 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3779
Location: Nieuwpoort, Belgium
Hi,
Just added a small list of "Pitfalls" when using PIC's and mikroPascal, meant for beginners.
See section "Tips" on the website with URL below.

_________________
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: PC->PIC Speed Fix
PostPosted: 09 Jan 2009 00:26 
Offline

Joined: 25 Jun 2007 16:50
Posts: 47
Hi Dany,

I do more research. Now, I have speed about 326.37KB (PC->PIC) with your Ping Pong Library.

Before, PC->PIC limited about 64KB. This is because I send 64 bytes per packet. (PIC is full speed, packet size max:64bytes).

I search many info from web. Someone say microchip's mpusbapi.dll can handle more than 64bytes each time send/receive. Mean, if you send 128bytes to mpusbapi.dll, then it will send two packet (64bytes) to PIC. So, your PC program only send one time to mpusbapi.dll, and can send 128bytes. I try to send 16Kbytes each time. Wow, speed is fast. And mpusbapi.dll don't report error. Seems it work fine. I'll do more test soon. I just want to tellyou I'm happy with your Library ! :D :D

-Tomy


Top
 Profile  
 
 Post subject: Re: PC->PIC Speed Fix
PostPosted: 09 Jan 2009 11:18 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3779
Location: Nieuwpoort, Belgium
Tomy wrote:
I do more research. Now, I have speed about 326.37KB (PC->PIC) with your Ping Pong Library.

Before, PC->PIC limited about 64KB. This is because I send 64 bytes per packet. (PIC is full speed, packet size max:64bytes).

I search many info from web. Someone say microchip's mpusbapi.dll can handle more than 64bytes each time send/receive. Mean, if you send 128bytes to mpusbapi.dll, then it will send two packet (64bytes) to PIC. So, your PC program only send one time to mpusbapi.dll, and can send 128bytes. I try to send 16Kbytes each time. Wow, speed is fast. And mpusbapi.dll don't report error. Seems it work fine. I'll do more test soon. I just want to tellyou I'm happy with your Library ! :D :D
Waw! That is good news! :D Thanks a lot for doing all those tests. I will try asap also do some tests with the mpusbapi.dll. :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: Re: PC->PIC Speed Fix
PostPosted: 09 Jan 2009 15:39 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3779
Location: Nieuwpoort, Belgium
Dany wrote:
Tomy wrote:
I do more research. Now, I have speed about 326.37KB (PC->PIC) with your Ping Pong Library.

Before, PC->PIC limited about 64KB. This is because I send 64 bytes per packet. (PIC is full speed, packet size max:64bytes).

I search many info from web. Someone say microchip's mpusbapi.dll can handle more than 64bytes each time send/receive. Mean, if you send 128bytes to mpusbapi.dll, then it will send two packet (64bytes) to PIC. So, your PC program only send one time to mpusbapi.dll, and can send 128bytes. I try to send 16Kbytes each time. Wow, speed is fast. And mpusbapi.dll don't report error. Seems it work fine. I'll do more test soon. I just want to tellyou I'm happy with your Library ! :D :D
Waw! That is good news! :D Thanks a lot for doing all those tests. I will try asap also do some tests with the mpusbapi.dll. :D

Hi Tomy, a few requests: :oops:
- together with the usage of the mpusbapi.dll, should there be any other driver be installed? (or is it a windows standard driver?)
- Did you adapt my speed test program or did you write one of your own? In the first case, would you send me please the Delphi function prototypes of the dll routines?

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: Re: PC->PIC Speed Fix
PostPosted: 09 Jan 2009 16:51 
Offline

Joined: 25 Jun 2007 16:50
Posts: 47
Dany wrote:
Hi Tomy, a few requests: :oops:
- together with the usage of the mpusbapi.dll, should there be any other driver be installed? (or is it a windows standard driver?)
- Did you adapt my speed test program or did you write one of your own? In the first case, would you send me please the Delphi function prototypes of the dll routines?

Thanks in advance! :D

1) It is lucky that I use Delphi. No need any driver. You can call this DLL with Delphi component. Here : http://www.sixca.com/delphi/article/microchip_usb.html

2) No, I don't write my own. I modify your test program.

You need to modify MAXSIZE=64; to MAXSIZE=32768; in order to use fast transfer. After you send big size packer like 16384 bytes. Then DLL will return how many bytes sended. If error, it will return 0. Seems, send 1 to 16384 is safe. I always get no error. I try to send 32768 bytes, it got error, return 0.

Second thing is modify in/out pipe from '\MCHP_EP1' to '\MCHP_EP3' in order to use your ping pong Library.

Third thing is modify vid_pid to meet the one with your Library.

I don't modify your Libraray, but I use the Bulk mode for your Library. I don't use CDC function on your test program.

When PC see this USB device, i point it to the driver from my hard drive : C:\Microchip Solutions\USB Device - MCHPUSB - Generic Driver Demo\Driver and inf
Example is here : C:\Microchip Solutions\USB Device - MCHPUSB - Generic Driver Demo\PC Software\Borland_C
It use Borland C, but you can use Delphi. It is same.
It is from microchip framework. (v2.3) But now, it is v2.3.1
Here : http://www.microchip.com/stellent/idcpl ... e=en537044

At last, someone in Micorchip forum have same problem with us. Original microchip CDC Library have same 64K limit like your Library. So, your Library should be good, 64K limit not from your Library I think. Only different is your Library can't use usbser.sys.
Here : http://forum.microchip.com/tm.aspx?m=395107

Anything not clear, you can ask me again. :wink:

-Tomy


Top
 Profile  
 
 Post subject:
PostPosted: 09 Jan 2009 19:55 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3779
Location: Nieuwpoort, Belgium
Tomy wrote:
Anything not clear, you can ask me again.

Wonderfull! Thanks a lot! :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: 09 Jan 2009 20:00 
Offline

Joined: 25 Jun 2007 16:50
Posts: 47
Hi Dany,

Your Library use CDC class. Can you help to change it to Bulk class ? (I don't know the class name)
It should be little different than CDC class. Then we can have a USB Bulk Library.
Thanks. :D

-Tomy


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, 6, 7, 8 ... 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: