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.

Novice Alex's Content

There have been 39 items by Novice Alex (Search limited from 29-March 23)


By content type

See this member's


Sort by                Order  

#39176 Introducing Netduino Plus 2

Posted by Novice Alex on 12 November 2012 - 03:33 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi Chris, Firstly, I like to congrats on your latest N+2 which I have been waiting for a long long time. Just like to check is there any other reseller other than the 3 listed on your site? So far, looks like only Amazon has stocks, but it "refuse" to do shipping to Singapore. Any chance from other resellers? Regards, Alex Chan



#35929 SD File corrupted

Posted by Novice Alex on 24 September 2012 - 11:29 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi Chris, I remember the SD card corruption happens after around 7 days of "burn test". I have been trying to do "hot swap" for newly design PCB to see any effect on the system reliability. Then it starts to hang the whole N+. After putting in a few debug statement, it came to know that it was hang during the writing to a data text file. I have tried to do file deleting on the SD card on my PC, but it still exists after I do a screen refresh. So, no choice but to reformat it. I suppose it can be caused by the loss of power during the writing (while doing the "hot swap"), but how can we recover from there if such incident happens again, given that this system will be deployed to remote sites out in the sea, so it will be quite trouble to access. From my attached class, is there any potential problem that you can foresee? Thanks in advance. Regards, Novice Alex



#35898 SD File corrupted

Posted by Novice Alex on 24 September 2012 - 02:56 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi Guys,

I have done up a commercial project and now doing the "burn test".
This project suppose to do data logging of the fuel consumption from different flow meters on a 5 mins interval.
However, I found that randomly the log file could be corrupted and it will cause the whole N+ to hang when accessing it.
I have tried to access the SD card using my PC and can see that that particular "problem" file exists but I am not able to access it and I can't delete it from my PC. So the only way is to reformat my SD card and start fresh. This gives me some sense of "uncertainty".

Does anyone know how can we handle such cases to avoid the N+ to hang? By the way, when I say hang, it means not even when I short the reset pin to ground or press the reset can restart N+, the only way is to power it down completely.

Below is my SD card class library.
Imports System.IO
Imports SecretLabs.NETMF.Hardware.Netduino
Imports SecretLabs.NETMF.Hardware
Imports Microsoft.SPOT


Public Class cSDCard
#Region "Enumeration"

#End Region

#Region "Declaration"
    Public Shared Event LastError(ex As Exception)
    Public Shared Event SDEject()
    Private Shared m_bSDEjected As Boolean = True
#End Region

#Region "Property"
    Public Shared Property SD_Ejected() As Boolean
        Get
            Return m_bSDEjected
        End Get
        Set(value As Boolean)
            m_bSDEjected = value
        End Set
    End Property

#End Region

