PDA

View Full Version : Pic 18f Usb



NavMicroSystems
- 29th June 2005, 17:10
Has anybody worked with these PICs:

18F2455, 18F4455, 18F2550, 18F4550

and EaysHID yet?

Do you have any experience (or code) to share?

I have received my ICD2 today and started playing with a 18F4550.
(PICSTART+ doesn't suport the 18F4550!)

Bruce
- 29th June 2005, 18:09
I've used it, and if you're looking to get started with USB, then Dave's new
EasyHID & the PIC18F4550 are definitely the way to go.

Download & install EasyHID.
http://www.mecanique.co.uk/products/usb/easyhid.html

I have several projects for USB coming shortly, but in the mean time, I've
loaded the files for a complete USB project on our website.

The zip file contains PBP source code for a PIC18F4550, and VB source for a
USB analog data-logger. Should be fun for anyone interested in tinkering with
EasyHID and the new full-speed 18F USB parts.

Here are the files: http://www.rentron.com/mcstudio/EasyHIDPrj.zip

You'll need VB6 & SoftWire. You can download SoftWire from here. It's free.
http://www.softwire.com/swdownload/softwiredownload.htm

I used the activx controls in SoftWire for the analog meter interface. Really
nice stuff.

You'll also need PBP version 2.46 since this is the version offering support for
the newer 18F USB parts.

If anyone's looking for an excellent book on USB, then grab a copy of Jan
Axelson's new 3rd edition of USB Complete. We just got them in. I spent the
last few days reading mine, and it's awesome.

Jan has done an outstanding job on her 3rd edition of this book. Even "I" can
understand it now...;o]

Demon
- 9th July 2005, 00:06
I'm also in the middle of trying to use EasyHID. I'm just not sure where the USB18.ASM file fits in the grand scheme of things.

I used the PIC18F4550, PBP and VB. The file is in the project PBP folder.

I also got USB Complete as well as USB Design By Example. It's too bad they chose to use EZ-USB chips from Cypress or else I could have used their examples directly. Unfortunately I don't know enough about MPASM Assembler, let alone Cypress' version to convert things around.

Robert
:)

Demon
- 9th July 2005, 00:46
Is it complicated to get the generated code to be compatible with the slower USB speed? I'd like to be able to connect to PCs that do not yet have USB 2.0.

Robert
:)

Demon
- 9th July 2005, 00:59
Bruce,

I get a LOT more files generated on the PIC side?

It's that large Assembler file with all the VERY important USB routines that I don't know where that fits in. It doesn't seem to be linked with the PBP base program at all, or I missed something?

Robert
?

Demon
- 9th July 2005, 01:04
Bruce,

Don't forget to add a README that mentions mcHID.dll and where the user can get it. Your PC-side code won't work without it.

Robert
:)

Bruce
- 9th July 2005, 01:07
Hi Robert,

You should have 8 (PBP) files total generated by EasyHID. All this stuff is required, and included when you compile for the 18F USB part.

Look in your PBP\USB18 directory for USB.TXT. This explains what most of
the files are.

Demon
- 9th July 2005, 01:42
Thanks Bruce, that's the only place I hadn't looked for help.


"The header file for the device, the files USB18.ASM, USB18MEM.ASM, USB18.INC, USBDESC.ASM and the project descriptor file, as well as any desired sample programs, should be copied to the project source subdirectory before being used."

Ok, so we just have those files sitting there when we compile and the compiler takes care of everything, cool!


"For low-speed USB operation, the main changes are to set the system clock postscaler to divide by 4 and change the define for UCFG_VAL in the descriptor file for the project. The sample project descriptor files show settings of UCFG_VAL for both full-speed and low-speed. With these settings, for full-speed, the PIC core runs at 48MHz. For low-speed, the PIC core runs at 24MHz."

Ok, I haven't checked the details, but at least it's possible to adjust for low-speed USB, excellent!


Robert
:)

mbramwel
- 9th July 2005, 06:30
This is a very interesting thread. I am especially interested in the data logger. I was thinking about putting together a PIC based scope project. Something that could clip onto a few pins and display the waveforms on a PC screen. Your project looks very interesting. Any special hardware being used? How to you hookup the inputs without fear of over voltage?

Do you get 0 to 5 volts readings or more like .7v to 4.xx readings?

mbramwel
- 9th July 2005, 06:59
hmm, softwire seems to be vb.net only.

I do not see vb6 support. Any chance you are using an older version of softwire?

Demon
- 9th July 2005, 07:14
I downloaded VB Express, it's free without any strings attached.


"How to you hookup the inputs without fear of over voltage?"

How to process the signals MCU-side, beats me. I'd do a search on comparing voltage, I've seen lots of stuff on that.


Just don't even consider feeding that through the USB line. Even a PIC has limitations, I would place some sort of step-down circuit before the PIC. Google is your friend.

Robert
:)

mister_e
- 9th July 2005, 12:04
hmm, softwire seems to be vb.net only.

I do not see vb6 support. Any chance you are using an older version of softwire?
Suppose to be available.. look here (http://www.softwire.com/swdownload/softwiredownload.htm)


Any special hardware being used? How to you hookup the inputs without fear of over voltage?

Well as you want to build a kind of scope, it could be interesting that your input also provide an high impedance. So use a simple OP AMP buffer would do the trick IMHO.

But if don't need any buffer, a simple resistor between PIC and Unit wil do the job. Look at the datasheet, most PIC have two diode as 'Over/Under voltage protection...

mbramwel
- 9th July 2005, 22:11
Thanks for the 'old' link for 3.1
The regular download button was only showing the newer VB.net version. I do have VB.net because of our University site license (less than $5 per copy) but have a hard time loading up gigabytes of compiler for what should be simple apps. Maybe I should byte the bullet and move up from vb6.

At least I can now try running the app posted earlier in this thread.


I'll read the datasheet for the pic chip. My concern was due to many sites saying never exceed the supply voltage on an input pin.

The scope project would be for hobby based projects. The PIC would monitor a few pins and transmit the data via USB to the PC. The PC would graph the result. If anything already exists that has source and is free, I would check it out. I do not mind starting from scratch. I do not copywrit anything I write, it would be for public consumption.

Brian J Walsh
- 14th July 2005, 00:58
I've just started on this, having been encouraged by EasyHID.

I noticed that the interrupt check box is disabled if PBP is the device code genrator selected. Does this mean that PBP programs have to jump to service the USB every 10ms? That's surely not very practical.

Do ME Labs have a fix in the pipeline for this or do I feel an upgrade to my neglected Proton+ coming on?

I can't see me investing the time in making USB work with PBP if the USB connection cannot be maintained in the background.

Any advice greatly welcomed.


Brian Walsh
Glasgow
Scotland

Demon
- 14th July 2005, 01:31
I haven't started on the USB aspect yet, but offhand I would say that's the function of the "USBservice" command.

An easy way to manage this? I have absolutely no idea yet.

Robert
:)

mister_e
- 14th July 2005, 01:42
Please somebody shoot me if i'm wrong, didn't find time to play enough with USB, BUT none of both compiler will do the refresh for you.. sorry. Timer interrupt one of the way to go or keep track of your code and sprinkle few USBSERVICE. No big deal

paramotor
- 21st July 2005, 04:58
Has anybody worked with these PICs:

18F2455, 18F4455, 18F2550, 18F4550

and EaysHID yet?

Do you have any experience (or code) to share?

I have received my ICD2 today and started playing with a 18F4550.
(PICSTART+ doesn't suport the 18F4550!)


You have try this circuit from this project
http://www.sixca.com/eng/articles/usbdaq.php

Tissy
- 27th August 2005, 18:15
Hi,

I've built the simple piece of hardware using the 18F2550, it has been programmed as per the files generated by the EasyHID application.

Having plugged the hardware into the USB port, it states the device is not recognised. I was expecting it to come up with the device name as i stated in the EasyHID compilation.

I was expecting a .ini file or similar to be generated for the installation of the device.

Can anyone help why this might be.

Many thanks.

Tissy
- 28th August 2005, 04:29
OK, seem to have that issue sorted now, it actually was something to do with the programming fuses.

Although it now connects OK, when i look at the device manager, it only shows up as a 'USB Human Interface Device' and HID-Compliant Device' and not as i set in the EasyHID maker.

Also, can anyone help with what is required at the VB and PIC end to light a simple LED. ie when i click a 'button' in the VB code, it turns an LED on one of the ports, ie PORTB.1.

Many thanks,

Steve

Tissy
- 31st August 2005, 02:59
Can anybody help with the above request or point me in a direction of who / where might?

Many thanks,

Steve

Bruce
- 1st September 2005, 02:22
Hi Steve,

If you have the PIC being recognized as an HID device, try this. It's real simple, but will allow you to control an LED from VB6 (should also work with VB5) but I don't have that to test it with.

Create your VB code with EasyHID. Open the project, and drop two command buttons on your form. Add this code for your buttons --

Private Sub Command1_Click()
BufferOut(8) = 0 ' LED on
hidWriteEx VendorID, ProductID, BufferOut(0)
End Sub

Private Sub Command2_Click()
BufferOut(8) = 1 ' LED off
hidWriteEx VendorID, ProductID, BufferOut(0)
End Sub

Modify the PBP code created by EasyHID something like this --

PORTB = 0
TRISB = 0

usbinit ' initialise USB...
ProgramStart:
gosub DoUSBIn
PORTB = USBBuffer[7]
goto ProgramStart

Note this doesn't send data, it's just a sit & spin simple app reading USB input, and placing the value received in USBBuffer(7) on RB.

Tissy
- 2nd September 2005, 03:02
Bruce, thanks ever so much for taking the time to reply and for starting me in the right direction. Indeed i now have VB talking to the PIC over USB.

Do you have any knowledge of the EasyHID application? Having used EasyHID to set the base code etc, when i look at the device manager, it only shows up as a 'USB Human Interface Device' and 'HID-Compliant Device' and not as i set in the EasyHID maker, such as 'USB LED Controller'.

I was expecting an .inf file or similar to be compiled. Is this something that needs to be done manually? It would be a nice touch to have that when i plug in the device, in the task bar, the name of this device is displayed like any other USB device when connected.

Thanks again for you kind help,

Steve Tisseyre

Bruce
- 2nd September 2005, 22:02
Hi Steve,

The information you enter when creating USB framework files with EasyHID is just for the embedded side with a very handy .dll that handles host to function communications.

EasyHID just gives you the USB framework. As far as I know, it does not create a Windows .inf file. That's up to you to create.

If you don't have your own .inf file or HID driver, then Windows will install its own HID drivers, and your new USB gadget is just going to show up with the default Windows name in Device Manager like 'USB Human Interface Device' and 'HID-Compliant Device'.

If you're running XP, look in the Windows input.inf file, and you'll see why. It tries to match the descriptors, VID, PID with existing "certified" manufacturers & hardware. If your new USB gadget isn't in the list, Windows uses the default HID compliant description with generic HID drivers.

Download the Microchip USB framework and take a look at how they setup the .inf & driver files. That will help you understand what's required.

If you plan on making a USB enabled "product", then you might also want to grab a copy of Jan Axelson's USB Complete 3rd edition. It's worth every penny, and gives you details on how to get your USB product/manufacturer name to show up in Windows Device Manager.

EasyHID will get you started, (and really quick I might add), but there's still a lot left to the end user to figure out.

Hats off to Dave at Mecanique for putting in the HUGE amount of time & study required just to give everyone that nifty "free" utility.

Tissy
- 5th September 2005, 01:45
Hi Bruce,

I have now ordered the book as you recommended, i'm sure it will come in very handy.

I have figured out that if you use EasyHID to set the maximum Buffer size to 32, then you can increase the amount of outputs on the PIC that you can set HIGH or LOW. ie the PIC side is odd numbers 1 - 31 and the VB side is even numbers 2 - 32.

ie on the PIC side requires:

PORTC.1 = USBBuffer[23]

where as on the VB side requires:

BufferOut(24) = 1 ' LED on

If i want to use all of PORTA and PORTB, is there an easy way of listing these in the two codes, or do they have to be done seperately? ie:

PIC
PORTA.1 = USBBuffer[1]
PORTA.2 = USBBuffer[3]
PORTA.3 = USBBuffer[5]
PORTA.4 = USBBuffer[7]
PORTA.5 = USBBuffer[9]

VB
BufferOut(2) = 1 ' LED on
BufferOut(4) = 1 ' LED on
BufferOut(6) = 1 ' LED on
BufferOut(8) = 1 ' LED on
BufferOut(10) = 1 ' LED on

Moving on from the switching of outputs HIGH or LOW, how would one send say text from the PIC to a text box in VB. For example, on the PIC, if a certain routine is executed, it sends a command to the VB application which is then displayed in a text window. Or is this getting too advanced for a quick explanation??

Thanks again for you assistance,

Steve

andresnavas
- 8th September 2005, 19:33
Hello. I don't know what happend but my EasyHID only create 4 files:
DESCUSBProject.asm
USBDESC.asm
USBProject.asm
USBProject.pbp

What i doing wrong? why it don't creat the other files like the USB18.c

Thanks for yours help!!!

Please if somebody have any example send it to me at: [email protected]

Thanks!

Tissy
- 9th September 2005, 03:54
andresnavas,

I have sent the reply straight to your personal email address. It would appear that the files aren't generating properly. All i can suggest is check the compilation settings again. If that doesn't work, try installing the application again.

I certainly haven't had any problems like that.

Within the directory you specified in the project settings (default is C:\Program Files\Mecanique\EasyHID\) should see another directory as per your title, such as USBProject. Within that directory is 2 sub directories, one for the VB or C code and one for the Proton or PICBasic code.

I have sent you a zip file containing what you should expect to see for a default VB and PICBasic code using the PIC18F4550 also with all the default settings.

Hope this helps,

Steve

judy
- 17th October 2005, 12:39
Hi all,

Absolutely brilliant thread, a lot of quality info and best of all can be done fast, cheers to all those involved. I am really new to this interfacing stuff, so if I'm asking too much or the newbie stink is unbearable, feel free to tell me to sling my hook.

I was wondering how one would go about changing the HID code provided by Easy HID USB code generator to simply read in up to three pulse width inputs (as far as I know the digital ins on the 18f2455 support this) and up to three analog ins through on board adc (ideally varying between -3 to +3v) simultaneously and as fast as possible, in fact how many samples per second is possible using the HID approach? Sin e.

I would greatly appreciate any help with this/direction to where help should be sought.

Thanks in advanced
Judy

Bruce
- 17th October 2005, 19:21
Steve,

You're dealing with bytes. PORTA.1 = USBBuffer[1] isn't the way to go since you can't place a byte value on a single port "bit".

Just place the byte you need on the whole port. You can send a single byte value from the PC app, and simply place it on the port.

I.E. PORTA = USBBuffer[1] should work fine - assuming that's the byte element you want.

Sending data from the PIC to PC is equally simple. Here's one example. Note this isn't everything. Just the sections I added to the framework file created with EasyHID.


DEFINE OSC 48
DEFINE LOADER_USED 1
DEFINE ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source /32
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS
DEFINE RESET_ORG 800h ' <-- I used the Microchip USB loader

BufferSize con 8
DataBuffer Var Byte(BufferSize) ' data buffer
DataBufferCount Var Byte ' buffer size
Quanta con 1251
TRISD = 0
PORTD = 0

' Variables
X VAR byte
Adval VAR WORD

TRISA.0 = 1 ' RA0 input
ADCON1 = %00001110 ' A/D channel 0
ADCON2 = %10000011 ' Right justify for 10-bit
USBInit

Main:
GOSUB DoUSBIn
PORTD = DataBuffer[7]

ADCIN 0,adval ' Read A/D channel 0 into ADval variable
ADval = ADval */ Quanta ' Quanta result

' Load data buffer
DataBuffer(0) = Adval DIG 3
DataBuffer(1) = "."
DataBuffer(2) = Adval DIG 2
DataBuffer(3) = Adval DIG 1
DataBuffer(4) = Adval DIG 0
GOSUB DoUSBOut
FOR X = 0 to 99 ' Short delay between updates
PAUSEUS 1000
USBSERVICE ' Maintain HID connection during delay period
NEXT X
GOTO Main
On the PC side, modify the USB framework file created with EasyHID something like this;
Dim MyText As String ' create your string storage space

In the OnRead sub-routine;
MyText = (CStr(BufferIn(1)) + Chr$(BufferIn(2)) + CStr(BufferIn(3)) + CStr(BufferIn(4)) + CStr(BufferIn(5)) + "V")
Label1.Caption = MyText ' Place string text into label displaying A/D value

Judy,

Reading three pulse widths or A/D values doesn't really have anything to do with USB. The USB PIC is just another PIC with the addition of the USB module. Using the onboard A/D is pretty much the same as any other PIC.

All you need here is the datasheet, and a little time to experiment getting your pulse measurement & A/D routines working. Sending this all to the PC via the USB module is no more than stuffing your values into the outgoing buffer like in the previous example.

Just be sure to keep the USB connection alive by avoiding the use of blocking functions, long delays, etc,,. It's really not that hard, but you will need to experiment a tad.

Tissy
- 25th October 2005, 17:02
Bruce,

Would you mind posting all of your ADC code, i am getting errors. I've had a look, but can't figure it out.

The code posted above seems to be missing the DoUSBIn and DoUSBOut subroutines.

I also get an error on the DataBuffer(1) = "."

I want to use it as a 5v voltage monitor passing the results to Vb.

Many thanks,

Steve

Bruce
- 25th October 2005, 17:29
Hi Steve,

Sure. Here's the complete file. Just be sure you've used EasyHID to generate the required USB support files.


DEFINE LOADER_USED 1
DEFINE OSC 48
DEFINE ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source /32
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS
DEFINE RESET_ORG 800h ' For Microchip USB loader

BufferSize con 8
DataBuffer Var Byte(BufferSize) ' data buffer
DataBufferCount Var Byte ' buffer size
Quanta con 1251
TRISD = 0
PORTD = 0

' Variables
X VAR byte
Adval VAR WORD

TRISA.0 = 1 ' RA0 input
ADCON1 = %00001110 ' A/D channel 0
ADCON2 = %10000011 ' Right justify for 10-bit
USBInit

Main:
GOSUB DoUSBIn
PORTD = DataBuffer[7]

ADCIN 0,Adval ' Read A/D channel 0 into ADval variable
ADval = ADval */ Quanta ' Quanta result

' Load data buffer
DataBuffer(0) = Adval dig 3
DataBuffer(1) = "."
DataBuffer(2) = Adval DIG 2
DataBuffer(3) = Adval DIG 1
DataBuffer(4) = Adval DIG 0
GOSUB DoUSBOut
FOR X = 0 to 99 ' Short delay between updates
PAUSEUS 1000
USBSERVICE ' Maintain HID connection during delay period
NEXT X
GOTO Main

' USB in...
DoUSBIn:
DataBufferCount = BufferSize
USBService
USBIn 1, DataBuffer, DataBufferCount, DoUSBIn
RETURN

' USB out...
DoUSBOut:
DataBufferCount = BufferSize
USBService
USBOut 1, DataBuffer, DataBufferCount, DoUSBOut
RETURN

END
Here's the PIC & VB source for a USB A/D datalogger http://www.rentron.com/mcstudio/USB_AD.zip

Tissy
- 25th October 2005, 18:04
Great, thanks Bruce. Unfortuanatly i am still getting a big 0 in VB. I'm sure its only something small i am doing wrong (hopefully) !!

Here is the code, can you spot anything obvious that i have done wrong?

Its a PIC18F2455 where i am putting 5v onto RA0.



DEFINE LOADER_USED 1
DEFINE OSC 48
DEFINE ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source /32
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS
'DEFINE RESET_ORG 800h ' For Microchip USB loader

BufferSize con 8
DataBuffer Var Byte(BufferSize) ' data buffer
DataBufferCount Var Byte ' buffer size
Quanta con 1251


' Variables
X VAR byte
Adval VAR WORD

TRISA.0 = 1 ' RA0 input
ADCON1 = %00001110 ' A/D channel 0
ADCON2 = %10000011 ' Right justify for 10-bit
USBInit

Main:
GOSUB DoUSBIn
PORTB = DataBuffer[7]

ADCIN 0,Adval ' Read A/D channel 0 into ADval variable
ADval = ADval */ Quanta ' Quanta result

' Load data buffer
DataBuffer(0) = Adval dig 3
DataBuffer(1) = "."
DataBuffer(2) = Adval DIG 2
DataBuffer(3) = Adval DIG 1
DataBuffer(4) = Adval DIG 0
GOSUB DoUSBOut

FOR X = 0 to 99 ' Short delay between updates
PAUSEUS 1000
USBSERVICE ' Maintain HID connection during delay period
NEXT X

GOTO Main

' ************************************************** **********
' * receive data from the USB bus *
' ************************************************** **********
DoUSBIn:
DataBufferCount = BufferSize
USBService
USBIn 1, DataBuffer, DataBufferCount, DoUSBIn
RETURN

' ************************************************** **********
' * wait for USB interface to attach *
' ************************************************** **********
DoUSBOut:
DataBufferCount = BufferSize
USBService
USBOut 1, DataBuffer, DataBufferCount, DoUSBOut
RETURN
END


In VB, i have placed a label on the form and this is in the read event section



'************************************************* ****************
' on read event...
'************************************************* ****************
Public Sub OnRead(ByVal pHandle As Long)

' read the data (don't forget, pass the whole array)...
If hidRead(pHandle, BufferIn(0)) Then

