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

PIC Simulator

Discussion in 'Oshonsoft' started by Transistorman, Aug 16, 2010.

  1. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,187
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    ONLINE
    hi,
    The hardware UART is a logic block that exists in the PIC and it controls all the bit timing to create RS232 signals.
    A software only exists in the program, you have to create the bit timing etc within the program in order to meet the RS232 specification for the signals.
     
  2. Transistorman

    Transistorman Member

    Joined:
    Jun 7, 2010
    Messages:
    390
    Likes:
    2
    Location:
    Indonesian
    hi
    i just uploaded new program

    just a simple program that mixed i from code to code :)

    i dont know what to explain , maybe i will be just post the code

    so you can have a try :)
     

    Attached Files:

    Last edited: Aug 25, 2010
  3. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,187
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    ONLINE
    hi,
    It works fine for me, whats supposed to be wrong.?

    Did you have this line Define SIMULATION_WAITMS_VALUE = 1 just under AllDigital.???
     
  4. dave

    Dave New Member

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


     
  5. Transistorman

    Transistorman Member

    Joined:
    Jun 7, 2010
    Messages:
    390
    Likes:
    2
    Location:
    Indonesian

    ok , i add it to the code :)
     

    Attached Files:

  6. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,187
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    ONLINE
    hi TT,
    Try my version.

    AllDigital

    Define SIMULATION_WAITMS_VALUE = 1

    Define LCD_BITS = 8
    Define LCD_DREG = PORTB
    Define LCD_DBIT = 0
    Define LCD_RSREG = PORTA
    Define LCD_RSBIT = 1
    Define LCD_EREG = PORTA
    Define LCD_EBIT = 3
    Define LCD_RWREG = PORTA
    Define LCD_RWBIT = 2

    Lcdinit

    TRISA = 1
    TRISC = 0

    Lcdout "PORTA.0 = "
    loop:
    Lcdcmdout LcdLine1Pos(11)

    If PORTA.0 = 1 Then
    Lcdout "ON "
    PORTC.4 = 1
    PORTC.5 = 0
    Else

    Lcdout "OFF"
    PORTC.5 = 1
    PORTC.4 = 0
    Endif
    WaitMs 1000
    Goto loop
     
  7. Transistorman

    Transistorman Member

    Joined:
    Jun 7, 2010
    Messages:
    390
    Likes:
    2
    Location:
    Indonesian
    its work ok too :)
     
  8. FreeThinker

    FreeThinker New Member

    Joined:
    Jul 16, 2010
    Messages:
    17
    Likes:
    0
    Lcd.pdf

    Hi Eric

    Do you have a link to part 2 of this article?how2lcd1.pdf
    Thanks
     
    Last edited: Aug 25, 2010
  9. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,187
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    ONLINE
    I dont have a direct link to part2, try Googling epemag

    try here:
    http://www.epemag3.com/
     
    Last edited: Aug 25, 2010
  10. FreeThinker

    FreeThinker New Member

    Joined:
    Jul 16, 2010
    Messages:
    17
    Likes:
    0
    Thanks! Found it, Should help immensely helpful in a project I am playing with.What I'm trying to do is write user defineable graphics (8 at a time) to the screen, update the UDG's and reprint them to a different area fo the screen etc. creating a (sort of) dot addressable display on a alphanumeric screen.I understand the limitations I will run up against not least the gaps between characters, but it fascinates me to see how far this can be taken.I have managed to get 32 different chars on a 2x16 display so it is possible.
    Ultimately I would like to write an Interupt driven 'Blitter' to dot scroll some sort of large graphic.Proberably not very practical but appeals to my hardware hacker nature.
     
  11. Transistorman

    Transistorman Member

    Joined:
    Jun 7, 2010
    Messages:
    390
    Likes:
    2
    Location:
    Indonesian
    it seems i have no idea what to make :confused:

    anyone can suggest me what to make ?
     
    Last edited: Aug 26, 2010
  12. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,187
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    ONLINE
    hi,
    Tell me which major electronic items you have on the shelf, we may have some ideas
     
  13. Transistorman

    Transistorman Member

    Joined:
    Jun 7, 2010
    Messages:
    390
    Likes:
    2
    Location:
    Indonesian
    i have LCD ( 16x2 ), some LEDs , some NPN transistor , LDR , Motor , and four servo , 2 7 segment display and Pickit 2 ( for UART communication )

    what do you suggest ? :)
     
  14. Transistorman

    Transistorman Member

    Joined:
    Jun 7, 2010
    Messages:
    390
    Likes:
    2
    Location:
    Indonesian
    hi eric

    how can i make analog input become two ?

    like " value PORTA.0 = 500 "
    ....." value PORTA.1 = 200 "
     
    Last edited: Aug 30, 2010
  15. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,187
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    ONLINE
    hi,
    Look at this.
    Code (text):
    '16F886 and 16F88

    AllDigital

    Define SIMULATION_WAITMS_VALUE = 1

    Define LCD_BITS = 4
    Define LCD_DREG = PORTB
    'Define LCD_DBIT = 8

    Define LCD_RSREG = PORTB
    Define LCD_RSBIT = 3

    Define LCD_EREG = PORTB
    Define LCD_EBIT = 2

    Define LCD_RWREG = PORTB
    Define LCD_RWBIT = 1

    Dim adcv0 As Word
    Dim adcv1 As Word

    TRISA = 3  'RA0 (AN0) is input
    TRISB = 0  'PORTB is output

    ANSEL = 0x03
    'Initialize the A/D converter
    ADCON1 = %00000011  'Make AN0 analog inputs,
    'make reference voltage = VDD
    ADCON0 = %11000101  'A/D clock is internal RC, select AN0

    Lcdinit

    loop:
    Lcdcmdout LcdLine1Home
    Adcin 0, adcv0
    Lcdcmdout LcdLine1Home
    Lcdout "adc0 test=", #adcv0, "  "

    Adcin 1, adcv1

    Lcdcmdout LcdLine2Home
    Lcdout "adc1 test=", #adcv1, "  "

    Goto loop

    End      
     
  16. Transistorman

    Transistorman Member

    Joined:
    Jun 7, 2010
    Messages:
    390
    Likes:
    2
    Location:
    Indonesian
    thanks

    it work

    i will show my new code after i finished it :)
     
  17. Transistorman

    Transistorman Member

    Joined:
    Jun 7, 2010
    Messages:
    390
    Likes:
    2
    Location:
    Indonesian
    how can i disable Vref on RA2/RA3 ?
     
    Last edited: Aug 30, 2010
  18. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,187
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    ONLINE
    If you mean the last program I posted, the Vref's are NOT enabled, RA2 and 3 are outputs.
     
  19. Transistorman

    Transistorman Member

    Joined:
    Jun 7, 2010
    Messages:
    390
    Likes:
    2
    Location:
    Indonesian
    hi

    i do a little research

    i think i only need to change the code to this :)

    Code (text):
    [COLOR="red"]ANSEL = 0x07  'make RA0, RA1 and RA2 Analog Input[/COLOR]
    'Initialize the A/D converter
    ADCON1 = 0
    'make reference voltage = VDD
    ADCON0 = %11000101  'A/D clock is internal RC, select AN0
     
     
    Last edited: Aug 30, 2010
  20. Transistorman

    Transistorman Member

    Joined:
    Jun 7, 2010
    Messages:
    390
    Likes:
    2
    Location:
    Indonesian
    hi

    i have just finished my new code :)

    ALREADY TESTED IN REAL WORLD

    it can count up to 1000 rather than 255 , right ? :)

    [​IMG]

    i will upload the video later :)
     

    Attached Files:

    Last edited: Sep 2, 2010
  21. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,187
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    ONLINE
    hi,
    I will give your softuart2.bas a run in Oshonsoft
    Code (text):
    Define SEROUT_DELAYUS = 500

    Dim i As Word  'to declare i as word not byte because Byte is just only around 256
    i = 1000  'make i to 1000
    WaitMs 1000  '1000 ms delay
    For i = 1 To 1000 Step 1  'from 1 to 1000 , +1 every Step
    Serout PORTB.7, 9600, "Number: ", #i, CrLf  'set and use portb.7 to send data and set baud rate to 9600
    WaitMs 500  'delay 500 ms
    Next i  'step again
    [COLOR=Blue]
    'this section of the code is incomplete.??[/COLOR]
    loop:
    Serin PORTB.6, 9600, i  'things that will be displayed at uart window
    Serout PORTB.7, 9600, "Number: ", #i, CrLf

     
     
    Last edited: Sep 2, 2010

Share This Page