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.

liqdfire's Content

There have been 18 items by liqdfire (Search limited from 30-March 23)


By content type

See this member's

Sort by                Order  

#58743 How to 3D print your project a custom case!

Posted by liqdfire on 16 June 2014 - 11:23 PM in General Discussion

I would not buy a printer from XYZ Printing, their printers take proprietary cartridges, that have a DRM chip in them. There have been articles on how to hack them, but I refuse to support a company that takes open source ideas and close source them, not to mention making it restrictive for their customers to use  standard filament. 

 

I personally have a MakerGear M2, bought it as a kit, it is an excellent printer, but not anywhere near the price of the XYZ. If you are looking for something in that price range, take a look at pirate3D bucaneer. The are very promising machines, they have a very successful kickstarter, and just closed pre-orders so they can do fulfillment. The pre-order was right around 500, so in a similar price range.

 

The thing you have to remember about FDM (Fused Deposit Modeling) is that there are a lot of factors that directly effect your print quality. The inexpensive printers tend to take a lot more tweaking to get good print quality. Though, any printer is going to require some amount of tweaking and tuning. 

 

If you really just want something cheap that works decent, there is also printrbot. They are laser cut, so I would not use them anywhere but indoors, especially if you live in a humid climate; the warping can toss your print quality out mid print.




#58701 Frequent writing into SD card caused lost data in reading from serial port

Posted by liqdfire on 13 June 2014 - 02:46 PM in Netduino Plus 2 (and Netduino Plus 1)

I have this problem as well, thought I am using two serial ports, at the same time as the SD card.

 

I have read on the forums, it may be caused by the SD card turning interrupts off on the microcontroller when it is doing writes, and the serial port misses putting the data on the buffer.




#56951 Dependency Injection

Posted by liqdfire on 20 March 2014 - 03:18 AM in Netduino 2 (and Netduino 1)

Agreed, even though I do not use full DI, all of my netduino app still have very string OO in them.




#56949 Multithread Problem 3 blinking LED's

Posted by liqdfire on 20 March 2014 - 03:14 AM in Visual Basic Support

It basically puts thread 1 and 2 into a wait state, and they wake up and execute the next line when the Joined thread exits.

You very well could have continued executing code in thread 1 and 2 after the join.

 

It just so happens that the next line of code in those methods is the exit sub, which signals to the CLR that the threads are finished and it can clean them up.

 

Edit: in this case we could have gotten the exact same results by calling _thread3Wait.WaitOne()

 

 

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?




#56947 Multithread Problem 3 blinking LED's

Posted by liqdfire on 20 March 2014 - 03:07 AM in Visual Basic Support

If you look at the last line in in led1t and led2t they do a .Join on _threadZ

A join causes the existing thread to block until the Joined thread exits. This causes the overhead of the thread exit cleanup by the CLR, etc to be delayed until the timing cycle is complete.

 

http://msdn.microsof...(v=vs.110).aspx

 

You are very welcome, hope you learned a little but about threading in .Net :)




#56945 Multithread Problem 3 blinking LED's

Posted by liqdfire on 20 March 2014 - 03:02 AM in Visual Basic Support

Sure just put a Sleep(Timeout.Infinite), but then you have no way to wake it up.

You could also create another set of wait events, but that does not gain you much over waiting for the other thread to exit.

 

It all depends on what the rest of your logic / program flow needs to look like.

 

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




#56944 Multithread Problem 3 blinking LED's

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

You could do that with a shift register easily, you write a byte to the SPI bus. Each bit of that byte represents the desired state of one of the 8 output pins, it latches them all at the exact time, and you can get very fast timings out of the SPI bus. You would just have to use some bit wise logic and thinking to determine which motor to turn on if you wanted them to step in sync but at different duty cycles.

 

 

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




#56942 Multithread Problem 3 blinking LED's

Posted by liqdfire on 20 March 2014 - 02:59 AM in Visual Basic Support

If you look carefully you see the pauses are directly correlated to when another channel is finished, the CLR has to cleanup the thread and notify the debugger. When you hit reset the debugger is not attached, so the overhead of notifying the debugger that the thread exited and releasing the debugging hooks is not incurred.

 

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 ?




#56940 Multithread Problem 3 blinking LED's

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

