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:
No comments:
Post a Comment