Ok Thanks Steve! Looks like I will have to buy some 18f4550 .
Well, one in the list... 18F4550, 2550,2455, 4455 they all works.
As you'll see, it's fun to have it's first working USB project....even if you're aware of post #7 and #8
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Hopefully this Topic is still alive as I am really keen to do some experimenting with USB.
I have looked at all the posts and haven't found any refering to my problem.
I am using the 18F4550 pic, Picbasic Pro 2.50 and MicroCode Studio Plus 3.0.0.5
When I compile it stops on Line 81
Line 81: UCFG var byte EXT ' include UCFG register... Yeah Melabs didn't (
Line 82: ucfg = %00010100 ' enable internal USB pull-up, Full speed USB
With the following Error Message:
ERROR Line 81: Redefinition of VAR. (USBDemo.pbp)
I notice that when I paste the code from mister-e's zip file into MicroCode Studio it changes the case of line 82:
Line 81: UCFG var byte EXT ' include UCFG register... Yeah Melabs didn't (
Line 82: UCFG = %00010100 ' enable internal USB pull-up, Full speed USB
the ucfg is now in Capitals, I don't know if this has anything to do with it?
Previous versions of PBP didn't have the UCFG register defined in the include files. And usbdemo was written at that time.
PBP 2.50 does have the UCFG register, so defining it in the main program causes a "re-definition" error.
Just comment out the UCFG var byte EXT line and the error should go away.
hth,
DT
I am using the 18F4550 pic, Picbasic Pro 2.50 and MicroCode Studio Plus 3.0.0.5
When I compile it gives the following errors.
Error[118] c:\progr~1\mecani~1\mcs\usbdemo.asm 87 : Overwriting previous address contents (0000)
Error[118] c:\progr~1\mecani~1\mcs\usbdemo.asm 87 : Overwriting previous address contents (0001)
Error[118] c:\progr~1\mecani~1\mcs\usbdemo.asm 93 : Overwriting previous address contents (0000)
Error[118] c:\progr~1\mecani~1\mcs\usbdemo.asm 93 : Overwriting previous address contents (0001)
Error[118] c:\progr~1\mecani~1\mcs\usbdemo.asm 98 : Overwriting previous address contents (0002)
Error[118] c:\progr~1\mecani~1\mcs\usbdemo.asm 98 : Overwriting previous address contents (0003)
Error[118] c:\progr~1\mecani~1\mcs\usbdemo.asm 99 : Overwriting previous address contents (0004)
Error[118] c:\progr~1\mecani~1\mcs\usbdemo.asm 99 : Overwriting previous address contents (0005)
Error[118] c:\progr~1\mecani~1\mcs\usbdemo.asm 100 : Overwriting previous address contents (0006)
Error[118] c:\progr~1\mecani~1\mcs\usbdemo.asm 100 : Overwriting previous address contents (0007)
Are these errors anything to be concerned with?
Also out of interest, I am using a 4Mhz Resonator but in the code it is: DEFINE OSC 48
What is that about?
However, I seem to be making progress because when I plug it into the USB of the computer. I get the message found new hardware "USB Demo" but then it gives a message There were problems ........ etc etc.
The VB Application is not picking it up yet.
What to do if i get "overwriting previous address content" error message?
http://www.picbasic.co.uk/forum/showthread.php?p=6775
The 18F/USB PIC's have an amazing oscillator/PLL structure.Also out of interest, I am using a 4Mhz Resonator but in the code it is: DEFINE OSC 48
What is that about?
With the proper CONFIG settings, You can use any crystal that's a multiple of 4mhz (4,8,12,16,20) and still have a system clock of 48mhz.
If the timing doesn't work well with your program, you can also have 48mhz going to the USB module, and 4/8/12/16/20/24/32 mhz going to the system clock.
It all depends on the CONFIG's.
<br>
DT
I commented out the four offending lines in the 18F4550.INC file and now don't get any errors. However, still get a error message from windows when I attach the PIC
Messages are: Found New Hardware. USB Device
USB Human Interface Device
A problem occurred during hardware installation. Your new hardware might not work properly.
I have tried USBDemo.exe and HIDmonitor.exe neither of these seems to see the PIC.
Any suggestions as to what I should try to do now to find the fault. At this stage I have not connected the push buttons or the trim pot to the breadboard but this shouldn't affect the pic being recognised as a USB device.
P.S. I have the USB connected to 18F4550 in the following way. D- to pin 23, D+ to pin 24 and the -ve usb connection and the USB case connected to vss. I have not connected the +ve usb connection to anything.
Last edited by kiwipiper; - 25th January 2008 at 02:20.
Forget my last I have figured it out ....... a very happy man here.
I had left out the .47uF cap on Vusb. Connected this and all is working.
Will now have a serious play with it, which I sure will create a bunch more questions.
Thanks for all your help Darrel.
This One for Darrel Taylor. My question is how did you get on modifying the USBDemo program from VB to Delphi. I am much more comfortable working in Delphi than VB and would be really interested in any examples of Delphi Code for this project. I found a good component at http://www.soft-gems.net/index.php?o...d=14&Itemid=33 and have had some success in using it to connect to my PIC but my limited programming ability slows me down a fair bit, although I am learning a lot. If I had a working example in Delphi I am sure it would help me understand what is going on much better.
A second question is how do you put a serial number into the program. I have been playing around with the DESCUSBDemo.asm
file and tried to put a serial number into the code. Here is what I did:
; serial number
String3
retlw (String4-String3)/2
retlw DSC_STR
retlw '4'
retlw 0x00
retlw '3'
retlw 0x00
retlw '2'
retlw 0x00
retlw '0'
retlw 0x00
retlw '8'
retlw 0x00
retlw '8'
retlw 0x00
retlw '8'
retlw 0x00
Not working. Any suggestions.
Both questions can be answered with EasyHID.
The serial number is entered on one of the setup screens.
And EasyHID will make a "Starting" program for either VB or Delphi.
<br>
DT
Thanks for that Darrel .... I did not understand the significance of EasyHID when it was being discussed in this thread earlier on. Making some real progress now and think I should be able to recreate the VB USBDemo.exe in Delphi. Very exciting stuff this USB.
Hi....i'm new in 18f4550..
Can picbasic pro program this PIC?
How to open the USB port on this PIC?
Thanks a lot....
Hi
Here is an adaptation of Mister_E USBDemo but in Delphi. It's not completely finalised but it works. This example bases on the PICPROTO-USB board from MELabs (you can get all the information on this board from their web site).
It's PIC18F4550 @ 20 MHz based. I hope the rest is self explanatory. PWM signal is on PORTC.2.
If you need more info, just let me know. Please, take into account I am not very often on this forum, i.e. please, allow longer reaction times in case you need feedback.
Have fun
Last edited by Momboz; - 30th January 2008 at 21:16.
Thanks Momboz but I managed to completely recreate Mister_E's USBDemo.exe in Delphi. It was pretty easy once I understood what EasyHID was all about. Had a little bit of trouble with the PWM but in the end once I understood what MSB and LSB was all about that fell into place as well. The only thing I can get working is showing a serial number.
Anyway, thank you to everyone who has contributed to this thread it was all very helpful getting me on the right track. For those just starting with this I concur with skimask's comments two posts back that all the information you need is in this wonderful thread. It is the journey of discovery that is the important part and a bit of a struggle makes it all the more rewarding when you get there in the end.
Here is a link to my KPUSBDemo.zip for another take on the computer interface. It is slightly over the 200K limit, most likely due to my coding skills and overuse of graphics to pretty it up some. If anyone is keen on the code I could clean it up a bit, zip it up and put it up somewhere.
http://www.breambay.com/downloads/KPUSBDemo.zip
Hi....what is EasyHID? Is it same as picbasic pro software?
Where can I download the EasyHID?
Thanks a lot....
Hi mister_e & all who have contributed. I am quite new to PBP and this is my first post to this list. I just found this demo a week ago, read the thread, ordered the parts, assembled a proto board on Saturday and - (insert Windows USB Device da-dink! sound) it worked FLAWLESSLY, the first time. I am either lucky standing on the shoulders of giants - but oh, my, what a good feeling.
I have been tinkering incessantly since then.
Thank you for giving me super powers.
Take my advice...Give out while you still can...
I have lost countless hours of sleep playing with USB and that demo, spent untold amounts of money, not to mention ticked off the wife numerous times...
Seriously though...Good game...
I wish other Noobs would take that as an example...especially the part about 'reading the thread'....
NOTE: If your going to use LONG variables, you MUST copy the PIC18Xxxxx.BAL file in your source directory as well, unless you'll receive some compilation errors.
The .BAL file is located in \PBP\USB18 directory.
If you're using PIC18F4550, you MUST copy the 18F4550.BAL file in your source code directory.
@Darrel.. is this possible to paste it in the first post as well as the other source code (or link) for the other PICs (post 99 http://www.picbasic.co.uk/forum/show...8&postcount=99) ?
Last edited by mister_e; - 4th April 2008 at 20:21.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Ok so first of THANK YOU to everyone.
I'm much further than I was a year ago already...which is a device windows enumerates....
Now for the problem
So i have a 2550. I commented out the old .inc file lines updated the ASM line to reflect the proper PBP version i have, implemented the corrected Fuse settings for the 20mhz crystal. and When I plug up the device to Windows I get "USBDemo" then it changes to two different things Hid compliant device and USB Human Interface Device. Then The HID compliant one disappears...then the USB Human Interface Device Gets an ! over it...
If i run the USB demo VB program the Device Manager Updates and sometimes It will remove teh USB device all together...or sometimes just change to a USB Unknown Device.
WTF?!
Earlier I plugged it in and the DEMO vb Recognized it and displayed the RX data for like...20 loops....then then everything stopped. it didnt recognize the usb device anymore as the Mister_E USBdemo that the program previously displayed...
Other than the ASM changes, "DEFINE OSC 20" and fuse changes ....i haven't changed anything software side. Hardware I have a .33uf because well...the store had a .47uf in 300volts size..and that was to large for the board..and kinda ridiculous. PBP version is 2.46
Is there a setting in MELABS programmer for the internal pull ups? I saw there was on in the code..but maybe it was being overwritten?
I've been toying for 3 days now...re reading the thread and looking at others...
Also...I dont have a .BAL file...*.bal search turned up nothing.. GR....
Anyone?
Last edited by UnaKRon; - 7th June 2008 at 03:53.
Which are rather large changes considering you have to have the right freq for the USB to run right in the first place.
Don't know if it'll fix your problem or not, but there is a 2.46 patch, and a few updates for $25 that gets you up to PBP 2.50A. A few fixes for USB and PIC18F types. Might help, might not.PBP version is 2.46
Internal pullups on Port B are described in the datasheet for the particular PIC.Is there a setting in MELABS programmer for the internal pull ups?
And you won't unless you're using PBP 2.50A.Also...I dont have a .BAL file...*.bal search turned up nothing.. GR....
Hello..
I'm using 18F2550 and USB is working very well... I've been trying to increase the buffer size from 8 to 16 but it do not work.
On Pic's code, I've only changed this:
On VB's code, this:Code:BufferSize con 16 ' BufferSize con 8
Any idea of what is the problem?Code:Private Const BufferInSize = 16 ' Private Const BufferInSize = 8
Thanks!!
Sylvio,
The IN/OUT "Report" length is usually set in one of the easyHID dialogs.
Or it can be changed manually in the Descriptor file.
If you re-run easyHID for the same project, it will wipe out any changes you've made. So create a new project, set everything the way you want it in easyHID, then just copy the descriptor file to your existing project.
hth,
DT
Hello,
First, Mister e This is an outstanding demo. Was able to get running right out of the box on a PIC18f4550.
I've been trying to add an additonal 8 LEDs to the demo but keep getting overrun errors. Which I'm sure it's caused on the VB side. I'm almost sure the PIC side is ok as i can turn on the original 8 LED or the ones added to PORTD. Can even turn on 4 on PORTB and 4 on PORTD. I'm just unable to get all 16 working at the same time.
I think my problem is in this part of the VB side code. I was hoping someone could point me back in the proper direction
Any assistance would be greatly appricatedCode:Private Sub Check1_Click(index As Integer) ' ' Convert PORTB check box to decimal value before sending it ' to USB bus. Result is store in BufferOut(1) ' Dim LoopCheck, PORTB As Byte PORTB = 0 For LoopCheck = 0 to 15 ' 0 To 7 PORTB = PORTB + (Check1(LoopCheck).Value * (2 ^ LoopCheck)) Next BufferOut(1) = PORTB WriteSomeData End Sub
Last edited by Philtkp; - 8th August 2008 at 18:59. Reason: Formatting
Well of course it won't work.
PortB is a Visual Basic Byte variable (or whatever you want) which gets stored in a Byte Array and sent over the USB to the PIC as a Byte variable stored in a Byte array, which is then stored in the PIC as a Byte variable.
Code:Private Sub Check1_Click(index As Integer) ' ' Convert PORTB check box to decimal value before sending it ' to USB bus. Result is store in BufferOut(1) ' Dim LoopCheck, PORTB As Byte PORTB = 0 For LoopCheck = 0 to 15 ' 0 To 7 PORTB = PORTB + (Check1(LoopCheck).Value * (2 ^ LoopCheck)) Next BufferOut(1) = PORTB WriteSomeData End Sub
i want to use usbdemo to count rpm of motor and display the rpm in computer. how to do that?
Begin small, begin by finding a way to count the RPM, show it on a lcd or via a serial communication... once you have it done, port your to code to USBDemo.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
i use 8 slot encoder.
after googling few minutes. i add this code into usbdemo
Code:COUNT PORTA.2,100,speed speed = speed * 10 * 60 / 8 rpm[0] = speed / 1000 // 10 rpm[1] = speed / 100 // 10 rpm[2] = speed / 10 // 10 rpm[3] = speed // 10 rpm[4] = 0 rpm[5] = 0 rpm[6] = 1 rpm[7] = 1 @ SendUSB _rpm
With the release of PBP version 2.60, mister-e's USBdemo (or any other program derived from EasyHID) will no longer compile (without some changes).
The new way of doing USB with PBP is really nice.
So here's a modification to Steve's program that will allow it to be compiled with PBP 2.60, and hopefully show how much easier it is to do USB.<hr>
√. If you haven't already ... download and extract the USBDemo from the beginning of this thread.
√. Then create a new folder (USBDemo260) and copy the USBDemo.pbp file from Steve's archive into the new folder.
That is the only file that is valid with 2.60, so don't copy any of the others.
√. Download the USBDEMOdesc.bas.txt (descriptor) file attached to this post and place it in the same folder. Remove the .txt extension.
√. In the USB18 folder, inside your PBP folder ...
Copy the following files to the project ...
usb_dev.asm
usb_dev.inc
usb_hid.asm
usb_hid.inc
usb_mem.asm
√. Add this line to the USBDemo.PBP program ... and compile.And away you go, with a little Ding-Dong ... Or maybe a Dong-Ding. <hr>Code:INCLUDE "USBDEMOdesc.bas"
Make sure you change the configs if you're not using a 4Mhz crystal.
And comment out the UCFG EXT variable since it's not needed anymore.
The Visual Basic part of mister-e's demo is the same.
You can use the pre-compiled program, or modify it as desired.
DT
Steve, the link to the PC interface schematic as posted in your original is broken. Can you please give me a valid link or email me the schematic at [email protected]? I want to check your USBDemo out!
Haven't seen him around for awhile.
His website is gone too.
Here's the schematic he had previously posted.
DT
Bookmarks