1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Beginning with PIC Simulator IDE

Discussion in 'Oshonsoft' started by micol, Oct 23, 2011.

  1. micol

    micol New Member

    Joined:
    Oct 19, 2011
    Messages:
    8
    Likes:
    0
    Location:
    Villeurbanne, France
    Hello,

    I have the whole package for PIC and PIC18. Full versions (not trial).

    On yesterday, I tried "PIC 18 Getting Started". All works well except "Run to next basic statement" which stays inactive (grey).

    Now, I am trying "Getting started" with the other version (not 18) and program timer0.bas and I have exactly the same problem.
    Why cannot I acced to this function ?

    second question (only by curiousity) :
    What is the use of lines with R0L to R9H found in the beginning of all compiled files ?

    have a good sunday
     
  2. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,185
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    ONLINE
    Hi,
    If you post your full program listing I can run it in Oshonsoft and help to debug it with you.
    Use the
    Code (text):
    '#'
    symbol on the Menu above to enclose your list, in that way it will retain the code formatting.
     
    Last edited: Oct 23, 2011
  3. micol

    micol New Member

    Joined:
    Oct 19, 2011
    Messages:
    8
    Likes:
    0
    Location:
    Villeurbanne, France
    I guessed this but not understood why il does not works even when i load .bas file and key "F9".

    I have not yet personnal programs : I use Oshonsotf exemples.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,185
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    ONLINE

    hi,
    Try this using Basic.
    Set the RATE to Step by Step, this then should allow the Run to Next Basic

    If you want the program to RUN at full Rate and then want to STEP at a particular point in the program , add a BREAK instruction at that point in the program list.

    So when you Run the program it will Run at the Ultimate Rate until it reaches the BREAK command, after that you can use the Run to Next Basic.

    Let me know how it goes.
     
  6. micol

    micol New Member

    Joined:
    Oct 19, 2011
    Messages:
    8
    Likes:
    0
    Location:
    Villeurbanne, France
    Now it works.
    Maybe because on this morning, I did not open the assembler window.
    :)
     
  7. micol

    micol New Member

    Joined:
    Oct 19, 2011
    Messages:
    8
    Likes:
    0
    Location:
    Villeurbanne, France
    Hi,

    I tried and wrote any data into a 4550 using USB.

    Here is part of the VB5 code, happening when we click on "Test" button :

    and part of PIC code, adapted from Oshonsoft:

    I put resistors and leds on each pin of PORTB.
    These leds shine quickly on plug-in but never after.

    When I clik on the TEST button :
    1st time, I get the message "écriture exécutée."
    2nd time : no action, even if I clicked on other buttons between 1st and second click.
    3rd time : the program freezes. All buttons are blocked until I unplug USB wire and then the program closes itself.

    [​IMG]

    I did not progress much during last 2 months. I shall look at package USB_Term2 as soon as I receive 2550 and displays recently ordered from Hong-Kong.

    Merry Christmas to everybody on this forum.

    Michel
     
    Last edited: Dec 30, 2011
  8. micol

    micol New Member

    Joined:
    Oct 19, 2011
    Messages:
    8
    Likes:
    0
    Location:
    Villeurbanne, France
    Hi,

    I changed my purpose. I copied, studied, modified HIDTerminal.

    Something is worrying : there are subroutines called before sending anything to PC, but no way to send without being requiered.
    Exemple of what I need : sending some values to PC when I push on a button on the board.
    I know 18F4550 allows this kind of things. I did a programm who does so witn Microchip C18 and I seek how doing the same with OshonSoft pack.

    I read "getting started", and several exemples on this forum (USB_Demo1/2/3.bas) whithout finding any Basic command sending data to PC.

    :(
     
    Last edited: Feb 7, 2012
  9. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,185
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    ONLINE
    hi,
    If I understand correctly what you are asking for, ? this is an example of a PIC to PC data transfer, using the Report and Feature buffers

    Code (text):

     'preload Feature array, before calling service
    f1(0) = "P"
    f1(1) = "O"
    f1(2) = "R"
    f1(3) = "T"
    f1(4) = "A"
    f1(5) = "="
    f1(6) = 0x20  '''''Note the IDE will not allow a space of " "
    f1(7) = PORTA And 0xfc  'read PORTA digital inputs
    f1(7) = ShiftRight(f1(7), 2)  'move to lower nibble
    f1(7) = f1(7) Or 0x30  'make ascii

     'preload Report array with ascii value, before calling service
    r1(0) = "V"
    r1(1) = "0"
    r1(2) = "="
    r1(3) = asc1(3)
    r1(4) = "."
    r1(5) = asc1(2)
    r1(6) = asc1(1)
    r1(7) = asc1(0)


    UsbService '  This Command starts the PIC to PC transfer
     
     
    Last edited: Feb 8, 2012
  10. micol

    micol New Member

    Joined:
    Oct 19, 2011
    Messages:
    8
    Likes:
    0
    Location:
    Villeurbanne, France
    Thank you for your quick answer.

    Now, I see better where is the problem. It is on the PC side. Your example (and what I tried before) sends data to PC . But the PC does not read it because nothing tells it : "it is time to HIDReadReport" .

    The problem is in the dll, not so complete as mcHID.dll in which "setReadNotify" does this.

    I shall explore this way.

    :)
     
    Last edited: Feb 8, 2012
  11. micol

    micol New Member

    Joined:
    Oct 19, 2011
    Messages:
    8
    Likes:
    0
    Location:
    Villeurbanne, France
    No result :eek:

    From Oshonsoft hidTerminal, I made a VB6 program using both mcHID.dll and hidterm.dll. This prog receives datas from board when he asked for them but not those send spontaneously by the board.

    a week later :

    I tried another way. I used my first VB6 program (who receives data when PIC contains a programm from MSLab IDE) and wrote a program with PICSimulator with the same result as before.

    Now, I give up for a while, begining the learning of another system : Arduino.

    View attachment 61109
     
    Last edited: Feb 19, 2012
  12. jose9186

    jose9186 New Member

    Joined:
    Feb 21, 2012
    Messages:
    13
    Likes:
    0
    I just read from post #8 :

    UsbService ' This Command starts the PIC to PC transfer

    does this command also starts de PC to PIC transfer, in other words does this command makes the PIC to wait information??
     
  13. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,185
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    ONLINE
    hi,
    The USBService command is required for transfers from the PC to PIC and PIC to PC.

    Before calling the USBService, preload your PIC buffers [Report and Feature] 8 Bytes each.

    On calling the USBService the the service will read and Save the contents of the 'usbiobuffers' from the PC and then Send the contents of the PIC buffers to the PC, which are read by the PC program.

    As its HID its not a very fast transfer rate, I use a Timer in Visual Basic to read the USB buffers at 1mSec intervals. This transfers 2*8 bytes [ the Report and Feature] buffers

    Code (text):
    'stores data PC>pcb>PC
    usbonioin:
    UsbIoBuffer(0) = "0"
    UsbIoBuffer(1) = "1"
    UsbIoBuffer(2) = "2"
    UsbIoBuffer(3) = "3"
    UsbIoBuffer(4) = "4"
    UsbIoBuffer(5) = "5"
    UsbIoBuffer(6) = "6"
    UsbIoBuffer(7) = "7"
    Return                                            

    'store data  PC>pcb>PC
    usbonftin:
    UsbFtBuffer(0) = "A"
    UsbFtBuffer(1) = "B"
    UsbFtBuffer(2) = UsbFtBuffer(2) - 1
    UsbFtBuffer(3) = UsbFtBuffer(3) - 1
    UsbFtBuffer(4) = UsbFtBuffer(4) - 1
    UsbFtBuffer(5) = UsbFtBuffer(5) - 1
    UsbFtBuffer(6) = UsbFtBuffer(6) - 1
    UsbFtBuffer(7) = UsbFtBuffer(7) - 1
    Return  
     
  14. jose9186

    jose9186 New Member

    Joined:
    Feb 21, 2012
    Messages:
    13
    Likes:
    0
    Thank you for the help any further Q I´ll be back :D
     

Share This Page