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.

Bainesbunch's Content

There have been 54 items by Bainesbunch (Search limited from 29-May 23)


By content type

See this member's


Sort by                Order  

#25175 3 RGB leds with netduino?

Posted by Bainesbunch on 06 March 2012 - 10:49 PM in General Discussion

Hi You can always use 3 other IO lines to connect to the common cathodes of the RGB LEDS pulling them to gound one at a time and multiplex the PWM outputs. You would only ever achive a miaxmum of 30% duty cycle on any LED but that may do you. Cheers Pete.



#22843 4.2 VB.net String to double conversion

Posted by Bainesbunch on 16 January 2012 - 08:11 PM in Netduino Plus 2 (and Netduino Plus 1)

Actualy the plot thickens. This code works on the emulator but NOT on the device .. what is going on here ????



Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
Imports SecretLabs.NETMF.Hardware
Imports SecretLabs.NETMF.Hardware.NetduinoPlus
Module Module1
    Sub Main()
        Dim ErectParkDecerlationPoint As Double = CDbl("10.000")
        Debug.Print("ErectParkDecerlationPoint = " & ErectParkDecerlationPoint.ToString) '--> ErectParkDecerlationPoint = 10
        Dim a As Double = CDbl("12345.6789")
        Debug.Print("a = " & a.ToString) 'a = 12345.678900000001
        Dim b As Double = CDbl("166511.001e9")
        Debug.Print("b = " & b.ToString) 'b = 166511.00099999999
    End Sub
End Module



#22841 4.2 VB.net String to double conversion

Posted by Bainesbunch on 16 January 2012 - 07:51 PM in Netduino Plus 2 (and Netduino Plus 1)

CDbl works for me in MF 4.2 RC1

Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
Imports SecretLabs.NETMF.Hardware
Imports SecretLabs.NETMF.Hardware.NetduinoPlus
Module Module1
    Sub Main()
        Dim ErectParkDecerlationPoint As Double = CDbl("10.000")
        Debug.Print("ErectParkDecerlationPoint = " & ErectParkDecerlationPoint.ToString) '--> ErectParkDecerlationPoint = 10
        Dim a As Double = CDbl("12345.6789")
        Debug.Print("a = " & a.ToString) 'a = 12345.678900000001
        Dim b As Double = CDbl("166511.001e9")
        Debug.Print("b = " & b.ToString) 'b = 166511.00099999999
    End Sub
End Module
I have not experienced many of the problems reported for RC3 using RC1. It might be worthwhile to revert back until these problems are solved.

Baxter


OK so where do I get 4.2 RC1 from for the plus for me to try this out please

A link would be good if you have one.

Cheers Pete



#22832 4.2 VB.net String to double conversion

Posted by Bainesbunch on 16 January 2012 - 03:12 PM in Netduino Plus 2 (and Netduino Plus 1)

Hello Folks,

I am having some issues converting a string into a double using the CDbl(...) method. It is throwing a System.NotImplementedException.

How do we convert a string into a double without this method ?

I have a configuration file stored on the SD card where i save and retrieve values in an eye readable format so that the user can "edit" them in notepad etc. I.E. 100,10.000,2.5,6 these need to be read back into the application and converted into either bytes integers doubles etc. any help gratefully received.

the offending code looks like this


dim ErectParkDecerlationPoint as double = CDbl("10.000")