See if this is any better, I already put my logic analyzer away. 

Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
Imports SecretLabs.NETMF.Hardware
Imports SecretLabs.NETMF.Hardware.NetduinoPlus

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)

    Private _thread1Wait As AutoResetEvent
    Private _thread2Wait As AutoResetEvent
    Private _thread3Wait As AutoResetEvent

    Private _threadX As Thread
    Private _threadY As Thread
    Private _threadZ As Thread

    Sub Main()

        _thread1Wait = New AutoResetEvent(False)
        _thread2Wait = New AutoResetEvent(False)
        _thread3Wait = New AutoResetEvent(False)

        _threadX = New Thread(AddressOf led1t)
        _threadY = New Thread(AddressOf led2t)
        _threadZ = New Thread(AddressOf led3t)


        _threadX.Start()
        _threadY.Start()
        _threadZ.Start()

        _thread1Wait.Set()
        _thread2Wait.Set()
        _thread3Wait.Set()

        System.Threading.WaitHandle.WaitAll(New System.Threading.AutoResetEvent() {_thread1Wait, _thread2Wait, _thread3Wait})

        led4.Write(True)
        Thread.Sleep(Timeout.Infinite) ' Call this here or your program will exit..
    End Sub

    Sub led1t()
        _thread1Wait.WaitOne()

        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)
        End While

        _thread1Wait.Set()
        _threadZ.Join()
    End Sub

    Sub led2t()
        _thread2Wait.WaitOne()

        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)
        End While

        _thread2Wait.Set()
        _threadZ.Join()
    End Sub

    Sub led3t()
        _thread3Wait.WaitOne()

        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)
        End While

        _thread3Wait.Set()
    End Sub

End Module




#56938 Multithread Problem 3 blinking LED's

Posted by liqdfire on 20 March 2014 - 02:55 AM in Visual Basic Support

I think what you are seeing is the thread exiting, you can even fix that still by having it Join the other threads so they do not exit until all of them are done....

 

You could try putting them in one thread and using one loop. 

 

You could connect the LEDs to a shift register and use SPI to control it (I actually this one on a bigger project I am doing)

https://www.sparkfun.com/products/733




#56936 Multithread Problem 3 blinking LED's

Posted by liqdfire on 20 March 2014 - 02:43 AM in Visual Basic Support

Something else to keep in mind, .NetMF is not a real time OS, there are no exact timing guarantees. Sleep(25) just means that the thread will sleep for no less than 25ms, but it could take a little bit longer depending what the CPU is doing. That and the fact that these devices are single core devices so even though you can create threads only one can actually run at a time, the rest is handled by the thread scheduler.




#56934 Multithread Problem 3 blinking LED's

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

There is quite a bit of overhead required for creating a thread, and starting it so I synchronized the thread start of execution by making the threads wait until all of them were started and in the running state. 

 

Timings with Synchro starts

https://www.dropbox....chro starts.png

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)

    Private _thread1Wait As AutoResetEvent
    Private _thread2Wait As AutoResetEvent
    Private _thread3Wait As AutoResetEvent

    Private _threadX As Thread
    Private _threadY As Thread
    Private _threadZ As Thread

    Sub Main()

        _thread1Wait = New AutoResetEvent(False)
        _thread2Wait = New AutoResetEvent(False)
        _thread3Wait = New AutoResetEvent(False)

        _threadX = New Thread(AddressOf led1t)
        _threadY = New Thread(AddressOf led2t)
        _threadZ = New Thread(AddressOf led3t)


        _threadX.Start()
        _threadY.Start()
        _threadZ.Start()

        _thread1Wait.Set()
        _thread2Wait.Set()
        _thread3Wait.Set()

        System.Threading.WaitHandle.WaitAll(New System.Threading.AutoResetEvent() {_thread1Wait, _thread2Wait, _thread3Wait})

        led4.Write(True)
        Thread.Sleep(Timeout.Infinite) ' Call this here or your program will exit..
    End Sub

    Sub led1t()
        _thread1Wait.WaitOne()

        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)
        End While

        _thread1Wait.Set()
    End Sub

    Sub led2t()
        _thread2Wait.WaitOne()

        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)
        End While

        _thread2Wait.Set()
    End Sub

    Sub led3t()
        _thread3Wait.WaitOne()

        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)
        End While

        _thread3Wait.Set()
    End Sub

End Module




#56933 Multithread Problem 3 blinking LED's

Posted by liqdfire on 20 March 2014 - 01:47 AM in Visual Basic Support

ok, I think I misunderstood what you were experiencing, I almost wonder if that is not a difference thread start times right after deploy.

 

