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.

entens

Member Since 09 Aug 2010
Offline Last Active Sep 29 2011 02:45 PM
-----

Posts I've Made

In Topic: Little Hydraulic Arm

12 January 2011 - 07:32 PM

Hi all,
I'm still learning electronics and the Netduino but just wanted to float a question out there to see if I'm going in the right direction. I'm trying to control a small hydraulic arm (just a cylinder and a rod that goes out and back) and I was thinking I'd need a small air pump and a three way solenoid valve (one way to pump/push the arm out and one to release the air letting a weak spring in the cylinder push the arm back.

Anyone seen a netduino/arduino project like that or any components that might suit. Any help at all most gratefully received.


Many Thanks in advance.
Eddie


I think your looking for a solenoid actuated spool valve. In my experience, I've only used them with PLC's to actuate powerful hydraulic servos so I'm not exactly sure of the availability for something small scale.

If you shooting for small scale, I would actually use two small solenoid valves with a pressure relief valve feeding back into my supply reservoir.

In Topic: Program Storage and Execution

07 December 2010 - 05:24 PM

Wow, Pyxis is a goldmine!

The contents of 'AppLoader.cs' is probably what you'll want to use. It essentially grabs a byte array and uses 'System.Reflection' to load it as an executable assembly. This should work, but I see problems with a lack of memory while using the Netduino.


Contents of AppLoader.cs so you don't have to download the Pyxis source:
/*
Copyright 2010 Thomas W. Holtquist

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

using System;
using System.Collections;
using System.IO;
using System.Reflection;
using System.Runtime;

using Microsoft.SPOT;

namespace Skewworks.Pyxis.Kernel
{
    internal static class AppLoader
    {

        /// <summary>
        /// The interface for a standlone application
        /// </summary>
        interface IApplication
        {
            void RunFromBytes(ref ApplicationKey AppKey, ref PyxisAPI APIRef, ref string path, ref string[] parameters);
            AppIcon GetAppIcon(byte[] bytes);
        }

        /// <summary>
        /// A class that can be loaded across applicaiton domains which
        /// implements the IApplicaiton interface
        /// </summary>
        public class Application : MarshalByRefObject, IApplication
        {

            /// <summary>
            /// we need a defautl consturctor to create an instance of this object
            /// across an application domain
            /// </summary>
            public Application()
            {
            }

            public AppIcon GetAppIcon(byte[] bytes)
            {
                // Attempt to execute DLL
                try
                {
                    Assembly asm;
                    MethodInfo[] m;

                    asm = Assembly.Load(bytes);
                    if (asm == null)
                    {
                        return new AppIcon();
                    }

                    Type[] t = asm.GetTypes();
                    for (var j = 0; j < t.Length; j++)
                    {
                        m = t[j].GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance);
                        for (int i = 0; i < m.Length; i++)
                        {
                            if (m[i].Name == "PyxisIcon")
                            {
                                return (AppIcon)m[i].Invoke(asm, null);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    // Do nothing
                }

                return new AppIcon();
            }

            public void RunFromBytes(ref ApplicationKey AppKey, ref PyxisAPI APIRef, ref string path, ref string[] parameters)
            {
                string[] supporting = Directory.GetFiles(Path.GetDirectoryName(path));

                for (int i = 0; i < supporting.Length; i++)
                {
                    if (supporting[i] != path)
                    {
                        try
                        {
                            Assembly.Load(File.ReadAllBytes(supporting[i]));
                        }
                        catch (Exception)
                        {
                            // move along
                        }
                    }
                }

                RunAppFromBytes(AppKey, APIRef, File.ReadAllBytes(path), parameters);
            }

            private void RunAppFromBytes(ApplicationKey AppKey, PyxisAPI APIRef, byte[] bytes, string[] parameters)
            {

                // Attempt to execute DLL
                try
                {
                    Assembly asm;
                    MethodInfo[] m;

                    asm = Assembly.Load(bytes);
                    if (asm == null)
                    {
                        return;
                    }

                    Type[] t = asm.GetTypes();
                    for (var j = 0; j < t.Length; j++)
                    {
                        m = t[j].GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance);
                        for (int i = 0; i < m.Length; i++)
                        {
                            if (m[i].Name == "PyxisApp")
                            {
                                AppStartup myStartup = (AppStartup)m[i].Invoke(asm, new object[] { AppKey, APIRef, parameters });
                                APIRef.ActivateApplication(myStartup, AppKey);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    // Do nothing
                    APIRef.Prompt("Failed to launch program.\n" + e.Message, "System Alert", PromptType.OKOnly);
                }

            }

        }

        #region Variables

        private static IApplication iApp = null;
        
        #endregion

        /// <summary>
        /// The executable entry point.
        /// </summary>
        public static void LaunchApplication(PyxisAPI APIRef, string path, string[] parameters)
        {
            int AppID = GetAppID(APIRef);

            // Create the Application
            PyxisApplication PA = new PyxisApplication();
            PA.Forms = new ArrayList();
            PA.Domain = AppDomain.CreateDomain("PyxisApp" + AppID);
            PA.Key = new ApplicationKey(AppID, PA.Domain);
            APIRef._runningApps.Add(PA);

            // create an instance of the IApplication type
            // please note that the following call will also load the assembly that contains that type
            // which we pass as first parameter 
            try
            {
                iApp = (IApplication)PA.Domain.CreateInstanceAndUnwrap(typeof(IApplication).Assembly.FullName, typeof(Application).FullName);

                // Allow system time to catch up
                System.Threading.Thread.Sleep(100);

                // Launch the Program
                iApp.RunFromBytes(ref PA.Key, ref APIRef, ref path, ref parameters);

            }
            catch (Exception e)
            {
                APIRef.Prompt("Failed to launch application!\n" + e.Message + "\n" + e.InnerException.ToString(), "System Alert", PromptType.OKOnly);
                APIRef._runningApps.Remove(PA);
                return;
            }


        }

        public static AppIcon GetApplicationIcon(byte[] bytes)
        {
            AppIcon AI;

            // Create the Domain
            AppDomain ad = AppDomain.CreateDomain("PyxisAppDesktopIcon");

            // create an instance of the IApplication type
            // please note that the following call will also load the assembly that contains that type
            // which we pass as first parameter 
            if (iApp == null)
            {
                try
                {
                    iApp = (IApplication)ad.CreateInstanceAndUnwrap(typeof(IApplication).Assembly.FullName, typeof(Application).FullName);
                }
                catch (Exception e)
                {
                    AppDomain.Unload(ad);
                    return new AppIcon();
                }
            }

            // Get the Icon
            AI = iApp.GetAppIcon(bytes);

            // Destroy Domain
            iApp = null;
            AppDomain.Unload(ad);

            return AI;
        }

        private static int GetAppID(PyxisAPI APIRef)
        {
            bool bConflict = false;
            int AppID = 0;
            int i;
            PyxisApplication PA;

            while (true)
            {
                bConflict = false;
                for (i = 0; i < APIRef._runningApps.Count; i++)
                {
                    PA = (PyxisApplication)APIRef._runningApps[i];
                    if (PA.Domain.FriendlyName == "PyxisApp" + AppID)
                    {
                        bConflict = true;
                        break;
                    }
                }
                if (!bConflict) return AppID;
                AppID++;
            }
        }

    }
}


Unrelated side note: Would it be possible to get a 'spoiler' tag added so you can embed long pieces of code in collapsible block?

In Topic: DTMF chip coding problem

06 December 2010 - 05:58 PM

You might want to read up on how to interface those LEDs with the microcontroller too. Just put the positive on the output port, and the negative to the ground port.

You can make the leds match the input using this code:
	public static void Main()
	{
		// setup LEDs
		OutputPort led1 = new OutputPort(Pins.GPIO_PIN_D5, false);
		OutputPort led2 = new OutputPort(Pins.GPIO_PIN_D5, false);
		OutputPort led4 = new OutputPort(Pins.GPIO_PIN_D5, false);
		OutputPort led8 = new OutputPort(Pins.GPIO_PIN_D5, false);
		
		// instantiate the DTFM driver
		DTFM toneDecoder = new DTFM(Pins.GPIO_PIN_D0, Pins.GPIO_PIN_D1, Pins.GPIO_PIN_D2, Pins.GPIO_PIN_D3);
		
		// main loop
		while (true)
		{
			int value = toneDecoder.Read();
			
			// initialize leds
			led1.Write(false);
			led2.Write(false);
			led4.Write(false);
			led8.Write(false);
			
			// set LED array based on value
			switch(value)
			{
				case 0:
					// no leds lit
					break;
				case 1:
					led1.Write(true);
					break;
				case 2:
					led2.Write(true);
					break;
				case 3:
					led1.Write(true);
					led2.Write(true);
					break;
				case 4:
					led4.Write(true);
					break;
				case 5:
					led1.Write(true);
					led4.Write(true);
					break;
				case 6:
					led2.Write(true);
					led4.Write(true);
					break;
				case 7:
					led1.Write(true);
					led2.Write(true);
					led4.Write(true);
					break;
				case 8:
					led8.Write(true);
					break;
				case 9:
					led1.Write(true);
					led8.Write(true);
					break;
				case 10:
					led2.Write(true);
					led8.Write(true);
					break;
				case 11:
					led1.Write(true);
					led2.Write(true);
					led8.Write(true);
					break;
				case 12:
					led4.Write(true);
					led8.Write(true);
					break;
				default:
					// cannot have value for 13-16
					break;
			}
			
			// wait for next round of input
			Thread.Sleep(200);
		}
	}

In Topic: DTMF chip coding problem

06 December 2010 - 05:42 PM

I'm just going to repost my answer to your last post here.

    public class DTFM : IDisposable
    {
        private Thread ListenThread;
        private bool Listening;

        private int LastValue;

        private InputPort Binary1;
        private InputPort Binary2;
        private InputPort Binary4;
        private InputPort Binary8;

        public delegate void OutputHandler(object sender, int value);
        public event OutputHandler Output;

        public DTFM(Cpu.Pin Binary1, Cpu.Pin Binary2, Cpu.Pin Binary4, Cpu.Pin Binary8)
        {
            // Initialize the local InputPort's utilized by the DTFM
            this.Binary1 = new InputPort(Binary1, false, Port.ResistorMode.Disabled);
            this.Binary2 = new InputPort(Binary2, false, Port.ResistorMode.Disabled);
            this.Binary4 = new InputPort(Binary4, false, Port.ResistorMode.Disabled);
            this.Binary8 = new InputPort(Binary8, false, Port.ResistorMode.Disabled);

            // Initialize the listener thread
            Listening = true;
            ListenThread = new Thread(new ThreadStart(Listen));
            ListenThread.Start();
        }

        public void Dispose()
        {           
            // Make the thread expire
            Listening = false;
            Thread.Sleep(10);

            // Force the thread dead just in case
            if (ListenThread.IsAlive)
                ListenThread.Abort();

            // Free the InputPort's
            Binary1.Dispose();
            Binary2.Dispose();
            Binary4.Dispose();
            Binary8.Dispose();
        }
		
		public int Read()
		{
			int result = 0;
			
			// Build the current value from the DTFM
			if (Binary1.Read())
				result += 1;
			if (Binary2.Read())
				result += 2;
			if (Binary4.Read())
				result += 4;
			if (Binary8.Read())
				result += 8;
		}
		
        void Listen()
        {
            while (Listening)
            {
                // Don't execute if nothing is attached to the event
                if (Output != null)
                {
                    int CurrentValue = 0;

                    CurrentValue = Read();

                    // If the value has changed, throw a new event
                    if (CurrentValue != LastValue)
                    {
                        LastValue = CurrentValue;
                        Output(this, CurrentValue);
                    }
                }
                // Wait
                Thread.Sleep(100);
            }
        }
    }


Using your provided code, you can either manually read using the Read() function, or receive events by attaching to the Output event like:
DTFM toneDecoder = new DTFM(Pins.GPIO_PIN_D0, Pins.GPIO_PIN_D1, Pins.GPIO_PIN_D2, Pins.GPIO_PIN_D3);
toneDecoder.Output += new OutputHandler(ToneReceived);

In Topic: Netduino and the Zune?

05 December 2010 - 04:39 AM

Has anyone been able to, or have any insight on how to, 'talking' to the Netduino with a Zune?
is it possible to do without wifi, so with a cable?


I guess you can get started with the cable pinouts

Pin 01 - USB 5VDC(+) (common with Pins 2,3)
Pin 02 - 5VDC(+) (common with pins 1,3)
Pin 03 - 5VDC(+) (common with pins 1,2)
Pin 04 - Unknown (used on travel remote) 1.75 VDC (+)
Pin 05 - Unknown (used on travel remote) 1.75 VDC (+)
Pin 06 -
Pin 07 -
Pin 08 -
Pin 09 - Video (+)
Pin 10 -
Pin 11 -
Pin 12 -
Pin 13 - Audio L (+) (also audio on travel remote)
Pin 14 - Audio R (+) (Also audio on travel remote)
Pin 15 -
Pin 16 -
Pin 17 - Unknown (used on travel remote) these are likely our trigger
Pin 18 - Unknown (used on travel remote) these are likely our trigger
Pin 19 - Ground (common with Pins 22,23,24,and shield)
Pin 20 - USB Data (-)
Pin 21 - USB Data (+)
Pin 22 - USB Ground (common with Pins 19,23,24,and shield)
Pin 23 - Ground (common with Pins 22,19,24,and shield)
Pin 24 - Ground (common with Pins 22,23,19,and shield)

source: http://www.zuneboard...ne-pinouts.html

You also might contemplate taking a look at the datasheet for the Wolfson WM8978 chip. Eventually, thats what that cable connnects to. http://www.wolfsonmi...s/en/WM8978.pdf

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.