DIG command I need help with how to use it
sam_sam_sam
Posts: 2,286
The Digit operator (DIG) returns the specified decimal digit of a 16-bit positive value. Digits are numbered from 0 (the right-most digit) to 4 (the left-most digit of a 16-bit number; 0 to 65535).
[img]mk:@MSITStore:C:\Program%20Files\Parallax%20Inc\Stamp%20Editor%20v2.2.6\PBASIC.chm::/graphics/bs2all_inline.gif[/img] value VAR Wordidx VAR NibMain: value = 9742 DEBUG ? value DIG 2 ' Show digit 2 (7) FOR idx = 0 TO 4 DEBUG ? value DIG idx ' Show digits 0 - 4 of 9742 NEXT END'
'·· File....... SW21-EX28-ADC0831-Simple-Vref.BS2
'·· Purpose.... Servo control and positioning with a potentiometer
'·· Author..... (C) 2000 - 2005, Parallax, Inc.
'·· E-mail..... support@parallax.com
'·· Started....
'·· Updated.... 01 SEP 2005
'
'·· {$STAMP BS2}
'·· {$PBASIC 2.5}This the part of this code that I have a question about is there a way to change it to this 2 digit 12.00 like thisThis code below show with 1 digit it like this 1.200Main:
· DO
··· GOSUB Read_0831···························· ' read the ADC
··· mVolts = result */ Cnts2Mv················· ' convert to millivolts
··· DEBUG HOME,································ ' report
········· CRSRXY, 9, 0, DEC result, CLREOL,
········· CRSRXY, 9, 1, DEC mVolts DIG 3,
······················· ".", DEC3 mVolts·......>>>>>>>>·I tryed to change this line " " to this· 1·200 show this way
··································································· I want to change where the "." point is in the display
··································································· How·do i change it·······
··· PAUSE 100
·LOOP
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 3/19/2008 3:33:10 AM GMT
[img]mk:@MSITStore:C:\Program%20Files\Parallax%20Inc\Stamp%20Editor%20v2.2.6\PBASIC.chm::/graphics/bs2all_inline.gif[/img] value VAR Wordidx VAR NibMain: value = 9742 DEBUG ? value DIG 2 ' Show digit 2 (7) FOR idx = 0 TO 4 DEBUG ? value DIG idx ' Show digits 0 - 4 of 9742 NEXT END'
'·· File....... SW21-EX28-ADC0831-Simple-Vref.BS2
'·· Purpose.... Servo control and positioning with a potentiometer
'·· Author..... (C) 2000 - 2005, Parallax, Inc.
'·· E-mail..... support@parallax.com
'·· Started....
'·· Updated.... 01 SEP 2005
'
'·· {$STAMP BS2}
'·· {$PBASIC 2.5}This the part of this code that I have a question about is there a way to change it to this 2 digit 12.00 like thisThis code below show with 1 digit it like this 1.200Main:
· DO
··· GOSUB Read_0831···························· ' read the ADC
··· mVolts = result */ Cnts2Mv················· ' convert to millivolts
··· DEBUG HOME,································ ' report
········· CRSRXY, 9, 0, DEC result, CLREOL,
········· CRSRXY, 9, 1, DEC mVolts DIG 3,
······················· ".", DEC3 mVolts·......>>>>>>>>·I tryed to change this line " " to this· 1·200 show this way
··································································· I want to change where the "." point is in the display
··································································· How·do i change it·······
··· PAUSE 100
·LOOP
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 3/19/2008 3:33:10 AM GMT
Comments
·
I recommend you read in the editor help until you understand exactly how these commands work. Do some experimenting.
·
Just guessing here, because I don't have access to the editor or the help file from work, but I think it might be like DIG3, DIG2, ".", DEC2
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Rick
Thank you for your reply
I recommend you read in the editor help until you understand exactly how these commands work
This is all it has about this command·in the ·Basic Stamp Editor Help say· this
The Digit operator (DIG) returns the specified decimal digit of a 16-bit positive value. Digits are numbered from 0 (the right-most digit) to 4 (the left-most digit of a 16-bit number; 0 to 65535).
I could be wrong, but if I remember right, the way the code works it sends digit 3 (DIG3), a decimal point ("."), then the rest of the decimal number truncated to 3 digits (DEC3).
This what i though so i changed 3 (DIG3), from 3 to 2 and 1 and did not change where the "." point was
So i at loss of how you change where "."point is
The one thing i did was look at what the Basic Stamp Editor Help say about this commmand before i ask the question the
on the forum
Now i could just change these two ·line
·CRSRXY, 9, 1, DEC mVolts DIG 3,
······················· ".", DEC3 mVolts
To
········ Dec3 ?, mVolts
································· ·but then i would not be able to put the "." point in there· if this is case i will have to live this
.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Thank You for your reply That will ·help a lot
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
This code will do what you want, display the specified digits with the decimal point in the center.
DEBUG DEC mVolts DIG 3, DEC mVolts DIG 2, ".", DEC mVolts DIG 1, DEC mVolts DIG 0
This will display the same thing.
DEBUG DEC mVolts DIG 3, DEC mVolts DIG 2, ".", DEC2 mVolts
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Rick
Post Edited (RDL2004) : 3/19/2008 9:13:17 PM GMT