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 03-May 23)


By content type

See this member's


Sort by                Order  

#25422 Netduino Firmware v4.2.0 RC4 (Netduino + Netduino Plus)

Posted by Bainesbunch on 12 March 2012 - 08:38 PM in Beta Firmware and Drivers

Hi Chris, How far are we off seeing a release of 4.2, or another RC. Cheers Pete.



#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.



#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




#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.



#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.



#43374 Multi threading

Posted by Bainesbunch on 14 January 2013 - 09:55 AM in Visual Basic Support

Same as you do in any .NET environment :)




#28088 ReDim Preserve

Posted by Bainesbunch on 25 April 2012 - 04:53 PM in Visual Basic Support

Unfortunately at the moment there is ,as it says, no array copy functionality built in. What you have to do is create a second array the size you are trying to redim and copy one by one the values from you original array :o 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.



#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




#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




#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.



#25970 PWM Input from the ground up

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

Hi Anthony, this is not as difficult as it seems since we have edge driven interrupts on the pins of our Netduinos. Basically if you have a methods that is called on both the leading (rising edge) and the falling edge of the pin then you can calculate the time between the two. This will give you your pulse width. Since you are not interested in the duty cycle then you won’t be wanting to measure time between leading edges. I can give you a snippet of code to do this in VB if you want it. Let me know. 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



#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'




#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



#25903 Seedstudio Keypad Module

Posted by Bainesbunch on 23 March 2012 - 06:04 PM in Netduino 2 (and Netduino 1)

Well done !! :D Now go and have some more fun



#25859 Seedstudio Keypad Module

Posted by Bainesbunch on 22 March 2012 - 05:36 PM in Netduino 2 (and Netduino 1)

Aha! Ok will I will try that.


do you have a pinout for this keyboard ?



#25852 Seedstudio Keypad Module

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

Hello,

If you look at the Arduino code that is on the webpage for this keypad it looks like a basic 3x3 multiplexed matrix


void setup() 
{
  Serial.begin(9600);
  for(i=0;i<3;i++) 	pinMode((KeyOPin + i), OUTPUT); 	
  for (i=0;i<3;i++)	pinMode(( KeyIPin + i), INPUT); 
} 	

void loop()
{
   scankey();
   if (press)
   {
	press=0;
	Serial.print("Keycode is ");
	Serial.println(oldkey,HEX);
   }
}

void scankey()
{
  reg = 1;
  for (i=0;i<3;i++)
  {
	for (n=0;n<3;n++)
	{
      if((reg>>n)&1)        digitalWrite(KeyOPin+n , HIGH); 
      else                  digitalWrite(KeyOPin+n , LOW);
	}   
	for (n=0;n<3;n++)
	{
  	if(digitalRead(KeyIPin + n))
  	{ 	
    	key = key | (1<<(4+n));	
    	key = key | reg ; 
      }                    
	}
	reg = reg << 1;
  }

  if (key & 0xf8)
  {
	if (key!=oldkey)   {   
  	press = 1;  
  	oldkey = key ; 
	}
  }
  else   	oldkey = 0;


  key = 0;
}


it is an easy task to translate this code from the Arduino C++ Variant to C# or VB

It would be useful to know the pin outs on the IDC connector they have attached to the board so you know which pins connect to the 3 ports that are outputs and which should be connected to the inputs.

If you are having problem drop me a PM or ask further here and I can do the translation for you. But it is best to try yourself first.

Cheers Pete.



#23967 Multiple i2C Devices with VB

Posted by Bainesbunch on 08 February 2012 - 01:48 PM in Visual Basic Support

Hi, I don't know if this is any use but I have two accelerometers connected using the Love electronics libs written in c#. What I did was to compile the resource lib into a dll and reference it in my vb project. this allows multiple I2C devices connected at the same time using the SharedI2CDevice method. The source is available from Love electronics. If all that fails then attached is my compilation Attached File  LoveElectronics.Resources.zip   38.76KB   37 downloads of their dll for you to use. Cheers 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.



#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.



#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.




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.