CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug Reports on this forum. Send them to support@ccsinfo.com

PIC18F24K50 USB
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
temtronic



Joined: 01 Jul 2010
Posts: 6066
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Nov 18, 2017 6:43 am     Reply with quote

You may want to 'cut the cord' and disconnect the PIC from the PC for some testing.

Replace the PIC project with a 'loopback' wire from the TTL<>USB modules TX and RX TTL pins.

Use any Terminal program and every key pressed on the keyboard should be displayed on the PC screen.

1st test setup will have the module attached to the PC.
2nd test setup, connect the module to a USB 'extension' cable. You probably already have that one.

Once you see that it works for simple key presses, then cut a VB program to send a 'data packet' of 64 bytes. Be sure to use KNOWN data, like 'The quick brown fox...' NOT just random characters. Send in a loop, say 1 per second.
Run, sit back and observe what happens...

If it fails in 'setup 1' it's and PC problem (OS or MB), if it passes #1, fails #2...then the USB extension cable is probably faulty.

If it passes all combinations of the above tests then I suspect the PIC hardware or software is at fault.

As a 'reference' I've run a 64MHz PIC18F46K22 as follows:
PC USB> USB<>TTL module>PIC UART1
UART1 > UART2
UART2>UART1
UART1> TTL<>USB Module

This 'daisy chained loopback' configuration ran both UARTS at 115K200 for days with NO data problems. The modules are cheap ($2 back then) offshore, having both 5 and 3V options, power and data LEDs.
There's a 1M USB cable, magic, spring loaded, coils up like old window blinds did...very small wires too ! It's the same type I use to connect PICKit3 to my XP PC.

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 13045

View user's profile Send private message

PostPosted: Sat Nov 18, 2017 11:58 am     Reply with quote

Just try putting 22R resistors in the D+ and D- lines close to the PIC (just cut the wire/track and insert these in line). You will see these on a lot of USB devices. They help massively in reducing reflections at the end of the bus if there is a slight impedance mismatch.
georpo



Joined: 18 Nov 2008
Posts: 127
Location: Athens, Greece.

View user's profile Send private message

PostPosted: Sun Nov 19, 2017 10:33 am     Reply with quote

Today I tried on a windows 10 laptop with the same error results.
By now I have modified the vb code to send a detach command to the PIC
and reopen the comm port so I never get stuck anymore. I have a variable that increments every time this happens and I have to say that I get disconnected 1-2 times per minute.

I also have to admit that this pcb was not meant to have USB so I have the D+ and D- lines connected with wire to the side of the pcb where the USB plug is soldered.

Finally I hope that when I assemble the proper designed pcb the problems will be less.


_________________
George.
temtronic



Joined: 01 Jul 2010
Posts: 6066
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Nov 19, 2017 10:46 am     Reply with quote

well a picture IS worth 1,000 words !

I'd replace those two grey wires from the USB connector to the PCB with 22r resistors, as Mr. T said. It is important that both D+ and D- wires are the same length. It will help reduce(not eliminate) reflection problems.


I am curious as to what the PCB does of course......

Jay
georpo



Joined: 18 Nov 2008
Posts: 127
Location: Athens, Greece.

View user's profile Send private message

PostPosted: Sun Nov 19, 2017 11:02 am     Reply with quote

I also tried with 22R resistors on both lines but I removed them after reading page 339 of the 30000684B.pdf manual:



This pcb will measure ambient temperature and open a valve that will let water flow from the plumbing network of a house in case the temperature is near freezing point.
This way it is supposed to prevent pipes breaking from ice...

I added USB in order to change parameters temperature etc.

And let me correct myself. The pcb was supposed to have USB but not with this side plug.

Of course I will make the loopback tests and see what happens.
_________________
George.
Ttelmah



Joined: 11 Mar 2010
Posts: 13045

View user's profile Send private message

PostPosted: Sun Nov 19, 2017 12:42 pm     Reply with quote

The resistors are not needed _if your PCB circuit has the right impedance_. This is what the data sheet tells you.
However if there is a mismatch, because (for instance) there is a ground plane close to the USB pins, the resistors help.

Try them.

It is also necessary to have the two lines very close to the same length. In the picture one line is a lot longer than the other. Currently two lines without a properly spaced ground, means these will be functioning as if these are stubs. Huge amounts of reflection. Not surprised the USB is having real problems....
temtronic



Joined: 01 Jul 2010
Posts: 6066
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Nov 19, 2017 5:01 pm     Reply with quote

I did a 'run around' on the USB hardware/software issue years ago. It's actually cheaper and far more reliable to just buy a $2 TTL<>USB module.
I don't so production runs of 100 let alone 10,000 so it's easier to just buy the modules. We all hear 'horror stories' anout USB 'issues' and I learned 40 years ago, it's best to spend a buck extra up front and KNOW the product will work reliably for decades.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group