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

Oshonsoft users?

Discussion in 'Oshonsoft' started by Jay Davis, Jan 22, 2008.

  1. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,189
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi Jim,

    This should do it, unzip the attached zip.

    Read the notes at the top of the Basic Program listing.
     

    Attached Files:

  2. jimbobsimmonds

    jimbobsimmonds New Member

    Joined:
    Sep 15, 2009
    Messages:
    53
    Likes:
    0
    just uploaded that all to my real life PIC and it is only displaying the top line as a solid block and that is it...

    the sample runs fine along with a few other things in real life so the hardware is just fine; and the assembler runs well in OS... but in real life we have this problem... wouldn't be much of a problem if i didnt have just 36 hours... at least i got the winter olympics to keep me company while i work on this...

    i believe the problem is in here:


    T1CON.T1OSCEN = 1
    T1CON.TMR1CS = 0
    T1CON.TMR1ON = 1
    T1CON.T1CKPS0 = 1 'tmr1 prescaler /256 gives a 2 microsec clock period
    T1CON.T1CKPS1 = 1

    TMR1H = 0x3c ''0x3c ~ 0.1 sec/intr
    TMR1L = 0xb0 ''0xb0

    INTCON.GIE = 1
    INTCON.PEIE = 1

    PIR1.TMR1IF = 0
    '''''''''''''''''''''''''''''''

    ADCON0 = %01000001 'fosc/8
    ADCON1 = %10000100 'Dis clk div,,,an0 > an3 analaog rest dig

    TRISA = %00001111
    TRISB = %00000001 'reserve portb.0 for ext interrupts, if required
    TRISC = %11111111


    i think this is all the internal timers... maybe that is effecting my hardware in some way. the reason i think it is in here is because when i add this section to the working sample of mine the same fault appears in the hardware...
     
  3. jimbobsimmonds

    jimbobsimmonds New Member

    Joined:
    Sep 15, 2009
    Messages:
    53
    Likes:
    0
    ahh, did not see that... maybe this could be something to do with it???

    would it just be a matter of seeing if removing:

    TMR1H = 0xfe
    TMR1L = 0xfe

    and replacing with:

    TMR1H = 0xcf 'FFFF - CF2C = 30D3 == 12500 * 8 = ~ 0.1 sec/intr
    TMR1L = 0x2c

    cheers...
     
    Last edited: Feb 16, 2010
  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,189
    Likes:
    644
    Location:
    Ex Yorks' Hants UK


    hi Jim,
    Please confirm the frequency of the PIC crystal that you are using

    The one above is for a 4mHz xtal and the TMR1H = 0x3c TMR1L = 0xb0 is for a 16mHz.

    These values are ONLY for the sim
    TMR1H = 0xfe
    TMR1L = 0xfe



    EDIT:
    Where is the RW pin of the LCD connected too.?
     
    Last edited: Feb 17, 2010
  6. jimbobsimmonds

    jimbobsimmonds New Member

    Joined:
    Sep 15, 2009
    Messages:
    53
    Likes:
    0
    good morning.

    will have to confirm in a little while when i get to my proper computer, but i am relatively confident it is 16MHz and that the R/W pin is not attached to anything...
     
  7. jimbobsimmonds

    jimbobsimmonds New Member

    Joined:
    Sep 15, 2009
    Messages:
    53
    Likes:
    0
    can confirm that the R/W is detached and its 16MHz...
     
  8. jimbobsimmonds

    jimbobsimmonds New Member

    Joined:
    Sep 15, 2009
    Messages:
    53
    Likes:
    0
    also what difference does the config word (2007h) make when programming the PIC with the OS software? i have been told to set it to 3f72 though the default was 3f71...

    could be part of the fault?
     
  9. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,189
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi,
    The LCD R/W MUST be connected to 0V if not connected to the PIC.

    The change from 3f71 to 3f72 changes the Xtal select From XT to HS.

    The Oshonsoft keeps setting at XT, you can try it set to HS.


    If the R/W is floating your LCD will not work...:)
     
    Last edited: Feb 17, 2010
  10. jimbobsimmonds

    jimbobsimmonds New Member

    Joined:
    Sep 15, 2009
    Messages:
    53
    Likes:
    0
    will iterally try attaching my LCD to ground now, see wat occurs...

    at the moment it is displaying but not entirely correctly, just a solid top line and nothing on the bottom...
     
    Last edited: Feb 17, 2010
  11. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

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

    hi Jim
    Programming a PIC OK with the last program I posted, it runs fine.

    The problem is due to the Oshonsoft making the CONFIG LVP and DEBUG..

    Use CONFIG: 3F32


    EDIT:
    hi,
    Tested it using a 16F876A PIC, at 4mHz 10mHz and 20mHz, no problems.

    Made up a resistive divider for an0 to give the required 4.88V with a +5Vsrc.
    Checked the calibration points at 0.488V , 2.05V, 3.62V, reads 000% 00.0L... 050% 10.0L.... 100% 20L all ok.

    I think your intro header screens are too fast to read.!!!

    Regards
    Eric
    Regards
    Eric
     
    Last edited: Feb 17, 2010
  12. jimbobsimmonds

    jimbobsimmonds New Member

    Joined:
    Sep 15, 2009
    Messages:
    53
    Likes:
    0
    my theory too because a couple of the sample things were running ridiculously fast but i slowed them down and it worked...

    how would i slow the headers down or should i just get rid of them?

    really thanks for this
     
  13. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,189
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi,
    Even with a 4mHz the headers are to fast to read on the PIC/LED, the Percent/L readings refresh at about 2sec intervals, which you would expect for a 16mHz program..

    I would use WAITMS 2000 [ 2secs for each header] the data update is 0.5secs as planned, using a 16mHz xtal.
     
    Last edited: Feb 17, 2010
  14. jimbobsimmonds

    jimbobsimmonds New Member

    Joined:
    Sep 15, 2009
    Messages:
    53
    Likes:
    0
    i am just concidering if i cant get this going in the next hour or so just cutting my losses and finding a way of adapting the lcd sample that comes with it and doing the maths to get it to go between 0.5 and 3.7V and merely display 0.0-20.0L... better than nothing
     
  15. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,189
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi,
    Do you have a diagram showing how you have the PIC and LCD etc connected.

    It works as you specified on the hardware setup at my end.
     
  16. jimbobsimmonds

    jimbobsimmonds New Member

    Joined:
    Sep 15, 2009
    Messages:
    53
    Likes:
    0
    hi eric, had to cut my losses (server down at work so had no internet for whole day)...

    went with this in the end:

    Define LCD_RWREG = 0 'set to 0 if not used, 0 is default
    Define LCD_RWBIT = 0 'set to 0 if not used, 0 is default
    Define LCD_COMMANDUS = 2000 'REM'' 'delay after LCDCMDOUT, default value is 5000
    Define LCD_DATAUS = 50 'REM' 'delay after LCDOUT, default value is 100
    Define LCD_INITMS = 2 'REM''' 'delay used by LCDINIT, default value is 100
    'the last three Define directives set the values suitable for simulation; they should be omitted for a real device
    Dim an0 As Word
    Dim abc As Byte
    Dim suman0 As Word
    Dim lit As Byte
    Dim dec As Byte
    TRISA = 0xff 'set all PORTA pins as inputs
    ADCON1 = 0 'set all PORTA pins as analog inputs
    Lcdinit 0 'initialize LCD module; cursor is blinking

    loop:
    abc = 0
    suman0 = 0
    avrg:
    Adcin 0, an0
    suman0 = suman0 + an0
    abc = abc + 1
    If abc < 10 Then Goto avrg
    an0 = suman0 / 10

    If an0 < 102 Then
    an0 = 102
    Endif

    If an0 >= 757 Then
    an0 = 757
    Endif

    an0 = an0 - 102
    an0 = an0 * 100
    an0 = an0 / 327
    lit = an0 / 10
    dec = an0 Mod 10

    Lcdcmdout LcdClear 'clear LCD display
    Lcdout "Fuel Level" 'text for the line 1
    Lcdcmdout LcdLine2Home 'set cursor at the beginning of line 2
    Lcdout "Volume: ",
    If lit < 10 Then Lcdout " ",
    Lcdout #lit, ".", #dec, " L" 'formatted text for line 2
    WaitMs 100 'larger value should be used in real device
    Goto loop 'loop forever


    going to have a little fiddle with it to spruce it up a little bit tonight but it runs...

    thanks
    james
     
  17. jimbobsimmonds

    jimbobsimmonds New Member

    Joined:
    Sep 15, 2009
    Messages:
    53
    Likes:
    0
    Lcdcmdout LcdClear 'clear LCD display
    Lcdout "Fuel Level " 'text for the line 1
    If lit < 10 Then
    Lcdout "<50% Fuel "
    Endif
    If lit < 5 Then
    Lcdout "Low Fuel: <25% "
    Endif
    If lit < 2 Then
    Lcdout "EMERGENCY FUEL "
    Endif
    WaitMs 5 '000
    Lcdout "EMERGENCY <10% "
    Lcdcmdout LcdLine2Home 'set cursor at the beginning of line 2
    Lcdout "Volume: ",
    If lit < 10 Then Lcdout " ",
    Lcdout #lit, ".", #dec, " L" 'formatted text for line 2
    WaitMs 1 '00 'larger value should be used in real device
    Goto loop 'loop forever



    tried the above to get the top line to display "<50%" when fuel falls below 10L then "Low fuel" when it falls below 5L etc etc but it just seems to run them all at once... maybe i need to include an interupt somewhere?
     
  18. kjennejohn

    kjennejohn New Member

    Joined:
    Mar 19, 2006
    Messages:
    338
    Likes:
    8
    Location:
    Bay Area, California
    Once you get down to 2 liters, then you're also less than 5 liters and 10 liters at the same time, so of course all three conditionals report the corresponding fuel status for that situation. You need to set up a range for two situations, 5 liters (>2 and <5) and 10 liters (>5 and <10). I used "=>" in a few places. Without these the value concerned gets ignored and no status prints out. I tend to look for the smaller values first, so swapped the order in which the values are studied, Ie, while you you looked for 10, 5, and 2, I looked for 2, 5, and 10. What threw me is you go and print out "EMERGENCY <10%" outside of a conditional statement. Maybe I just dropped the thread here. If none of the other warnings are true, print "FUEL GOOD, >50%".
    Here is my version of the code:
    Code (text):

    loop  ' Start of endless loop
    ... take fuel readings here...

    ' Detemine fuel status here, print it out.
    Lcdcmdout LcdClear 'clear LCD display
    Lcdout "Fuel Level: " 'text for the line 1

    If lit =< 2 Then
    Lcdout "EMERGENCY FUEL "
    Endif

    If lit > 2 AND lit < 5 Then
    Lcdout "<25% "
    Endif

    If lit => 5 AND < 10 Then
    Lcdout "<50% Fuel "
    Endif

    WaitMs 5 '000

    ' Here's a problem: after determing and printing your fuel status above,
    ' you just print this next line out without a conditional
    Lcdout "EMERGENCY <10% "  ' Try using "FUEL GOOD, >50%" here to indicate OK fuel status

    Lcdcmdout LcdLine2Home 'set cursor at the beginning of line 2
    Lcdout "Volume: ",
    If lit < 10 Then Lcdout " ",
    Lcdout #lit, ".", #dec, " L" 'formatted text for line 2

    WaitMs 1 '00 'larger value should be used in real device
    Goto loop 'loop forever
    [END CODE]

    Hope this helps.
    kenjj
     
    Last edited: Feb 17, 2010
  19. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,189
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi James,
    From your latest post you seem to have the hardware and program working, in that the LCD displays OK.

    I was under the impression that the LCD would only display blocks according to your earlier posts.???

    If the program you have now written displays OK, there is no reason why the program I zipped for you will not work.

    Its working alongside me as per your specification, using a PIC in a project board, with a range of xtals 4, 10 and 20mHz.

    I would appreciate an update of what is and is not working.:)
     
  20. jimbobsimmonds

    jimbobsimmonds New Member

    Joined:
    Sep 15, 2009
    Messages:
    53
    Likes:
    0
    we're all stumped truth be told eric... will update soon :)
     
  21. jimbobsimmonds

    jimbobsimmonds New Member

    Joined:
    Sep 15, 2009
    Messages:
    53
    Likes:
    0
    OS v5.22 will not compile the if and functions in the same line...

    Define ADC_CLOCK = 3 'default value is 3
    Define ADC_SAMPLEUS = 20 'default value is 20
    Define LCD_BITS = 8 'allowed values are 4 and 8 - the number of data interface lines
    Define LCD_DREG = PORTD
    Define LCD_DBIT = 0 '0 or 4 for 4-bit interface, ignored for 8-bit interface
    Define LCD_RSREG = PORTC
    Define LCD_RSBIT = 0
    Define LCD_EREG = PORTC
    Define LCD_EBIT = 1
    Define LCD_RWREG = 0 'set to 0 if not used, 0 is default
    Define LCD_RWBIT = 0 'set to 0 if not used, 0 is default
    Define LCD_COMMANDUS = 2000 'REM'' 'delay after LCDCMDOUT, default value is 5000
    Define LCD_DATAUS = 50 'REM' 'delay after LCDOUT, default value is 100
    Define LCD_INITMS = 2 'REM''' 'delay used by LCDINIT, default value is 100
    'the last three Define directives set the values suitable for simulation; they should be omitted for a real device
    Dim an0 As Word
    Dim abc As Byte
    Dim suman0 As Word
    Dim lit As Byte
    Dim dec As Byte
    TRISA = 0xff 'set all PORTA pins as inputs
    ADCON1 = 0 'set all PORTA pins as analog inputs
    Lcdinit 0 'initialize LCD module; cursor is blinking
    Lcdcmdout LcdHome
    Lcdout "****************"
    Lcdcmdout LcdLine2Home
    Lcdout "****************"
    WaitMs 2000

    loop:
    abc = 0
    suman0 = 0
    avrg:
    Adcin 0, an0
    suman0 = suman0 + an0
    abc = abc + 1
    If abc < 10 Then Goto avrg
    an0 = suman0 / 10

    If an0 < 102 Then
    an0 = 102
    Endif

    If an0 >= 757 Then
    an0 = 757
    Endif

    an0 = an0 - 102
    an0 = an0 * 100
    an0 = an0 / 327
    lit = an0 / 10
    dec = an0 Mod 10

    Lcdcmdout LcdClear 'clear LCD display
    If lit >= 5 Then
    Lcdout "Fuel Level" 'text for the line 1
    Endif

    If lit < 5 Then
    Lcdout "LOW FUEL: <25%"
    Endif
    If lit <= 5 And lit > 2
    Then Lcdout "Low Fuel: <25%"
    Endif

    'If lit >= 5 And lit < 10 Then
    'Lcdout "Fuel Level: <50%"
    'Endif


    Lcdcmdout LcdLine2Home 'set cursor at the beginning of line 2
    Lcdout "Volume: ",
    If lit < 10 Then Lcdout " ",
    Lcdout #lit, ".", #dec, " L" 'formatted text for line 2
    WaitMs 150 'larger value should be used in real device
    Goto loop 'loop forever


    can't see why it won't compile... any chance u can just post the text of the hex file on here for me?

    Thanks

    P.S, hardware engineers on the way as we speak, already defeated 2 of them :)
     

Share This Page