#Region "Method"
    Public Shared Function MountSD() As Boolean
        MountSD = False
        SD_Ejected = True
        Try
            SecretLabs.NETMF.IO.StorageDevice.MountSD("SD", Microsoft.SPOT.Hardware.SPI.SPI_module.SPI2, 21, 57)
            Dim dirinfo As New DirectoryInfo("\SD")
            If (dirinfo.Exists) Then
                MountSD = True
                SD_Ejected = False
            End If
        Catch ex As Exception
            SD_Ejected = True
        End Try
    End Function

    Public Shared Function UnMountSD() As Boolean
        Try
            If SD_Ejected = True Then
                Exit Function
            End If

            SecretLabs.NETMF.IO.StorageDevice.Unmount("SD")
        Catch ex As Exception

        End Try
    End Function

    Public Shared Function ReadFile(sFilename As String, ByRef sContent As String, Optional bReadLastLineOnly As Boolean = False) As Boolean
        ReadFile = False
        Try
            Dim lFileSize As Long = 0
            Dim sTmp As String = ""
            sContent = ""
            If SD_Ejected = True Then
                Exit Function
            End If

            If File.Exists(sFilename) Then
                Dim myFile As New StreamReader(New FileStream(sFilename, FileMode.Open, FileAccess.Read))
                If bReadLastLineOnly = True Then
                    While (1)
                        sTmp = myFile.ReadLine
                        If Not sTmp Is Nothing Then
                            sContent = sTmp
                        Else
                            Exit While
                        End If
                    End While
                Else
                    sContent = myFile.ReadToEnd
                End If
                myFile.Close()
            Else
                Debug.Print(sFilename & " not found!!!")
            End If

            ReadFile = True
        Catch ex As Exception
            RaiseEvent LastError(ex)
        End Try
    End Function

    Public Shared Function WriteFile(sFilename As String, sContent As String, Optional bAppend As Boolean = True) As Boolean

        WriteFile = False
        Try

            If SD_Ejected = True Then
                Exit Function
            End If

            Dim myFile As StreamWriter

            If bAppend = True Then
                myFile = New StreamWriter(New FileStream(sFilename, FileMode.OpenOrCreate, FileAccess.Write))
            Else
                DeleteFile(sFilename)
                myFile = New StreamWriter(New FileStream(sFilename, FileMode.CreateNew, FileAccess.Write))
            End If
            myFile.WriteLine(sContent)
            myFile.Close()

            WriteFile = True
        Catch ex As Exception
            RaiseEvent LastError(ex)
        End Try
    End Function

    Public Shared Function DeleteFile(sFilename As String) As Boolean
        DeleteFile = False
        Try

            If SD_Ejected = True Then
                Exit Function
            End If

            If File.Exists(sFilename) Then
                File.Delete(sFilename)
            End If
            DeleteFile = True
        Catch ex As Exception
            RaiseEvent LastError(ex)
        End Try
    End Function
#End Region
End Class

Thanks in advance.

Regards,
Alex Chan



#35145 How to debug program without using VS?

Posted by Novice Alex on 13 September 2012 - 11:45 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi Chris, I am running in the latest .NETMF 4.2 release recently. But I am running the Netduino firmware on the N+ board as I need the SD card feature but without the Ethernet capability. Currently, the board is power by an external source +12Vdc and also connected the usb cable to my computer for easy deployment when needs arise. May I know where can I change the deployment port to COM1 or COM2? Is there any setting that I need? Regards, Novice Alex



#35124 How to debug program without using VS?

Posted by Novice Alex on 13 September 2012 - 02:08 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi Guys,

I have completed my coding and allow my program runs for a few days. But recently I realise that after around 3 days of running, N+ will hang. Even the external watchdog is not able to reset it. In fact, I even try to ground the RESET pin directly still no good. Lastly I have no choice but to power it off and power it up again to consider as reset. This is no good for any commercial project.

Now I need to know if I can do the debug statements printout like "Debug.writeline" in the "Immediate window" in VS. I thought of using the USB as the comm port and hock up to hyper terminal to receive the debug printout. Is it possible? I don't wish to enable the VS all the day as I am using my laptop for our development.

Please advise.

Regards,
Novice Alex



#34666 Protect or encrypt program Code in N+

Posted by Novice Alex on 04 September 2012 - 11:48 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi Novice Alex,

Let me start with a few tips and let others chime in as well...

Since .NET code is a close approximation to C# source, you may want to look at a program like Dotfuscator which will help keep your code from getting decompiled easily. NETMF HEX files are already one step away from standard MSIL DLLs, but in theory they're still MSIL.

My second recommendation is to add a security key to your deployment file (using MFDeploy) and using an "RTM" version of NETMF firmware to lock out any debuggers This will help make sure your board uses signed firmware.

We use direct flashing and custom boot loaders for commercial projects...but we can search around for some documentation on MFDeploy's signing/encryption methods if needed.

Chris


Hi Chris,

Noted. Just like to know that steps for the MFDeploy, is it that I only need to selected the "encrypted" exe and it will deploy to the correct segment of the N+? So far, I only use MFDeploy for the firmware upgrades procedures.