Here is the output trace for the call.



Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.IsHexOrOctValue'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.IsHexOrOctValue'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.IsHexOrOctValue'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.GetCultureInfo'
Step into: Stepping over non-user code 'System.Globalization.CultureInfo.CurrentUICulture.get'
Step into: Stepping over non-user code 'System.Globalization.CultureInfo.CurrentUICulture.get'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.GetCultureInfo'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble'
Step into: Stepping over non-user code 'System.Globalization.CultureInfo.NumberFormat.get'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.GetNormalizedNumberFormat'
Step into: Stepping over non-user code 'System.Globalization.NumberFormatInfo.NumberDecimalSeparator.get'
Step into: Stepping over non-user code 'System.Globalization.CultureInfo.EnsureStringResource'
Step into: Stepping over non-user code 'System.Globalization.NumberFormatInfo.NumberDecimalSeparator.get'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.GetNormalizedNumberFormat'
Step into: Stepping over non-user code 'System.Globalization.NumberFormatInfo.NumberGroupSeparator.get'
Step into: Stepping over non-user code 'System.Globalization.CultureInfo.EnsureStringResource'
Step into: Stepping over non-user code 'System.Resources.ResourceManager.GetObjectFromId'
Step into: Stepping over non-user code 'System.Resources.ResourceManager.GetObjectFromId'
Step into: Stepping over non-user code 'System.Globalization.CultureInfo.EnsureStringResource'
Step into: Stepping over non-user code 'System.Globalization.NumberFormatInfo.NumberGroupSeparator.get'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.GetNormalizedNumberFormat'
Step into: Stepping over non-user code 'System.Globalization.NumberFormatInfo.NumberDecimalSeparator.get'
Step into: Stepping over non-user code 'System.Globalization.CultureInfo.EnsureStringResource'
Step into: Stepping over non-user code 'System.Globalization.NumberFormatInfo.NumberDecimalSeparator.get'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.GetNormalizedNumberFormat'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.GetNormalizedNumberFormat'
Step into: Stepping over non-user code 'System.Globalization.NumberFormatInfo.NumberGroupSeparator.get'
Step into: Stepping over non-user code 'System.Globalization.CultureInfo.EnsureStringResource'
Step into: Stepping over non-user code 'System.Globalization.NumberFormatInfo.NumberGroupSeparator.get'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.GetNormalizedNumberFormat'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.GetNormalizedNumberFormat'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.ToHalfwidthNumbers'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble'
Step into: Stepping over non-user code 'double.Parse'
Step into: Stepping over non-user code 'System.Convert.ToDouble'
Step into: Stepping over non-user code 'System.Convert.ToDouble'
Step into: Stepping over non-user code 'System.Convert.ToDouble'
Step into: Stepping over non-user code 'System.Convert.ToDouble'
Step into: Stepping over non-user code 'System.Convert.ToDouble'
Step into: Stepping over non-user code 'System.Convert.ToDouble'
Step into: Stepping over non-user code 'System.Convert.ToDouble'
Step into: Stepping over non-user code 'System.Convert.GetDoubleNumber'
Step into: Stepping over non-user code 'System.Convert.ToDouble'
A first chance exception of type 'System.NotImplementedException' occurred in mscorlib.dll
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble'
A first chance exception of type 'System.NotImplementedException' occurred in Microsoft.VisualBasic.dll
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble'
Step into: Stepping over non-user code 'System.Exception.Message.get'
Step into: Stepping over non-user code 'System.Exception.Message.get'
Step into: Stepping over non-user code 'System.Exception.Message.get'
Step into: Stepping over non-user code 'System.Exception.Message.get'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble'
Step into: Stepping over non-user code 'System.InvalidCastException.InvalidCastException'
Step into: Stepping over non-user code 'System.SystemException.SystemException'
Step into: Stepping over non-user code 'System.Exception.Exception'
Step into: Stepping over non-user code 'System.Exception.Exception'
Step into: Stepping over non-user code 'System.SystemException.SystemException'
Step into: Stepping over non-user code 'System.InvalidCastException.InvalidCastException'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble'
A first chance exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll
Step into: Stepping over non-user code 'System.IO.TextReader.Dispose'
Step into: Stepping over non-user code 'System.IO.StreamReader.Dispose'
Step into: Stepping over non-user code 'System.IO.Stream.Close'
Step into: Stepping over non-user code 'System.IO.FileStream.Dispose'
Step into: Stepping over non-user code 'System.IO.FileStream.Dispose'
Step into: Stepping over non-user code 'System.IO.FileSystemManager.RemoveFromOpenList'
Step into: Stepping over non-user code 'System.IO.FileSystemManager.RemoveFromOpenList'
Step into: Stepping over non-user code 'System.Collections.ArrayList.Remove'
Step into: Stepping over non-user code 'System.Array.IndexOf'
Step into: Stepping over non-user code 'System.Array.IndexOf'
Step into: Stepping over non-user code 'System.Collections.ArrayList.Remove'
Step into: Stepping over non-user code 'System.Collections.ArrayList.Remove'
Step into: Stepping over non-user code 'System.IO.FileSystemManager.RemoveFromOpenList'
Step into: Stepping over non-user code 'System.IO.FileStream.Dispose'
Step into: Stepping over non-user code 'System.IO.Stream.Close'
Step into: Stepping over non-user code 'System.IO.Stream.Close'
Step into: Stepping over non-user code 'System.IO.StreamReader.Dispose'
Step into: Stepping over non-user code 'System.IO.TextReader.Dispose'
Step into: Stepping over non-user code 'System.IO.TextReader.Dispose'
Step into: Stepping over non-user code 'System.IO.Stream.Dispose'
Step into: Stepping over non-user code 'System.IO.Stream.Close'
Step into: Stepping over non-user code 'System.IO.FileStream.Dispose'
Step into: Stepping over non-user code 'System.IO.Stream.Close'
Step into: Stepping over non-user code 'System.IO.Stream.Close'
Step into: Stepping over non-user code 'System.IO.Stream.Dispose'
Step into: Stepping over non-user code 'Microsoft.VisualBasic.CompilerServices.ProjectData.SetProjectError'




