PDA

View Full Version : USB Pics, ICD2, pic basic pro



vacpress
- 17th January 2007, 20:59
Hello everybody. I have some experience with pics, pic basic, etc. but I was hoping someone with much more experience could comment on some stuff... Answer some questions which, I have been googling and stuff, but it isnt becomming totally clear. My questions are pretty easy, I think, for someone else to just say yes\no to. Here we go!

1. Does an ICD2 device program the USB Pic devices?(18f4550, etc)
2. Can I use protoboards designed for other 40 pin pics (ec 18f425) for my USB experiments? Just gotta add those extra components?
3. Does anyone know of protoboards that are specifically designed for the 18f4550? All I can find is boards with an FTDi rs232 chip, or boards just designed for general purpose 40-pin pics.

Thanks alot everone! I am at work and trying to be productive while brainstorming, cant sit on google searching! I am a new user. Please bear with me!

-R

vacpress
- 18th January 2007, 04:06
#1 Yes the USB pics seem to be in the ICD2 device list, which i finally found...

Now onto figuring out if the 40 pin 18f4550 is compatible with my protoboard from dhmicro.com (40xli)

Darrel Taylor
- 18th January 2007, 04:41
Glad you answered #1, since I don't use ICD2.


2. Can I use protoboards designed for other 40 pin pics (ec 18f425) for my USB experiments? Just gotta add those extra components?

Hmmm, 18F425, not familiar with that one.
But the 18F4550 has the same basic pinout as the 18F452. So anything that uses a 452 footprint will work for USB.
Of course you need a USB connector.

Here's one that I have several of...
Prototyping/Experimental Kit W/MINI-USB
http://cgi.ebay.com/Prototyping-Experimental-Kit-W-MINI-USB-Receptacle_W0QQitemZ300061148210QQihZ020QQcategory Z36327QQssPageNameZWDVWQQrdZ1QQcmdZViewItem

Or, The B version...
Prototyping/Experimental kit W/USB Type B Receptacle
http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=300061150043&ssPageName=MERC_VI_RUPX_BIN_Stores_IT&refitem=300061148210&itemcount=8&refwidgetloc=active_view_item&usedrule1=UpSell_LogicX&refwidgettype=cross_promot_widget

Or, The A version...
Prototyping/Experimental Kit W/USB Type A Receptacle
http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=300053358704&ssPageName=MERC_VI_RUPX_BIN_Stores_IT&refitem=300061150043&itemcount=8&refwidgetloc=active_view_item&usedrule1=UpSell_LogicX&refwidgettype=cross_promot_widget

And for #3, well, anything for the 452 will work, it doesn't specifically need to be for a 4550. But here's a good one for the price.
EasyPic 4
http://www.picbasic.co.uk/forum/showpost.php?p=30952&postcount=15

dhouston
- 18th January 2007, 12:47
Or, The B version...
Prototyping/Experimental kit W/USB Type B Receptacle
http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=300061150043&ssPageName=MERC_VI_RUPX_BIN_Stores_IT&refitem=300061148210&itemcount=8&refwidgetloc=active_view_item&usedrule1=UpSell_LogicX&refwidgettype=cross_promot_widget

Here's an assembled Type B breadboard adapter for an excellent price.
http://www.winfordeng.com/products/pbcub1f.php

vacpress
- 19th January 2007, 01:17
Hey!

Thanks. I actually just ordered some products from Winford. Fair enough prices on some stuff I need.

So, I managed to get as far as 'unknown USB device' in win xp pro sp2 when using the microchip bootloader files. I found a compiled .hex for the 18f4550 on the forums here somewhere.

When I specifiy the correct device driver, it refuses it, prefering to be unknown. Jerk.

Any insights on this? I should note that Ive got a 10pf cap pulling pin 18(usbv) to ground, not the specified 470nf. 10pf is the smallest ive got!

Thanks!

Darrel Taylor
- 19th January 2007, 01:35
That capacitor is probably the culprit.

