1. You could do it that way but you are still going to have to use
the same amount of variable space. There is not a varible between a
byte and a word so you would end up with a decimal value between 0
and 729 (3^6). Since that is greater than 256 (8 bits) you have to
go one step up to a word (16 bits). When you do this, you have no
way to save the left over bits so use them however you want. So your
method won't actually save any space over mine, they both use 729 * 2
bytes of storage. I don't know if I have made since here or not, if
not, I will try to clarify.
2. Those statements will not work. There is only 256 bytes of space
available on the EEPROM (Internal) and you are trying to use 2187
bytes. Also when you specify a nibble versus a byte, the compiler
only lets you use the first 4 bits but all 8 bits are allocated
(Hense the RShift, LShift, Mod...). That is one reason I rarely use
nibbles or boolean values, they do not save any space, they all use
one byte of RAM space.
--- In oopic@yahoogroups.com, "tuandung248" <trungtuandung@...> wrote:
>
> Thanks a lot!! That's a cool way of making use of the EEPROM. It's
a
> great idea to store the 6-digit word as one variable.
>
> 1. How about taking a 6-bit word as a base-3 number (digit 0,1,2)
and
> convert it to a decimal number instead? My concern is that, your
> method use shift operation on 2 bits which is probably faster while
> mine below might be slow due to multiply/divide operations. Should
I
> sacrifice one more bit and use base-4 like what you did instead?
>
> Dim Leg(6) As Nib
> Dim Index As Word
>
> Sub HashToIndex(Void)
> 'take a state from Leg(1..6) (eg. 012012)
> 'and convert to decimal. eg 140 for 012012
> Index = Leg(6) + Leg(5)*3 + Leg(4)*9 + Leg(3)*27 + Leg(2)*81 +
> Leg(1)*243
> End Sub
>
> Sub HashToState(Void)
> Leg(6) = Index Mod 3
> Index = Index / 3
> Leg(5) = Index Mod 3
> Index = Index / 3
> Leg(4) = Index Mod 3
> Index = Index / 3
> Leg(3) = Index Mod 3
> Index = Index / 3
> Leg(2) = Index Mod 3
> Index = Index / 3
> Leg(1) = Index
> End Sub
>
> 2. Last time I thought sByte is the only way to store var to EEPROM,
> but i realize sByte doesn't work anymore, and there's a better
option:
>
> Dim Relevance(729) As EEPROM Nib
> Dim Reliability(729) As EEPROM Nib
> Dim Weight(729) As EEPROM Nib
>
> As you see I need to store corresponding Relevance, Reliability,
> Weight (and a more few more similar columns that i'm trying to
reduce)
> to each state. Now that I hash each 6-digit word into an index
> decimal number, I can get a round with the 2D array. However, is it
> reliable to use the variables as declared above on ooPic-R, compiler
> 6.1.1, yet? Or is it more reliable to handle the oEEPROM object
like
> you did?
>
> Thank you for the quick help, hope to hear more from you and others.
>
>
> --- In oopic@yahoogroups.com, "tinslwc" <tinslwc@> wrote:
> >
> > You are going to have to store the table in the EEPROM. Even if
you
> > were able to use all the available bits in the regular RAM space,
you
> > would need almost 1100 bytes (729*6=4374 @ 2 bits each). If
EEPROM
> > space is limited, you can store each row of 6 values in one word
(16
> > bit) variable. I would then write a function to call out which
one
> > that you want. Here is an example:
> >
> > Dim EEPROM_Table As oEEProm
> > Const TableOffset = 10000
> >
> > Sub Main()
> > EEPROM_Table.Node = cvE0 ' or cvE1 if you have it)
> > EEPROM_Table.Width = 1 ' Set to 16 bit transfers
> > EEPROM_Table.NoInc = cvTrue ' Do not automatically increment
> > End Sub
> >
> > Function GetValue(x_Index As Word, y_Index As Byte) As Byte
> > EEPROM_Table.Location = TableOffset + (x_Index * 2)
> > x_Index = EEPROM_Table.Value ' Read 16 Bit Value
> > x_Index.RShift(y_Index * 2)
> > x_Index = x_Index And 3 ' Clear all but last 2 bits
> > Return x_Index
> > End Function
> >
> > Sub WriteValue(x_Index As Word, y_Index As Byte, Data As Byte)
> > Dim Temp As Word
> > EEPROM_Table.Location = TableOffset + (x_Index * 2)
> > x_Index = EEPROM_Table.Value
> > Temp = 3
> > Temp.LShift(y_Index * 2)
> > Temp = Temp Xor 65535
> > x_Index = x_Index And Temp
> > Temp = Data
> > Temp.LShift(y_Index * 2)
> > x_Index = x_Index + Temp
> > EEPROM_Table.Value = x_Index
> > End Sub
> >
> >
> > This code compiles but I did not test it to see if it works
> > properly. It should be able to read and write 2 bits at a time
> > (enough to represent 0, 1, 2, or 3) to the EEPROM table at the
> > location specified by x_Index and y_Index. It will not be really
> > fast although your application of this does not sound like it
will be
> > a problem. They say that the B versions of the oEEPROM object
has
> > some trouble with two byte transfers but I think you could rewite
> > this to use one byte transfers. The Table offset is where the
table
> > will begin on the EEPROM. Depending on the size of the EEPROM
you
> > use, you may need to change this. The table will take up 1458
bytes
> > so you need to keep that in mind and if you are using it on E0,
you
> > need to make sure that it is stored above your program location.
> > Good luck.
> > --- In oopic@yahoogroups.com, trungtuandung@ wrote:
> > >
> > > Hi all,
> > > I'm new here and hoping that somebody can help me with this.
I'm
> > using ooPic-R which is connected to 2 sensors and a SSC-32 servo
> > controller (with 12 servos). I want to make it learn how to walk
> > just by sensors and without walk sequence. Now I need huge
tables.
> > >
> > > The ooPic manual says that i can use object oVar3
> > > http://www.oopic.com/ovar.htm
> > >
> > > but the 6.1.1 oopic compiler online understands oVar8 and
oVar16.
> > I need a table of the size 729 by 6 and each cell has 3 values -
1, 0,
> > 1 (preferably, if not possible, i can settle with 0, 1, 2)
> > >
> > > What's the most efficient way to store them? I read somewhere
that
> > you can only store array of objects, in which case I'm out of
luck
> > because there are only 86 bytes object memory.
> > >
> > > Thanks in advance for your help,
> > > Harley
> > >
> >
>
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/oopic/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/oopic/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:oopic-digest@yahoogroups.com
mailto:oopic-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
oopic-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/