#25965 Application to run I/O ports

Posted by Bainesbunch on 25 March 2012 - 02:31 PM in Netduino Plus 2 (and Netduino Plus 1)

Hello,
Probably the easiest way to control all of the output pins is to create an array for OutputPins, and create a output pin for each output. Then loop through the array to set the value for each.
The analog inputs can output like a DIO i believe.

I hope that helps,
Ralim


You can also create a dictionary of type outputpins, this way you can access all the properties and methods without having to cast them back into their types and address them using a key rather than an index into an array. I also belive that the Analogue pins can act as both Input and output pins like any other I/O pin in the system.



Pete.



#25817 Bluetooth Communication

Posted by Bainesbunch on 21 March 2012 - 08:40 PM in Netduino Plus 2 (and Netduino Plus 1)

Hello,

I am using a BT serial adapter connected to my Netduino and talking to my PC through a BT dongle.

Pairing was my first issue. Once i hade the BT to serial paired with my PC then I simply connected the TX and RX lines of the BT to Serial together to make a loopback. I then used a terminal emulator program (http://www.compuphas...are_termite.htm) on my PC to send characters through the serial BT to see if they were echoed back.

Once this was working I then set about writing the code to receive the data on the Netduino and echo it back.

It all worked as expected once I had gone through these steps. One gotchya however it the TX/RX they seem to differ from one manufacturer to another. So it might be worth switching them around if you are not receiving any data at the Netduino end.

Sometimes it is good to set some debug.prints to show what is coming in on the port.

I did notice however that you are trying to read 32 bytes into a buffer. The read will not return until it has read 32 bytes or timed out. Try setting the buffer length to 1 byte. This will echo every byte one at a time and not wait for the buffer of 32 bytes to be read.


Hope this helps ... and good luck.

Cheers Pete.



#23029 Debugging stops

Posted by Bainesbunch on 19 January 2012 - 11:05 PM in General Discussion


public static void Main()
{
   while (true)
   {
      System.Threading.Thread.Sleep(1000);
   }
}




This is interesting then what happens if you create and instantiate a new thread. Do all threads terminate when the main loop exits ?

Should you terminate any threads you create after exiting the main loop before the application exits.

Cheers Pete.



#23053 Debugging stops

Posted by Bainesbunch on 20 January 2012 - 12:19 PM in General Discussion

OK I have tried using just threads in my second test and it seems that the problem is with timers potentially not running in the thread they are created in or interfering with each other.

In the attached code I have removed the timers from the code path and just toggle the LED states within a loop in the individual threads. This seems to work a treat with NO blocking issues. Now i have to re-think my code and instead of timers in threads simply loop with a sleep.

Cheers Pete.

Attached Files




#23051 Debugging stops

Posted by Bainesbunch on 20 January 2012 - 10:37 AM in General Discussion

It is my understanding that everything will terminate when the main thread exits. That's why you need to keep it alive for the lifetime of your application run.

That's not to say it has to DO anything. Like I said, it can sleep the whole time and not take up any execution time. In this case, all the work would be done using other threads and events. This approach of event-based programming means your system might go into low power mode because there is nothing that needs attention right at this second. As soon as some interrupt or event is fired, the system will process the instructions then fall back to sleep.

This contrasts with the design of having a single thread that just loops instructions forever. In this case, unless you insert sleep states, you will be using power checking for changes rather than waiting for them to occur and run down your battery very quickly.

-Erik



OK lets separate the principles of threads from events.

Events as we know are raised by several methods, a transition of state on an input pin, a byte arriving at the UART, a timer rolling over of even a user generated event.

Threads are the individual program paths that can run contemporaneously on the device.

Putting the main thread into a sleep is not suspending the CPU and reducing power requirements. The underlying OS is beavering away waiting for events tiding up memory (Garbage collection) etc etc.

So I have some questions.

Are all events in the MF thread safe. In the CF and ordinary frameworks we usually use delegates to handle cross threading events. This does not seem to exists in the MF.

If we do a thread.sleep with a child thread it is blocking sibling threads or the parent thread as well as the thread it is executed on. Take the snippet of code here …



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

Module Module1

    Private HeartBeatThread As Thread
    Private StatusLEDThread As Thread
    Private watchdogTimer As Timer
    Private StatusLEDTimer As Timer
    Private LED_1 As New OutputPort(Pins.GPIO_PIN_D5, False)
    Private LED_2 As New OutputPort(Pins.GPIO_PIN_D6, False)

    Sub Main()

        ' create 2 new threads

        HeartBeatThread = New Thread(AddressOf StartHeartBeatThread)
        StatusLEDThread = New Thread(AddressOf StartStatusLEDThread)

        'Start them up
        HeartBeatThread.Start()
        StatusLEDThread.Start()

        'enter main loop and loop forever
        While True
        End While

    End Sub

    Private Sub StartHeartBeatThread()
        Dim HeartBeatDelegate As New TimerCallback(AddressOf LED1)
        watchdogTimer = New Timer(HeartBeatDelegate, Nothing, 1000, 1000)
        'enter endless loop in thread
        While True
        End While
    End Sub

    Private Sub StartStatusLEDThread()
        Dim StatusLEDDelegate As New TimerCallback(AddressOf LED2)
        StatusLEDTimer = New Timer(StatusLEDDelegate, Nothing, 250, 250)
        'enter endless loop in thread
        While True
        End While
    End Sub

    Private Sub LED1(ByVal stateInfo As Object)
        LED_1.Write(Not LED_1.Read)
        HeartBeatThread.Sleep(500)
    End Sub

    Private Sub LED2(ByVal stateInfo As Object)
        LED_2.Write(Not LED_2.Read)
    End Sub


End Module



So we create two new threads point them at some code and start them. Within the code of each we create a timer and point the event handler at another method. Then in each thread we enter an endless loop. Now in theory each timer is operating within its own thread and the thread is looping endlessly.


Now some questions.

  • When we exit the main loop does the system kill the two threads we have created for us [No the threads we have created continue to run even after the main loop has exited, they need to be explicitly stopped in the main thread with a HeartBeatThread.Abort() and StatusLEDThread.Abort()]
  • No matter what blocking we have on thread "HeartBeatThread" we should expect the LED2 method on thread "StatusLEDThread" to be called every 250ms. [This does NOT work calls to the Sleep on method in the "HeartBeatThread" thread (HeartBeatThread.Sleep(500) or Thread.CurrentThread.Sleep(500)) cause the whole program to sleep, this is not good as it means that threads can become application blocking, this negates the whole point of threads]



You can also get rid of the infinite loop in te main thread if you wish by executing the following Thread.Sleep(Threading.Timeout.Infinite) Oddly enough however this does not seem to block unlike a sleep in another thread.




Code attached to play with.

Cheers Pete.

Attached Files




#29872 Extendedtimer

Posted by Bainesbunch on 28 May 2012 - 11:43 AM in Visual Basic Support

Hi Mark,


Depending on the precision of the timer you can set a standard timer to test the TimeSpan from the point that you started the timer, resetting the start point and raising an event when it is reached.



So if you wanted to check every second then set the timer to 1 second then in the sub that it calls do a simple TimeSpan

Here is a link to TimeSpan

http://forums.asp.net/t/1386180.aspx/1

The second alternative it to start a new worker thread that checks the TimeSpan in a loop and resets the start point and raises an event when the time has expired.


Hope this helps

Cheers Pete.



#34291 Firmware update issue / VS issue

Posted by Bainesbunch on 27 August 2012 - 06:05 PM in Netduino Plus 2 (and Netduino Plus 1)

You did flash the Netduino Plus version and not the non plus version ... right ?

Its just that looking at the report it says "HalSystemInfo.halVendorInfo: Netduino (v4.2.0.0) by Secret Labs LLC"

Just a thought

Cheers Pete.



#24723 Help an Accountant switch Serials. :)

Posted by Bainesbunch on 27 February 2012 - 08:36 AM in Visual Basic Support

Hello Crystal, Within you application you should have a communications port showing in the bottom of the designer screen for the form. If you right click this you will get the properties for that com port. In there you can specify the name of the com port to connect to. I hope this is of some help. I am not sure how it is Netduino related though. Cheers Pete.



#23027 How to control 220V stuff

Posted by Bainesbunch on 19 January 2012 - 10:57 PM in Netduino 2 (and Netduino 1)

I realy have nothing to add to this thread other than to say that I am NOT Dutch :D :D Pete.



#22887 How to Create a VB Netduino DLL with CIL/IL

Posted by Bainesbunch on 17 January 2012 - 08:24 PM in Visual Basic Support

Hi Baxter,

Can this not simply be done by setting the application Type in the Netduino project properties in a c# or vb project to "Class library" this will then create a DLL that can be used for the MF, you need to be sure you are targeting the correct .NET version.


The steps I use

  • Right click in the solution explorer on the Netduino project name and select Properties (alt+Enter)
  • In the application Tab go to the dropdown for the application type and select "Class Library"
  • Build the application
  • Now go and look in the "bin" folder under the source folder and then into either "debug" or "release" folder depending on your build
  • This is your DLL. It is best left here and referenced from your project. If you want to move it into your new project folder then I suggest you create a folder called LIBS and copy ALL THREE items the DLL and the two folders that are with it called "be" and "le" you do not need the .PDB file.

I often use libraries that are in the public domain but written in c# i compile them into DLLs and then reference them in my VB application. this can be useful if you only want part of a public library. You can remove the stuff you don’t want and then only compile the bits that you need. This is useful if memory is getting short.


Cheers Pete.



#22992 IMU Fusion Board

Posted by Bainesbunch on 19 January 2012 - 10:33 AM in Netduino Plus 2 (and Netduino Plus 1)

Hy,
I have a problem with my IMU Fusion Board. I am able to communicate with the gyro and the acc but my problem is that I only get positve values back. So I can not differ the direction of the movment.
It would be nice if somebody could help me



Hi Rich,

I am not sure why you are receiving only positive values from the Gyro but I have another question in the way of offering you some advice.

Why are you instantiating and then disposing of the I2C object in every write and read ?

Would you not be better declaring them in the class as variables. Instantiating them on the class creation and then cleaning up in a class dispose call.

This would be far more efficient than doing it the way you are. It also is a fair bit quicker and would also make lighter work for the garbage collector.

Cheers Pete.



#28274 Industrial Use Case

Posted by Bainesbunch on 28 April 2012 - 06:58 PM in General Discussion

Thanks for sharing your experience Pete. Impressive use of the Netdruino. Just shows what's possible. Without giving away any details (as I understand your situation) did you have to customize the Netdruino to get the level of reliability up. A simple yes or no would suffice! Thanks


Yes. I basicly built it onto another PCB that took care of the nasty stuff that the outside world can though at it :D

Pete.



#28035 Industrial Use Case

Posted by Bainesbunch on 24 April 2012 - 05:20 PM in General Discussion

Hello, I am not doing anything on the net or with the cloud but I have developed a mission critical system to control camera dollies on a filming rig for use in live recording using the Netduino and the plus. They act as intermarries sampling data testing sensors and sending commands to the motor controllers. They relay this information back to a host PC doing all the data correlation and sending motor control commands back to the Netduino to pass on to the controllers. Everything is in closed loop so that any breakdown of communication caused the who system to go into emergency stop. I have had the system soak testing now for a continues period of 4 weeks without any issues. It will be going live in about 3 weeks and my confidence level is very high. Unfortunately the details of the system are protected by an NDA or I would be willing to share it here. In short I have no issues with using the Netduino in mission critical real time control situations. Hope this helps Cheers Pete.



#25306 Is my netduino faulty? Simple analog test = 1023 constant :(

Posted by Bainesbunch on 09 March 2012 - 09:16 PM in Netduino 2 (and Netduino 1)

Hello, The file was not attached :( Can you try tying all the analogue ports you are NOT using to ground and re-try the mesuments on the port again. You should be seeing 0 on all the ports tied to ground and you should only see a value on the port you have the sensor attached to. Cheers Pete.



#25250 Is my netduino faulty? Simple analog test = 1023 constant :(

Posted by Bainesbunch on 08 March 2012 - 07:54 PM in Netduino 2 (and Netduino 1)

Hi,

You might want to try adding a simple digital low-pass filter to the output of the ADC to remove the noise..

This is an example of one that I am using in some inclinometer readings to remove the high frequency stuff and just give me the filtered version of the signal.

i have attached the code here to Attached File  Lowpass.vb   844bytes   1 downloads



Imports System

Public Class LowPassFilter

	Private m_Top As Double
	Private m_Cutoff As Double
	Private m_Value As Double

	Public ReadOnly Property Value() As Double
    	Get
        	Return m_Value
    	End Get
	End Property

	Public Sub New(ByVal cutoff As Double)
    	Me.New(cutoff, 0)
	End Sub

	Public Sub New(ByVal cutoff As Double, ByVal initialState As Double)
    	If cutoff > 0.75 Then
        	Throw New ArgumentOutOfRangeException("cutoff should be less than 0.75")
    	End If
    	m_Cutoff = cutoff
    	m_Top = 1 - m_Cutoff

    	m_Value = initialState
	End Sub

	Public Function Update(ByVal value As Double) As Double
    	m_Value = (m_Value * m_Top) + (value * m_Cutoff)
    	Return m_Value
	End Function

End Class



You call "update" each time you take a reading passing the raw reading to the filter and then use the "value" property of the filter to get the filtered value.

You instantiate the class object with either just a cut-off value or both a cut-off value and an initial value.


Have fun and I hope this helps :D


<edit for additional ideas >

One way to make this smoothe is to put your code that reads and updates the filter into a thread of its own. You can put a small thread sleep of say 100ms. The faster you read the adc the better the noise rejection of the filter. I have some examples of how I do this in my inclinometer code if you would like to use them drop me a MP and I will send you the code.

<edit end>

Cheers Pete.



#25299 Is my netduino faulty? Simple analog test = 1023 constant :(

Posted by Bainesbunch on 09 March 2012 - 08:12 PM in Netduino 2 (and Netduino 1)

Hi, This is showing a pot not your IR LED. What is the resistor bridge for ? If you Zip up the FZ file it should load to the forun OK :) Cheers Pete.



#25297 Is my netduino faulty? Simple analog test = 1023 constant :(

Posted by Bainesbunch on 09 March 2012 - 07:34 PM in Netduino 2 (and Netduino 1)

Do you have or have you used "Fritzing". Website

It is an excellent tool for designing circuits and sharing them with others.

It has a breadboard build platform that allows you to design your system using a visual interface.

If you get this and design your idea using it you can share the .fz file here on the forum and other can modify it and send it back to you.

This may help us to understand the way you have things wired up and make suggestions on how to fix it.

Cheers Pete.



#24534 LCD EA_DIP_204_4

Posted by Bainesbunch on 21 February 2012 - 09:26 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi, It could be that the timers are interfering with each other calling the function whilst it is being called by another timer. This would definitely mess it up. ;) You could try putting a synclock on the method (that drives the LCD) you are calling to prevent it being entered whilst servicing another timer. Cheers Pete.