MyText = (CStr(BufferIn(1)) + Chr$(BufferIn(2)) + CStr(BufferIn(3)) + CStr(BufferIn(4)) + CStr(BufferIn(5)) + "V")
Label1.Caption = MyText ' Place string text into label displaying A/D value


' ** YOUR CODE HERE **
' first byte is the report ID, e.g. BufferIn(0)
' the other bytes are the data from the microcontrolller...
End If
End Sub



Many thanks again.

Steve

Bruce
- 25th October 2005, 18:33
Private Const VendorID = 6017
Private Const ProductID = 2000

Check to make sure the vendor & product ID numbers in your VB source match the vendor/product ID #'s in the PIC framework files generated by EasyHID. If these don't match, the VB app will never respond.

Tissy
- 25th October 2005, 18:46
Although i have changed the ProductID from 2000 to 2005, the device is recognised.

The VB program displays a text box which says USB Device Connected or indeed Disconnected, depending on its status.

So, i think this bit is OK.

Steve

Bruce
- 25th October 2005, 19:02
What exactly is happening? Are you getting nothing on the label caption? Have you verified your hardware with something simple like reading the A/D input, and displaying the result on an LCD, serial terminal, etc?

Tissy
- 25th October 2005, 19:57
Basically i'm putting 5v on the PORTA.0 pin and just gettin 'label1' in the label of VB.

Should VB always be updating and looking at the USBinput or should there be a READ button thats calls the procedure?

Also on the VB side it has:



MyText = (CStr(BufferIn(1)) + Chr$(BufferIn(2)) + CStr(BufferIn(3)) + CStr(BufferIn(4)) + CStr(BufferIn(5)) + "V")


Most of it contains CStr but the bit thats contains Chr$, i presume thats for the "." as sent from the PIC.

I've tried playing around with it, but still no joy. If you have it, is it worth sending me the vb source file you have just for this bit?

Are you on messenger, i am, i thought it might be easier to converse?

Thanks again,

Steve

Bruce
- 25th October 2005, 20:22
I'll be happy to send you the working source for one example. Email me directly at tech@rentron

Demon
- 29th October 2005, 19:03
...
Download the Microchip USB framework and take a look at how they setup the .inf & driver files. That will help you understand what's required.
...


Hi Bruce, do you have a link? I did a search on the Microchip site for <Microchip USB framework> and couldn't find a download.

(I'm assuming this is some sort of compile utility that will help Windows XP make a link between the USB device and our EasyHID-generated VB code.)

Robert
:)

Bruce
- 29th October 2005, 21:02
Hi Robert,

The Microchip USB framework files are C18 code for the USB PIC. Look under Development Tools for PIC Demo Boards. Go to the page for the full speed USB board. All files & app notes can be downloaded from that page.

When you run the setup program for the PIC USB demo board it installs the framework files. You'll want to grab all the associated app notes on the same page, and USB loader if you plan on using that.

With PBP v2.46 you use DEFINE RESET_ORG 800h to force user code to start at the proper location when using the Microchip USB loader.

Tissy
- 29th October 2005, 21:08
Is the USB loader so you can bootload the PIC over USB with a new firmware?

Bruce
- 29th October 2005, 21:17
Yes. It's the same USB boot-loader provided with the Microchip full speed PIC USB demo board.

Demon
- 29th October 2005, 23:09
Is the USB loader so you can bootload the PIC over USB with a new firmware?


Yes. It's the same USB boot-loader provided with the Microchip full speed PIC USB demo board.

I wasn't planning on using In Circuit Serial Programming at first, but if we can include a user-friendly firmware upgrade feature then that changes everything.

Robert
:)

Demon
- 29th October 2005, 23:17
Ok, this is strange. I've downloaded the files from Microchip:
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en021940&part=DM163025

And these 3 files all install the same thing; MICROCHIP USB FRAMEWORK SOFTWARE:
- USB_Bootloader_Setup.EXE
- MCHPFSUSB_Setup
- HID_Setup.EXE

Do I have some sort of cookie problem going on? I've had something similar once with an old unzip program and was wondering if I was seeing straight.

Robert
:)

