View previous topic :: View next topic |
Author |
Message |
tiket
Joined: 14 Apr 2005 Posts: 31
|
Posted: Fri Jun 29, 2012 4:39 pm Post subject: |
|
|
For last question I answer myself not work with 12MHz crystal too.
Signal on D+ and D- is 3v and 3.4V.
Have anyone test USB library with mega2561? |
|
Back to top |
|
|
ollopa
Joined: 03 Sep 2007 Posts: 233 Location: California
|
Posted: Fri Jun 29, 2012 5:40 pm Post subject: |
|
|
ollopa wrote: | I have personally tested the library on a Tiny461, Mega8, Mega48, Mega644, and Mega2560. 12MHz and 15MHz are working |
What version of swusb.lbx are you using? What pins did you put D+ and D- on and did you update the code to match your physical arrangement? Can you post schematics? |
|
Back to top |
|
|
tiket
Joined: 14 Apr 2005 Posts: 31
|
Posted: Sat Jun 30, 2012 8:28 am Post subject: |
|
|
hi mr Hollopa,
I'm using the library v1.06 that I have downloader here:http://www.mcselec.com/index2.php option=com_forum&Itemid=59&page=viewtopic&t=7537&postdays=0&postorder=asc&start=210
I have attached schematics and your USB_HID_keyboard modify for mega2561. |
|
Back to top |
|
|
tiket
Joined: 14 Apr 2005 Posts: 31
|
Posted: Wed Jul 04, 2012 9:19 am Post subject: |
|
|
Hi, no one can help me? I think that if library work with mega2560 should work with mega2561 too. |
|
Back to top |
|
|
Ajaxelectronic
Joined: 22 Nov 2009 Posts: 171 Location: Iran
|
Posted: Thu Jul 05, 2012 2:42 pm Post subject: |
|
|
Hi
First special thanks from Mr. Ollopa for this nice LIB.
i used from it and it work good.
but i can't understand role of this section :
Code: |
'Check for reset here
While _usb_pin._usb_dminus = 0
Incr Resetcounter
If Resetcounter = 1000 Then
Call Usb_reset()
End If
Wend
|
when _usb_pin._usb_dminus will zero? _________________ www.mrkelectronic.blogfa.com
Best Regards |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Thu Jul 05, 2012 5:34 pm Post subject: |
|
|
Ajaxelectronic wrote: | Hi
Code: |
'Check for reset here
While _usb_pin._usb_dminus = 0 'Stay in loop unitil usb_dminus <> 0
Incr Resetcounter 'Increment a delay conter
If Resetcounter = 1000 Then 'If the counter is 1000 then
Call Usb_reset() 'Call the usb reset routine
End If
Wend
|
when _usb_pin._usb_dminus will zero? |
So when ._usb_dminus is zero wait 1000 loops then call Usb_reset. or in other words if ._usb_dminus is low for long enough reset USB.
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
Ajaxelectronic
Joined: 22 Nov 2009 Posts: 171 Location: Iran
|
Posted: Thu Jul 05, 2012 6:19 pm Post subject: |
|
|
Quote: | So when ._usb_dminus is zero wait 1000 loops then call Usb_reset. or in other words if ._usb_dminus is low for long enough reset USB |
yes, i know. thanks. but when occur it? what is its doer? _________________ www.mrkelectronic.blogfa.com
Best Regards |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Thu Jul 05, 2012 8:13 pm Post subject: |
|
|
The USB bus has 4 wires +5, Ground, Data + and Data -.
According to the USB specification when the Data- line is held low for atleast 10ms. From the USB 2.0 specification page 145.
Reset D+ and D- < VOL (max) for ≥10ms D+ and D- < VIL (max) for ≥10 ms
I could be wrong, I don't really know the LIB that well.
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
Ajaxelectronic
Joined: 22 Nov 2009 Posts: 171 Location: Iran
|
Posted: Thu Jul 05, 2012 9:11 pm Post subject: |
|
|
thanks a lot i.dobson
New question!
i wrote some code that measure voltage with ADC and then send it to the PC. for this measuring i used from a For-Next to increase my accuracy. all things are good. but when i connect my device to the USB port it take about 10 Seconds to PC can recognize my device! when i remove For-Next from my code my device recognize immediately.
why?
Code: |
For I = 1 To 10
Adc_value = Getadc(0)
Sum = Sum + Adc_value
Waitms 25
Next
|
_________________ www.mrkelectronic.blogfa.com
Best Regards |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Fri Jul 06, 2012 12:25 am Post subject: |
|
|
Hello Ajaxelectronic
The getadc() does two reads of the value so when you do it ten times its really twenty times so you doing it five times is more than enough, as to why its affecting the USB I do not know.
Regards Paul |
|
Back to top |
|
|
Ajaxelectronic
Joined: 22 Nov 2009 Posts: 171 Location: Iran
|
Posted: Fri Jul 06, 2012 12:33 am Post subject: |
|
|
thanks Paulvk
but i want to know yet, why reading ADC resulting is slower recognize?
i test my code without ADC but with a virtual For-Next! and get same result! i'm confusing really!?
i used from this For-Next :
Code: |
For I = 1 To 10
Waitms 100
Next
|
_________________ www.mrkelectronic.blogfa.com
Best Regards |
|
Back to top |
|
|
ollopa
Joined: 03 Sep 2007 Posts: 233 Location: California
|
Posted: Fri Jul 06, 2012 3:29 am Post subject: |
|
|
Where did you put this loop? If possible, attach the .bas file so we can see the full picture of what you are doing... |
|
Back to top |
|
|
Ajaxelectronic
Joined: 22 Nov 2009 Posts: 171 Location: Iran
|
Posted: Fri Jul 06, 2012 12:31 pm Post subject: |
|
|
Hi Mr. Ollopa
i attached my code. i change For-Next location after send checker or between receive checker and send checker, both have same result. _________________ www.mrkelectronic.blogfa.com
Best Regards |
|
Back to top |
|
|
Ajaxelectronic
Joined: 22 Nov 2009 Posts: 171 Location: Iran
|
Posted: Fri Jul 06, 2012 12:40 pm Post subject: |
|
|
oh... Mr. Ollopa
would you rather explain for me this section?
when dminus will zero?
Code: |
'Check for reset here
While _usb_pin._usb_dminus = 0
Incr Resetcounter
If Resetcounter = 1000 Then
Call Usb_reset()
End If
Wend
|
_________________ www.mrkelectronic.blogfa.com
Best Regards |
|
Back to top |
|
|
ollopa
Joined: 03 Sep 2007 Posts: 233 Location: California
|
Posted: Fri Jul 06, 2012 4:02 pm Post subject: |
|
|
Have a look here http://www.usbmadesimple.co.uk/ums_3.htm
Quote: | Reset
When the host wants to start communicating with a device it will start by applying a 'Reset' condition which sets the device to its default unconfigured state.
The Reset condition involves the host pulling down both data lines to low levels (SE0) for at least 10 ms. The device may recognise the reset condition after 2.5 us.
This 'Reset' should not be confused with a micro-controller power-on type reset. It is a USB protocol reset to ensure that the device USB signaling starts from a known state. |
|
|
Back to top |
|
|
|