B
B9 Robot Jim
Hi, I am new here and even newer to VB so if this is the wrong place to
post this or i use the wrong terms i apologize, it is not my intention to
offend or insult.
I am using VB 2008 Express edition. I did not write the code below but i was
told that it works but it dont.
I am building an 8 x 8 x 8 led cube and have most of the code i need to make
it work but i can not figure out how to make VB callup(?) a .txt
(template)file to control the cube designs. Below is the code so far (some of
it is in Italian i think) and the file name i want to use is;
RainbowExplosion_8x8x8_bw_bit01 VER1.txt
Public Declare Sub Out Lib "inpout32.dll" Alias "Out32" (ByVal PortAddress
As Integer, ByVal Value As Integer)\par
'--------------------------COSTANT FOR LPT1
ADDRESS--------------------------------\par
Public Const IndirizzoData As String = "&H378" 'DATA REGISTER: 8 bit\par
'-------------------------------------------------------GLOBAL
VARIABLES----------------------------------------------------\par
Public StatoCubo(1 To 8, 1 To 64) As Integer 'variable that contains the
actual state of cube\par
'-------------------------------------------------------------FUNCTIONS--------------------------------------------------------\par
Public Function ScriviCubo(NumeroCicli As Integer) 'function for write into
cube the state stored in StatoCubo matrix\par
Dim ByteLpt As Byte\par
Dim ContaLivelli As Integer\par
Dim ContaLed As Integer\par
Dim ContaCicli As Integer\par
For ContaCicli = 1 To NumeroCicli\par
For ContaLivelli = 1 To 8\par
'set all bit of shift reg. of columns without clocking on shift reg. of
layers and disabling EVER all clear pins (xx 01x _1_)\par
For ContaLed = 64 To 1 Step -1 'For ContaLed = 1 To 64\par
'SHIFT REG. LAYERS:\par
'MSB (D5) = 0 --> clock disables\par
'CENTRAL (D4) = 1 (valore=16)--> clear disabled\par
'LSB (D3) = not important\par
'SHIFT REG. LED:\par
'MSB (D2) = 0 --> clock disabled\par
'CENTRAL (D1) = 1 (valore=2)--> clear disabled\par
'LSB (D0) = StatoCubo(ContaLivelli, ContaLed)\par
ByteLpt = (0 + 16 + 0) + (0 + 2 + StatoCubo(ContaLivelli, ContaLed))\par
Call ClokkaLed(ByteLpt) 'send the value at function that give 1 clock signal
to the shift reg. of columns\par
Next ContaLed\par
'SHIFT REG. LAYERS:\par
'MSB (D5) = 0 --> clock disabled\par
'CENTRAL (D4) = 1 (valore=16)--> clear disabled\par
'LSB (D3) = (if layer = 1--> 1(value=8); if layer <> 1--> 0) --> set 1 only
the fist time\par
'SHIFT REG. LED:\par
'MSB (D2) = 0 --> clock disabled\par
'CENTRAL (D1) = 1 (valore=2)--> clear disabled\par
'LSB (D0) = not important\par
\cf2\fs18 \par
\cf1\fs15 If ContaLivelli = 1 Then 'if I\'19m setting the first layer I send
a 1 at the shift reg. of layers, after I will send only the clock signal\par
ByteLpt = (0 + 16 + 8) + (0 + 2 + 0)\par
Else\par
ByteLpt = (0 + 16 + 0) + (0 + 2 + 0)\par
End If\par
Call ClokkaLivello(ByteLpt) 'send value to the function that give a clock
signal to the shift reg. of layers\par
Call Aspetta(60000) 'calling the function for generate a delay (the cube
stops flashing from 60.000 to 70.000 cycles)\par
Next ContaLivelli 'restart the cycle for setting the next layer\par
Call ClearAll 'call the function for activate clear on all shift register
(switch off all leds)\par
Next ContaCicli\par
End Function\par
Public Function ClokkaLed(Valore As Byte)\par
Out Val(IndirizzoData), Val(Valore) 'clock DISABLED\par
'add 4 because I want to set at 1 the clock bit of shift register of columns
for giving clock signal\par
Out Val(IndirizzoData), Val(Valore + 4) 'clock ENABLED\par
End Function\par
Public Function ClokkaLivello(Valore As Byte)\par
Out Val(IndirizzoData), Val(Valore) 'clock DISABLED\par
'add 32 because I want to set at 1 the clock bit of shift reg. of layers for
giving clock signal\par
Out Val(IndirizzoData), Val(Valore + 32) 'clock ENABLED\par
End Function\par
Public Function ClearAll() 'function for enable the clear pin on all shift
register\par
Dim ByteLpt As Byte\par
'enabling clear on all shift register (value=0) (xx x0x x0x)\par
ByteLpt = 0 '00 000 000\par
Out Val(IndirizzoData), Val(ByteLpt)\par
End Function\par
Public Function Aspetta(Ncicli As Long) 'function used to delay the cycle of
updating the each layers\par
Dim Contatore As Long\par
Dim Contato As Long\par
For Contatore = 0 To Ncicli\par
Contato = Contatore 'assignment operation (only for do a CPU operation)\par
Next Contatore\par
End Function\cf0\fs20\par
}
I hope that helps.
If any one can help i would really appreciate it
Thank you
post this or i use the wrong terms i apologize, it is not my intention to
offend or insult.
I am using VB 2008 Express edition. I did not write the code below but i was
told that it works but it dont.
I am building an 8 x 8 x 8 led cube and have most of the code i need to make
it work but i can not figure out how to make VB callup(?) a .txt
(template)file to control the cube designs. Below is the code so far (some of
it is in Italian i think) and the file name i want to use is;
RainbowExplosion_8x8x8_bw_bit01 VER1.txt
Public Declare Sub Out Lib "inpout32.dll" Alias "Out32" (ByVal PortAddress
As Integer, ByVal Value As Integer)\par
'--------------------------COSTANT FOR LPT1
ADDRESS--------------------------------\par
Public Const IndirizzoData As String = "&H378" 'DATA REGISTER: 8 bit\par
'-------------------------------------------------------GLOBAL
VARIABLES----------------------------------------------------\par
Public StatoCubo(1 To 8, 1 To 64) As Integer 'variable that contains the
actual state of cube\par
'-------------------------------------------------------------FUNCTIONS--------------------------------------------------------\par
Public Function ScriviCubo(NumeroCicli As Integer) 'function for write into
cube the state stored in StatoCubo matrix\par
Dim ByteLpt As Byte\par
Dim ContaLivelli As Integer\par
Dim ContaLed As Integer\par
Dim ContaCicli As Integer\par
For ContaCicli = 1 To NumeroCicli\par
For ContaLivelli = 1 To 8\par
'set all bit of shift reg. of columns without clocking on shift reg. of
layers and disabling EVER all clear pins (xx 01x _1_)\par
For ContaLed = 64 To 1 Step -1 'For ContaLed = 1 To 64\par
'SHIFT REG. LAYERS:\par
'MSB (D5) = 0 --> clock disables\par
'CENTRAL (D4) = 1 (valore=16)--> clear disabled\par
'LSB (D3) = not important\par
'SHIFT REG. LED:\par
'MSB (D2) = 0 --> clock disabled\par
'CENTRAL (D1) = 1 (valore=2)--> clear disabled\par
'LSB (D0) = StatoCubo(ContaLivelli, ContaLed)\par
ByteLpt = (0 + 16 + 0) + (0 + 2 + StatoCubo(ContaLivelli, ContaLed))\par
Call ClokkaLed(ByteLpt) 'send the value at function that give 1 clock signal
to the shift reg. of columns\par
Next ContaLed\par
'SHIFT REG. LAYERS:\par
'MSB (D5) = 0 --> clock disabled\par
'CENTRAL (D4) = 1 (valore=16)--> clear disabled\par
'LSB (D3) = (if layer = 1--> 1(value=8); if layer <> 1--> 0) --> set 1 only
the fist time\par
'SHIFT REG. LED:\par
'MSB (D2) = 0 --> clock disabled\par
'CENTRAL (D1) = 1 (valore=2)--> clear disabled\par
'LSB (D0) = not important\par
\cf2\fs18 \par
\cf1\fs15 If ContaLivelli = 1 Then 'if I\'19m setting the first layer I send
a 1 at the shift reg. of layers, after I will send only the clock signal\par
ByteLpt = (0 + 16 + 8) + (0 + 2 + 0)\par
Else\par
ByteLpt = (0 + 16 + 0) + (0 + 2 + 0)\par
End If\par
Call ClokkaLivello(ByteLpt) 'send value to the function that give a clock
signal to the shift reg. of layers\par
Call Aspetta(60000) 'calling the function for generate a delay (the cube
stops flashing from 60.000 to 70.000 cycles)\par
Next ContaLivelli 'restart the cycle for setting the next layer\par
Call ClearAll 'call the function for activate clear on all shift register
(switch off all leds)\par
Next ContaCicli\par
End Function\par
Public Function ClokkaLed(Valore As Byte)\par
Out Val(IndirizzoData), Val(Valore) 'clock DISABLED\par
'add 4 because I want to set at 1 the clock bit of shift register of columns
for giving clock signal\par
Out Val(IndirizzoData), Val(Valore + 4) 'clock ENABLED\par
End Function\par
Public Function ClokkaLivello(Valore As Byte)\par
Out Val(IndirizzoData), Val(Valore) 'clock DISABLED\par
'add 32 because I want to set at 1 the clock bit of shift reg. of layers for
giving clock signal\par
Out Val(IndirizzoData), Val(Valore + 32) 'clock ENABLED\par
End Function\par
Public Function ClearAll() 'function for enable the clear pin on all shift
register\par
Dim ByteLpt As Byte\par
'enabling clear on all shift register (value=0) (xx x0x x0x)\par
ByteLpt = 0 '00 000 000\par
Out Val(IndirizzoData), Val(ByteLpt)\par
End Function\par
Public Function Aspetta(Ncicli As Long) 'function used to delay the cycle of
updating the each layers\par
Dim Contatore As Long\par
Dim Contato As Long\par
For Contatore = 0 To Ncicli\par
Contato = Contatore 'assignment operation (only for do a CPU operation)\par
Next Contatore\par
End Function\cf0\fs20\par
}
I hope that helps.
If any one can help i would really appreciate it
Thank you