Legacy Forum: Preserving Nearly 20 Years of Community History - A Time Capsule of Discussions, Memories, and Shared Experiences.

Request vb sample code for Module RM-G144

Based on DMP's Vortex processor / SoC this board is a full computer capable of running a standard Windows and Linux installation on the backpack of your robot.
4 postsPage 1 of 1
4 postsPage 1 of 1

Request vb sample code for Module RM-G144

Post by eydi » Wed May 30, 2012 7:27 pm

Post by eydi
Wed May 30, 2012 7:27 pm

Request vb sample code for Module RM-G144 ??????

(not usage C++ sample code )
Request vb sample code for Module RM-G144 ??????

(not usage C++ sample code )
eydi
Newbie
Newbie
Posts: 3
Joined: Wed May 30, 2012 7:18 pm

Post by eydi » Fri Jun 01, 2012 5:33 am

Post by eydi
Fri Jun 01, 2012 5:33 am

please help help help
please help help help
eydi
Newbie
Newbie
Posts: 3
Joined: Wed May 30, 2012 7:18 pm

Re: Request vb sample code for Module RM-G144

Post by acentw » Tue Jun 05, 2012 7:17 am

Post by acentw
Tue Jun 05, 2012 7:17 am

eydi wrote:Request vb sample code for Module RM-G144 ??????

(not usage C++ sample code )