Tissy
- 29th October 2005, 23:22
OK. I haven't got the USB Demo board, i just use the 18F2550 and 18F4550.

I will have to look at this, because the device i am designing is a USB device. So it would be good to be able to flash it for an upgrade using this facility over USB without worrying about other IcSP connections etc.

LordLafebre
- 2nd November 2005, 09:24
Hi Everybody...

there is a schematic for Bruce's example...?

Sorry but my english is not good....!

Regards...!

GIO

LordLafebre
- 10th November 2005, 04:34
Hi:

Can anybody helpme whit a elemental example....? Im usin EasyHID, PIC 18F4550, VB and PBP... thanx.

Lamento no poderme expresar bien en ingles, pero para alguien que me entienda, le estaria agradecido si me pudiera guiar con un ejemplo sencillo para un PIC 18F4550 con PBP VB y easyHID...

Gracias...!

Raflex
- 17th September 2006, 18:51
Hello, i have a problem with usb. Here is the code:

PBP code:

DEFINE LOADER_USED 1 ' Using Mecanique 18f4550 loader
DEFINE OSC 20
Define ADC_BITS 10 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source /32
Define ADC_SAMPLEUS 50 ' Set sampling time in uS

BufferSize con 8
DataBuffer Var Byte(BufferSize) ' data buffer
DataBufferCount Var Byte ' buffer size
Quanta con 1251

' Variables
X VAR byte
Adval VAR WORD

TRISA.0 = 1 ' RA0 input
ADCON1 = %00001110 ' A/D channel 0
ADCON2 = %10000011 ' Left justify for 10-bit
USBInit

Main:
ADCIN 0,adval ' Read A/D channel 0 into ADval variable
ADval = ADval */ Quanta ' Quanta result

' Load data buffer
DataBuffer(0) = Adval dig 3 'Y.LowByte
DataBuffer(1) = "."
dATAbUFFER(2) = Adval DIG 2
DataBuffer(3) = Adval DIG 1
DataBuffer(4) = aDVAL DIG 0
gosub DoUSBOut
for X = 0 to 99 ' Short delay between updates
pausEUS 1000
USBSERVICE ' Maintain HID connection during delay period
NEXT X
goto Main

' USB in...
DoUSBIn:
DataBufferCount = BufferSize
USBService
USBIn 1, DataBuffer, DataBufferCount, DoUSBIn
return

' USB out...
DoUSBOut:
DataBufferCount = BufferSize
USBService
USBOut 1, DataBuffer, DataBufferCount, DoUSBOut
return

end

-----------------------------------------------------------

VB code:

' vendor and product IDs
Private Const VendorID = 6017
Private Const ProductID = 2000

' read and write buffers
Private Const BufferInSize = 8
Private Const BufferOutSize = 8
Dim BufferIn(0 To BufferInSize)
Dim BufferOut(0 To BufferOutSize)
Dim voltaje As String



' ************************************************** **************
' when the form loads, connect to the HID controller - pass
' the form window handle so that you can receive notification
' events...
'************************************************* ****************
Private Sub Form_Load()
' do not remove!
ConnectToHID (Me.hwnd)
End Sub

'************************************************* ****************
' disconnect from the HID controller...
'************************************************* ****************
Private Sub Form_Unload(Cancel As Integer)
DisconnectFromHID
End Sub

'************************************************* ****************
' a HID device has been plugged in...
'************************************************* ****************
Public Sub OnPlugged(ByVal pHandle As Long)
If hidGetVendorID(pHandle) = VendorID And hidGetProductID(pHandle) = ProductID Then
' ** YOUR CODE HERE **
estado.Caption = "Plugged in"

End If
End Sub

'************************************************* ****************
' a HID device has been unplugged...
'************************************************* ****************
Public Sub OnUnplugged(ByVal pHandle As Long)
If hidGetVendorID(pHandle) = VendorID And hidGetProductID(pHandle) = ProductID Then
' ** YOUR CODE HERE **
estado.Caption = "Unplugged"
Label1.Caption = "Nothing"
End If
End Sub

'************************************************* ****************
' controller changed notification - called
' after ALL HID devices are plugged or unplugged
'************************************************* ****************
Public Sub OnChanged()
Dim DeviceHandle As Long

' get the handle of the device we are interested in, then set
' its read notify flag to true - this ensures you get a read
' notification message when there is some data to read...
DeviceHandle = hidGetHandle(VendorID, ProductID)
hidSetReadNotify DeviceHandle, True
End Sub

'************************************************* ****************
' on read event...
'************************************************* ****************
Public Sub OnRead(ByVal pHandle As Long)

' read the data (don't forget, pass the whole array)...
If hidRead(pHandle, BufferIn(0)) Then
' ** YOUR CODE HERE **
' first byte is the report ID, e.g. BufferIn(0)
' the other bytes are the data from the microcontroller...

voltaje = (CStr(BufferIn(1)) + "." + CStr(BufferIn(3)) + CStr(BufferIn(4)) + "V")
Label1.Caption = voltaje

End If
End Sub

'************************************************* ****************
' this is how you write some data...
'************************************************* ****************
Public Sub WriteSomeData()
BufferOut(0) = 0 ' first by is always the report ID
BufferOut(1) = 10 ' first data item, etc etc

' write the data (don't forget, pass the whole array)...
'hidWriteEx VendorID, ProductID, BufferOut(0)
End Sub

------------------------------------------------------------------


It doesnt work in visual basic, i only receive ".V" in the label, but i tested with the demo datalogger and it works. I dont know whats happened. Help me please

Thanks in advance

Demon
- 18th September 2006, 02:55
I'm no expert, but doesn't USB run at 48MHz?

Check out Bruce's code at Rentron and see what he does.

Robert
:)

Raflex
- 18th September 2006, 06:12
Hi. I have tested the communication with bruce's software and it works fine whit 20Mhz xtal. But with my code doesnt work. :(

Raflex
- 18th September 2006, 06:31
Got it!!! Take a look:

VB code:

' vendor and product IDs
Private Const VendorID = 6017
Private Const ProductID = 2000

' read and write buffers
Private Const BufferInSize = 8
Private Const BufferOutSize = 8
Dim BufferIn(0 To BufferInSize) <---Mistake here, need to declare as byte !!!
Dim BufferOut(0 To BufferOutSize)
Dim voltaje As String

------------------------------------------------------------

I need to write 1000 lines with the next message:

"Dont forget declaration of variables" LOL

RYTECH
- 10th June 2007, 00:41
Hi i've recently begun experimenting with the 18F4550 i've got a working example program that lets me flash an led connected to PORTB.7, I use VB6 on the PC side.

Basically my project has been halted by an unexpected problem in compiling some code added to work the A/D. Both Bruce's USB_AD.zip example and my own code cannot compile this:

ADCON1 = %00001110 ' A/D channel 0
ADCON2 = %10000011 ' Left justify for 10-bit

I get a syntax error.... any ideas - full code posted below.

I'm running version 2.2.1.1 of microcode studio. I'm using the new beta program for the EPIC parallel programmer (with the 40 pin adapter)



DEFINE OSC 20
DEFINE LOADER_USED 1
'ADC defines
Define ADC_BITS 10 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source /32
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
Quanta con 1251
Adval VAR WORD

USBBufferSizeMax con 64 ' maximum buffer size
USBBufferSizeTX con 64 ' input
USBBufferSizeRX con 64 ' output

' the USB buffer...
USBBuffer Var Byte[USBBufferSizeMax]
USBBufferCount Var Byte
x VAR BYTE


TRISA.0 = 1 ' RA0 input

ADCON1 = %00001110 ' A/D channel 0
ADCON2 = %10000011 ' Left justify for 10-bit

usbinit ' initialise USB...
x = 0
LOW PORTB
BlinkLED:
if x = 7 then ProgramStart
x = x + 1
HIGH PORTB.7
PAUSE 1000
LOW PORTB.7
PAUSE 500
goto blinkLED
ProgramStart:
x = 0
gosub DoUSBIn
gosub DoUSBOut
goto ProgramStart

' ************************************************** **********
' * receive data from the USB bus *
' ************************************************** **********
DoUSBIn:
USBBufferCount = USBBufferSizeRX ' RX buffer size
USBService ' keep connection alive
USBIn 1, USBBuffer, USBBufferCount, DoUSBIn ' read data, if available
if usbbuffer[2] = 1 then
high portb.7
ENDIF
IF USBbuffer[2] = 0 THEN
LOW portb.7
ENDIF
goto DoAD
return
DoAD:
ADCIN 0,adval ' Read A/D channel 0 into ADval variable
ADval = ADval */ Quanta ' Quanta result

