Continue to Site

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.

  • 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.

Oshonsoft users?

Status
Not open for further replies.

Jay Davis

New Member
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
 
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:
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:
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
--------------------------------------------------------------------
Hi All.
Jay Davis i think this may help you
**broken link removed**
This is the place oshonsoft users hang out
all the best from
oz1lqb / Claus
 
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

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.
 
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 :)
 
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
 
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

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...
 
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 :)

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%
 
hi eric....

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

thanks!
 
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.
 
hi eric....

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

thanks!

hi Jim,
Read your link, 16F877A.ok
Are you using the assembler or Oshonsoft Basic.?? also is the LCD a HD44780 Hitachi standard.?
 
hi eric....

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

thanks!

hi Jim,
Look at this OS Basic prog, it should help you get started.


Code:
'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
 
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:
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!

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.
 
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:
ascbfr3 = binval / 1023  'delete for 16 bit conv
temp3 = binval Mod 1023  'delete for 16 bit

Wilksey
 
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!!!
 
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
 
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?)
 
Status
Not open for further replies.

Latest threads

Back
Top