Bar Graph (Advanced) What need to be change to have an output from the MAX186 s
This from my from my meter code
The scale for this one is· 0 to 50 C and a scale 0 to 125 F
I want to display it as a Bar Graph this code·using this what need to be changed
I also want to use this as well and I want to display it as a Bar Graph this code·using this what need to be changed
I aslo have where I to do the same thing with voltage 0 to 4 volts·
Thank to any one that can help
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·Now wanting to learn Spin· Thanks for any·
·that you may have and all of your time finding them 
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 5/4/2010 2:38:32 PM GMT
The scale for this one is· 0 to 50 C and a scale 0 to 125 F
SEROUT TX, T2400, [noparse][[/noparse]LcdCls]
DO
PAUSE 5
LOW CS ' Enable ADC
SHIFTOUT DataIn, Clock, MSBFIRST, [noparse][[/noparse]%10111101] ' Select CH0, Single-Ended [noparse][[/noparse]%1XXX1101]
SHIFTIN DataOut, Clock, MSBPOST, [noparse][[/noparse]KLN\12] ' Read ADC
HIGH CS ' Disable ADC
tC = KLN - 275
' convert to tenths C
SEROUT TX, T2400, [noparse][[/noparse]LcdLine1, "TC ", DEC TC] ' Displays voltages & digital value
LOW CS ' Enable ADC
SHIFTOUT DataIn, Clock, MSBFIRST, [noparse][[/noparse]%11111101] ' Select CH7, Single-Ended
SHIFTIN DataOut, Clock, MSBPOST, [noparse][[/noparse]KLN1\12] ' Read ADC
HIGH CS ' Disable ADC
tC1 = KLN1 - 275 ' convert to tenths C
SEROUT TX, T2400, [noparse][[/noparse]LcdBLon, LcdLine1_1, "TC1 ", DEC TC1] ' Displays voltages & digital value
LOW CS ' Enable ADC
SHIFTOUT DataIn, Clock, MSBFIRST, [noparse][[/noparse]%11001101] ' Select CH1, Single-Ended [noparse][[/noparse]%1XXX1101]
SHIFTIN DataOut, Clock, MSBPOST, [noparse][[/noparse]results0\12] ' Read ADC
HIGH CS
Volts0 = results0 */ Cnts2Mv
IF volts0 > 1 THEN
SEROUT TX, T2400, [noparse][[/noparse]LcdLine1_2, "VT ",DEC Volts0 ]
ELSE
SEROUT TX, T2400, [noparse][[/noparse]LcdLine1_2, "V ____" ]
SEROUT TX, T2400, [noparse][[/noparse]LcdLine2, " " ]
PAUSE 100
ENDIF
LOOP
I want to display it as a Bar Graph this code·using this what need to be changed
' -----[noparse][[/noparse] Initialization ]--------------------------------------------------
HIGH LCD ' Setup Serial Output Pin
PAUSE 100 ' Give LCD Time To Settle
Download_Chars:
FOR index = 0 TO 45 ' Download Custom Characters
READ CC0 + index, work ' Read EEPROM Data
SEROUT LCD, Baud, [noparse][[/noparse]work] ' Send To LCD CGRAM
NEXT
SEROUT LCD, Baud, [noparse][[/noparse]LcdOn1, LcdBLon] ' Turn LCD Display & Backlight On
' Backlight Only On Backlit Models
PAUSE 10 ' Allow LCD Time To Settle
highVal = 255 ' You can change this value to any
' Non-Zero value
' -----[noparse][[/noparse] Program Code ]----------------------------------------------------
Main:
DO
SEROUT LCD, Baud, [noparse][[/noparse]LcdCls] ' Clear LCD Screen
PAUSE 10 ' Must Follow CLS
FOR index = 0 TO highVal ' Count To highVal can add (Step 100}
GOSUB Disp_Graph ' Update Display
NEXT
PAUSE 5000 ' Wait 5 Seconds Then Repeat
LOOP ' Forever
STOP
' -----[noparse][[/noparse] Subroutines ]-----------------------------------------------------
Disp_Graph:
perCent = ((index * 100) / highVal)
' Draw index, highVal and perCent Values. This line can be removed.
SEROUT LCD, Baud, [noparse][[/noparse]LcdLine1, DEC5 index, "/",
DEC5 highVal, "=", DEC perCent, "%"]
' Draw Header And Left-Most, Solid Blocks
SEROUT LCD, Baud, [noparse][[/noparse]LcdLine2, "0%", REP 4\(perCent MIN 1 - 1 / 10)]
' Draw Partial Block
IF perCent > 0 THEN SEROUT LCD, Baud, [noparse][[/noparse](perCent - 1 / 2) // 5]
' Draw Right-Most, Blank Blocks And Footer
SEROUT LCD, Baud, [noparse][[/noparse]REP 32\10 - ((perCent + 9) / 10), "100%"]
RETURN
I also want to use this as well and I want to display it as a Bar Graph this code·using this what need to be changed
I aslo have where I to do the same thing with voltage 0 to 4 volts·
' -----[noparse][[/noparse] Initialization ]--------------------------------------------------
HIGH LCD ' Setup Serial Output Pin
PAUSE 100 ' Give LCD Time To Settle
Download_Chars:
FOR index = 0 TO 72 ' Download Custom Characters
READ CC0 + index, work ' Read EEPROM Data
SEROUT LCD, Baud, [noparse][[/noparse]work] ' Send To LCD CGRAM
NEXT
SEROUT LCD, Baud, [noparse][[/noparse]LcdOn1, LcdBLon] ' Turn LCD Display & Backlight On
' Backlight Only On Backlit Models
PAUSE 10 ' Allow LCD Time To Settle
highVal = 5000 ' You can change this value to any
' Non-Zero value
' -----[noparse][[/noparse] Program Code ]----------------------------------------------------
Main:
DO
SEROUT LCD, Baud, [noparse][[/noparse]LcdCls] ' Clear LCD Screen
PAUSE 10 ' Must Follow CLS
FOR index = 0 TO highVal ' Count To highVal can add (Step 100}
GOSUB Disp_Graph ' Update Display
NEXT
PAUSE 5000 ' Wait 5 Seconds Then Repeat
LOOP ' Forever
STOP
' -----[noparse][[/noparse] Subroutines ]-----------------------------------------------------
Disp_Graph:
perCent = (index / (highVal / 100)) ' Calculate Percent Value
' Draw index, highVal and perCent Values. This line can be removed.
SEROUT LCD, Baud, [noparse][[/noparse]LcdLine3, DEC5 index, " / ", DEC5 highVal]
' Draw Header And Left-Most, Solid Blocks
SEROUT LCD, Baud, [noparse][[/noparse]LcdLine1, "0% ", REP 4\(perCent MIN 1 - 1 / 10)]
' Draw Partial Block
IF perCent > 0 THEN SEROUT LCD, Baud, [noparse][[/noparse](perCent - 1 / 2) // 5]
' Draw Right-Most, Blank Blocks And Footer
SEROUT LCD, Baud, [noparse][[/noparse]REP 32\10 - ((perCent + 9) / 10), DEC perCent, " %"]
SEROUT LCD, Baud, [noparse][[/noparse]LcdBLon ,LcdLine2,5,7,7,7,7,7, 6," KW"]
RETURN
Thank to any one that can help
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·Now wanting to learn Spin· Thanks for any·
·that you may have and all of your time finding them 
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 5/4/2010 2:38:32 PM GMT

Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·Now wanting to learn Spin· Thanks for any·
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 5/4/2010 2:35:01 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·Now wanting to learn Spin· Thanks for any·
·
·
·
·
Sam
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
·
also how do you scale the bar graph as well
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·Now wanting to learn Spin· Thanks for any·
·
·
·
·
Sam
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
·
How do you take the data that you have from the ADC part of the code and Put in·to the Bar Graph part of the code
There is where I am··I am ·REAL·Lost or just have REAL big brain f
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·Now wanting to learn Spin· Thanks for any·
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 5/5/2010 8:33:49 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
·
Could you also post the code that you used
Thanks for your help
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·Now wanting to learn Spin· Thanks for any·
·
·
·
·
Sam
Yep, got the programs and code done last night here at work, however I had forgotten when I got home that my main PC is down and the HD had just arrived. I didn't have time to install it last night. I will get it back up tonight though. If you're not sure what I am talking about, see this post.
Or this one.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
·
I do understand and I did read·that post on your web site
Please take a much as you need I am in no big hurry· I just want to know how you do this
Thanks for you time and help in this project
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·Now wanting to learn Spin· Thanks for any·
·
·
·
·
Sam
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
·
Episode 5: Merging Programs Part 1 of 2
Episode 6: Merging Programs Part 2 of 2
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
·
That was a GREAT how to do video
···········································
·············································· That help alot
··································································
········································································ ·Thanks
····························································································· I got it to work
·································································································································· ··
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·Now wanting to learn Spin· Thanks for any·
·
·
·
·
Sam
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
·
The second part video (Episode 6) has been fully updated and posted at the link above. It gives more details than I thought I had time for originally.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
·
Thanks for taking the time to make this video. You explain alot in a clear manner that helps people like me really understand the thinking process in merging programs together. Well done!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Shawn Lowe
When all else fails.....procrastinate!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
·
The info that you add at the end ·WAS GREAT··that helps alot Thank for all of your help
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·Now wanting to learn Spin· Thanks for any·
·
·
·
·
Sam
' ========================================================================= ' ' File...... MAX186 Bar Graph (Hi-Res_Advanced).bs2 ' Purpose... Demostrate A Hi-Res Advanced Bar Graph ' Author.... Sam ' E-mail.... [url=mailto:sam1030@comcast.net]sam1030@comcast.net[/url] ' Started... 5-12-2010 ' Updated... ' ' {$STAMP BS2} ' {$PBASIC 2.5} ' ' ========================================================================= ' ' I want to thank Chris Savage for his help writing the line of ' code to make ADC chip work with the Bar graph ' ' -----[noparse][[/noparse] Program Description ]--------------------------------------------- ' This program shows how to draw an Advanced Bar Graph Display on a ' Paralax 2X16 Serial LCD. The subroutine needs only to know the highVal ' and the current index to display the Percent and Bar Graph. Feel free to ' change the code to suit your own application. ' ' NOTE: This code includes other unused constants for the display so you ' have them, however if not used, these do not take up any memory in the ' BASIC Stamp, so they are good to have available. ' ' You can change the value of highVal and see how it affects things. ' highVal and index are Word values and should never exceed 65535. ' -----[noparse][[/noparse] Revision History ]------------------------------------------------ ' Increased resolution from 255 to 65535. ' -----[noparse][[/noparse] I/O Definitions ]------------------------------------------------- LCD PIN 15 ' LCD Serial I/O Pin CS PIN 1 ' Chip Select Clock PIN 0 ' Clock DataOut PIN 3 ' DataOut DataIn PIN 2 ' DataIn ' -----[noparse][[/noparse] Constants ]------------------------------------------------------- LcdBkSpc CON $08 ' Move Cursor Left LcdRt CON $09 ' Move Cursor Right LcdLF CON $0A ' Move Cursor Down 1 Line LcdCls CON $0C ' Clear LCD (Use PAUSE 5 After) LcdCR CON $0D ' Move Pos 0 Of Next Line LcdBLon CON $11 ' Backlight On LcdBLoff CON $12 ' Backlight Off LcdOff CON $15 ' LCD Off LcdOn1 CON $16 ' LCD On; Cursor Off, Blink Off LcdOn2 CON $17 ' LCD On; Cursor Off, Blink On LcdOn3 CON $18 ' LCD On; Cursor On, Blink Off LcdOn4 CON $19 ' LCD On; Cursor On, Blink On LcdLine1 CON $80 ' Move To Line 1, Column 0 LcdLine2 CON $94 ' Move To Line 2, Column 0 LcdCC0 CON $F8 ' Define Custom Char 0 LcdCC1 CON $F9 ' Define Custom Char 1 LcdCC2 CON $FA ' Define Custom Char 2 LcdCC3 CON $FB ' Define Custom Char 3 LcdCC4 CON $FC ' Define Custom Char 4 LcdCC5 CON $FD ' Define Custom Char 5 LcdCC6 CON $FE ' Define Custom Char 6 LcdCC7 CON $FF ' Define Custom Char 7 Baud CON 396 ' 2400 Kbps (BS2) Cnts2Mv CON $00F6 ' x 245 ' -----[noparse][[/noparse] Variables ]------------------------------------------------------- work VAR Byte ' Work Variable index VAR Word ' Current Value Of Count/Loop highVal VAR Word ' Highest Value Expected perCent VAR Byte ' Percentage result VAR Word ' Conversion Result CH0 mVolts VAR Word ' Result0 --> mVolts ' -----[noparse][[/noparse] EEPROM Data ]----------------------------------------------------- CC0 DATA LcdCC0, $10, $10, $10, $10, $10, $10, $10, $10 CC1 DATA LcdCC1, $18, $18, $18, $18, $18, $18, $18, $18 CC2 DATA LcdCC2, $1C, $1C, $1C, $1C, $1C, $1C, $1C, $1C CC3 DATA LcdCC3, $1E, $1E, $1E, $1E, $1E, $1E, $1E, $1E CC4 DATA LcdCC4, $1F, $1F, $1F, $1F, $1F, $1F, $1F, $1F ' -----[noparse][[/noparse] Initialization ]-------------------------------------------------- HIGH LCD ' Setup Serial Output Pin PAUSE 100 ' Give LCD Time To Settle Download_Chars: FOR index = 0 TO 45 ' Download Custom Characters READ CC0 + index, work ' Read EEPROM Data SEROUT LCD, Baud, [noparse][[/noparse]work] ' Send To LCD CGRAM NEXT SEROUT LCD, Baud, [noparse][[/noparse]LcdOn1, LcdBLon] ' Turn LCD Display & Backlight On ' Backlight Only On Backlit Models PAUSE 10 ' Allow LCD Time To Settle highVal = 4095 ' You can change this value to any ' Non-Zero value ' -----[noparse][[/noparse] Program Code ]---------------------------------------------------- Main: DO SEROUT LCD, Baud, [noparse][[/noparse]LcdCls] GOSUB Read_ADC ' Read ADC Value index = result ' Copy to index GOSUB Disp_Graph ' Draw Graph PAUSE 100 ' Small Delay LOOP ' Forever ' -----[noparse][[/noparse] Subroutines ]----------------------------------------------------- Disp_Graph: perCent = (index / (highVal / 100)) ' Calculate Percent Value ' Draw index, highVal and perCent Values. This line can be removed. ' SEROUT LCD, Baud, [noparse][[/noparse]LcdLine1, DEC5 index, "/", ' ] ' Draw Header And Left-Most, Solid Blocks SEROUT LCD, Baud, [noparse][[/noparse]LcdLine1, "0_", REP 4\(perCent MIN 1 - 1 / 10)] ' Draw Partial Block IF perCent > 0 THEN SEROUT LCD, Baud, [noparse][[/noparse](perCent - 1 / 2) // 5] ' Draw Right-Most, Blank Blocks And Footer SEROUT LCD, Baud, [noparse][[/noparse]REP 32\10 - ((perCent + 9) / 10), DEC perCent, "%" ] RETURN Read_ADC: LOW CS ' Enable ADC SHIFTOUT DataIn, Clock, MSBFIRST, [noparse][[/noparse]%11001101] ' Select CH1, Single-Ended [noparse][[/noparse]%1XXX1101] SHIFTIN DataOut, Clock, MSBPOST, [noparse][[/noparse]result\12] ' Read ADC HIGH CS ' Disable ADC mVolts = result */ Cnts2Mv ' Convert To Millivolts RETURN▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·Now wanting to learn Spin· Thanks for any·
·
·
·
·
Sam