Here is a couple of screen shots, from my logic analyzer running the code I posted.

 

right after deploymeny

https://www.dropbox....fter deploy.png

 

after reset button

https://www.dropbox....after reset.png

 

You can see there is a pretty big difference in the output timings on start up after debugging




#56924 Multithread Problem 3 blinking LED's

Posted by liqdfire on 19 March 2014 - 08:38 PM in Visual Basic Support

Ok, you have a few things going on here, mainly your program is exiting as soon as it initializes everything

 

In your sub main you need to add Thread.Sleep(Timeout.Infinite) or the app will exit and I am pretty sure the CLR will dump it.

Also your threads are scoped locally, so even if the CLR does not dump they are falling out of scope, and the GC more than likely will collect them.

 

More of a stylistic, there is no need for the 4th thread, and using a ManualResetEvent for thread synchronization is a much better mechanism than a boolean. also you do not need to check if you reached your max value every loop of the while, the while will auto exit when it has reached its exit condition, so you can put your thread finished notification outside of the loop saving cpu cycles.

 

Here is a quick sample I pulled together for you (cannot run because I am at work, but looks correct)

Imports System.Threading
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)

    Private _thread1Wait As ManualResetEvent
    Private _thread2Wait As ManualResetEvent
    Private _thread3Wait As ManualResetEvent

    Private _threadX As Thread
    Private _threadY As Thread
    Private _threadZ As Thread

    Sub Main()

        _thread1Wait = New ManualResetEvent(False)
        _thread2Wait = New ManualResetEvent(False)
        _thread3Wait = New ManualResetEvent(False)

        _threadX = New Thread(AddressOf led1t)
        _threadY = New Thread(AddressOf led2t)
        _threadZ = New Thread(AddressOf led3t)


        _threadX.Start()
        _threadY.Start()
        _threadZ.Start()

        System.Threading.WaitHandle.WaitAll(New System.Threading.ManualResetEvent() {_thread1Wait, _thread2Wait, _thread3Wait})

        led4.Write(True)
        Thread.Sleep(Timeout.Infinite) ' Call this here or your program will exit..
    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)
        End While
        _thread1Wait.Set()
    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)
        End While
        _thread1Wait.Set()
    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)
        End While

        _thread1Wait.Set()
    End Sub
End Module




#56896 Dependency Injection

Posted by liqdfire on 18 March 2014 - 11:33 PM in Netduino 2 (and Netduino 1)

No I completely understand, one case where I could see DI being helpful is if you wrote stubs for devices for use in the simulator instead of debugging on the real hardware. Really rolling a very simple service locator type of DIish is not that hard in that case.

 

You are right, I feel very comfortable in the dev environment but every once in a while I will have to stop and rethink an approach to a task based on supported framework pieces.




#56849 Dependency Injection

Posted by liqdfire on 16 March 2014 - 05:11 PM in Netduino 2 (and Netduino 1)

I am not aware of any DI frameworks for NETMF. You may be able to compile an older version of Ninject for the NETMF. Though you may want to re-evaluate your app architecture. While the benefits of using DI on a desktop / web app are widely known, writing code for am embedded device does, and in my opinion should, take a drastically different approach. 

 

These devices are severely resource limited as compared to a desktop / web app. The entirety of your available code space is only 384k on a N+2, the Ninject 4.5 release is 125k by itself. That is a significant amount of code space loss just for a DI framework; additionally, the additional memory requirements for loading and housing the DI framework also needs to be taken into account.

 

If you still feel the need for DI is there, then your best bet would be to roll your own lightweight DI framework, just keep in mind there is no generic support. 

 

As far as config files go, the easiest way it to put an SD card in it, and serialize / deserialize your own format and structure. 




#56404 Netduino Plus 2 Firmware v4.3.1

Posted by liqdfire on 25 February 2014 - 07:42 PM in Netduino Plus 2 (and Netduino Plus 1)

My upgrade with without a hitch, and all code appears to be working well.

 

Debugging is definitely improved a lot, especially stepping through code. Getting variable values is still a little slow, but I suspect that has to do with the MF driver over the WINUSB, at least VS is not disconnecting.




#52249 SD Card strange behavior

Posted by liqdfire on 21 August 2013 - 12:47 AM in Netduino Plus 2 (and Netduino Plus 1)

What size is it?

Is it form matted FAT32?





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.