Subscripted variables
ERIC THE GREAT
Posts: 19
Can you have a subscripted variable that is a word? ·Example DIGIT VAR WORD (4). I suspect that you cant. If not, what is the alternative.
Thanks· Eric
Post Edited (ERIC THE GREAT) : 9/1/2008 11:27:20 PM GMT
Thanks· Eric
Post Edited (ERIC THE GREAT) : 9/1/2008 11:27:20 PM GMT
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
One way around it is to copy data from an array of BYTEs into a WORD variable.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"A government big enough to give you everything you want, is big enough to take away everything you·have."·· Thomas Jefferson
"It is our choices, Harry, that show what we truly are, far more than our abilities."·Dumbledore from Harry Potter
www.iElectronicDesigns.com
·
Now define a PUT subroutine and GET function for that array like this:
And, finally, write your code:
Since the SX has 16-byte banks you could use this for groups of eight words -- just change the original array definition.
so storage can hold 4 words (You cannot declare a word array like w_storage).
The two subroutines are· used to store and retrieve word values
pp var word
n var byte
PUT_WORD n,pp····· 'store pp as element n, eg. w_storage(n) =·pp
pp = GET_WORD n·· 'retrieve element n and assign it to pp, eg. pp = w_storage(n)
Note that n must be in the range 0 to 3 (because storage only holds 4 words)
regards peter
Thanks Eric
I added a word WVALUE that holds a retrieved value from the word array.
Note that I let the interrupt jump over sub declarations and startup code.
regards peter
Eric
All your DIGITx results have value 0 to 9.
What do you want to store in the word array?
regards peter
regards peter
with digits from your calculation.
The isr then uses the digits to get the pattern.
You need to add a sub UPDATE_SEGS that writes the pattern to the correct segment.
Note that the word array is still there, but not used.
regards peter
Eric
regards peter
Since your pulse inputs are coming in pretty swiftly (based on your original program) I updated my program so that it can count rising edges at up to 100 KHz.
[noparse][[/noparse]Edit] For fun I updated the program to remove leading zeroes from the displayed value -- this looks more professional.
[noparse][[/noparse]Edit] I did one more version that is closer to your goal: this one allows you to direct the counter to one pin or another as you're doing in your program. This should get you pretty close.
Post Edited (JonnyMac) : 9/8/2008 1:31:40 AM GMT
1) If the sFactor is zero then scale will be zero -- in SX/B a zero divisor returns zero
-- To fix item #1 I think you want to multiply your pulses by 2 when sFactor is set to 200
2) In SX/B 1.51.03 there is a divide by 1 error; this has been fixed in the 2.0 beta
-- To deal with #2 don't divide anything when sFactor is set to 1.
Post Edited (JonnyMac) : 9/8/2008 6:15:51 AM GMT
Thanks for your help, Eric