#22950 Mifare RFID Example Code With I2C LCD Output

Posted by Bainesbunch on 18 January 2012 - 05:15 PM in Visual Basic Support

Hello Folks, Here we have another piece of code that may be of use to other developers. It is basically a class that abstracts the basic functionality of an Mifare RFID reader. The device I have used (YHY502CTG) is self-contained and talks using UART level serial data and reads/writes to all Mifare cards. I have included the data sheet in the zip for reference. The sample application that it is a part of the download simply connects to the reader and requests its software revision and reader ID. It also uses the card present pin to trigger an interrupt that causes the device to start to read the present card. The class raises events when a card id read passing the card ID as a parameter. It also raises events for other things like error trapping and data transfer. It displays the data is reads onto 3 lines of a 4x20 LDC with the adafruites backpack attached talking via the I2C bus. I have used a re-compiled cut down version of the "MicroLiquidCrystal" library that I have included for completeness. It uses the "MCP23008LcdTransferProvider" to interface to tee LCD. The reader I have chosen has a lot more functionality than I have included in my abstraction. I only exposed the bits I needed. Please feel free to use this and if you have a need expand on the additional functions of the reader like electronic purse etc. and post it back. If you have any question please ask me and I will try and answer. Cheers Pete.

Attached Files




#22966 Mifare RFID Example Code With I2C LCD Output