Hi, eydi
I modify the sample code on the RoBoard RM-G144 page
(http://www.roboard.com/G144.html) as following:

It is VB.NET (not Visual Basic 6.0) code
Code: Select all
' To read ADXL345
Imports System.Threading.Thread
Imports RoBoIO_DotNet.RoBoIO ' import the RoBoIO .Net Warper

Module ADXL345

    Sub wait_ms(ByVal t As Integer)
        Sleep(t)
    End Sub

    Sub Main()
        Dim i2c_address As Byte
        Dim buf(10) As Byte
        Dim X_data As Integer
        Dim Y_data As Integer
        Dim Z_data As Integer

        i2c_address = &H53
        ' first set the correct RoBoard version
        roboio_SetRBVer(RB_100)
        'roboio_SetRBVer(RB_110)  ' if your RoBoard is RB-110
        'roboio_SetRBVer(RB_050)  ' if your RoBoard is RB-050
        'roboio_SetRBVer(RB_100RD)' if your RoBoard is RB-100RD

        If (i2c_Init(I2CMODE_AUTO, 400000) = False) Then ' init I2C lib to 400Kbps
            Console.WriteLine("ERROR: fail to init I2C lib (" & roboio_GetErrMsg() & ")!")
            GoTo I2C_END
        End If

        'Setting ADXL345
        buf(0) = &H2D 'Pwoer_Control register
        buf(1) = &H28 'link and measure mode
        i2c_Send(i2c_address, buf, 2)

        wait_ms(100)

        buf(0) = &H31 'Data_Format register
        buf(1) = &H8 'Full_Resolution
        i2c_Send(i2c_address, buf, 2)

        wait_ms(100)

        buf(0) = &H38 'FIFO_Control register
        buf(1) = &H0 'bypass mode
        i2c_Send(i2c_address, buf, 2)

        wait_ms(100)

        'Send "READ" Command
        i2c_SensorRead(i2c_address, &H32, buf, 6)

        'buf(0) = X LSB
        'buf(1) = X MSB
        'buf(2) = Y LSB
        'buf(3) = Y MSB
        'buf(4) = Z LSB
        'buf(5) = Z MSB
        If ((buf(1) / 128) > 0) Then
            X_data = &HFFFF0000 + buf(1) * 256 + buf(0)
        Else
            X_data = buf(1) * 256 + buf(0)
        End If

        If ((buf(3) / 128) > 0) Then
            Y_data = &HFFFF0000 + buf(3) * 256 + buf(2)
        Else
            Y_data = buf(3) * 256 + buf(2)
        End If

        If ((buf(5) / 128) > 0) Then
            Z_data = &HFFFF0000 + buf(5) * 256 + buf(4)
        Else
            Z_data = buf(5) * 256 + buf(4)
        End If

        Console.WriteLine("Acc of X-axis : " & X_data)
        Console.WriteLine("Acc of Y-axis : " & Y_data)
        Console.WriteLine("Acc of Z-axis : " & Z_data)

        i2c_Close()  'close I2C lib

I2C_END:
    End Sub

End Module
eydi wrote:Request vb sample code for Module RM-G144 ??????

(not usage C++ sample code )


Hi, eydi
I modify the sample code on the RoBoard RM-G144 page
(http://www.roboard.com/G144.html) as following:

It is VB.NET (not Visual Basic 6.0) code
Code: Select all
' To read ADXL345
Imports System.Threading.Thread
Imports RoBoIO_DotNet.RoBoIO ' import the RoBoIO .Net Warper

Module ADXL345

    Sub wait_ms(ByVal t As Integer)
        Sleep(t)
    End Sub

    Sub Main()
        Dim i2c_address As Byte
        Dim buf(10) As Byte
        Dim X_data As Integer
        Dim Y_data As Integer
        Dim Z_data As Integer

        i2c_address = &H53
        ' first set the correct RoBoard version
        roboio_SetRBVer(RB_100)
        'roboio_SetRBVer(RB_110)  ' if your RoBoard is RB-110
        'roboio_SetRBVer(RB_050)  ' if your RoBoard is RB-050
        'roboio_SetRBVer(RB_100RD)' if your RoBoard is RB-100RD

        If (i2c_Init(I2CMODE_AUTO, 400000) = False) Then ' init I2C lib to 400Kbps
            Console.WriteLine("ERROR: fail to init I2C lib (" & roboio_GetErrMsg() & ")!")
            GoTo I2C_END
        End If

        'Setting ADXL345
        buf(0) = &H2D 'Pwoer_Control register
        buf(1) = &H28 'link and measure mode
        i2c_Send(i2c_address, buf, 2)

        wait_ms(100)

        buf(0) = &H31 'Data_Format register
        buf(1) = &H8 'Full_Resolution
        i2c_Send(i2c_address, buf, 2)

        wait_ms(100)

        buf(0) = &H38 'FIFO_Control register
        buf(1) = &H0 'bypass mode
        i2c_Send(i2c_address, buf, 2)

        wait_ms(100)

        'Send "READ" Command
        i2c_SensorRead(i2c_address, &H32, buf, 6)

        'buf(0) = X LSB
        'buf(1) = X MSB
        'buf(2) = Y LSB
        'buf(3) = Y MSB
        'buf(4) = Z LSB
        'buf(5) = Z MSB
        If ((buf(1) / 128) > 0) Then
            X_data = &HFFFF0000 + buf(1) * 256 + buf(0)
        Else
            X_data = buf(1) * 256 + buf(0)
        End If

        If ((buf(3) / 128) > 0) Then
            Y_data = &HFFFF0000 + buf(3) * 256 + buf(2)
        Else
            Y_data = buf(3) * 256 + buf(2)
        End If

        If ((buf(5) / 128) > 0) Then
            Z_data = &HFFFF0000 + buf(5) * 256 + buf(4)
        Else
            Z_data = buf(5) * 256 + buf(4)
        End If

        Console.WriteLine("Acc of X-axis : " & X_data)
        Console.WriteLine("Acc of Y-axis : " & Y_data)
        Console.WriteLine("Acc of Z-axis : " & Z_data)

        i2c_Close()  'close I2C lib

I2C_END:
    End Sub

End Module
acentw
Newbie
Newbie
Posts: 5
Joined: Wed Sep 08, 2010 10:08 am

Re: Request vb sample code for Module RM-G144

Post by acentw » Tue Jun 05, 2012 7:19 am

Post by acentw
Tue Jun 05, 2012 7:19 am

Code: Select all
' To read HMC5843
Imports System.Threading.Thread
Imports RoBoIO_DotNet.RoBoIO ' import the RoBoIO .Net Warper

Module HMC5843

    Sub wait_ms(ByVal t As Integer)
        Sleep(t)
    End Sub

    Sub Main()
        Dim i2c_address As Byte
        Dim buf(10) As Byte
        Dim X_data As Integer
        Dim Y_data As Integer
        Dim Z_data As Integer

        i2c_address = &H1E
        ' first set the correct RoBoard version
        roboio_SetRBVer(RB_100)
        'roboio_SetRBVer(RB_110)  ' if your RoBoard is RB-110
        'roboio_SetRBVer(RB_050)  ' if your RoBoard is RB-050
        'roboio_SetRBVer(RB_100RD)' if your RoBoard is RB-100RD

        If (i2c_Init(I2CMODE_AUTO, 400000) = False) Then ' init I2C lib to 400Kbps
            Console.WriteLine("ERROR: fail to init I2C lib (" & roboio_GetErrMsg() & ")!")
            GoTo I2C_END
        End If

        'Setting HMC5843
        buf(0) = &H2 'mode register
        buf(1) = &H0 'continue-measureture mode
        i2c_Send(i2c_address, buf, 2)

        wait_ms(100)

        'Send "READ" Command
        i2c_SensorRead(i2c_address, &H3, buf, 6)

        'buf(0) = X MSB
        'buf(1) = X LSB
        'buf(2) = Y MSB
        'buf(3) = Y LSB
        'buf(4) = Z MSB
        'buf(5) = Z LSB
        If ((buf(0) / 128) > 0) Then
            X_data = &HFFFF0000 + buf(0) * 256 + buf(1)
        Else
            X_data = buf(0) * 256 + buf(1)
        End If

        If ((buf(2) / 128) > 0) Then
            Y_data = &HFFFF0000 + buf(2) * 256 + buf(3)
        Else
            Y_data = buf(2) * 256 + buf(3)
        End If

        If ((buf(4) / 128) > 0) Then
            Z_data = &HFFFF0000 + buf(4) * 256 + buf(5)
        Else
            Z_data = buf(4) * 256 + buf(5)
        End If

        Console.WriteLine("X axis : " & X_data)
        Console.WriteLine("Y axis : " & Y_data)
        Console.WriteLine("Z axis : " & Z_data)

        i2c_Close()  'close I2C lib

I2C_END:
    End Sub

End Module
Code: Select all
' To read HMC5843
Imports System.Threading.Thread
Imports RoBoIO_DotNet.RoBoIO ' import the RoBoIO .Net Warper

Module HMC5843

    Sub wait_ms(ByVal t As Integer)
        Sleep(t)
    End Sub

    Sub Main()
        Dim i2c_address As Byte
        Dim buf(10) As Byte
        Dim X_data As Integer
        Dim Y_data As Integer
        Dim Z_data As Integer

        i2c_address = &H1E
        ' first set the correct RoBoard version
        roboio_SetRBVer(RB_100)
        'roboio_SetRBVer(RB_110)  ' if your RoBoard is RB-110
        'roboio_SetRBVer(RB_050)  ' if your RoBoard is RB-050
        'roboio_SetRBVer(RB_100RD)' if your RoBoard is RB-100RD

        If (i2c_Init(I2CMODE_AUTO, 400000) = False) Then ' init I2C lib to 400Kbps
            Console.WriteLine("ERROR: fail to init I2C lib (" & roboio_GetErrMsg() & ")!")
            GoTo I2C_END
        End If

        'Setting HMC5843
        buf(0) = &H2 'mode register
        buf(1) = &H0 'continue-measureture mode
        i2c_Send(i2c_address, buf, 2)

        wait_ms(100)

        'Send "READ" Command
        i2c_SensorRead(i2c_address, &H3, buf, 6)

        'buf(0) = X MSB
        'buf(1) = X LSB
        'buf(2) = Y MSB
        'buf(3) = Y LSB
        'buf(4) = Z MSB
        'buf(5) = Z LSB
        If ((buf(0) / 128) > 0) Then
            X_data = &HFFFF0000 + buf(0) * 256 + buf(1)
        Else
            X_data = buf(0) * 256 + buf(1)
        End If

        If ((buf(2) / 128) > 0) Then
            Y_data = &HFFFF0000 + buf(2) * 256 + buf(3)
        Else
            Y_data = buf(2) * 256 + buf(3)
        End If

        If ((buf(4) / 128) > 0) Then
            Z_data = &HFFFF0000 + buf(4) * 256 + buf(5)
        Else
            Z_data = buf(4) * 256 + buf(5)
        End If

        Console.WriteLine("X axis : " & X_data)
        Console.WriteLine("Y axis : " & Y_data)
        Console.WriteLine("Z axis : " & Z_data)

        i2c_Close()  'close I2C lib

I2C_END:
    End Sub

End Module
acentw
Newbie
Newbie
Posts: 5
Joined: Wed Sep 08, 2010 10:08 am


4 postsPage 1 of 1
4 postsPage 1 of 1