Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

twinnaz's Content

There have been 26 items by twinnaz (Search limited from 29-March 23)


By content type

See this member's


Sort by                Order  

#60985 Write Port frequency

Posted by twinnaz on 16 December 2014 - 01:42 AM in Netduino Plus 2 (and Netduino Plus 1)

netpulse.jpg




#60812 Playing with neopixels

Posted by twinnaz on 28 November 2014 - 09:25 PM in Project Showcase

Here's the class I made. After reading a lot about these Neopixels I decided to get a Neopixel stick. Thanks to Jcoders post and a lot of others I was able to write one myself. Im by far not a programmer just a hobby so code might not be the most efficient or professional but I tried.

Imports System
Imports Microsoft.SPOT
Imports System.Text

Public Class Pixel


    ' Gets the string reprsentation on an 24bit rgb color. For 1 Neopixel led Red = 8 bit Green = 8 Bit Blue = 8 bit 

    Function color(ByVal green As Integer, ByVal red As Integer, ByVal blue As Integer) As String
        Dim R As String = Convert2Bin(red)
        Dim G As String = Convert2Bin(green)
        Dim B As String = Convert2Bin(blue)
        red = CInt(R)
        green = CInt(G)
        blue = CInt(B)
        Dim binaryred = (red.ToString("D8"))
        Dim binarygreen = (green.ToString("D8"))
        Dim binaryblue = (blue.ToString("D8"))
        ' Return a 24 bit string in the GBR order needed for the neopixel
        Dim Led24bitcolor = binarygreen & binaryred & binaryblue
        Return Led24bitcolor
    End Function

    ' Same as above but used for more that 1 pixel ''' Obsolete uses alot of memory can crash when led count > 60 '''
    ' Use SendAllLedData(color,x)  instead of Color(string,x). In theroy can handle 400+ led YMMV (Ps** Will "light up 3000 leds" :):D no effects and stuff like that though :( try to keep it lower)

    Function color(ByVal green As Integer, ByVal red As Integer, ByVal blue As Integer, ByVal leds As Integer) As String
        Dim R As String = Convert2Bin(red)
        Dim G As String = Convert2Bin(green)
        Dim B As String = Convert2Bin(blue)
        red = CInt(R)
        green = CInt(G)
        blue = CInt(B)
        Dim binaryred = (red.ToString("D8"))
        Dim binarygreen = (green.ToString("D8"))
        Dim binaryblue = (blue.ToString("D8"))
        Dim Led24bitcolor = binarygreen & binaryred & binaryblue

        'Repeats the string by any given amount 

        Dim allLed24bitcolor As String = New StringBuilder().Insert(0, Led24bitcolor, leds).ToString
        Return allLed24bitcolor
    End Function


    ' Converts integer number representing a byte (0-255) to string in a binary format (00000000 to 11111111)
 
    Function Convert2Bin(ByVal LedValue As Integer) As String
        Dim sb As New System.Text.StringBuilder
        While LedValue <> 0
            sb.Insert(0, (LedValue Mod 2).ToString, 1)
            LedValue \= 2
        End While
        Return sb.ToString()
    End Function



    'Phases the string to a byte array. Neopixels require a centain timing logic for data. Using SPI the netduino is able to meet the demand. 

    Shared Function SendAllLedData(ByVal color As String, ByVal LedCount As Integer) As Byte()

        'Setting up the byte array and splitting the sting in a string array so that each element can be phases into required logic 1 or 0 

        Dim x As Integer = 0
        Dim bitcolor As String() = New String(color.Length - 1) {}
        Dim b2sa As Byte() = New Byte(bitcolor.Length - 1) {}
        Dim LedsData() As Byte = Nothing
        Dim y, z As Integer

        For i As Integer = 0 To color.Length - 1
            bitcolor(i) = color(i).ToString()
        Next

        ' Phases each element in the string array and replaces 0 with 128 and 1 with 252 then dumps each elemnet into a byte array in the same order it came in 

        For i As Integer = 0 To bitcolor.Length - 1
            Dim data As String = bitcolor(i)
            Select Case data
                Case "0"
                    bitcolor(i) = "128"
                Case "1"
                    bitcolor(i) = "252"
            End Select
        Next

        For i As Integer = 0 To bitcolor.Length - 1
            b2sa(i) = Byte.Parse(bitcolor(i))
        Next

        ' Used if controlling more than 1 pixel 

        y = (24 * LedCount) - 1
        z = 0
        ReDim LedsData(y)

        While z <= y
            Array.Copy(b2sa, 0, LedsData, z, 24)
            z += 24
        End While

        Return LedsData


    End Function
End Class

Here is how to use it 

Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
Imports SecretLabs.NETMF.Hardware
Imports SecretLabs.NETMF.Hardware.Netduino
Imports NetduinoApplication10.Pixel




Module Module1
    Sub Main()

        Dim NeopixelConfig As SPI.Configuration
        Dim NeopixelSpi As SPI

        NeopixelConfig = New SPI.Configuration(Pins.GPIO_PIN_D10, False, 0, 0, False, True, 6666, SPI.SPI_module.SPI1)
        NeopixelSpi = New SPI(NeopixelConfig)

        ' Neopixels require a reset time of 9us to 40 us inbetween new data packets this just send 0 bytes lasting about 16 us. Still have to integrate into a funtion

        Dim Reset As Byte() = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
        Dim Pixel As New Pixel
        ' Seting us the colot data 
        Dim White = Pixel.color(255, 255, 255)

        ' Preping the color data to be sent as one big array. Note - Using loops during spi.wirte causes a delay breaking the timing needed for the neopixels
        ' 8 is for the amount of leds I will be using (Neopixel stick) 

        Dim data = SendAllLedData(White, 8)

        'Send all data 

        NeopixelSpi.Write(data)
        NeopixelSpi.Write(Reset)

    End Sub

End Module

Still writing a bit of functions such as (shifting led colors, animation, and fading) for it will be added soon

If you have any algorithms or functions you'd like to share psot or pm 




#60793 Playing with neopixels

Posted by twinnaz on 24 November 2014 - 11:40 PM in Project Showcase

Playing around with a Neopixel library I wrote 

 

Fading 

https://onedrive.liv...E84D56B35!15115

 

Pulse fade

https://onedrive.liv...E84D56B35!15118

 

Will post code when I add a couple more functions 




#59724 Netduino and Xsockets.net Led blink example

Posted by twinnaz on 14 August 2014 - 10:32 PM in General Discussion

anybody wants to try out the code and check if its working I can't seem to get it working on my computer




#59695 Netduino and Xsockets.net Led blink example

Posted by twinnaz on 13 August 2014 - 02:45 AM in General Discussion

Just sharing an example of Xsockets.net running on Netduino Plus 2 , browser and console application with full duplex communication.

 

Controls the on-board LED from the browser also by pressing the on-board button, the netduino will send the chat message to the browser and the Console client application.

 

All files can be found here : https://github.com/X...ockets.Netduino

Lets see what we can create with the new Xsockets.Net 4.0 framework :)




#58952 C# implementation of the GoBus transport layer ??

Posted by twinnaz on 30 June 2014 - 02:45 AM in General Discussion

I was just wondering if this was still in the works for the Neutrino Plus line of boards.

 

We'll also be sharing a fully-C# implementation of the GoBus transport layer which can be used on regular Netduinos.

 

 




#56998 Netduino CNC

Posted by twinnaz on 22 March 2014 - 03:47 PM in Project Showcase

There was an unreachable code socket.Close() in lineserver.cs

I just changed it and everything's working now  

            commSocket.Close();
                        }
                        socket.Close();

                        Debug.Print("Netduino server stopped");
                    }
                }



#56985 Netduino CNC

Posted by twinnaz on 22 March 2014 - 03:23 AM in Project Showcase

The program seems to timeout every time after connecting cant seem to find the problem




#56950 Multithread Problem 3 blinking LED's

Posted by twinnaz on 20 March 2014 - 03:17 AM in Visual Basic Support

Thanks once again



#56948 Multithread Problem 3 blinking LED's

Posted by twinnaz on 20 March 2014 - 03:11 AM in Visual Basic Support

So in short it just tells thread1 and 2 to hop into the other timing cycle until Thread z is done then the CLR kicks in?




#56946 Multithread Problem 3 blinking LED's

Posted by twinnaz on 20 March 2014 - 03:05 AM in Visual Basic Support

Your last code worked perfectly !! :) What did you change?
nevermind i see you used thread join.
Thanks very much for your help really appreciate it.




#56943 Multithread Problem 3 blinking LED's

Posted by twinnaz on 20 March 2014 - 03:01 AM in Visual Basic Support

Is it possible to just pause the thread when count is reached instead of exiting ?




#56941 Multithread Problem 3 blinking LED's

Posted by twinnaz on 20 March 2014 - 02:58 AM in Visual Basic Support

I was thinking about controlling 3 steppers motors and having them receive the same step pulses in sync. 




#56939 Multithread Problem 3 blinking LED's

Posted by twinnaz on 20 March 2014 - 02:56 AM in Visual Basic Support

I just took a look at you pic. After observing I can see in the middle section on channel 0 and channel 2 that it goes out of sync Ch0 starts high and ch 2 starts low causing the ping pong light effect. I'm guessing the timing is causing this ?




#56937 Multithread Problem 3 blinking LED's

Posted by twinnaz on 20 March 2014 - 02:50 AM in Visual Basic Support

Alright tested your new code it deploys and runs as expected (blinks 3 LEDS at the same time) but after led2 reaches count it goes out of sync again. :( I read up about the timing on .netmf I was just testing some multi threading for fun, but I guess I can scrap the code now since I cant get it working. Thanks for your effort !

What would be an alternate way of flashing 3 leds in sync if I may ask. Is there another route?




#56935 Multithread Problem 3 blinking LED's

Posted by twinnaz on 20 March 2014 - 02:38 AM in Visual Basic Support

Just expecting for all leds blink at the same time after deploying without resetting the netduino.In the first half of the video you can see that the leds aren't flashing at the same time, (whice is the part I don't want).

In the second half of the video I press the reset button and then you can see all the leds flashing in sync that's what I want right from the get go not needing to reset the netduino



#56928 Multithread Problem 3 blinking LED's

Posted by twinnaz on 19 March 2014 - 10:45 PM in Visual Basic Support

thanks for making some corrections but unfortunately your code does the same thing as mines. I uploaded a video showing what it does right at deploy and then after a reset (what i want it to do ).

 

http://1drv.ms/1hJJew6




#56921 Multithread Problem 3 blinking LED's

Posted by twinnaz on 19 March 2014 - 07:55 PM in Visual Basic Support

I have this code that blinks 3 LED's at the same time and also counts a value in each thread.

The problem is when I deploy the project and everything starts running the LED's are out of sync and i get pauses whenever a value is reached until I push the reset button on the Netduino then everything runs as expected, but then I lose the ability to monitor the values in the debugger. Am I missing something or is this a glitch in .NETMF

Code Below 

Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
Imports SecretLabs.NETMF.Hardware
Imports SecretLabs.NETMF.Hardware.Netduino

Module Module1

    Dim led1 As New OutputPort(Pins.GPIO_PIN_D0, False)
    Dim led2 As New OutputPort(Pins.GPIO_PIN_D1, False)
    Dim led3 As New OutputPort(Pins.GPIO_PIN_D2, False)
    Dim led4 As New OutputPort(Pins.GPIO_PIN_D3, False)
    Public led1done As Boolean = False
    Public led2done As Boolean = False
    Public led3done As Boolean = False
    Sub Main()

        Dim x As New Thread(AddressOf led1t)
        Dim y As New Thread(AddressOf led2t)
        Dim z As New Thread(AddressOf led3t)
        Dim Done As New Thread(AddressOf DBit)

        x.Start()
        y.Start()
        z.Start()
        Done.Start()

    End Sub
    Sub led1t()

        Dim x As Integer = 0

        While x < 30
            x += 1
            led1.Write(True)
            Thread.Sleep(25)
            led1.Write(False)
            Thread.Sleep(25)
            Debug.Print("Led1 Blink Count = " & x.ToString)
            If x = 30 Then led1done = True
        End While
    End Sub
    Sub led2t()

        Dim y As Integer = 0

        While y < 15
            y += 1
            led2.Write(True)
            Thread.Sleep(25)
            led2.Write(False)
            Thread.Sleep(25)
            Debug.Print("Led2 Blink Count = " & y.ToString)
            If y = 15 Then led2done = True
        End While
    End Sub
    Sub led3t()

        Dim z As Integer = 0

        While z < 55
            z += 1
            led3.Write(True)
            Thread.Sleep(25)
            led3.Write(False)
            Thread.Sleep(25)
            Debug.Print("Led3 Blink Count = " & z.ToString)
            If z = 55 Then led3done = True
        End While
    End Sub
    Sub DBit()
        While True
            If led1done And led2done And led3done = True Then
                led4.Write(True)
                Thread.Sleep(Timeout.Infinite)


            End If
        End While
    End Sub
End Module




#56660 Netduino CNC

Posted by twinnaz on 05 March 2014 - 10:59 PM in Project Showcase

Alright found that one last question which project do we deploy to the Netduino. I see two solutions NetduinoDevice2  and gcodephaser-Netduino

but when deploying either one of these it deploys quite fast and doesn't go through the regular steps (**As in lights on the Netduino lights up, debugger assembles everything, and then says ready)  




#56653 Netduino CNC

Posted by twinnaz on 05 March 2014 - 05:35 PM in Project Showcase

Just tested On my Netduino Plus 2 running .Netmf 4.3 after adding the references and deploying im getting an exception when trying to connect.

xun9.jpg




#56651 Netduino CNC

Posted by twinnaz on 05 March 2014 - 04:42 PM in Project Showcase

Nice im going to have to test this out and scrap my code I was writing, haha. Thanks




#55852 N+2 ethernet communication with Windows Form

Posted by twinnaz on 04 February 2014 - 01:21 PM in Netduino Plus 2 (and Netduino Plus 1)

You can check my code out its not entirely working but you can send a message or value over using sockets. I still have to get it to continuously loop sending messages back and fourth. http://forums.netdui...h-windows-form/




#55840 SocketServer No response

Posted by twinnaz on 03 February 2014 - 08:22 PM in Netduino Plus 2 (and Netduino Plus 1)

Anybody??



#55821 SocketServer No response

Posted by twinnaz on 03 February 2014 - 01:29 AM in Netduino Plus 2 (and Netduino Plus 1)

So I have got it to work but it only does it once then throws exception target machine is actively refusing it .I guess now I need to set up  a loop to continuously send and listen between both programs , but how would I get that done. Kind of a newb exploring waters for something bigger :)

Netduino App  

Imports System.NetImports System.Net.SocketsImports Microsoft.SPOTImports Microsoft.SPOT.HardwareImports SecretLabs.NETMF.HardwareImports SecretLabs.NETMF.Hardware.NetduinoImports System.TextModule Module1    Dim rawData As String = Nothing    Dim cdat As String = "done"    Dim dataco As Byte() = Encoding.UTF8.GetBytes(cdat)    Sub Main()        Try            Using socket As System.Net.Sockets.Socket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)                socket.Bind(New IPEndPoint(IPAddress.Any, 8080))                socket.Listen(10)                Using commSocket As Socket = socket.Accept()                    If commSocket.Poll(-1, SelectMode.SelectRead) Then                        Dim bytes As Byte() = New Byte(commSocket.Available - 1) {}                        Dim count As Integer = commSocket.Receive(bytes)                        rawData = (New String(Encoding.UTF8.GetChars(bytes)))                    End If                End Using            End Using            Debug.Print(rawData)        Catch ex As SocketException            Debug.Print(ex.ToString)        End Try        Try            Using socket2 As System.Net.Sockets.Socket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)                Dim ipSelect As String = "192.168.1.231"                Dim portSelect As Integer = 8080                Dim remoteIPAddress As System.Net.IPAddress = System.Net.IPAddress.Parse(ipSelect)                Dim remoteEndPoint As New System.Net.IPEndPoint(remoteIPAddress, portSelect)                socket2.Connect(remoteEndPoint)                socket2.Send(dataco)                socket2.Close()            End Using        Catch e As SocketException            Debug.Print(e.Message)        End Try        Thread.Sleep(Timeout.Infinite)    End SubEnd Module

Windows Form App 

Imports System.Collections.GenericImports System.ComponentModelImports System.DataImports System.DrawingImports System.LinqImports System.TextImports System.Windows.FormsImports System.Net.SocketsImports System.NetPublic Class Form1    Private Sub sendbtn_Click(sender As Object, e As EventArgs) Handles sendbtn.Click        Dim cdat As String = Nothing        cdat = value1.Text        Dim Client As Socket        Dim data As Byte() = Encoding.ASCII.GetBytes(cdat)        Dim data2 As String = Nothing        Try            Client = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)            Dim ipSelect As String = ipadd.Text            Dim portSelect As Integer = Convert.ToInt16(port.Text)            Dim remoteIPAddress As System.Net.IPAddress = System.Net.IPAddress.Parse(ipSelect)            Dim remoteEndPoint As New System.Net.IPEndPoint(remoteIPAddress, portSelect)            Client.Connect(remoteEndPoint)            Client.Send(data)        Catch [error] As SocketException            MessageBox.Show([error].Message)        End Try        Try            Using Client2 = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)                Client2.Bind(New IPEndPoint(IPAddress.Any, 8080))                Client2.Listen(1)                Using commSocket As Socket = Client2.Accept()                    If commSocket.Poll(-1, SelectMode.SelectRead) Then                        Dim bytes2 As Byte() = New Byte(commSocket.Available - 1) {}                        Dim count As Integer = commSocket.Receive(bytes2)                        data2 = (New String(Encoding.UTF8.GetChars(bytes2)))                    End If                    MessageBox.Show(data2)                End Using            End Using        Catch ex As SocketException            MessageBox.Show(ex.SocketErrorCode)        End Try    End SubEnd Class

Attached Files




#55752 Interrupt on output port?

Posted by twinnaz on 31 January 2014 - 03:43 AM in Netduino Plus 2 (and Netduino Plus 1)

Reply I got it working I just put in a led.read to a counter everytime led.read goes high or true you can delete post thanks




home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.