+ Reply to Thread
Page 2 of 5 FirstFirst 12345 LastLast
Results 41 to 80 of 169
  1. #41

    Default Re: PIC USB HID breakout board

    I'm not sure if it's possible to detect the difference between a key with caps held down and capslock. Let me do a little research.

    Edit. If you google for detect capslock, you get a whole mess of javascript stuff, means nothing to me, probably will to you.

    Later edit. Oh it appears you can do it in Win32 as well, CapsLock is a virtual key V_CAPITAL. Which of course is obvious now I come to think of it.
    Last edited by towlerg; - 30th November 2018 at 11:53.
    George

  2. #42
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    172

    Default Re: PIC USB HID breakout board

    George, Thanks I'm probably going to give both a try thanks for the heads up.

  3. #43
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    172

    Default Re: PIC USB HID breakout board

    Quote Originally Posted by towlerg View Post
    I'm not sure if it's possible to detect the difference between a key with caps held down and capslock. Let me do a little research.

    Edit. If you google for detect capslock, you get a whole mess of javascript stuff, means nothing to me, probably will to you.

    Later edit. Oh it appears you can do it in Win32 as well, CapsLock is a virtual key V_CAPITAL. Which of course is obvious now I come to think of it.
    Actually what I need would be for JavaScript to send back through the HID something I can read with the PIC

  4. #44

    Default Re: PIC USB HID breakout board

    That might be a bit more work, how does a real keyboard generate a virtual key? I guess it must be in a report.

    BTW. Again I not sure if this helps or hinders but the include is a compiled version of the Proton code I posted. It's for a 18F2550 with a 20MHz crystal.
    George

  5. #45
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    172

    Default Re: PIC USB HID breakout board

    Quote Originally Posted by towlerg View Post
    That might be a bit more work, how does a real keyboard generate a virtual key? I guess it must be in a report.

    BTW. Again I not sure if this helps or hinders but the include is a compiled version of the Proton code I posted. It's for a 18F2550 with a 20MHz crystal.
    thanks... I am defintely going to give this a try.

    Agreed I have no clue how the keyboard is actually polled to show the caps lock on. I'm under the assumption that the keyboard places data in the buffer and it's a one way street I don't think I can send anything back to the keybord through the standard hid keyboard driver. It is probably not going to be possible for my javascript to send something back. The idea would be to send something back so that I could disable sensing while a human was present. Once there was inactivity or the human moved away I could react and resume sensing for the next person.

  6. #46

    Default Re: PIC USB HID breakout board

    Heres how I think it works, if any USB savvy people can correct me if I'm wrong. The caps lock key is pressed, firmware sends Virtual key to PC, PC latches the fact that keyboard requests caps lock and sends a control report to turn on LEDs. I've modified my Proton code and it seems to work (ie. characters without modifiers are displayed as upper case). Easier than I thought.

    I have not got the LED setting part working yet.

    Edit. Still can't get the LED working (even tho I forgot to TRISA it and didn't put a delay before the second send capslock) it just flashes briefly. But no matter (you don't need the LED), the keyboard indicator comes on at the correct time so I guess my theory is correct.
    Last edited by towlerg; - 30th November 2018 at 15:57.
    George

  7. #47
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    172

    Default Re: PIC USB HID breakout board

    cool I will have a look. I wish my PIC's were here! looks like they will be here tomorrow.

  8. #48

    Default Re: PIC USB HID breakout board

    I know you don't need it but for completness the key states for the toggle keys (CapLock, NumLock and Scrolllock) are bit values in the first byte of the returned array - capslock is the second bit.
    George

  9. #49
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    172

    Default Re: PIC USB HID breakout board

    arghhh... my 18F25K50 just showed up and it looks like I have pretty old version of PBP which doesn't support it. Looks like I have to upgrade to PBP3.1 gold shoot. My wife is not going to be happy with this purchase.

  10. #50
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    172

    Default Re: PIC USB HID breakout board

    Darn it.... proton does not support the 18f25k50 for free and it doesn't look like you can purchase it online and download it immediately

  11. #51

    Default Re: PIC USB HID breakout board

    Yes, it looks like the free USB capable devices are 18F14K50 and 18F2550.

    Click on "Buy" on the forum main page. Proton uses a USB dongle for copy protection so you obviously need to receive that in the post. I don't suppose you can get a 18F2550 (it's pin compatible with the newer 18F25K50). Where are you? I've a spare if you want to borrow, I'm in Ireland.
    George

  12. #52
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    172

    Default Re: PIC USB HID breakout board

    Quote Originally Posted by towlerg View Post
    Yes, it looks like the free USB capable devices are 18F14K50 and 18F2550.

    Click on "Buy" on the forum main page. Proton uses a USB dongle for copy protection so you obviously need to receive that in the post. I don't suppose you can get a 18F2550 (it's pin compatible with the newer 18F25K50). Where are you? I've a spare if you want to borrow, I'm in Ireland.
    George, Thanks for the offer unfortunately I am in the states. I see on Proton it does use the dongle that sucks I can't just purchase it and download it and get a reg code or something like I can with PBB. The code looks pretty simple and easy to follow and less expensive than PBP, pretty close anyway after the exchange rate for $. I'm trying to find out if this is something I can purchase from a distributor in the states and not have to wait so long for the dongle to come in the mail. This time of year I probably would not get it from the UK until after the holidays.

  13. #53

    Default Re: PIC USB HID breakout board

    I'll recompile for 18f25k50 put the source and the compiled hex in zip so you can at least run the code. Just burn with a PicKit2 or similar, the fuse settings will be embedded in the hex file.
    George

  14. #54
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    172

    Default Re: PIC USB HID breakout board

    George, Thanks..... That would be appreciated. I purchased PBP3 last night (wife not happy). Once I get it all wired up I will test your program then go from there with pedja089 example. I'll keep an eye out for you post.
    Thanks again
    David
    p.s. I think I have all the other routines working fairly well with my 12f683. For my test I have the code listening for the distance from the sonar/ultrasound sensor. If the distance is less then 48" I start to keep track of the seconds with the interrupt logic I have used before. If 2 seconds elapse then I'm confident someone walked up to the kiosk (sensor) and I sound a buzzed for 500ms (any longer and it is annoying) however this code of buzzed sounding will be replaced with sending "wakeup" to the USB HID keyboard. Once the person walks away and the distance is greater than 48" start over waiting for the next person. The last piece of the puzzle now will be the USB HID Keyboard code.

    If it's possible and I can send back through the buffer/modifier that the caps lock, scroll lock or num lock has been pressed and javascript will let me emulate pressing one of those keys then the idea is once I've woken up the kiosk via the "wakeup" I will instruct the PIC to stop listening for the sonar/ultrasound sensor until the lock key is pressed again releasing it.
    Last edited by DavyJones; - 3rd December 2018 at 12:01.

  15. #55
    Join Date
    Sep 2009
    Posts
    774

    Default Re: PIC USB HID breakout board

    In my example I didn't menage to get status information about Caps, Num Lock, ScrLk.
    As far as I understand, there is no definition in descriptor for it.

  16. #56
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    172

    Default Re: PIC USB HID breakout board

    pedja, it's not a problem I was not sure if that was going to be something that was possible or not. I can work with timing too it was just a little extra I was hoping to be able to do.
    Thanks
    David

  17. #57

    Default Re: PIC USB HID breakout board

    @pedja
    In my example I didn't menage to get status information about Caps, Num Lock, ScrLk.
    As far as I understand, there is no definition in descriptor for it.
    I'm not familar with the PBP descriptor format but I suspect you're correct. If you look at the descriptor I posted, you will see Endpoint descriptor, In and Out. I'm sure you can add an endpoint to the descriptor you posted.

    @DavyJones I'm away from home till Wednesday, so although I can post code, I can't test it. Not happy posting untested code. Did you get your PIC's yet?
    BTW I can confirm there is no US distributor. See
    http://www.protonbasic.co.uk/showthr...l=1#post514859
    Last edited by towlerg; - 3rd December 2018 at 14:49.
    George

  18. #58
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    172

    Default Re: PIC USB HID breakout board

    George, No problem yes I did get my pic's I am trying to get pedja code so it will work with the 18f25k50 that I have. It looks like his was for a different pic.
    I'm certain I am doing something so completely wrong. His program compiles and I can load it onto the pic but I get (eventually after a couple of seconds) a popup in windows that the device is not recognized.

  19. #59

    Default Re: PIC USB HID breakout board

    The clock setup of the 25K50 is different. I haven't looked through all of pedja's code to see if there's anything else that needs to change, but try replacing:
    Code:
        #config
        CONFIG PLLDIV = 2       ;for 8 mhz chip
        CONFIG XINST = OFF
        CONFIG STVREN = ON    ;stack overflow reset
        CONFIG WDTEN = OFF
        CONFIG CP0 = OFF
        CONFIG IESO = OFF
        CONFIG FCMEN = OFF
        CONFIG CCP2MX = DEFAULT
        CONFIG WDTPS = 32768
        CONFIG CPUDIV = OSC1  ;DIVIDE BY 1 MODE
        CONFIG FOSC = HSPLL
        CONFIG MSSPMSK = MSK5
        #Endconfig                 
    
        Define OSC 48
    
    	OSCTUNE.6 = 1		' Enable PLL for 18F87J50 family
    	PAUSE 500
    with this:
    Code:
        ; 18F25K50 usb setup
        Define OSC 48
    
        #config
        ; CONFIG1L
        CONFIG CFGPLLEN = OFF          ; control PLL in code
        CONFIG PLLSEL = PLL3X          ; done in code 
        CONFIG CPUDIV = NOCLKDIV
        CONFIG LS48MHZ = SYS48X8
        ; CONFIG1H
        CONFIG FOSC = INTOSCIO
        CONFIG PCLKEN = OFF
        CONFIG FCMEN = OFF
        CONFIG IESO = OFF
        ; CONFIG2L
        CONFIG NPWRTEN = ON
        CONFIG MCLRE = ON
        ; CONFIG4L
        CONFIG STVREN = ON
        CONFIG LVP = OFF
        CONFIG XINST = OFF
        #endconfig
    
        ; this code assumes the use of the internal FRC clock and active clock tuning
        ; you must set CONFIG registers to match
    
        ; turn off PLL for safety while we setup clock
        OSCCON2.4 = 0             ; PLLEN
    
        OSCCON = %01110000 		  ; PRIMARY_OSC 48Mhz (16MHz + 3xPLL)
        OSCTUNE.7 = 1             ; SPLLMULT 3xPLL
        OSCCON2.4 = 1             ; PLLEN
    
        ; Enable Active Clock Tuning
        ACTCON.4 = 1              ; set ACTSRC to use USB host clock
        ACTCON.7 = 1              ; set ACTEN to enable ACT module
    
        ; wait a bit for the clock to stabilize
        PAUSE 10

  20. #60
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    172

    Default Re: PIC USB HID breakout board

    Tumbleweed, woohoo.... That worked! I was looking at that I was pretty certain that is what I needed to work on for the pic to get recognized as the HID keyboard. I've never worked with any pics that could communicate via USB just serial and that's a boat load easier. I think you for your help. I'll keep this thread going I am sure it can help others. I'm going to try and integrate the rest of my process now into the 18f25k50
    thanks
    David

  21. #61
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    172

    Default Re: PIC USB HID breakout board

    Well now I am a little stumped. When I turn the power on and the device is connected to my USB port it does come up and I can see it enumerate as a HID keyboard but I can't follow what pedja is doing next to throw data at the keyboard buffer. I am not sure what PORTB is I just want to throw a word into the buffer. I think I should be able to open notepad or something like that up and what I throw at it should appear.

    Main:
    DelayVal=100
    call DelaymS
    if PORTB<255 THEN
    if PORTB.7=0 THEN
    For i = 0 To 20
    lookup i,[KEY_R, KEY_O, KEY_U, KEY_T, KEY_E, KEY_ENTER, 0], USBBufferOut[2]
    call DoUsbOut
    IF USBBufferOut[2]=0 THEN EXIT
    Next i
    elseif PORTB.6=0 THEN
    For i = 0 To 20
    lookup i,[KEY_R, KEY_I, KEY_P, KEY_U, KEY_P, KEY_ENTER, 0], USBBufferOut[2]
    call DoUsbOut
    IF USBBufferOut[2]=0 THEN EXIT
    Next i
    elseif PORTB.5=0 THEN
    For i = 0 To 20
    lookup i,[KEY_S, KEY_E, KEY_T, KEY_SPACE, KEY_W, KEY_I, KEY_R, KEY_E, Key_Min, KEY_B, KEY_E, KEY_N, KEY_D, KEY_SPACE, KEY_2, KEY_ENTER, 0], USBBufferOut[2]
    if i=8 then USBBufferOut[0]=LSHIFT
    call DoUsbOut
    IF USBBufferOut[2]=0 THEN EXIT
    Next i
    elseif PORTB.4=0 THEN
    For i = 0 To 20
    lookup i,[KEY_M, KEY_O, KEY_V, KEY_E, KEY_ENTER, 0], USBBufferOut[2]
    call DoUsbOut
    IF USBBufferOut[2]=0 THEN EXIT
    Next i
    elseif PORTB.3=0 THEN
    For i = 0 To 20
    lookup i,[KEY_C, KEY_O, KEY_P, KEY_Y, KEY_ENTER, 0], USBBufferOut[2]
    call DoUsbOut
    IF USBBufferOut[2]=0 THEN EXIT
    Next i
    elseif PORTB.2=0 THEN
    For i = 0 To 20
    lookup i,[KEY_D, KEY_E, KEY_L, KEY_E, KEY_T, KEY_E, KEY_ENTER, 0], USBBufferOut[2]
    call DoUsbOut
    IF USBBufferOut[2]=0 THEN EXIT
    Next i
    elseif PORTB.1=0 THEN
    For i = 0 To 20
    lookup i,[KEY_N, KEY_A, KEY_M, KEY_E, KEY_ENTER, 0], USBBufferOut[2]
    call DoUsbOut
    IF USBBufferOut[2]=0 THEN EXIT
    Next i
    elseif PORTB.0=0 THEN
    For i = 0 To 20
    lookup i,[KEY_V, KEY_A, KEY_L, KEY_U, KEY_E, KEY_ENTER, 0], USBBufferOut[2]
    call DoUsbOut
    IF USBBufferOut[2]=0 THEN EXIT
    Next i
    endif
    WHILE PORTB<>255
    DelayVal=100
    call DelaymS
    wend
    ENDIF
    GOTO Main

  22. #62
    Join Date
    Sep 2009
    Posts
    774

    Default Re: PIC USB HID breakout board

    @towlerg
    Descriptors are in ASM format, I don't have time now to finish that project, and I think it should be compatible, or easy to implement in PBP.
    @DavyJones,
    On PORTB there is 8 buttons, with pull up.
    You can delete all that code, and just put this
    Code:
    Main:
    DelayVal=1000
    call DelaymS
    For i = 0 To 20 'This loop send up to 20Keys
    lookup i,[KEY_R, KEY_O, KEY_U, KEY_T, KEY_E, KEY_ENTER, 0], USBBufferOut[2] 'This will put letter in variable EDIT: or to be precise, it will put KEY
    call DoUsbOut' this will send letter to PC
    IF USBBufferOut[2]=0 THEN EXIT 'This detect last key and exit loop, you can type exact length in for loop, but for me is easier this way
    Next i  
    goto Main
    Now every second you should see route<crlf> in notepad.
    Just make sure that notepad is selected, because example press enter so it can lunch who know what on your PC.
    Or just remove KEY_ENTER...
    Last edited by pedja089; - 3rd December 2018 at 19:46.

  23. #63
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    172

    Default Re: PIC USB HID breakout board

    towlerg, You beat me to that. I RTFM on port b and figured that out. I hooked up RB0.7 just to see if it would work and it did not. Anyway what you posted here worked not sure why it did not work for me I did try something like that perhaps the delayval I used was not enough or maybe something else I missed anyway I am good I think at this point. I did see "route" in notepad followed by carriage return show up every second.
    Thanks for you help.

    p.s. silly me I forgot the pullup resistor on RB0 pins it's working as pedja designed it
    Last edited by DavyJones; - 3rd December 2018 at 20:00.

  24. #64
    Join Date
    Sep 2009
    Posts
    774

    Default Re: PIC USB HID breakout board

    Great!
    Just don't use any pause, or blocking command. That can break USB.
    If you need pause, use
    DelayVal=1000
    call DelaymS
    In DelaymS you can see why...

  25. #65
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    172

    Default Re: PIC USB HID breakout board

    Quote Originally Posted by pedja089 View Post
    Great!
    Just don't use any pause, or blocking command. That can break USB.
    If you need pause, use
    DelayVal=1000
    call DelaymS
    In DelaymS you can see why...
    Gotcha!!! Thanks so much for every ones help help to this point. This is pretty cool. It's been years since I messed with my PIC projects. I'll keep posting my results. This is so cool this is working now.
    I have to say you all were right too this is much easier using a single USB capable pic then trying to integrate it with a FTDI or Holtec I was looking at. the !8F is not crazy big and the qfn or sop will probably be fine.
    Last edited by DavyJones; - 3rd December 2018 at 20:05.

  26. #66
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    172

    Default Re: PIC USB HID breakout board

    Hey guys just wondering I am having some trouble setting up the ADC on the 18F25K50. Probably because it's been a while since I read a datasheet and was able to figure out what to set and why.
    I got it set up but it's not working the same way as it did on my 12F683. I am getting readings but the number I get is much higher than what I got on my 12F683. Think you can help me out on this thread or should I start a new thread specific to questions about the ADC?
    The sonar/ultra sonic sensor should put out 0 to 512 at ~9.6mv per inch. The 12F683 worked perfect. I don't think I am setting it up correctly to read 10bits I think that is what the problem is.
    Last edited by DavyJones; - 3rd December 2018 at 21:59.

  27. #67
    Join Date
    Sep 2009
    Posts
    774

    Default Re: PIC USB HID breakout board


  28. #68
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    172

    Default Re: PIC USB HID breakout board

    Quote Originally Posted by pedja089 View Post
    Pedja, Thanks I am trying to follow those steps, I've been reading up on this tonight, having trouble trying to figure this out the differences and references are so much different than the 12f683 which was really easy to follow along with the sample program I saw. I have the analog hooked into pin 5 which is RA3
    So far following along I have this. does this look correct?
    TRISA = %11111111 ' Set PORTA to all input
    ADCON1 = %00001010 ' Set PORTA analog...

    lol then I get lost

  29. #69
    Join Date
    Sep 2009
    Posts
    774

    Default Re: PIC USB HID breakout board

    You need to read just this datasheet, forget any other...
    From this DS:

    A/D CONVERSION PROCEDURE
    This is an example procedure for using the ADC to
    perform an Analog-to-Digital conversion:
    1.
    Configure Port:
    • Disable pin output driver (See TRIS register)
    • Configure pin as analog 'Set ANSELx page 147
    ANSELA.3=1
    2.
    Configure the ADC module:
    • Select ADC conversion clock
    • Configure voltage reference
    • Select ADC input channel
    • Select result format
    • Select acquisition delay
    • Turn on ADC module

    For all this just copy from ds
    ADCON2=%10101111 ;right justify, Frc,
    ; & 12 TAD ACQ time
    ADCON1 =%00000000 ;ADC ref = Vdd,Vss

    All other steps are should be handled by ADCIN.
    ADCIN 3,ADWord

  30. #70
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    172

    Default Re: PIC USB HID breakout board

    Pedja, thank very much for guiding me through this. It's been a few years since I looked at the data sheets so I am trying to get back into it for my project. I'm getting back on track I appreciate you folks holding my hand through this project. It's a little difficult at times I'm jumping from this desk using several languages and to my day job desk using even more languages it gets confusing at times. Primarily in my day job I program in MUMPS which is an entirely different world.
    Regards
    David

  31. #71
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    172

    Default Re: PIC USB HID breakout board

    Everything is coming together so it is looking really good that I will be able to accomplish this. I have one question. In my testing with the 12F683 I set an interrupt to keep track of how many seconds elapsed when a target is in sonar range (0-48") if an object (person hopefully) standing there or walking up and 2 seconds elapse then I can be confident they have approached and this should be my trigger to send "wakeup" to the keyboard buffer. before I attempt this with the 18f25k50 does anyone know if an interrupt can be enabled and not affect the keyboard/USB processes?
    Thanks
    David

  32. #72
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    172

    Default Re: PIC USB HID breakout board

    On a separate note I'm thinking I will be ready to get a prototype board made in about another week after some more testing. I've been using https://oshpark.com/ here in the U.S. for prototypes. they are really cheap, fast turn over and could not be happier with the boards they make. I use diptrace to design my circuit and send it off to osh park and a week or 2 later I get 3 boards. I was just wondering if any of you use osh park or some other mfg similar with quick turn around, good boards and cheap.
    Thanks
    David

  33. #73

    Default Re: PIC USB HID breakout board

    before I attempt this with the 18f25k50 does anyone know if an interrupt can be enabled and not affect the keyboard/USB processes?
    Sure, but I wouldn't try to transmit from within the ISR... just set a flag when the time expires that your main routine can check and send whatever at that point.

  34. #74
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    172

    Default Re: PIC USB HID breakout board

    ok cool I am going to give it a try....

  35. #75
    Join Date
    Sep 2009
    Posts
    774

    Default Re: PIC USB HID breakout board

    Quote Originally Posted by DavyJones View Post
    ...week or 2 later I get 3 boards...
    Try JLCPCB.com, I got my board manufactured for $2 (2 layer, 100x100mm, 10pc) delivered within 4 days from submitting files.
    Within week I got 4 layer boards, but this time it cost lot more because of size.
    Shipping was around 20$ from china to Serbia.
    I'm just sharing my experience, not marketing them.

  36. #76

    Default Re: PIC USB HID breakout board

    Again for completness and untested.
    George

  37. #77
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    172

    Default Re: PIC USB HID breakout board

    Quote Originally Posted by pedja089 View Post
    Try JLCPCB.com, I got my board manufactured for $2 (2 layer, 100x100mm, 10pc) delivered within 4 days from submitting files.
    Within week I got 4 layer boards, but this time it cost lot more because of size.
    Shipping was around 20$ from china to Serbia.
    I'm just sharing my experience, not marketing them.
    Well the price is right but shipping a bit on the expensive side. osh parks deal is $10 ( 2 layer 1"x1" 3 pc) and free shipping. I guess with shipping it's probably coming out competitive.

  38. #78
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    172

    Default Re: PIC USB HID breakout board

    Ok I think I got most of the interrupt figured out comparing what was set in the 12f683 and how to set similar register on the 18F25K50 but I am overlooking/don't understand something.
    the 12F683 what I had was
    Code:
    ' Set TMR0 to interrupt every 16.384 milliseconds
       OPTION_REG = $d5 ' Set TMR0 configuration
       INTCON = $a0     ' Enable TMR0 interrupts
       On Interrupt Goto tickint
    For the 18F25K50 I thought this was correct but I am wrong
    Code:
       'OPTION_REG = $d5 ' Set TMR0 configuration
       T0CON =  $d5   
       INTCON = $a0     ' Enable TMR0 interrupts
       On Interrupt Goto tickint
    This takes about 3 seconds or so maybe a little more before it reaches 60 where in tickint I add one to the variable second and check to see if it has reached 60. the way I think I understand this is when it overflows that is when the interrupt gets called and would add one to my counter so how ever many cycles in the 12F683 I guess it interrupts every 16.384 milliseconds and overflows pretty close to 1 second. So I am really missing something on the number of cycles and how to calc or get pretty close to when it overflows in the 18f it's about 1 second. If I take the prescaler in the 18F down to 1:2 setting T0CON=$D0 it overflows faster it appears but it is a little longer than a second maybe 1.5 seconds.
    Ideas I think I am getting close
    thanks

  39. #79
    Join Date
    Sep 2009
    Posts
    774

    Default Re: PIC USB HID breakout board

    Try $D8. So not to use prescaler.
    But you use 8 bit mode, so it should overflow very often when running on 48MHz. 48MHz/4(fosc/4)/2(prescaler)/256(tick until overflow)=23.5KHz
    So look's like you have some delays in your code, that slow down software interrupt(on interrupt is software base interrupt, it isn't hardware). PBP check between 2 commands is interrupt happen.
    Or there is something else. Newer used that pic, so...

  40. #80
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    172

    Default Re: PIC USB HID breakout board

    thanks I will try $d8...… I thought that was how the interrupt worked between 2 commands. the timing is not crucial + or minus a .5 second will be fine. I am turning the interrupt off and on during crucial processes like sending data to the USB. The goal here is once the sonar has picked up an object (person) that is within 48" and stay within 48"'s for 2 or 3 seconds then trigger the USB to send the data.

Similar Threads

  1. USB hid maker help please.
    By BobEdge in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd April 2013, 14:49
  2. HID USB on 18F87J50
    By pedja089 in forum USB
    Replies: 56
    Last Post: - 25th August 2011, 09:24
  3. USB HID and RealBasic
    By PJALM in forum USB
    Replies: 5
    Last Post: - 6th July 2011, 07:49
  4. USB HID Problem
    By Gitchie in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 20th January 2011, 15:15
  5. Usb hid
    By yatyas72 in forum USB
    Replies: 5
    Last Post: - 3rd December 2010, 15:45

Members who have read this thread : 28

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts