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. Jay Davis

    Jay Davis New Member

    Joined:
    Jan 22, 2008
    Messages:
    2
    Likes:
    0
    I have been searching the Web looking for discussion or forums of people that use the Oshonsoft PIC IDE but have been unable to find one.

    Can somebody tell me how to write a brief Oshonsoft BASIC program for the 16F877a to read in 0.00V up to 5.00VDC (with 2 decimal accuracy)?

    Thank you,
    Jay
     
  2. m_saeed_soliman

    m_saeed_soliman New Member

    Joined:
    Jan 16, 2008
    Messages:
    29
    Likes:
    0
    hi , i am sorry i have never dealt with pic16f77a
    but , i only replied to make your post in the first page for some to see it and help you
    please if any one can help , please do
     
    Last edited: Jan 25, 2008
  3. JPGS

    JPGS New Member

    Joined:
    Jan 29, 2010
    Messages:
    1
    Likes:
    0
    Please refer the LCD.bas program in the picsimulatoride under program files folder. it will give you the adc value as a count convert it in suitable range
     
    Last edited: Jan 29, 2010
  4. dave

    Dave New Member

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


     
  5. oz1lqb

    oz1lqb New Member

    Joined:
    Jan 23, 2005
    Messages:
    5
    Likes:
    0

    --------------------------------------------------------------------
    Hi All.
    Jay Davis i think this may help you
    pic_sim_ide : PIC SIMULATOR IDE
    This is the place oshonsoft users hang out
    all the best from
    oz1lqb / Claus
     
  6. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

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

    As 'oz1' says pic_sim_ide@yahoogroups.com is a good forum for OS.

    If you cant get the help there, come back I would be happy to help with the ADC.

    BTW: I am assuming that you want to use a LCD display.? Confirm the type you want to use.
     
  7. jimbobsimmonds

    jimbobsimmonds New Member

    Joined:
    Sep 15, 2009
    Messages:
    53
    Likes:
    0
    hi all...

    i am very new to coding but on the advise of much older, wiser people was told to buy oshonsoft... i have now got a copy and have a very similar problem to yourself in that i need to measure 0-5vdc though also need to convert it into a percentage scale (ie 1v=0% 5v=100% with an error message for under 1v)

    i will keep you updated with how i do but any help would be really appreciated!

    thanks :)
     
  8. Wilksey

    Wilksey Member

    Joined:
    Aug 16, 2009
    Messages:
    553
    Likes:
    20
    Location:
    Somerset, UK
    There is a problem with what you are trying to acheive.

    Oshonsoft BASIC compiler only supports integer, so a ADC input can go from 0 to 1023, for this to work you would need to perform the following:

    100 / 1023 * an0

    This would normally give you the answer, but as 100 / 1023 is 0.09 it will return an integer representation of 0, and of course 0 * anything is 0.

    I dont think it is possible to display this natively in Oshonsoft's software.

    Wilksey
     
  9. jimbobsimmonds

    jimbobsimmonds New Member

    Joined:
    Sep 15, 2009
    Messages:
    53
    Likes:
    0
    were you talking to me?

    if so thanks for letting me know but could you explain why this is the case. maybe if i explain what i need to achieve in a little more detail you could help...
     
  10. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,189
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi Jim.
    Consider using a simple resistive divider on the 5V, to make the 5V into 4.88V, then the 1000 counts in the ADC regs will be proportional to 100%
     
  11. jimbobsimmonds

    jimbobsimmonds New Member

    Joined:
    Sep 15, 2009
    Messages:
    53
    Likes:
    0
    hi eric....

    i have explained my problem in a little more detail here if you would care to take a little look for me.

    thanks!
     
  12. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

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

    hi,
    I have reposted in my Forum Blog the latest version of the Oshonsoft Analog3 External Module.

    Oshonsoft users will find this a useful tool for developing ADC type programs.
     
  13. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,189
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi Jim,
    Read your link, 16F877A.ok
    Are you using the assembler or Oshonsoft Basic.?? also is the LCD a HD44780 Hitachi standard.?
     
  14. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,189
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi Jim,
    Look at this OS Basic prog, it should help you get started.


    Code (text):
    '01 Feb 2010 Forum

    Define LCD_BITS = 4
    Define LCD_DREG = PORTB
    Define LCD_DBIT = 4
    Define LCD_RSREG = PORTA
    Define LCD_RSBIT = 4
    Define LCD_EREG = PORTA
    Define LCD_EBIT = 5

    Define SIMULATION_WAITMS_VALUE = 1
    '------------------------------------
    'setup temp variables
    Dim ascbfr4 As Byte
    Dim ascbfr3 As Byte
    Dim ascbfr2 As Byte
    Dim ascbfr1 As Byte
    Dim ascbfr0 As Byte

    Dim temp3 As Word
    Dim binval As Word

    Dim val0 As Word


    ADCON0 = %01000001  'adcchan0
    ADCON1 = %10001011  'Dis clk div,,,an0 > an3 analaog rest dig

    TRISA = %00000001
    TRISB = %11111111  'all inputs on portb
    TRISC = %11111111
    '-----------------------------------------------------

    Lcdinit

    main0:
    Lcdcmdout LcdClear

    main:
    Gosub readadc
    Goto main

    End                                              

    'scale the 5V input to 4.88v using a resistive divider
    readadc:
    'read adc word
    Adcin 0, val0

    binval = val0  'rename for the bin2asc subr
    Gosub bin2asc

    Lcdcmdout LcdLine1Home
    Lcdout "Percent: ", ascbfr3, ascbfr2, ascbfr1, ".", ascbfr0, "%"


    Return                                            


    'you can convert any binary value from 0000h to fffFh to 0000 to 65535 decimal
    'just name the binary word as binval and call this subr and the ASCII
    'result will be in ascbfr4,3,2,1,0, ready for your LCD or UART
    'just pop the DP in the output to the LCD [as shown above]

    bin2asc:
    'ascbfr4 = binval / 10000' add these 4 lines for 16 bit conv
    'temp3 = binval Mod 10000

    'ascbfr3 = temp3 / 1000
    'temp3 = binval Mod 1000

    ascbfr3 = binval / 1000  'delete for 16 bit conv
    temp3 = binval Mod 1000  'delete for 16 bit

    ascbfr2 = temp3 / 100
    temp3 = temp3 Mod 100

    ascbfr1 = temp3 / 10
    ascbfr0 = temp3 Mod 10
    'results are BCD so
    'convert to ASCII for LCD or UART
    ascbfr4 = ascbfr4 Or 0x30
    ascbfr3 = ascbfr3 Or 0x30
    ascbfr2 = ascbfr2 Or 0x30
    ascbfr1 = ascbfr1 Or 0x30
    ascbfr0 = ascbfr0 Or 0x30
    Return                                            


     
    AAesp02.gif
     
  15. jimbobsimmonds

    jimbobsimmonds New Member

    Joined:
    Sep 15, 2009
    Messages:
    53
    Likes:
    0
    i believe i am using basic but could be wrong. could be an old version of the complier ide... (in fact i believe the latter is the case)

    thanks for your help and am looking forward to trying the code out and having a little play with it (no OS at work :-( )... no doubt will return with more questions :)

    is it more convenient if we continue this all here or in the yahoo group?

    btw i believe the LCD is of that standard...

    thanks!
     
    Last edited: Feb 1, 2010
  16. jimbobsimmonds

    jimbobsimmonds New Member

    Joined:
    Sep 15, 2009
    Messages:
    53
    Likes:
    0
    Will it help if i get accurate minimum and maximum V levels to you asap. that is something i can do at work...
     
  17. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,189
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi Jim,
    I find it easier to work on this Forum, we can make any links to the Yahoo group as required.

    As you are a registered user of the OS IDE you should download the latest version from OS.
     
  18. Wilksey

    Wilksey Member

    Joined:
    Aug 16, 2009
    Messages:
    553
    Likes:
    20
    Location:
    Somerset, UK
    As Eric has suggested, the application will work but will need a 4.88V max unless you change the code in the bin2asc function to:
    Code (text):

    ascbfr3 = binval / 1023  'delete for 16 bit conv
    temp3 = binval Mod 1023  'delete for 16 bit
     
    Wilksey
     
  19. jimbobsimmonds

    jimbobsimmonds New Member

    Joined:
    Sep 15, 2009
    Messages:
    53
    Likes:
    0
    so if i can get the values between 0 and 4.88VDC this will make life easier?

    shouldn't be a problem will just require some fiddling with a pot...

    unfortunately i can't really get at my hardware or OS until Wednesday or thursday and the clock unfortunately is ticking and still haven't got the basics running :mad:

    will keep you guys updated.

    Thanks so far!!!
     
  20. Wilksey

    Wilksey Member

    Joined:
    Aug 16, 2009
    Messages:
    553
    Likes:
    20
    Location:
    Somerset, UK
    1023 is the ADC value for 5v, 1000 is the value for 4.88v

    So you can measure 0 - 5v using the code Eric provided and by changing the code as per my previous post.

    The output will be represented on an LCD as a percentage.

    Do not go above 5v however, else you will damage your PIC.

    Wilksey
     
  21. jimbobsimmonds

    jimbobsimmonds New Member

    Joined:
    Sep 15, 2009
    Messages:
    53
    Likes:
    0
    ahh i see now... will do my best to cal it to 4.88V then!!!

    what would i need to modify on the code to make it run on a 0-20 scale to 1d.p instead of 0-100 (ie not %age?)
     

Share This Page