' Load data buffer
USBBuffer[0] = Adval dig 3 'Y.LowByte
USBBuffer[1] = "."
USBBuffer[2] = Adval DIG 2
USBBuffer[3] = Adval DIG 1
USBBuffer[4] = aDVAL DIG 0
RETURN
' ************************************************** **********
' * wait for USB interface to attach *
' ************************************************** **********
DoUSBOut:
USBBufferCount = USBBufferSizeTX ' TX buffer size
USBService ' keep connection alive
USBOut 1, USBBuffer, USBBufferCount, DoUSBOut ' if bus available, transmit data
return

Raflex
- 10th June 2007, 01:47
Hello Rytech, your code is ok, i tried to compile it and it works. Probably you need a newer version of pbp or microcode studio.

RYTECH
- 10th June 2007, 04:03
I have PBP Compiler 2.46, Microcode studio 2.2.1.1 and version 4.21 beta of MeLabs Programmer software

RYTECH
- 10th June 2007, 04:19
Hopefully someone can comment on why my compiler doesnt know what ADCON1 & ADCON2 is for the 18F series chip.

If i take out ADCON2 and the usb stuff and compile for 16F877A it has no problems with ADCON1 - which to me suggest my support for a 18F4550 is buggered.

this compiles fine for the 16F877A:


DEFINE OSC 20
DEFINE LOADER_USED 1
'ADC defines
Define ADC_BITS 10 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source /32
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
Quanta con 1251
Adval VAR WORD

USBBufferSizeMax con 64 ' maximum buffer size
USBBufferSizeTX con 64 ' input
USBBufferSizeRX con 64 ' output

' the USB buffer...
USBBuffer Var Byte[USBBufferSizeMax]
USBBufferCount Var Byte
x VAR BYTE


TRISA.0 = 1 ' RA0 input

ADCON1 = %00001110 ' A/D channel 0
'ADCON2 = %10000011 ' Left justify for 10-bit

'usbinit ' initialise USB...
x = 0
LOW PORTB
BlinkLED:
if x = 7 then ProgramStart
x = x + 1
HIGH PORTB.7
PAUSE 1000
LOW PORTB.7
PAUSE 500
goto blinkLED
ProgramStart:
x = 0
gosub DoUSBIn
gosub DoUSBOut
goto ProgramStart

' ************************************************** **********
' * receive data from the USB bus *
' ************************************************** **********
DoUSBIn:
USBBufferCount = USBBufferSizeRX ' RX buffer size
' USBService ' keep connection alive
' USBIn 1, USBBuffer, USBBufferCount, DoUSBIn ' read data, if available
if usbbuffer[2] = 1 then
high portb.7
ENDIF
IF USBbuffer[2] = 0 THEN
LOW portb.7
ENDIF
goto DoAD
return
DoAD:
ADCIN 0,adval ' Read A/D channel 0 into ADval variable
ADval = ADval */ Quanta ' Quanta result

' Load data buffer
USBBuffer[0] = Adval dig 3 'Y.LowByte
USBBuffer[1] = "."
USBBuffer[2] = Adval DIG 2
USBBuffer[3] = Adval DIG 1
USBBuffer[4] = aDVAL DIG 0
RETURN
' ************************************************** **********
' * wait for USB interface to attach *
' ************************************************** **********
DoUSBOut:
USBBufferCount = USBBufferSizeTX ' TX buffer size
'USBService ' keep connection alive
'USBOut 1, USBBuffer, USBBufferCount, DoUSBOut ' if bus available, transmit data
return

RYTECH
- 10th June 2007, 04:43
I just applied the update for version 2.46 - no effect.

RYTECH
- 10th June 2007, 05:23
Updated MPLAB & MPASM to latest version - no effect.

skimask
- 10th June 2007, 22:34
Try this:

'ADCON2 = %10000011 ' Left justify for 10-bit
Poke $fc0, $83 'which is the same thing as the line above.

RYTECH
- 10th June 2007, 23:48
Ok that compiled... with warnings...

Warning c:\progra~1\picbas~1\18F4550.inc 20: _CONFIG has been depreciated for PIC18 devices. Use CONFIG (repeated about 8 ti

does the fact that the "POKE" command compiled tell us why ADCON1 & ADCON2 would not?

skimask
- 11th June 2007, 00:08
does the fact that the "POKE" command compiled tell us why ADCON1 & ADCON2 would not?

PBP 2.47 shows fixes for miscellaneous items and a few other things.
Maybe that's one of the fixes...who knows. And, heck, if Poke works, who cares :D

RYTECH
- 11th June 2007, 00:17
Ok, so poke just manually writes values to the given registers?

I'd still like to figure out why ADCON1 & ADCON2 is not working.



ADCON1 = %00001110 ' A/D channel 0

'ADCON2 = %10000011 ' Left justify for 10-bit
Poke $fc0, $83 'which is the same thing as the line above.

Raflex
- 11th June 2007, 01:30
Download Microcode Studio 3.0

http://www.mecanique.co.uk/code-studio/

RYTECH
- 11th June 2007, 03:14
This is now what I have installed
Version:

Microcode Studio 3.0
PBP 2.46 (w/patched 2.46 from support page)
MPASM v5.11
melabs Programmer Version 4.21 beta

PIC18F4550

RYTECH
- 11th June 2007, 03:24
no change to my situation.

ADCON1 = %00001110 ' A/D channel 0
ADCON2 = %10000011 ' Left justify for 10-bit
'Poke $fc0, $83 'which is the same thing as the line above.

compiling my code posted previously (no other changes) using the code above still causes a Syntax error.

'ADCON1 = %00001110 ' A/D channel 0
'ADCON2 = %10000011 ' Left justify for 10-bit
Poke $fc0, $83 'which is the same thing as the line above.

using the code above it compiles.

i'm new to poking ... :) I guess i've never had to directly write to any registers. I think i've peeked once.

Ok so I can deal with using POKE commands if they end up working to get my project moving along again.

RYTECH
- 11th June 2007, 03:59
PBP 2.47 shows fixes for miscellaneous items and a few other things.
Maybe that's one of the fixes...who knows. And, heck, if Poke works, who cares :D

Yeah if the peek and poke work thats fine for me, I had used ADCON commands before and am a little stumped about why it would work in once case for a certain PIC and not for another (the 18F4550). I knew it might be a matter of having support for the specific chip. i'm hoping other commands don't have syntax errors as i go...

I wonder if 2.47 resolves the Syntax error as I intend to start using the USB type 18Fxxxx type PICs

How do i find the microcontroller register address for ADCON0 - ADCON1 - ADCON2, is it in the datasheet? ( the sections describing A/D operation dont seem to list the address locations)

RYTECH
- 26th June 2007, 06:19
Is there no downloadable version of Pic Basic Pro Upgrade 2.47. The shipping is like 3 times the cost of the cdrom!!

mister_e
- 26th June 2007, 16:35
Probably the person who sell you the upgrade may do it for you?

RYTECH
- 26th June 2007, 19:02
Yeah I suppose I should ask about a downloadable version. I guess 50 bucks isn't all that much to pay for the upgrade in total.

gigel
- 19th September 2007, 08:01
I am trying to link my PC to my experimental board with PIC18F4550.
I am using EasyHID (mcHID.dll in delphi - for PC, and PROTON IDE for firmware from PIC) but the speed transfer of data from PC to PIC is very slow - about 64KB/sec.
I need more speed - I need over 240KB / sec. How can I make this data transfer to be fasterthan now?

Thank you

Bruce
- 19th September 2007, 08:12
This forum is for PBP not PROTON.

The PROTON forum can be found here http://www.picbasic.org/forum/

aman_b
- 16th December 2007, 13:10
Hi
I tried to access the link for zip file and the easy hid, but seems like they dont exist anymore. could you please attach them in the forum. That would very helpful
Aman




I've used it, and if you're looking to get started with USB, then Dave's new
EasyHID & the PIC18F4550 are definitely the way to go.

Download & install EasyHID.
http://www.mecanique.co.uk/products/usb/easyhid.html

I have several projects for USB coming shortly, but in the mean time, I've
loaded the files for a complete USB project on our website.

The zip file contains PBP source code for a PIC18F4550, and VB source for a
USB analog data-logger. Should be fun for anyone interested in tinkering with
EasyHID and the new full-speed 18F USB parts.

Here are the files: http://www.rentron.com/mcstudio/EasyHIDPrj.zip

You'll need VB6 & SoftWire. You can download SoftWire from here. It's free.
http://www.softwire.com/swdownload/softwiredownload.htm

I used the activx controls in SoftWire for the analog meter interface. Really
nice stuff.

You'll also need PBP version 2.46 since this is the version offering support for
the newer 18F USB parts.

If anyone's looking for an excellent book on USB, then grab a copy of Jan
Axelson's new 3rd edition of USB Complete. We just got them in. I spent the
last few days reading mine, and it's awesome.

Jan has done an outstanding job on her 3rd edition of this book. Even "I" can
understand it now...;o]

