
Originally Posted by
2k1Toaster
The first batch did have the timer off when no USB communication happens. So if it is going off when switching screens that means during that time, no USB communication, so it shuts off perhaps. When you made the plugin, what did you set the timer bits to?
this is the whole function that that handles send/receive. It runs in a .net timer every 2000ms.
Code:
Public Shared Function FB_SendReceive()
'MsgBox("function started")
For i = 0 To 11
OutputArray(i) = Convert.ToByte(0 & KeepAliveBit & DigOut(i))
Next
'MsgBox("Output array made")
FUSB_Send(pFusionUSB, OutputArray)
'MsgBox("data sent to fb")
'Now, get the info from the fusion brain
If (FUSB_Receive(pFusionUSB, InputArray)) Then
'It retured true, meaning it got data. Process it.
For i = 0 To 9
'The data coming in from the analog inputs is 10 bits long, so it has to come in two bytes.
'The first byte contains 8 bits, which are the most significant bits.
'The second byte contains only 2 bits, and they are the least significant bits. Personally, I ignore those two.
'AnalogIn(i) = CInt(InputArray(i * 2 + 12)) 'Uses only the first byte 0-255 (8 bits)
'Range of 0-255, so divide by 255 to get a percent, then multiply by 5 to get volts.
'AnalogIn(i) = (totalin / 255) * 5
AnalogIn(i) = (CInt(InputArray(i * 2 + 12)) * 4) + CInt(InputArray(i * 2 + 13) / 64) 'Uses both bytes 0-1023 (10 bits)
'Range of 0-1023, so divide by 1023 to get a percent, then multiply by 5 if you want to get volts.
'AnalogIn(i) = (totalin / 1023) * 5
Next
End If
'Toggle the keepalive bit for nexttime.
If KeepAliveBit = 0 Then
KeepAliveBit = 1
Else
KeepAliveBit = 0
End If
'MsgBox("done")
End Function
i could set it at a higher interval but i didnt think it was needed because RR only updates the data once per second.
Bookmarks