Posted by Bainesbunch on 18 January 2012 - 11:30 PM in Visual Basic Support

Hi Pete,

Thanks for the post I was looking into an RFID project myself!

Can you tell me how you found programming in VB on the mircro framework? I still torn between learning C# and just going ahead an using VB which I'm more familiar with?

Thanks

Logicalstep


Hi Logicalstep,

firstly let us start be dispelling a few misunderstandings about VB.

  • VB dates back over 15 years and has been about a lot longer than c#.
  • C and C++ however have been about almost the same time.
  • When MS included it in their first manifestation of Visual Studio it suddenly became accessible to more people.
  • You can create Dlls in VB just search for my other posts where I added to Baxters original post on the CLR.

I am a dedicated VB programmer in the .net arena from asp.net to windows application .NET to .net Compact framework and finally to .NET Micro Framework.

There is very little that you cannot do in VB that you can in c# after all they both compile down to the CLR.

If you need help or pointer on how to do things feel free to drop me a PM or post to this thread.

Cheers Pete.



#25544 Minimum AnalogInput Read value

Posted by Bainesbunch on 15 March 2012 - 01:32 PM in Netduino Plus 2 (and Netduino Plus 1)

So...
...proceed as follows:

  • comment the SetRange call, so that the value given by the port won't be elaborated at all;
  • point the multimeter on the analog input and give me a stable value;
  • at the same time, tell me what's the Read method returns.

I'd also try to swap the photosensor with any trimpot, if you have. Please, tell me if you own any, and -if so- what value is marked on.
Cheers


You might also want to tie the unused analogue inputs to ground. I have had erratic readings when these are alowed to "float"

Cheers Pete.




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.