PIC USB HID breakout board - Page 3


+ Reply to Thread
Page 3 of 3 FirstFirst 123
Results 81 to 113 of 113
  1. #81
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    141

    Default Re: PIC USB HID breakout board

    pedja, The goal is not to slow down anything or pause anything. The goal is to set an indicator so I know when approximately 2 seconds has elapsed. At the start of the person detection by the sonar/ultrasonic sensor I will set a byte to 2 and as long as the sonar keeps detecting a presence of a person I will decrement the counter. When the counter gets to 0 I will trigger the USB to send "wakeup" this logic indicates that the sonar has detected the presence of a human for 2 seconds and most likely they are not just passing by but have approached the kiosk device. Of course these values will get adjusted once I start to do some testing: walking up to use kiosk, walking past ignoring kiosk, etc..
    Ultimately I will be able to supply an image similar to this that will show the range of the device so they users can properly place the device for the optimal use.

    For their testing they used dowel rods of varying diameters placed in the objects field of view to determine the capability of detection of objects distance and peripheral side detection.
    https://www.maxbotix.com/pictures/se...n%20MB1010.gif

  2. #82

    Default Re: PIC USB HID breakout board

    If you don't care about being exact, if you set TMR0 to 16-bit mode with a 1:256 prescaler (T08BIT=0, T0CS=0, PSA=0, T0PS=111)
    you'll get TMR0IF set every 1.392 secs (65536x256x83ns @ 48MHz). Count two of them and you're done.

    Much easier than constantly being interrupted.

  3. #83
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    141

    Default Re: PIC USB HID breakout board

    tumbleweed I really don't care about being that accurate 1.392*2 would probably work. I've never done any kind of time except for the interrupt method we've all probably seen counting ticks.... does this work similar with on interrupt goto?
    Not sure how to implement that.

    Anyway I am getting real close. Still need to add timing event so I can make sure someone is actually in range for a second or 2. Given the sonar is 1" accuracy just walking up to it, it bounces sometimes, and checking for 48" or less that bounce comes from reading 48" then 49" (greater then 48" I reset my latch and try again) then back to 48" so it triggers it twice. If I reset if they are not in range for 2 seconds (or around there) that should debounce it ok.



    I'm getting very close. I just took a video. You can see the kiosk in a state of showing the slide show and when I approach the sensor you can hear it beep (I will take that out eventually) then the slideshow stops and gives the user the opportunity to scan their QR code. If they don't and have walked away the slideshow starts back up in 30 seconds waiting for the next victim. The project is coming together very nicely again thanks so far for everyones help.

    Initially I was powering the circuit from +5v power supply. I disconnected that and get the +5v and GND direct from the USB. That seems to simple is that all there is to it?

  4. #84

    Default Re: PIC USB HID breakout board

    does this work similar with on interrupt goto?
    You have to be aware of how PBP's ON INTERRUPT works. It isn't a true interrupt, it's a polling mechanism.
    It adds code in between every BASIC source code line to check if an "interrupt" occurred. It won't interrupt PBP statements,
    so long duration statements like "PAUSE 1000" will prevent the interrupt from being seen until the statement is finished executing.
    Read the section in the reference manual regarding BASIC interrupts vs assembly interrupts. This is why a lot of folks use
    DT-INTS to get better interrupt performance.

    ...and get the +5v and GND direct from the USB. That seems to simple is that all there is to it?
    Pretty much. If you're a bus powered device you're allowed to pull up to 100mA from the USB 5V without doing anything special.

  5. #85
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    141

    Default Re: PIC USB HID breakout board

    If you don't care about being exact, if you set TMR0 to 16-bit mode with a 1:256 prescaler (T08BIT=0, T0CS=0, PSA=0, T0PS=111)
    you'll get TMR0IF set every 1.392 secs (65536x256x83ns @ 48MHz). Count two of them and you're done.

    Much easier than constantly being interrupted
    .

    Tumbleweed, I knew how interrupts work (for the most part) is this method of setting the timer to 16 bit mode work as the interrupt that I normally use when timing and such is not important?
    normally I would use something like this I used for my pic 12f683 to just count and keep track of the seconds. I'm not sure how to code the way you describe. I try to not have any pause anything in my code (as much as possible anyway)


    Code:
       ' Set TMR0 to interrupt every 16.384 milliseconds 
       OPTION_REG = $d5 ' Set TMR0 configuration 
       INTCON = $a0     ' Enable TMR0 interrupts 
    On Interrupt Goto tickint
    main:
         'do something
         goto main
    disable
    tickint:
         ticks = ticks + 1  ' Count pieces of seconds
         If ticks < 61 Then tiexit ' 61 ticks per second (16.384ms per tick)
         ' One second elasped - update time
         second = second + 1
         If second >= 60 Then
              second = 0
         endif
    tiexit:
          INTCON.2 = 0
          resume
    end
    Thanks
    David

  6. #86

    Default Re: PIC USB HID breakout board

    Works basically the same way, David, except now you're counting in 1.392s increments.
    With 'ticks' as a byte you can wait up to 255x1.392 = 354secs
    Code:
    ticks var byte
    TMR0IF var INTCON.2
    
    ' set TMR0 to interrupt every 1.392 secs
    T0CON =  $07    ' TMR0ON=0, T08BIT=0, T0CS=0, PSA=0, T0PS=111
    TMR0H = 0
    TMR0L = 0
    TMR0IF = 0      ' clear TMR0IF
    T0CON.7 = 1     ' turn on timer
    
    INTCON.7 = 1    ' GIE enable interrupts
    
    On Interrupt Goto tickint
    main:
        ' wait for 2 ticks (~2.78s)
        ticks = 0
        repeat
        until ticks = 2
        
        goto main
    
    disable
    tickint:
         ticks = ticks + 1  ' count 1.3 sec ticks
    tiexit:
          TMR0IF = 0
          resume
    end

  7. #87
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    141

    Default Re: PIC USB HID breakout board

    ok I think this is something like what I did but not the same syntax. I will want to turn the interrupt on and off so without looking at the data sheet (I will when I get a second) INTCON.7=0 turns it off right

  8. #88
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    141

    Default Re: PIC USB HID breakout board

    I think I may be trying to over program this I am not sure I have to take some time to think about the pro's and con's of using the interrupt logic verses attaching a 555 which I have more then enough pins on the pic and real estate on the board I will make. a 555 with a 2 second delay would do it.
    so if the person was less than 48" start the 555 when it goes high (seconds later) then send "wakeup" through the USB. IF they step away the 555 would stop and never go high
    so something like
    if adval < 49 then
    start 555 port whatever high
    if port? high then
    send "wakeup"
    end
    else
    stop 555 port whatever low
    endif
    of course I would have to set something so that it would not start the 555 again the next time around or keep it from starting until adval>48 again
    Last edited by DavyJones; - 6th December 2018 at 22:58.

  9. #89

    Default Re: PIC USB HID breakout board

    INTCON.7=0 turns it off right
    If you're using ON INTERRUPT you shouldn't manipulate the GIE bit.

    From the manual:
    If it is desired to turn off interrupts for some reason after ON INTERRUPT is
    encountered, you must not turn off the GIE bit. Turning off this bit tells PBP that an
    interrupt has happened and it will execute the interrupt handler forever. Instead,
    clear the individual interrupt enable bit(s).

    So, clear TMR0IE instead (INTCON.5).

    While looking at the manual I noticed that I didn't follow some of the recommendations in that code snippet (I don't use ON INTERRUPT myself).
    Plus, I never enabled TMR0IE! Here's an update...
    Code:
    ticks var byte
    TMR0IF var INTCON.2
    TMR0IE var INTCON.5
    
    ' set TMR0 to interrupt every 1.392 secs
    T0CON =  $07    ' TMR0ON=0, T08BIT=0, T0CS=0, PSA=0, T0PS=111
    TMR0H = 0
    TMR0L = 0
    TMR0IF = 0      ' clear TMR0IF
    T0CON.7 = 1     ' turn on timer
    
    On Interrupt Goto tickint
    TMR0IE = 1       ' enable TMR0 intr
    INTCON.7 = 1    ' GIE enable interrupts (after ON INTERRUPT)
    
    main:
        ' wait for 2 ticks (~2.78s)
        ticks = 0
        repeat
        until ticks = 2
        
        goto main
    
    ' interrupt handler
    disable
    tickint:
         ticks = ticks + 1  ' count 1.3 sec ticks
    tiexit:
          TMR0IF = 0
          resume
    enable
    
    end

    About adding a 555, it seems sort of silly to me to have all that processor sitting there and add an external timer, but whatever floats your boat.
    Last edited by tumbleweed; - 7th December 2018 at 13:03.

  10. #90
    Join Date
    Sep 2009
    Posts
    677

    Default Re: PIC USB HID breakout board

    You have more than enough resource, to use 2 resistor and capacitor, to create timer on any pin.
    Same configuration as on NE555. One is pull up for charging cap, other is for discharge(low value eg 100R, just to limit discharge current)
    Just make pin output, discharge cap, make it input, and wait to become high.
    Time from low to hi is proportional to RC constant.

  11. #91
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    141

    Default Re: PIC USB HID breakout board

    agreed (sort of) the 555 seems kind of silly just thinking of different options and depending on whether or not what I am attempting to do next will dictate using external components or not. I appreciate the help with the interrupt and timer and if I can pull off this next part I am going with that option.

    At this time I am not really sure if what I want to do next is possible. I've been searching a bit to see if anyone had been successful with PC-->PIC via the HID Keyboard setup I am using here.

    So in my main loop I implemented a gosub DoUSBIn in which I hoped to see if something was sent/pressed on the keyboard attached to the PC. Initially I had the callback if nothing was there to DoUSBIn but of course that hung it and reason being nothing is being detected. Of course this just gets stuck in this routine and never returns to main. I had some experimental code in here to try and send what if anything I received and or any buffercount on my LCD display. Fire it up and start typing on my keyboard and nothing appears to come in. That's why I am not sure if that can be done given in the device manager there are 2 hid keyboard devices and I am not sure they share the same buffer so I am not sure if this is going to be possible or not.
    Any thoughts?

    DoUSBIn:
    USBBufferCount = USBBufferSizeRX ' RX buffer size
    USBService ' keep connection alive
    USBIn 1, USBBufferIn, USBBufferCount, USBexit 'DoUSBIn ' read data, if available
    USBexit:
    return

  12. #92
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    141

    Default Re: PIC USB HID breakout board

    Quote Originally Posted by pedja089 View Post
    You have more than enough resource, to use 2 resistor and capacitor, to create timer on any pin.
    Same configuration as on NE555. One is pull up for charging cap, other is for discharge(low value eg 100R, just to limit discharge current)
    Just make pin output, discharge cap, make it input, and wait to become high.
    Time from low to hi is proportional to RC constant.
    Pedja great idea I never thought of that that's perfect if I have to go that way this is great to know. Your right same idea behind the 555

  13. #93
    Join Date
    Sep 2009
    Posts
    677

    Default Re: PIC USB HID breakout board

    You can't expect that PC will send any data to keyboard, especially data from other keyboard.
    Only status led can be retrieved with correct descriptor.
    I wouldn't try to make it so complicated...
    Make pic send data to some txtbox and press enter.
    Then examine distance that you got in txtbox, and check if it is in range for what ever time period you need.
    2 or 3 keys can bi send in less than half second.
    So your java app can be updated several times per second. That gives more than you need for +/-0.5sec.

  14. #94
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    141

    Default Re: PIC USB HID breakout board

    Pedja, That is basically what I am doing now my javascript is reading the keypress event at the DOM level and I am looking for "wakup" from the pic this is the trigger/code word that wakes up the kiosk out of the slideshow mode (see the link to the video I posted showing a working demo)

    My goal was to attempt to communicate with the PIC bi directionally. I only need the pic to scan for a person when the slideshow is active and the slideshow is activated when there is 30 seconds of inactivity on the kiosk. If I was able to communicate from the PC to the PIC as I hoped this solves a few problems. 1. When the person brings up the kiosk web page it is obviously not in slide show mode so while the person is plugging in the proximity sensor it would not be trying to throw "wakeup" back at the pc while they are standing there getting things set up.
    1. walk up to kiosk and start the web page, plug in proximity sensor, nothing happens until the slide show starts 30 seconds of inactivity. Once 30 seconds of inactivity tell PIC (via call from PC to PIC) to start looking for someone (proximity)
    2. When a person is sensed and is in the vicinity (48" or less distance) stop the slide show and stop sensing no need to keep sensing
    3. When person walks away and slide show begins again tell PIC to start sensing.
    I know I have many options with a button they could press to wait 30 seconds or whatever after they plug it in for it to start listening and within the javascript to ignore events, data coming in the USB buffer, etc.. The easiest for all of this is to have bi-directional communication.

    one other thing I could do if bi-directional was available is I could set up a web page that could send keywords to the PIC like timeout and distance and store those values on the PIC for use in the routines. This would be more preferable then have the PIC constantly send the distance and then read those parms from another source.

    I might be able to accomplish this with a status key I am assuming you mean the modifiers like caps lock, scroll lock, num lock, shift, etc. How about function keys? How do you go about getting the values of those status keys?
    Thanks
    David

  15. #95
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    141

    Default Re: PIC USB HID breakout board

    The problem I am having with this method is that the pic never stops sending. I need a method that will tell the pic that I have received the data "wakeup" so you don't have to send it again my slide show has stopped. I then need a method to tell the pick the slide show is operating so I want you to start listening for someone entering the eye of the proximity detector again.
    I want the users to be able to set the range eg: 0"-12", 0"-24", 0"-36", 0"-48", etc... If the user selects let's say 0"-36" if the person enters anywhere from 0" to 36" then send the "wakeup" so the max distance is 36" anything above that will not trigger it. Once it is triggered then there is no need for the pic to send anything else until they finished the process and the kiosk goes back into slide show mode.
    I'm thinking if I can set num-lock and caps-lock on with javascript (not sure if that is actually possible yet) if I can poll the system to see if both of those keys are on then that could be the indicator to stop listening and just keep polling those keys until one of them is off.

    I've tried some examples to DoUSBin but they don't show me any values of the bits that are supposed to be set. Does anyone have any working examples?
    Thanks
    David

  16. #96
    Join Date
    Apr 2014
    Location
    Northeast
    Posts
    252

    Default Re: PIC USB HID breakout board

    I am "functional" with USB thanks to HIDmaker. It is a bit pricey, but it would do everything you need. If you can absorb the cost of the software (HIDmaker) into your project, I can help you get it working. Outside of using HIDmaker, I'm as dysfunctional as anybody else with USB.

  17. #97
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    141

    Default Re: PIC USB HID breakout board

    It doesn't look like javascript can set the keys and even simulate sending keystrokes back as if a user types something on the keyboard. It's a security thing. I think I am going to have to rely on letting the users somehow via a momentary push button set the distance and then trigger "wakeup" once and then latch it out until it is not sensing a person standing there anymore.

  18. #98
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    141

    Default Re: PIC USB HID breakout board

    Quote Originally Posted by mpgmike View Post
    I am "functional" with USB thanks to HIDmaker. It is a bit pricey, but it would do everything you need. If you can absorb the cost of the software (HIDmaker) into your project, I can help you get it working. Outside of using HIDmaker, I'm as dysfunctional as anybody else with USB.
    Yeah I was looking at the EasyHid that is part of microcode studio and reviewing the picbasic code it will produce but I think the problem is that the code for the usbin is only going to work with a normal kind of usb serial not the HID keyboard. Even if I could get my device to magically be able to read the buffer which would have to be loaded by someone typing on the other "keyboard" which is also a HID device javascript can't send anything into the computer simulating someone actually typing on the screen that's a big security risk. There is a WEBusb api but it is not available with internet explorer that would solve a bunch of problems but since it is not supported in IE yet it would only work in Chrome. Then again you have to jump through hoops getting it to work with chrome etc.... I want something that is so plug and play and browser compatible. I've getting there. I have it working I am just trying to fine tune it now so the end user can set the distance, etc... have you reviewed the video I posted?
    Thanks
    David
    Last edited by DavyJones; - 7th December 2018 at 21:15.

  19. #99
    Join Date
    Sep 2009
    Posts
    677

    Default Re: PIC USB HID breakout board

    I still don't understand why pic need to stop sending data.
    Make it to send always distance, and let host app on PC to deal with delays, distances, lunching of page etc...
    When someone approach output in notepad should look like this:
    3
    3
    3
    2
    2
    1
    1
    Make app that will always receive keys, and in your app decide is timing correct, is distance getting smaller or bigger etc...
    Again I say let pic send distance to object, not any wake key.
    And again keyboard cant read buffer from PC, it can only send key to buffer.
    That isn't limit of java, it is limit of keyboard functionality. Because keyboard don't have to know is any key pressed on another keyboard.
    Keyboard need to know status information like num lock led, caps lock led, scroll lock led, not shift etc. Just 3 bit for 3 led is more than enough to make keyboard do their job.
    If you really want two way comm from java, use usb to serial converter.

  20. #100
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    141

    Default Re: PIC USB HID breakout board

    Pedja I am not working in a java application. I am working in javascript for an html web page. I can only capture or monitor for input from a keyboard in javascript that is why I am working with the hid keyboard USB. Javascript not java. Javascript/html have no access to serial ports

  21. #101

    Default Re: PIC USB HID breakout board

    @Pedja
    And again keyboard cant read buffer from PC, it can only send key to buffer.
    I suspect we differ on how a HID USB keyboard works. I think the keyboard signals the press of one of the latching keys (Num, Scroll and Shift lock) in the normal way, the PC then sends a report to the keyboard with the latching keys status's in bit values in the first byte. The keyboard uses this information to set or clear the keyboard status LED's. It's simply (ha ha) a matter of adding an in report to go with the your existing out report, the descriptor I'm using has both in and out reports. BTW thats how a newly "inserted" keyboard will display the correct status ie the one the PC has.

    I know it's not ideal, but I have provided non-PBP code, which demonstates this. I'm sure it would be counterproductive (and will possibly get me introuble with the mods) to post more non-PBP code.

    Whether using latching keys status for this application is a seperate question.
    Last edited by towlerg; - 8th December 2018 at 00:24.
    George

  22. #102
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    141

    Default Re: PIC USB HID breakout board

    George, thanks I've been looking at your non pbp code just to try and get an idea... I have not tried to load it on my pic as I have the pbp code working basically exactly the way I want it.
    I think I understand what you are saying and if I do then it sounds like programmatically once I press the caps lock the PC latches it via the bit sent to the PC that says latch it however, I don't think anything would actually need to be sent back to the keyboard via a report what would the point be once the keyboard itself sees you press it's caps lock it would simply turn on it's LED and any subsequent key press would include the caps lock or shift modifier from this point forward. That is of course unless the keyboard wanted it back as a kind of confirmation that it was actually sent, seen and toggled.
    Anyway just to kind or re-iterate I have to go in this direction because HTML and JavaScript have no access to any serial driven devices it is a big security risk. Image browsing to a web site that could sniff out a USB drive or some other peripheral plugged into your computer, not good. The only thing HTML and JavaScript running client side can do out of the box without any special active x controls for internet explorer and add-on's in google chrome and other browsers is listen for keyboard events (keys being pressed) and capture those events then programmatically once you capture the keyboard events you can have the javascript react. Example is a bar code scanner plugged into a USB port, like the one I have here, most of these (If not all) plug in and are recognized as a HID Keyboard. Whatever field your cursor is in when a bar code is scanned goes into that text field or whatever (notepad, word, etc) as if a user entered the data manually on the keyboard. In javascript you don't have to have the cursor actually in a text box or anything else. You can simply program it to listen for any key being pressed while you are just sitting there on a web page, the cursor is actually focused on the web page itself not any one field on the web page.
    something like this.
    Code:
    function captureKeys {
         if  (which.key==13) {
            //I got a carriage return so lets check to see what I got
            if (slideshow==true) {
                if (captured_data=="wakeup") {
                    stopSlideShow();
                }
            }
           captured_data="";      
    }
          captured_data=captured_data+which.key
    }
    My actual code is a little more complex I check to make sure slideshow=true meaning it's displaying the slides and a bunch of other events are either flagged on or off. I only want to check for "wakeup" being sent from the keyboard (pic in this case) if the slideshow is running.
    In my video this is what is happening. I started the video when the slideshow was already running and when I approach the sensor and it detects me less then 48" away the pic sends "wakeup" when I see that in my javscript I stop the slideshow at which point even if the sensor sends "wakeup" again the web page just ignores it slideshow does not get set true again until 30 seconds has elapsed and no activity on the kiosk (additional web pages) has occurred.

    Now without telling the pic to stop trying to send anything it is going to keep sending "wakeup". it would have been nice if during the "startslideshow" routine I could have sent something back to the pic to tell it to wake up and start sensing for proximity and then when I hit "stopslideshow" send something to the pic to say stop trying to detect proximity then it is a done kind of deal. I don't really have to worry about any timing or having the pic continoulsy try to send data like "wakeup" or "distance48" over and over again. Obviously after all the dialogue and explanation in my best understanding this is going to be impossible for two reasons. The HID keyboard seems to be a one way communication meaning I can only send data stream of text from the PIC to the PC. The other thing I have discovered, even if I could send something like "stop" back to the PIC it is a security breach in HTML/JavaScript and you can not do it! Imagine visiting a web site and unbeknownst to you it can suddenly press "start/run/notepad.exe mypasswords.pwd" then "select all/copy" and retrieve that info... that would not be good.
    Last edited by DavyJones; - 8th December 2018 at 12:33.

  23. #103

    Default Re: PIC USB HID breakout board

    I don't think anything would actually need to be sent back to the keyboard via a report
    Actually it kinda does. Let me give you 2 situations where it has to -

    a. There are apps which set the default status of CapsLock.
    b. If you press CapsLock, unplug the keyboard, plug it back in.

    In both cases how could "tell" the keyboard that CapsLock was either on or off, unless it could receive data. How could either be true and the PC and keyboard not be out of sync?

    To acheive this you need to add another report to the descriptor that Pedja posted (which is the one I assume you are using). If you compare the two descriptors you will see "Endpoint1" described as "EP1, In" (note that USB naming conventions are relative the host - in this case the PC) whereas in the one I posted there are two "Endpoint descriptor (IN)" and "Endpoint descriptor (OUT)". Also at some point in your keyboard emulation code you need to call the routine thats reads a report - I assume DoUSBIN but thats just a guess.

    Having said that, my understanding was that on generating CapsLock the PIC part of your project had no further work to do? If that is true then then the above is totally irelevant except it furthers your understanding of USB.
    George

  24. #104
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    141

    Default Re: PIC USB HID breakout board

    George, you are correct about why (plugging unplugging keyboard I get it) Yeah I am used Pedja code let me have a look at it and see if I can spot the descriptor(s) you are talking about
    Thanks
    David

  25. #105

    Default Re: PIC USB HID breakout board

    So, to sum things up...

    1) HID keyboard communications can be bidirectional. All you need is the proper descriptors.

    2) #1 doesn't matter in this application because Javascript can't send data to anything. All it can do is listen for events, one of which are keypresses.

    ...and then when I hit "stopslideshow" send something to the pic
    Which violates #2 since you can't send anything to anything. Doesn't matter if it's serial, USB, or whatever. It's input only.

    If you want to use this approach it looks like you have to treat the pic just like your barcode scanner. It always sends barcode information and it's up to your javascript to ignore it when you're not interested.

  26. #106
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    141

    Default Re: PIC USB HID breakout board

    yes because of security reasons with html/javascript it's all a moot point even with bi directional HID keyboard communication. However..... once internet explorer catches up (maybe 12.0) There is WebUSB api that currently appears to be supported by google chrome. Once it is supported with IE I should be able to change things up and not have to rely on HID Keyboard. I should be able to do everything I want.

    Yes my script is ignoring it now it would have been nice but it's ok I will survive. My device may send some data when my script is not ready but I can code around that and ignore it. Once I turn off the "beep" it won't be a big deal.
    Last edited by DavyJones; - 8th December 2018 at 18:04.

  27. #107
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    141

    Default Re: PIC USB HID breakout board

    Ok basically at this point I have the 18F25K50 working not 100% but I have to do what I can so I am limited anyway.... I had purchased some of the 16F145x pics just to see if I could get the usb hid keyboard working. So starting out with my 18F program I started to attempt to convert this. So going over the datasheet for the 12F1454 (http://ww1.microchip.com/downloads/e...Doc/41620C.pdf) , reviewing how things were setup in the 18f compared to the 16f and reading the first thing I encounter is PLL enabling and disabling. From reading the 16F it lists this as being part of configuration word 2 so it does not look like it is enabled the same way as the 18f
    This is what I came up with I think is the correct way to enable this and disable it

    Code:
        ; turn off PLL for safety while we setup clock
    @ device 16F1454, _PLLEN_DISABLED 
        'OSCCON2.4 = 0             ; PLLEN
    Then to enable it

    Code:
        'OSCCON2.4 = 1             ; PLLEN
    @ device 16F1454, _PLLEN_ENABLED
    This appears to compile ok and gets past this. There are other items I still need to address but want to make sure I starting to understand this a bit better now that I am getting back into looking at the datasheets, etc.
    Thanks
    David

  28. #108
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    141

    Default Re: PIC USB HID breakout board

    correction I have switched to working with a 16F1455...... reason is the 1454 does not have ADC which I would need if I can get this to work as the USB HID device to read my proximity sensor.

  29. #109

    Default Re: PIC USB HID breakout board

    IIWY I'd stick with the 18F but thats just me.
    George

  30. #110
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    141

    Default Re: PIC USB HID breakout board

    Quote Originally Posted by towlerg View Post
    IIWY I'd stick with the 18F but thats just me.
    Yeah it is not a problem I just wanted to see if I could get it working as much as I could on my own. seems I got stuck right from the git go. I believe I got the interrupt back in working and also the ADC but as soon as I got past that the pbp3 compiler give me a few errors with regards to USBINIT, USBSERVICE, USBOUT, USBIN not found in macro file and pic16f1455.pbpinc not supported in this device

    datasheet seems to support it I guess pbp3 doesn't?

  31. #111

    Default Re: PIC USB HID breakout board

    you put a lot of work in that. The usb always deterred me due to all the programming just for sending and receiving. The wifi modules were much easier to deal with. I was able to program some 8266 modules to be 'transparent bridge' so they just send and receive when connected to with IP and port #. Also, jscript can connect for send and receive and handle name-value pairs or other data. I don't know the jscript enough but from reading am sure the routines can handle that.

  32. #112
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    141

    Default Re: PIC USB HID breakout board

    Quote Originally Posted by amgen View Post
    you put a lot of work in that. The usb always deterred me due to all the programming just for sending and receiving. The wifi modules were much easier to deal with. I was able to program some 8266 modules to be 'transparent bridge' so they just send and receive when connected to with IP and port #. Also, jscript can connect for send and receive and handle name-value pairs or other data. I don't know the jscript enough but from reading am sure the routines can handle that.
    Yes wifi would be much simpler (sort of).... There is a websockets api that works in both IE and Chrome so you can you can use any socket you want to listen on the wifi module. However you'd have to jump through some hoops if, in my situation, you'd have 10 different kiosks running (could be a good chance of that in my case) you'd have to use take that into consideration and most likely each wifi module would have to be configured to listen on a different socket, etc... USB hard wired is much simpler and less of a setup headache in the long run.

  33. #113

    Default Re: PIC USB HID breakout board

    The usb always deterred me due to all the programming just for sending and receiving.
    Yes it's a steep learning curve but once you done it once it's trivial. From the device side things are pretty simply, put stuff in a buffer and call OUT or call IN and look at the buffer. Things from the PC end can be more complex unless you use a HID type already supported by your OS, in which case nothing to do at all. If you go for HID custom (vendor whatever..), which you will eventually, it's more complicated but I suspect some PC programming environments do a lot of the work for you. Personally I use win32 API direct in a few boilerplate routines, SeekUSBbyVID, CommWithUSB, CloseUSB and CheckUSBStatus. All the details are in Axelson's book.

    What do you use for programming PC's?
    Last edited by towlerg; Today at 13:52.
    George

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, 16:15
  5. Usb hid
    By yatyas72 in forum USB
    Replies: 5
    Last Post: - 3rd December 2010, 16:45

Members who have read this thread : 23

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