It's there to stabilize the 3.3V Voltage Regulator for USB.

10pf is way too small. 0.22uF is recommended, but I've used .1uF once only because I didn't have a bigger one handy at the moment.

A larger capacitor will work fine, 1uF, 4.7uF whatever you have. It's just there for a filter.
<br>

vacpress
- 19th January 2007, 01:37
as i am about to go grab a bigger cap to try, let me ask, why do the schematics show a 470nf cap here then? isnt that much smaller than .22uf?

thanks!

Darrel Taylor
- 19th January 2007, 01:46
.000000470000
| | | |
mili-/ | | |
micro---/ | |
nano-------/ |
pico----------/

470nf = .000000470 F = .47uF = 470,000 pF
220nf = .000000220 F = .22uF

.

vacpress
- 19th January 2007, 01:50
I tried again with a 2.2uf. Sadly, no improvement. It continues to act the same on both available test systems. I am using a 20mhz ceramic resonator, is it possible this is a problem?

the 20mhx resonator has worked fine for other projects and it also runs the blinky led test on the 18f4550...

thanks! i really am not a lazy question asking *******... ive probably spent 20 hours on this in the last 4 days...

-robert

(p.s. i am trying to usb-ize some of my future projects, wanna see past stuff? the electronics are buried in the list. www.robertguyser.com)

vacpress
- 19th January 2007, 01:56
oi!

those stinking cap ratings and markings are madening!

thanks for the 101!

aaand, just in case someone who is also wanting to know about the icd2 and 18f4550 runs into this thread; they do work well together, not sure what debug features will work, but it programs the sucker.

Darrel Taylor
- 19th January 2007, 02:11
I am using a 20mhz ceramic resonator, is it possible this is a problem?

For 20mhz, what do your CONFIG's look like?

Here's an example from Bruce.
http://www.picbasic.co.uk/forum/showpost.php?p=19785&postcount=4
<br>

Darrel Taylor
- 19th January 2007, 03:17
wanna see past stuff? the electronics are buried in the list. www.robertguyser.com)

Ha ha, that Vacuum Former you drew up, looks just like my old Vac-U-Form I had when I was a kid. :)
Except it doesn't have a handle on the front to pull down the vacum. And it's a little bigger.

Vac-U-Form by Mattel
http://www.spookshows.com/toys/vacuform/vacuform.htm

vacpress
- 19th January 2007, 03:26
So. I am now attempting to use the code from Mister E's awesome looking USBDemo thread (http://www.picbasic.co.uk/forum/showthread.php?t=5418&highlight=18f4550)

I cannot get PBP code to compile through microcode studio, i get "Overwriting previous address contents (xxxx)" then it says 'too many errors quitting. I am using mpasm. Grrr

In the meantime, I have loaded the included .hex file and unfortunately i still get the same results. It is, I suppose that is a good sign... Any idea what it means? I dont have enough experience to troubleshoot this stuff, hence the posts. I gather USB is asking what the device is, and it isnt able to tell it. I know there is also something about enumeration failure, but i do not think this is the same..

??

continued thanks

Darrel Taylor
- 19th January 2007, 03:39
mister_e's example was setup for a 4mhz crystal. You'd have to modify it for 20mhz.

"Overwriting previous address contents (xxxx)" means that the CONFIG lines in the program are conflicting with the config lines in your 18F4550.inc file.

Which means you still need to answer post #11 :confused:

vacpress
- 19th January 2007, 03:50
mister_e's example was setup for a 4mhz crystal. You'd have to modify it for 20mhz.

"Overwriting previous address contents (xxxx)" means that the CONFIG lines in the program are conflicting with the config lines in your 18F4550.inc file.

Which means you still need to answer post #11 :confused:

Ahh. I see. Ok. Well. I actually switched to a 4mhz resonator, just to confirm that it is 'near working', i tried it with the 20mhz one and the pc didnt recognize it, so at least the code seems to be attempting a usb connection. I have turned my suspicions on the cable. Ive got the colors right, but when I try to test them to the usb cable pins as they are listed at (http://www.usbman.com/Guides/BelkinMotherboard_cable_assembly.htm) using a multimeter, they are all different. Interestingly, connecting the USB power lines into the power bus of my pic proto board powers it fine, i tried it with a non-usb led blinky and it powered it, so i still think the cable is OK...

Grrr. First timing USB is hard!

i will check the config conflict issues and see if i can get it to compile

vacpress
- 19th January 2007, 04:05
The _Configs. I looked at them and wasnt exactly sure what to do.. it looks to me like i should change the .inc to match the .pbp? The setting are in fact different. I dont know exactly what they all mean, but I see that the PLL settings are different, as well as most of the others.

Change the .inc to match?

How do i put the code in abox like in other posts?


from 18f4550.inc
--------------------
LIST
LIST p = 18F4550, r = dec, w = -311, f = inhx32
INCLUDE "P18F4550.INC" ; MPASM Header
__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
__CONFIG _CONFIG3H, _PBADEN_OFF_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L
NOLIST
endif
LIST
EEPROM_START EQU 0F00000h
BLOCK_SIZE EQU 32

from USBDemo.pbp
-----------------------
asm
__CONFIG _CONFIG1L, _PLLDIV_1_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
; ; ; USB clock source comes from the 96 MHz PLL divided by 2
; ; [OSC1/OSC2 Src: /1][96 MHz PLL Src: /2]
; No prescale (4 MHz oscillator input drives PLL directly)


__CONFIG _CONFIG1H, _FOSC_XTPLL_XT_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
; ; ; Oscillator Switchover mode disabled
; ; Fail-Safe Clock Monitor disabled
; XT oscillator, PLL enabled, XT used by USB
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _BORV_2_2L & _VREGEN_ON_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H
__CONFIG _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_ON_3H
__CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
endasm
DEFINE OSC 48

Darrel Taylor
- 19th January 2007, 04:27
Thanks,

The 18F4550.inc file was correctly setup for 20mhz. So it wasn't that.

To get mister_e's program to compile... Comment out all the CONFIG lines in the 18F4550.inc file with a semicolon ";". This will let the CONFIG lines in the program take effect.

Stick with the 4mhz osc. I know his program works, so that might help you work out the cable problem.

<hr>

How do i put the code in abox like in other posts?

At the bottom of each page, there's a box that says Posting Rules (scroll down). In that box is a link ... vB code is On.

That link explains all the post formatting commands. The one to put it in a box is
...

HTH,

vacpress
- 19th January 2007, 04:33
many thanks... rewiring the thing and commenting out _configs... will assuredly be back!

thanks for bearing with me... if you ever need solidworks tutoring...

vacpress
- 19th January 2007, 04:45
so, having commented out the .inc _configs, I now get far fewer errors, just 1, besides those irritating depreciation warnings... the error is..

Error[113]: Symbol not previously defined (_FCMEN_OFF_1H)

Darrel Taylor
- 19th January 2007, 06:13
Oh yeah, seen that one before.

For now, just change it to _FCMEM_OFF_1H

If you upgrade MPLAB in the future, you'll need to change it back.
Microchip changed it somewhere along the line.
<br>

vacpress
- 19th January 2007, 06:23
at any rate, it compiles without errors now, though i will not be surprised if it continues to refuse to work..

a question, i am testing this stuff on 2 laptops. one has usb 2, the other dosent..the one without is an old junker that i am using to save my good laptop the risk, any idea if this could be a problem? i dont suspect so, as it acts the same on both.

i will try the compiled hex..


also, incidently, what is that config flag, and where do i read about them? in the pic basic manual, or in microchip language manual? i come to this stuff from basic stamps and basicX controllers... this is why the assembler pic stuff is foreign to me yet i am trying a fairly difficult task...

when you tried this, did it go smoothly? what were your conditions?


Thanks

vacpress
- 19th January 2007, 06:40
well, it continues to misbehave. i suppose i might make a schematic of what ive got hooked up, i am working on a prefabricated protoboard so i have to trust their datasheet for some information because traces are hard to .. uhh.. trace, under the components.

what is a .COD?

Darrel Taylor
- 19th January 2007, 06:51
At best, a PIC can do "Full Speed" USB. Which is compatible with USB 1.1.
So the old laptop should be fine.

also, incidently, what is that config flag, and where do i read about them? To find out what they do... look in section 25.1 of the datasheet. Under "Special Features of the CPU" / "Configuration Bits".

To find out what to call them in your program, look at the bottom of the P18F4550.INC file in the same folder as MPASM.
<br>

Darrel Taylor
- 19th January 2007, 09:01
when you tried this, did it go smoothly? what were your conditions?

I started with mister_e's code. A pluggable Breadboard. And real USB cables.

From start to first Yahoo! was about an hour and a half.
Had an FCMEN error...
Had a problem with the capacitor too...
Then ... when I saw that little "Unrecognized" window, or actually, didn't see it. I was a very happy little Nerd.

<hr>

... i come to this stuff from basic stamps and basicX controllers...
http://darreltaylor.com/files/BadStomp.gif

vacpress
- 19th January 2007, 21:28
well. of course this example highlights the benefits of basic stamps. parallax would have put together coherant instructions. i am on like hour 15 of this now(not in a row, of course!). i have read so much about so many topics, and none has really helped, it still does the same thing it did 12 hours ago. very frustrating. unfortunately I cannot give up, combination of stubornness and having too much invested allready (time and money)

i suppose the next step is to rebuild the entire circuit on breadboard, giving up on my easy to work with protoboard... i suppose i also need to find a 4 and 20mhz crystal...as opposed to these resonators that always have worked fine for me in the past..

why is this so hard?

vacpress
- 19th January 2007, 22:01
So, Ive used the UBB USB Sniffer to see what is going on.. This is the log it makes, any ideas?

I see that it is getting back alot of 0s.. Just like when i try to verify a pic that isnt in the programmer socket... i will now scour the USB protocol so I can troubleshoot these foreign messages. Damn, this isnt how i like to spend my little spare devlopment time...



000000: PnP Event: Device Connected (UP), 19.01.2007 15:57:30.4977888
The USB device has just been connected to the system.

000001: PnP Event: Query ID (UP), 19.01.2007 15:57:30.4977888 +0.0
Device ID: USB\Vid_0000&Pid_0000

000002: PnP Event: Query Device Text (UP), 19.01.2007 15:57:30.4977888 +0.0
Description: USB Device

000003: PnP Event: Query Device Text (UP), 19.01.2007 15:57:30.4977888 +0.0
Location: USB Device

000004: PnP Event: Query ID (UP), 19.01.2007 15:57:30.4977888 +0.0
Instance ID: 3

000005: PnP Event: Query ID (UP), 19.01.2007 15:57:30.4977888 +0.0
Hardware IDs: USB\UNKNOWN

000006: PnP Event: Query ID (UP), 19.01.2007 15:57:30.4977888 +0.0
Compatible IDs: USB\UNKNOWN


this is what the logger reports when i set it to track the next device to be plugged in, and then plug in my project.

anyone know of any GOOD walkthroughs for this stuff? I am very close to plunking down the $60 for the Microchip.com demo board.this troubles me because i am poor enough as it is, and that is like, half my food money for the next 2 weeks!

-R

Darrel Taylor
- 19th January 2007, 22:28
> parallax would have put together coherant instructions

Naaa, they just make you use an FTDI chip, so they don't have to deal with it.

> ...i suppose i also need to find a 4 and 20mhz crystal...as opposed to these resonators...

I'm running mine on a 4mhz resonator here. Works just fine.
<br>

vacpress
- 19th January 2007, 23:01
off to the other room with it. i have a whole electronics lab, and ive been working on this in my bedroom for some reason.. i will now go rebuild the entire stupid circuit from scratch testing each section, use different USB cables to cut down the chance one is sketchy, etc... what a pain in the ass...

any other hints you may have? photos of your project? anything? suggestions?

thanks.

Darrel Taylor
- 20th January 2007, 01:26
If it will help...

<table><tr><td>http://www.darreltaylor.com/files/USB/USB_PROTO_TN.JPG (http://www.darreltaylor.com/files/USB/USB_PROTO_med.JPG)</td><td>http://www.darreltaylor.com/files/USB/USB_PR2_TN.jpg (http://www.darreltaylor.com/files/USB/USB_PR2_med.jpg)</td></tr><tr><td>Click image to enlarge</td><td>Click image to enlarge</td></table>

vacpress
- 20th January 2007, 09:07
I got it working! The stinking cable had the standard colors, red, black, green, white, but they were all odd configurations... black was NOT ground!

anyways, now on to the hard stuff.... getting the easyHID code to work in visual basic .net!

Thanks for all the help I am actually very grateful and dont take it for granted at all that you read pages of my inability to use check my USB cable!

I build the circuit on breadboard with a different cable, it worked right away! i tried my other cable.. didnt work, rewired it, it worked, tried my protoboard with the correct wiring: BINGO! like 12 hours later!

glad i went out for those 2 pints in between!

a shame the easyUSB project has 2 run errors in .net


any .net know how mr?

Darrel Taylor
- 20th January 2007, 09:22
Awesom!


any (visual basic) .net know how
Can't help you there, I'm a Delphi guy.

Please hold for the next available operator......beep...<img src=http://www.lagunabeachinfo.com/images/db/cal/music-note.gif width=90 height=35>

vacpress
- 20th January 2007, 10:32
one thing i am definiately interested in is cross platformness to linux and mac...

any idea if the HID driver is available for mac or linux..


heeelllo google.

keithdoxey
- 20th January 2007, 12:35
If it will help...

<table><tr><td>http://www.darreltaylor.com/files/USB/USB_PROTO_TN.JPG (http://www.darreltaylor.com/files/USB/USB_PROTO_med.JPG)</td><td>http://www.darreltaylor.com/files/USB/USB_PR2_TN.jpg (http://www.darreltaylor.com/files/USB/USB_PR2_med.jpg)</td></tr><tr><td>Click image to enlarge</td><td>Click image to enlarge</td></table>


Oi! Darrel ....NO!!!!

Hangs head in shame

Dont show pictures of extremely neat breadboards. Where is the possibility of accidently shorting stuff out during development.

Your looks almost like a PCB. The "defining connections" stage of routing a PCB is called a "ratsnest" for one good reason....so it can look like the breadboard that you prototyped on :)

vacpress
- 20th January 2007, 20:47
Oi! Darrel ....NO!!!!

Hangs head in shame

Dont show pictures of extremely neat breadboards. Where is the possibility of accidently shorting stuff out during development.

Your looks almost like a PCB. The "defining connections" stage of routing a PCB is called a "ratsnest" for one good reason....so it can look like the breadboard that you prototyped on :)

HA! I eventually used that as inspiration to do an extremely neat breadboarding myself, which worked first time...Imagine!

Really though, the hard part is this software. There is quite alot going on! It is really much more than I am used to, i thought my neworked BS2s had complex code....

Thanks guys, you are a real resource in a sea of difficulties(microcontroller development)

Robert

Darrel Taylor
- 20th January 2007, 20:50
Dont show pictures of extremely neat breadboards....
ROFL,

I'll take that as a compliment.

But really, it's just that you don't want to have anything that correlates to Rats in your proto-board, when you have 2 Evil glowing eye'd monsters in the house. :)

http://www.darreltaylor.com/files/USB/Cats_Eyes.jpg

They've caused more than a few hours of troubleshooting in the past.