Bruce
- 16th December 2007, 16:29
Sorry. These files are no longer available since the support applications you would need to install to use them have been discontinued.

Mecanique dropped the free version of EasyHID, and the VB6 version of Softwire is no longer available. Without these two applications, the .zip file would be useless.

See Mr E's USB example here: http://www.picbasic.co.uk/forum/showthread.php?t=5418

mister_e
- 16th December 2007, 18:04
problem now will be the .dll. Not sure if we are allowed to distribute it :(

RYTECH
- 17th December 2007, 22:27
So basically now it's part of microcode studio right?

This confused me too for a bit till i saw it in Microcode studio's "view" menu.

mister_e
- 18th December 2007, 05:21
And those having the old black installation CD... don't have this chance 'till now (december 18/2007) :(

Or once again, i still miss something... that's what happen when you're coming old.

Darrel Taylor
- 18th December 2007, 05:55
It's an ODD one.

Can't remember anyone UN-Releasing software that was once Free in the Public Domain.
Till now.

That's it, from now on, everyone must BUY Instant Interrupts. (NOT!)
Pffft!
<br>

T.Jackson
- 18th December 2007, 06:20
I was actually considerably shocked that it was free.

Darrel Taylor
- 18th December 2007, 06:26
Would you also be shocked to find out that 10 million people got it for free ...
But now you have to pay for it? (cuz it turned out to be good)
<br>

T.Jackson
- 18th December 2007, 06:53
Nope. People are in business to make money, not friends.

Darrel Taylor
- 18th December 2007, 07:12
Yes, but businesses are also responsible for their decisions.
Once you make them, you can't just go, Oh I didn't mean that.

And, as far as the law goes ... once you put something in the Public Domain,
It's there to stay.

No court in the world would convict you for passing on the previously downloaded EasyHID.

I should mention, that I think it would be OK to do this if there were major improvements that warranted additional costs. But it's still the same program. No upgrades, no new features. Just, you don't get it, lest you pay now. http://www.picbasic.co.uk/forum/images/icons/icon13.gif

.

T.Jackson
- 18th December 2007, 07:54
Can't say that I particularly like or even agree with their method. You'll probably find that they had plans to sell it right from the time of its conception. By initially offering it for free -- it attracts a larger audience, some people find a "niche" for it in their toolbox, some may even become entirely dependent on it. For most people it's a "gotcha" -- they now must simply pay for it in order to continue using it. The vendor would make a tonne more money doing this than initially trying to sell it. Mainly because most people don't fall in love with a piece of software until they've come to grips with it. Even a $30 purchase for many people is enough to make them procrastinate about;

1. Will I learn this easily enough?
2. Will I ever really use this thing?
3. Does it really work a good as they say?
4. Will it do exactly what I want it to?
5. Maybe I can find something cheaper?

When something is for free, none of those things enter our minds -- instead we just give it ago because we have nothing to lose. So all told, they'll reap in a tonne of cash from basically all dependent users. That's life ...

Feel free to disagree with my marketing theory

Darrel Taylor
- 18th December 2007, 09:17
Marketing Schmarketing.

You put software on the internet for free.
You allow all kinds of people to create programs that actually make that software useable.
Those people have invested MANY hours in developing your free product. (about 100 or so from me).
Once that product becomes popular, you go, ... Hey there's a lot of people that want this. I shouldn't be giving it away.

Hogwash!

Maybe it's time for DT_HID, or even TJ_HID.
<br>

T.Jackson
- 18th December 2007, 10:45
I certainly hope that they do the right thing by their contributors.

Another example of this sort of thing is MAME - (Multiple Arcade Machine Emulator) Initially back in 97 they swore on a stack of Bibles that it would never ever be for profit. Today it can be found on eBay living inside a rather large game box supporting over 1,000 games. Besides the fact that they've breached over a decade's worth of copyright -- where's the contributors share?

mackrackit
- 18th December 2007, 11:15
Maybe it's time for DT_HID, or even TJ_HID.
<br>

If you are going to start something like this, a cross platform version would be nice. Java?

I am not very good with Java yet, but I would help where I can.

T.Jackson
- 18th December 2007, 11:30
Java actually has all the protocols for USB. http://www.ibm.com/developerworks/linux/library/j-usb.html

mackrackit
- 18th December 2007, 11:41
The conclusion on that page says the two APIs are for linux, has any work been done for windows and mac?

Something that maybe could be compiled on the machine it is going to run on?

T.Jackson
- 18th December 2007, 11:59
That's right, good news for Linux users! Unfortunately, I don't think there's support for other OS's. You wouldn't do a project like this in Java. Out of the scope of my skill level, absolutely no way. I think it would take a kernel developer to pull it off actually.

T.Jackson
- 18th December 2007, 12:24
lmfao ...
I think Darrel's seriously having himself on too (unless of course he's a proficient expert in C++ and just hasn't mentioned it)

mackrackit
- 18th December 2007, 14:45
Being that I am a Linux user I might start playing with it.

Might be time to learn a little more about python. I have heard some good things about PyUSB, heard bad too~

Darrel Taylor
- 18th December 2007, 17:06
lmfao ...
I think Darrel's seriously having himself on too (unless of course he's a proficient expert in C++ and just hasn't mentioned it)

C++, never touch the stuff. I do Delphi.

However, there's no need for an external program.
It can all be handled by the assembler.
An include file, with the USB configuration defined in the top of the PBP program.

On the PC side, the program is just a standard example.
Plug in the VID/PID and away you go.
<br>

mister_e
- 18th December 2007, 17:11
serial number ;)

T.Jackson
- 19th December 2007, 03:04
C++, never touch the stuff. I do Delphi.

However, there's no need for an external program.
It can all be handled by the assembler.
An include file, with the USB configuration defined in the top of the PBP program.

On the PC side, the program is just a standard example.
Plug in the VID/PID and away you go.
<br>

I see. No custom dll to go between programming languages & OS means no C++ I guess.

T.Jackson
- 19th December 2007, 04:14
I take it that Delhi has USB support?, or are you just planing to use some 3rd party OCX or something?

mister_e
- 19th December 2007, 04:26
No need for any third party... API calls and that's it. But yeah it's tricky.

Reference... Jan Axelson's book... which i should buy again...

T.Jackson
- 19th December 2007, 05:43
Might have to get my hands on a copy of that book. I have read portions of her other titles; Parallel Port Complete, serial too. I was unaware that there were Win32 API's for doing this.

lengcallrobot
- 14th July 2008, 22:07
Hi everybody,

I am new in this forum. I use PBP compiler and VB6 for my application.

The problem are:
. When I used USBOUT to send the data via EndPoint #1 from PIC to PC, I can send only
the spead upto 64kbit/s (I use oscilloscope to measure the time of sending
one packet from PIC to PC, an the time is about 8ms for 64 Bytes).

. If I use EndPoint #3 (virtual COM port), I can send data upto 115200 bit/s but it still
so slow for my application because I need to send data about 10 Byte at 100 ksample/s

My question is:
How can I used PBP to send the data in hight speed mode or full speed
mode? Normally, I used EasyHID from MicrocodeStudio to generate the
template for PBP and VB.

Hope to hear from you all soon.

skimask
- 14th July 2008, 22:33
My question is:
How can I used PBP to send the data in hight speed mode or full speed mode?
PIC18xxxx USB capable PICs are not capable of the high speed (480mpbs) mode.

lengcallrobot
- 15th July 2008, 03:33
PIC18xxxx USB capable PICs are not capable of the high speed (480mpbs) mode.

So, how about full speed mode? What to do?

Rob
- 15th July 2008, 10:07
Hi Lengcallrobot and welcome to the forums!

This is taken from the EasyHID help file contained in the EasyHID folder:

"What is a HID Device?

...... One of the major advantages of HID is that you do not need to supply a custom driver, as one is already supplied with the operating system. A limitation of HID is that its data transfer rate is limited to a maximum of 64KB per second. However, this is still significantly faster than RS-232 (115200 baud is approximately 12KB per second)......"

You should be able to send 64kBytes/sec in Full-speed mode as shown above.

It looks to me as though you are sending data in Low-speed mode 64kbits/sec (or 8kBytes/sec) from what you have shown.

Are you using a 48MHz clock source for the USB and have you set bit 2 of the UCFG register to enable Full-speed?

I could be leading you up the garden path about the speeds but this is my understanding

Hope this helps

Rob

lengcallrobot
- 16th July 2008, 11:01
Are you using a 48MHz clock source for the USB and have you set bit 2 of the UCFG register to enable Full-speed?

Thank Rob, however, I cannot set UCFG.2=1 or FSEN=1 in my program. When I do this, I get error message . the below is my source code in pbp

================================================== =================
DEFINE OSC 48
DEFINE LOADER_USED 1

USBBufferSizeMax con 64 ' maximum buffer size
USBBufferSizeTX con 64
USBBufferSizeRX con 64

' the USB buffer...
USBBuffer Var Byte[USBBufferSizeMax]
USBBufferCount Var Byte

'Variables -----------------
I var byte
Ana var word

' Define ports
SP1 VAR PORTC.0

' ************************************************** **********
' * main program loop - remember, you must keep the USB *
' * connection alive with a call to USBService every couple *
' * of milliseconds or so... *
' ************************************************** **********

TRISD = %11110000 'Set PORTD 0-3 to output, 4-7 to input
'UCFG.2 = 1

usbinit ' initialise USB...

ProgramStart: 'Just want to test the USB speed

high sp1
gosub DoUSBIn
low sp1
gosub DoUSBOut

goto ProgramStart

' ************************************************** **********
' * receive data from the USB bus *
' ************************************************** **********
DoUSBIn:
USBBufferCount = USBBufferSizeRX ' RX buffer size
USBService ' keep connection alive (executed at least every 10ms)
USBIn 1, USBBuffer, USBBufferCount, DoNext ' read data, if available
PORTD = usbbuffer[2]
Ana = (usbbuffer[0] << 7) | usbbuffer[1]
freqout sp1,500,ana
DoNext:
return

' ************************************************** **********
' * wait for USB interface to attach *
' ************************************************** **********
DoUSBOut:
USBBufferCount = USBBufferSizeTX ' TX buffer size
USBService ' keep connection alive (executed at least every 10ms)
USBOut 1, USBBuffer, USBBufferCount, DoUSBOut ' if bus available, transmit data
return
================================================== =================

Do you know other way to get Full-Speed mode with pbp ?
Thank you in advance.

Rob
- 16th July 2008, 12:41
Thank Rob, however, I cannot set UCFG.2=1 or FSEN=1 in my program. When I do this, I get error message


I think you're using PBP 2.47 or older so the UCFG register is not included. Try this:

UCFG var byte EXT
UCFG.2 = 1

Cheers

Rob

Bruce
- 16th July 2008, 17:08
Unless you're using descriptors you found somewhere else, you shouldn't need to mess with
UCFG. Your PBP USB template descriptor file should have this already in place.

#define UCFG_VAL _PUEN|_TRINT|_FS|MODE_PP ; Full-speed

Arguments for the define are listed in the USB18.inc include file under UCFG Initialization
Parameters.

kirtcathey
- 4th January 2009, 07:52
I want to use EasyHID, so purchased Microcode Studio about one week ago. Since then, Mecanique has not responded to two emails, I cannot find where to download EasyHID, and am at a loss. Have since sent a complaint to WorldPay and have requested a refund... just in case.

Where can one get hold of a copy of EasyHID? Or, are there other solutions out there, so I don't have to beg for the software from some vendor?

Is Mecanique going out of business? Why doesn't anybody respond?

Archangel
- 4th January 2009, 08:08
Is Mecanique going out of business? Why doesn't anybody respond?
Holiday season many businesses are closed. Try again Monday.

Darrel Taylor
- 4th January 2009, 08:12
EASY ....

Down boy, down ... That's better. :)

David is a busy man.
With MicroCode Studio, the PROTON IDE, Swordfish Basic, and others, the poor guys got his hands full.
Please don't report him to Internet squeelers.

Be nice, ask real questions ... he'll get back to you.
<br>

kirtcathey
- 4th January 2009, 08:24
Thanks again Darrel. Okay, I can understand that situation very well, since I tend to be a one-man band. However, it seems like with that much going on, he'd hire a spare geek or two to handle the front end.
Getting back to the subject....

I am building a proof-of-concept prototype (aren't we all!!) that will sit between the keyboard and host. When the end-user types in a certain character string or key combination, the microcontroller will send a control signal to another receiving device to start and stop a motor. Should I make this a keyboard HID, a generic device HID, or none at all and somehow pull information off the wire?

Regards,
Kirt

Darrel Taylor
- 4th January 2009, 08:38
I should mention that EasyHID comes with MicroCode Studio.

It's located in the "C:\Program Files\Mecanique\MCSP\EasyHID" folder. (assuming default installation).

In that folder, there is a file EasyHID.chm.
Should answer most of your questions.

kirtcathey
- 4th January 2009, 10:23
Right. And after reading a bunch of posts on these forums (many by you) about it... I want it even more! Or, do I? I am thinking that things may work out with just a generic keyboard HID for the time being, but not sure.

Demon
- 4th January 2009, 19:54
....

I am building a proof-of-concept prototype (aren't we all!!) that will sit between the keyboard and host. When the end-user types in a certain character string or key combination, the microcontroller will send a control signal to another receiving device to start and stop a motor.

...



What micro-controller will you use? Last I heard (maybe over a year ago), the PIC could not act as host to a USB device. Has a new model been released?

Robert
:)

kirtcathey
- 5th January 2009, 02:13
Robert,

Thank you.

I'm using an 18F2550, since it's only 28 pins. Yes, I understand that it cannot be a USB host, which is why I am at a loss. What I am doing right now with somewhat positive results is programming for a keyboard device, then plugging the straight-wiring the keyboard to the host, then pulling power and data taps to the PIC. All is recognizing fine, except am working on finding the right host driver for this funky keyboard.

Going to catch a train to Akihabara in a few minutes to pickup a generic USB keyboard and some other stuff.

Demon
- 7th January 2009, 16:41
Robert,

Thank you.

I'm using an 18F2550, since it's only 28 pins. Yes, I understand that it cannot be a USB host, which is why I am at a loss. ...


Courtesy of Mister E, check out the PIC24 et PIC32 family.

:)

kirtcathey
- 8th January 2009, 21:21
Somebody at Mecanique was kind enough to get Microcode Plus to me so that I can now use EasyHID, but it doesn't work. I fo through all the dialogs, then in the last dialog I get Generation Error: Unable to locate device item.

After reading other posts, I paid careful attention to the mfr name and product name, making sure there were no special characters. Am trying to create a USB device with an 18F2550,

Any help is appreciated.

kirtcathey
- 12th January 2009, 00:32
I've had this EasyHID problem and nobody at Mecanique responds with support. One email arrived asking me to send in a screen shot... I sent the screen shot, which doesn't make sense since it is the same error that the EasyHID in the non-plus version of Microcode Studio gave, which is a version limitation (I thought).

I purchased the plus version of Microcode Studio over two weeks ago and still don't have EasyHID working. What disgusts me, is that most software vendors these days at least have a troubleshooting FAQ about their products and these banchies don't even have a forum!

This is from their web site:
"We will respond to all complaints within one working day, usually the same day. We aim to resolve any complaints or problems within five working days. We will keep you informed and do our best to resolve the situation as quickly as possible."

They have so far only replied to one email. I do not count the response to the WorldPay claim that I had to submit after waiting a week for a purchase/delivery confirmation.

Yeah, yeah, they are busy or so-and-so has a bunch of projects. BS! So do I and I am trying to use their solution. Refund, refund, denial of credit charges.... hate to do that, but....

mackrackit
- 12th January 2009, 00:56
I do not understand...
MCS+ was purchased to have EasyHID?
I have the version of MCS that comes with the compiler and EasyHID is there as Darrel mentioned.

Maybe the problem is...elsewhere?

Demon
- 12th January 2009, 01:09
[QUOTE=kirtcathey;68507]
...

All is recognizing fine, except am working on finding the right host driver for this funky keyboard.

...QUOTE]