Also for the security key, how and what are the steps on implementing it?

Sorry for my ignorance and thanks for the advice in advance.

Regards,
Novice Alex



#34643 Protect or encrypt program Code in N+

Posted by Novice Alex on 04 September 2012 - 08:46 AM in Netduino Plus 2 (and Netduino Plus 1)

Hi Chris, Just like to know what are the ways to encrypt our program code in the N+ to prevent others from decrypt it? I have completed a commercial project and would like to protect the program. Please advise. Regards, Novice Alex



#34251 PWM Setup

Posted by Novice Alex on 27 August 2012 - 04:03 AM in Netduino 2 (and Netduino 1)

Hi Guys,

I am trying to setup a PWM to generate constant pulse for my monitoring project.
Below are the codes.

Public WithEvents Supply As InterruptPort
Public PWM_Supply As New SecretLabs.NETMF.Hardware.PWM(Pins.GPIO_PIN_D5)

Supply = New InterruptPort(Pins.GPIO_PIN_D0, False, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeHigh)

Dim period As UInt32 = 1 * 1000 * 1000 '1 seconds
Dim duration As UInt32 = 5 * 100 * 1000 '0.5 seconds
PWM_Supply.SetPulse(period, duration)

After executing the last command "SetPulse", the below exception will be trigger
A first chance exception of type 'System.InvalidOperationException' occurred in Microsoft.SPOT.Hardware.PWM.dll

Can anyone highlight the problem in this declaration?
Thanks in advance.

Regards,
Novice Alex



#34183 Ways to read large (>12Kb) text files from SD card

Posted by Novice Alex on 25 August 2012 - 12:36 AM in Netduino Plus 2 (and Netduino Plus 1)

It all depends on the file format. Since you're writing daily stats? You could do several things:
- Make records an X amount of bytes large
- Create a file format that works with data blocks
- Create an index

I have too little information right now to really be able to help you out.

Hi Stefan,

That's sound like a good idea. Since each records is fit by the format [mins since 00:00 of the day] | [Double value with 3 decimal place]. I can fix string format for both. And use ReadBlock to do it. However, need to do some testing to see whether it improve in processing.

in fact, currently when I read back the full content, I will then pass the full file content (as string) back to the caller for further parsing and then determine the require range (report time start to end) and accumulate the total value in the field (2) - Double.

Regards,
Alex



#34182 Ways to read large (>12Kb) text files from SD card

Posted by Novice Alex on 25 August 2012 - 12:29 AM in Netduino Plus 2 (and Netduino Plus 1)

What are you doing with the file once you have read it?

Regards,
Mark


Hi Mark,

