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

Christmas Tree Scope


  • Please log in to reply
3 replies to this topic

#1 David Moisan

David Moisan

    New Member

  • Members
  • Pip
  • 4 posts

Posted 24 December 2011 - 01:27 AM

I've ported John De Cristofaro's Christmas Tree Scope display code to the Netduino.

The hardware is simple: An RC network (R, 20 kohms; C, 0.1 microfarad) is connected from pin 5 to ground to the X channel of the scope. An identical RC network is connected on pin 6 to ground to the Y channel.

The code is so short and simple I've pasted it here.

/* 	Oscilloscope Christmas Tree
 *
 *  	Created: Dec 10, 2011
 *  
 *	Author: John M. De Cristofaro
 *  Ported to Netduino by David Moisan, Dec. 19th, 2011
 *  
 *	License: This code CC-BY-SA 3.0 and is unsupported.
 *		 (see creativecommons.org/licenses for info)
 *
 */


//Using
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;

namespace ChristmasTree
{
    public class Program
    {
        
        // Static PWM objects, one for each axis, X on D5, Y on D6

        static PWM Xaxis = new PWM(Pins.GPIO_PIN_D5);
        static PWM Yaxis = new PWM(Pins.GPIO_PIN_D6);

        // ****** Code *******

        void setup()
        {
            // Any setup code goes here
        }
        public static void Main()
        // Draw Tree and other elements here
        {
            while (true)
            {
                DrawTree();  // Christmas Tree
                             // Nothing else yet
            }
        }

        static void DrawTree()
        {
            // Contains X,Y coordinates for Christmas Tree shape
            // Passes coordinates to generic drawing routine
            // Static consts    

            const int NUM_POINTS = 19;    // our tree is defined by 19 x/y coord. pairs

            // x coords
            uint[] Xpoints = new uint[NUM_POINTS] { 43, 43, 20, 32, 26, 38, 32, 43, 38, 49, 61, 55, 67, 61, 73, 67, 79, 55, 55 };

            // y coords
            uint[] Ypoints = new uint[NUM_POINTS] {6, 14, 14, 34, 34, 53, 53, 73, 73, 92, 73, 73, 53, 53, 34, 34, 14, 14, 6 };
            
            MakeTrace(Xpoints, Ypoints, NUM_POINTS);
        }

        static void MakeTrace(uint[] Xpoints, uint[] Ypoints, int Size)
        {
            // Generic drawing routine.  Accepts two arrays of uint, one representing X coords, 
            // one representing Y coords, and a uint size which applies to both arrays

            const int TRACE_DELAY = 1;
            // trace delay in mS. making this longer will
            // result in a straighter drawing, but slower
            // refresh rate. making it too short will result
            // in an angular blob.

            int t;
            for (t = 0; t < Size; t++)		// run through the points in x & y
                {
                    Debug.Print("MakeTrace t: "+ t + "x:" + Xpoints[t] + " y:" + Ypoints[t]);
                    Xaxis.SetDutyCycle(Xpoints[t]); // Set X
                    Yaxis.SetDutyCycle(Ypoints[t]); // Set Y
                    Thread.Sleep(TRACE_DELAY);		// wait TRACE_DELAY microseconds
                }
        }
    }
}

I refactored John's original code because I figured I could have multiple sequential displays one after another but didn't have time to play further. I'm also aware that I'm wasting the capabilities of the Plus. I'm not sure you could display much vector text and have it look good, but that would be next thing to try.

I've attached a picture.

Attached Files



#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 24 December 2011 - 11:49 AM

That's pretty cool. Thanks for sharing, David. This makes me want to set up an oscilloscope + netduino in my home... Much more high-tech than a fiber-optic Christmas tree :)

#3 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 24 December 2011 - 05:17 PM

I agree with Chris. Over the originality, this should be considered a very good base for learning something about the scope. My congrats, David, and my best wishes to anyone is reading, all over the world. Cheers
Biggest fault of Netduino? It runs by electricity.

#4 David Moisan

David Moisan

    New Member

  • Members
  • Pip
  • 4 posts

Posted 26 December 2011 - 01:39 PM

I have some suggestions for further improvement. I would have tried some of these except I was cooking over the holiday and I thought that and napping were more important than tinkering. (And I have too many other things in my pile to do anyway...) 1) Most scopes that support XY also have a Z axis input; this is not 3D--it's a blanking input. The trace is blanked with a voltage on that input. This is mandatory if you want to display any kind of text message. John's original project only had two PWM's, and the Netduino has two more so you could use one of them or just use a digital output. (You would have a third array with just 1's and 0's to blank. I think the Z-axis inputs on this scope take an intensity voltage but I haven't tried it.) 2) You could try one of the minimal web site projects and modify it to allow users to display simple text (A-Z, 0-9) messages and display a few predefined holiday shapes (the tree, the Frosty the Snowman that someone did, a random dot snowfall, etc. etc.) I'd thought about doing both those things, then I fell asleep. It would have been possible if I hadn't had to chase down an intermittent in my elderly HP 1722 that conveniently disabled the X axis. I hope everybody here had a good one. It was still nice to get some time on my board. Still, New Year's is coming up, so perhaps I'll get to it after all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

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.