Something tells me this might be a case of RTFM. When you say "funky keyboard", do you mean an uncommon keyboard that will run separately from the USB/PIC device? Or are you referring to the USB/PIC device itself?

If you are referring to a keyboard not known by your operating system, I fail to see how Mécanique can be held accountable. But if you are referring to a custom PIC/USB device, doesn't EasyHID generate the code for the PIC as well as the code for the PC (driver)?

I haven't used EasyHID in a long time, I've been using another USB code generation software so I might be getting them confused.

kirtcathey
- 12th January 2009, 01:22
Finding the right driver for the keyboard is irrelevant to EasyHID functioning or not. And I have USB devices working without EasyHID, but do not have EasyHID working. The keyboard issue was resolved minutes after that post. Please do not mix and try and match issues - RTFposting history - my questions about EasyHID have nothing to do with keyboards. Is there a manual, besides the cursory online help that offers no troubleshooting pointers, for EasyHID?

And no.... EasyHID is now only available with the plus version of MCS. When you run it all the way to the end without the plus version, it says that it cannot find the device and that you have to upgrade.

The unspoken truth about this matter, is that I have to resort to a forum to see if anybody knows what is going on.... or try and resolve this matter....

I am selecting PicBasic Pro as my compiler, since that is the only thing available on the pull-down. Is this okay? Or, should I be selecting MPASM, which is not an available choice?
Does the device need to be in the programmer and recognized before running EasyHID? Do I need to have the ICD working? Do I need to have MS VC++ or Delphi installed on the same system that will run EasyHID? Any help would be appreciated since I cannot rely on the software vendor.