These data files (daily) are records of the engine consumption that sample every 1 mins.
Currently the record format is as follows: [mins since today's 00:00] | [Double variable with 3 decimal places]

Regards,
Alex



#34148 Ways to read large (>12Kb) text files from SD card

Posted by Novice Alex on 24 August 2012 - 02:37 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi Stefan, If I don't do the readtoend method, the process will be very slow and it will cause exception from my interrupt (8 pulse inputs). Do you have any codes on how to do file seek? Maybe, I can use your method, but need to call the read file many times using the seek method to remember where I left off on the previous call.



#34146 Ways to read large (>12Kb) text files from SD card

Posted by Novice Alex on 24 August 2012 - 02:02 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi Guys, Currently I have developed a near to completed application on the N+ using Netduino firmware (to get the extra RAM). But only today, I realise N+ has a problem reading text file (with around 500 records) of size around 12Kb. I need to read back for historical reporting on daily basis. I am using the streamreader.readtoend method, but it will throw SystemOutofMemory. I also tried using the pre-define size buffer(1024) to read block by block, but still meet the same exception. I also tried using the readline method together with stringbuilder library to join each readline returns. But still hit the same exception. Then I finally give up. I have to reduce my sampling interval to ensure the daily file size is around 6K instead, then everything goes well. Just like to check anyone out there has a better idea how to handle large text file data log files? Thanks in advance. Regards, Novice Alex



#34132 Suddenly not able to do debugging (Solved)

Posted by Novice Alex on 24 August 2012 - 05:37 AM in Visual Basic Support

Hi Guys, Just to share my experience that I encounter today. I have been doing real-time debugging when developing my project. But out of a sudden, I am no longer able to kick off any debugging, which means all my break-points are not trigger. after much effort, include erasing the Netduino and reflash the firmware v4.2 also can not solved. Only after I open the project.user file (in my case vmas-mini.vbproj.user) and include the last statement <DebugType>full</DebugType> in the <PropertyGroup> tab. Everything is back to normal. I can now do the debugging as per normal. Regards, Alex



#33928 Netduino Firmware v4.2.0

Posted by Novice Alex on 20 August 2012 - 05:27 AM in Netduino 2 (and Netduino 1)

Hi Guys,

Just to share with you guys on my experience on the upgrading to 4.2.
After flashing my Netduino+ I execute the MFDeploy, it does not show the device when I select USB connection.

Then I realize i did not install the latest .NET Micro Framework v4.2 SDK (QFE2).
You may download from here

After installation, reset your netduino and plug it it, you should see the device in the MFDeploy application and continue your firmware upgrade.

Good luck.

Regards,
Alex



#33606 Announcing: .NET MF 4.2 upgrade for all Netduino hardware

Posted by Novice Alex on 14 August 2012 - 03:16 PM in General Discussion

Chris, Bingo and Thanks for the great news. Can't wait to get my hands on the upgrade. Care to share when will the >2G SD being integrated for 4.2? Any schedule?



#33558 Resources usage

Posted by Novice Alex on 13 August 2012 - 11:52 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi Alex,


They're both valid approaches and consume roughly the same number of MCU cycles. Threads are lightweight so I would go with option #1 purely because it simplifies your code. In effect, you just become a consumer of NewData...and as the way that that data is gathered changes your main code can stay the same.

If there's additional logic to your operation (such as needing to always read flow measurements in a certain order) then #2 becomes a good option.

Chris


Hi Chris,

Well noted.



#33496 Resources usage

Posted by Novice Alex on 12 August 2012 - 11:34 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi Guys, I am in a project to monitor some flow meters at the same time doing some remote monitoring. In my project, I have a class object for flow meters which is controlled and monitored by the main program loop that will send back current flow meters pulse counters on every 5 seconds. The question is which of the following method require more resource from N+? 1. On timer (5 seconds) interrupt in the each of flow meter object, I will raise a NewData event (passing back the current flow meter pulse counter) for my main program to handle them separately. 2. On timer (5 seconds) interrupt in my main program, i will called the public property in each flow meter to get the current flow meter pulse counter. Then handle them accordingly. Generally, just wonder is it better to use raise event method or pull method? Thanks in advance. Regards, Novice Alex



#33408 Detect Eject SD card in VB.net

Posted by Novice Alex on 11 August 2012 - 08:19 AM in Visual Basic Support

That code won't work in VB.NET since it works differently with events. This would work:

Module Module1

    Sub Main()
        AddHandler Microsoft.SPOT.IO.RemovableMedia.Eject, AddressOf RemovableMedia_Eject
        AddHandler Microsoft.SPOT.IO.RemovableMedia.Insert, AddressOf RemovableMedia_Insert
        Thread.Sleep(Timeout.Infinite)
    End Sub

    Sub RemovableMedia_Eject(sender As Object, e As Microsoft.SPOT.IO.MediaEventArgs)
        Debug.Print("Ejected")
    End Sub

    Sub RemovableMedia_Insert(sender As Object, e As Microsoft.SPOT.IO.MediaEventArgs)
        Debug.Print("Inserted")
    End Sub

End Module


Hi Carb & Stefan,

Thank you for your great helps.

Cheers!



#33344 Detect Eject SD card in VB.net

Posted by Novice Alex on 10 August 2012 - 01:30 AM in Visual Basic Support

Hi Guys,

Anyone familiar with VB.net can help with some code on how to detect the SD card been ejected?
I am following this topic, but I can do the same in VB.net. Please help and thanks in advance.

Links on how to detect presence of SD card



#33119 Drilling down to the StackFrame

Posted by Novice Alex on 04 August 2012 - 03:35 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi Bendage, Have you managed to find the solution to your above problem? Care to shared? Thanks in advance.



#33118 Debug info output?

Posted by Novice Alex on 04 August 2012 - 03:34 PM in Beta Firmware and Drivers

Upgraded to 4.2(RTM) and appropriate firmware on my N+.
Everything went fine, but now in my debug sessions I'm missing the RAM/ROM/META messages, which I really liked since I'm doing a lot of reflection, and it's nice to know how big the assemblies are that I'm loading.

Do I need to do anything differently now that I'm on the 4.2 SDK?


Hi H07R0D,

I too looking at using reflection to set the debug statement printout during exception being thrown out. Can you share with me how to use the reflection methods to extract the name of the method (within the class) that is causing the exception?

In VB.NET, I always include these statements in my catch statement.
Dim f As New StackFrame
cErrorHandler.LogError(f.GetMethod().DeclaringType.FullName & "." & System.Reflection.MethodBase.GetCurrentMethod().Name, ex)

Wonder how can I do the same in .NetMF 4.2

Thanks in advance.



#32779 Analog Pins for drive LEDs

Posted by Novice Alex on 27 July 2012 - 10:22 AM in Netduino Plus 2 (and Netduino Plus 1)

Hi Guys, thanks for your sharing. Now I managed to light up my LEDs as per normal by setting the Analog pins as output, but as mentioned by Stefan, the output current is limited, so it may not be too bright. Anyway is a good step.



#32733 Circuit example for 4-20mA measurement

Posted by Novice Alex on 26 July 2012 - 11:44 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi Guys, Separately, do you have any sample circuit to connect to N+ for measuring 4-20mA Analog input? Together with sample code will be great. Currently I am using VB.net to handle the 12V pulse input through opto-coupler circuit. Thanks in advance.



#32679 Analog Pins for drive LEDs

Posted by Novice Alex on 26 July 2012 - 02:54 AM in Netduino Plus 2 (and Netduino Plus 1)

Hi Guys, As I have exhausted all the Digital Pins for all my pulse counter and communication, now only left with the Analog pins untouched. May I know is there any way I can use the Analog pins for driving a LED (for machine status) purpose? also can it be configure to use to detect button press input? Thanks in advance.



#32676 Release COM2 (CTS, RTS)

Posted by Novice Alex on 26 July 2012 - 01:23 AM in Netduino Plus 2 (and Netduino Plus 1)

The general rule-of-thumb with microcontrollers is that pin assignments aren't always restricted to their architectural labelling. For example, a pin maybe labelled as PWM(Pulse Width Modulator) which would normally tie-in with a hardware clock and hardware interrupts. By default, the pin doesn't function as a PWM unless you actually configure it to be.

Much the same with the CTS and RTS pins, you can configure them as OutputPorts or InterruptPorts. If you try to use them for two purposes, you'll get a runtime exception when trying to initialise the pin for a second use. Example of using the RTS pin as a GPIO pin

SerialPort comPort = (SerialPorts.COM2, 9600, Parity.None, 8, StopBits.One); //Initialise COM2
OutputPort oPort = new OutputPort(Pins.GPIO_PIN_D7, false); //initialise the RTS pin as an output port with logic low as initial value;


Hi Nobby,

wonderful... That clears my doubts.
Just for knowledge, how can I configure PIND7 as RTS, do you have the code for it?

Thanks in advance.




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.