Robert Quote
But if you are referring to a custom PIC/USB device, doesn't EasyHID generate the code for the PIC as well as the code for the PC (driver)?
End Quote

No. I need the PC side of the code and I want/paid for EasyHID to do it. No. EasyHID does not work as described in previous posts.

Darrel Taylor
- 12th January 2009, 03:06
If I had a customer that was reporting me to credit card companies, and threatening to cancel payment unless I fix his problem NOW. I probably wouldn't be giving much help either. Although, I would just refund the money and say, go away.
Like I said before ... be nice to him, and he'll respond.

However, your problem appears to be related to EasyHID not being able to find the CodeGenerators.
Did you accept the default folders during installation? Or did you change them?

I can duplicate the error by hiding the CodeGenerators folder within EasyHID's folder.

<img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3101" /><!-- 3101 -->

But in order to do that, the screen previous to the error looks like this, with many options greyed out.

<img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3102" /><!-- 3102 -->

Does yours look like that as well?
<br>

kirtcathey
- 12th January 2009, 03:18
Darrel,

Thanks again. But I have been far less than demanding for NOW service on this issue. Two weeks, going on three weeks, have passed since purchasing the product and have only lodged one claim with WorldPay only after one week of the vendor not replying. As a consumer, I have not acted unreasonable. Like most consumers, after purchasing a product online, I like to have some kind of confirmation email from the vendor.

How often have you purchased software and have not been able to use it for three weeks? I have gone through software challenges before, but the vendor at least offered some kind of direct support.

All of the installation is default. The only difference is that I uninstalled the free version, rebooted, then installed the Plus version.

Here is my screen before the errors screen, which does not look like that.

kirtcathey
- 12th January 2009, 03:41
With no further ado.... and for those poor souls that will need this solution in the future.....

Go into the EasyHID program folder >> CodeGenerators folder and change the pbp.ini file so that the Target Folder is PBP (or whatever the name of your PBP program folder is).

Darrel Taylor
- 12th January 2009, 03:41
Try this ...

Instead of launching EasyHID from the IDE...

Go to C:\Program Files\Mecanique\MCSP\EasyHID with "Windows Explorer" and doubleclick EasyHID.exe to start the wizard.

Oops: too late.
<br>

dandyong
- 20th April 2009, 10:12
Hi all,

Nice to meet you. :)

I already have files generated by EasyHID.

What I want is when PIC18F4550 detect High in any of its digital inputs, Firefox is run automatically.

VB6 code to run Firefox for your reference.
Private Sub Form_Load()
Shell "C:\Program Files\Mozilla Firefox\firefox.exe", vbNormalFocus
End Sub

Just don't know how to write the part to detect HIGH in digital inputs of PIC18F4550.

Please send me the complete PIC source code & VB 6 source code for the above scenario to my email below.
[email protected]

I really appreciate your help.

Thanks and best regards.

mackrackit
- 20th April 2009, 11:09
Please send me the complete PIC source code & VB 6 source code for the above scenario to my email below.
But first you will have to transfer funds to my bank account.
Contact me at
"[email protected]"

mister_e
- 20th April 2009, 16:54
See this one
USBDemo, something to learn USB a little bit
http://www.picbasic.co.uk/forum/showthread.php?t=5418

And play with it.

That should cover most scenarios.

BobEdge
- 20th April 2009, 17:50
Hi,

Anyone know where I can get easy HID from?
The links at the start of this thread no longer work.

Regards
Bob...

mister_e
- 20th April 2009, 18:00
I think it's still available when you download the free version of MicroCode Studio.

http://www.rentron.com/mcstudio/mcsinstall.exe

Tom@Nottingham
- 20th April 2009, 20:11
Hi
Just to say I have recently installed easyhid to work with a pic18f4550 using the helm template to communicate with pc. On pc side I am using free 2005 vb express and all works great displaying 8 temperatures etc. e.g top of upright freezer -18 deg bottom -23 deg. Does anyone know if template will work with vb 2008, I have tried without success, any advice appreciated.

Tom

mister_e
- 20th April 2009, 21:03
Helm's one is mine, and yes it worked for me with VB2008 last time I tried (not for sure for express version though).

What kind of problem you have with?

mister_e
- 20th April 2009, 21:04
are you using Vista?

Tom@Nottingham
- 20th April 2009, 23:32
I will try again tomorrow. How does it know where to place template? I have both 2005 & 2008 vb installed.

Thanks for your swift reply.

Tom

mister_e
- 20th April 2009, 23:42
you just sit the USBTemplate.zip file as-is in My Documents\Visual Studio 2008\Templates\ProjectTemplates\ folder (here My Documents\Visual Studio 2008\Templates\ProjectTemplates\Visual Basic)

I no longer have 2005 or 2008 express, but Visual Studio 2008 Pro. Can't tell if 2005 & 2008 work properly all together.

Tom@Nottingham
- 20th April 2009, 23:46
Sorry I have not answered your question, I am using XP not Vista.

Tom

Tom@Nottingham
- 21st April 2009, 21:01
Steve
Thanks for your help, Template does now work fine with 2008 Express vb
after following your reply.

Tom

mister_e
- 22nd April 2009, 00:51
Sweet!

Enjoy!

eggman
- 30th June 2009, 12:24
Hello everyone,
I'm playing with the easyHID software and the great example USBDEMO (thank you mister E!) It works very well, but now I would like to program my PIC to act as a game controller so it will show up in the game controllers control panel. This way I will be able to use it with the Max/Msp programming language. I tried different PID/VID's but that does not seem to work. Anyone has an idea? thank you

BobEdge
- 1st July 2009, 12:04
Hi eggman,

I was about to post a similar thread. I want to make a "joystick" card that has 8 axes, 32 button inputs, and 4 POV inputs, but I am having trouble finding what I need to do.

I suspect it is all to do with the descriptor, and knowing what to do with it.
I could not find a working link to easyHID, so I am using HID maker FS. Any help would be appreciated.

Regards
Bob...

eggman
- 2nd July 2009, 10:22
Hello Bob,
Yes I delved a bit further into the USB stuff, the descriptor has to tell the host it is a joystick or game controller with so many channels and buttons. I don't think this can be done with easyhid, but maybe I'm wrong. Mechanique seems to have removed the easyHID download from their website but I found a copy here:
http://www.4shared.com/file/40239912/5a14733c/EasyHID.html
I found something else: www.create.ucsb.edu/~dano/CUI/ It's programmed in C but seems interesting

wjfong
- 31st March 2011, 09:51
I've used it, and if you're looking to get started with USB, then Dave's new
EasyHID & the PIC18F4550 are definitely the way to go.

Download & install EasyHID.
http://www.mecanique.co.uk/products/usb/easyhid.html

I have several projects for USB coming shortly, but in the mean time, I've
loaded the files for a complete USB project on our website.

The zip file contains PBP source code for a PIC18F4550, and VB source for a
USB analog data-logger. Should be fun for anyone interested in tinkering with
EasyHID and the new full-speed 18F USB parts.

Here are the files: http://www.rentron.com/mcstudio/EasyHIDPrj.zip

You'll need VB6 & SoftWire. You can download SoftWire from here. It's free.
http://www.softwire.com/swdownload/softwiredownload.htm

I used the activx controls in SoftWire for the analog meter interface. Really
nice stuff.

You'll also need PBP version 2.46 since this is the version offering support for
the newer 18F USB parts.

If anyone's looking for an excellent book on USB, then grab a copy of Jan
Axelson's new 3rd edition of USB Complete. We just got them in. I spent the
last few days reading mine, and it's awesome.

Jan has done an outstanding job on her 3rd edition of this book. Even "I" can
understand it now...;o]


good day, just tried out the easyhid & got some problems here, haha... i got the error msg: unable to locate device item.

can anybody tell me how can i rectify this problem??

thanks alot :D