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.

Jason Smith's Content

There have been 17 items by Jason Smith (Search limited from 19-January 21)


By content type

See this member's

Sort by                Order  

#434 Memsic 2125 Accelerometer / Servo

Posted by Jason Smith on 14 August 2010 - 07:22 PM in Project Showcase

Very nice!

Now, just get another servo, a sheet of plywood and make yourself a tilt maze. You could use light sensors to detect where the ball is and include random events to make the game harder, like maybe the axises would swap in the middle of a game.


Very true! I think it would actually be pretty simple to do something like this. Would probably be a fun little game.

Jason.



#433 Memsic 2125 Accelerometer / Servo

Posted by Jason Smith on 14 August 2010 - 07:20 PM in Project Showcase

Jason,

That's pretty awesome. Once you get it cleaned up, we'd love to showcase this for a while on the Projects page... If you'd be interested in that... We love showing off the cool things that community members build.

Chris


Thanks Chris! That sounds great! I will work on getting everything working a bit better this weekend and post my results here in the forum.

Jason.



#409 Memsic 2125 Accelerometer / Servo

Posted by Jason Smith on 14 August 2010 - 07:12 AM in Project Showcase

All,

I successfully got the Memsic 2125 Accelerometer to work on my Netduino, so I decided to take a crack at controlling a servo by measuring Tilt. I'm sure I could do a lot to make this more efficient but I just wanted to get this working first:

Below is the code I used (I plan on doing a lot more work to get this going right. Once I do, I will properly comment my code and clean things up to make it more user friendly.):

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace Memsic
{
    public class Program
    {
        static int count = 0;
        static uint _lastposition = 0;
        static InputPort Xin = new InputPort(Pins.GPIO_PIN_D2, false, Port.ResistorMode.Disabled);
        static InputPort Yin = new InputPort(Pins.GPIO_PIN_D3, false, Port.ResistorMode.Disabled);
        static PWM ServoY = new PWM(Pins.GPIO_PIN_D9);
        public static void Main()
        {
            while (true)
            {
                int X = TiltToServoPulse(GhettoTilt(Xin));
                int Y = TiltToServoPulse(GhettoTilt(Yin));
                MoveServo(ServoY, (uint)Y);
                //Debug.Print("X:" + X + "," + "Y: " +  Y);
             }
        }

       //Read the specified port and grab some values to calculate Ghetto Tilt.
        static int GhettoTilt(InputPort axe)
        {
            count = 0;
            // Loop until pin reads a low 
            while (axe.Read() == true) { }
            // Loop until pin reads a high 
            while (axe.Read() == false) { }
            // Loop until pin reads a low and count
            while (axe.Read() == true)
            {
                if (axe.Read() == false) { break; }
                count += 1;
            }
            count = count - 21;
            return count;
        }

        static void MoveServo(PWM whatservo, uint whereto, int sleep = 0)
        {
            if (_lastposition == whereto) { return; }
            uint HowLong = 0;
            if (whereto > 2000 || whereto < 1000) { return; }
            whatservo.SetPulse(20000, whereto);
            if (_lastposition == 0) { HowLong = 300; }
            else { HowLong = _lastposition > whereto ? (_lastposition - whereto) / 3 : (whereto - _lastposition) / 3; }
            Debug.Print("" + HowLong);
            Thread.Sleep((int)HowLong);
            whatservo.SetPulse(0, whereto);
            _lastposition = whereto;
            if (sleep != 0) { Thread.Sleep(sleep); }
        }

        static int TiltToServoPulse(double Tilt)
        {
            double pulse = 0;
            Tilt = Tilt - 1;
            double calc1 = Tilt / 18;
            pulse = (calc1 * 1000) + 1000;
            return (int)pulse;
        }
    }
}


..and a video of the results:
http://www.youtube.com/watch?v=xTijhSgqMfM

Jason



#374 Steps to restore an Erased Netduino

Posted by Jason Smith on 13 August 2010 - 07:33 PM in Netduino 2 (and Netduino 1)

How funny. And to think that we made sure to make the ERASE pad small and to put it in a corner (and to require 220ms+ to erase it). :)

I guess this is another testament to open source and to having firmware that can be manually installed. Glad it's working well for you, and thanks again for writing up such nice step-by-step instructions for the community.

Chris


Yeah, I couldnt believe it myself. I think its a great feature on the board, and I wouldnt change a thing about it.. Also, I might have never learned how to use SAM-BA if this didnt happen. Good stuff, and good learning. So far I am loving everything about the Netduino.

As for the Write-up, no problem at all. If it wasn't for good posts on forums, and the huge amount of information online, I would have had to go to college. lol

"The Internet - Saving you thousands of dollars in tuition since 1973."

Jason.



#371 Steps to restore an Erased Netduino

Posted by Jason Smith on 13 August 2010 - 07:06 PM in Netduino 2 (and Netduino 1)

How did you do that. Could you share a tip so it won't happen to us too?

Thanks


If you can believe it, I had a jumper plugged into 3.3v when I set my Netduino down on my table (Bad practice for sure...) and the jumper lead just happened to touch the erase pin long enough to erase it. 1 in a million chance. lol.

Jason.



#370 Steps to restore an Erased Netduino

Posted by Jason Smith on 13 August 2010 - 07:03 PM in Netduino 2 (and Netduino 1)

Also here in step 8 you say unplug and plug it back in. Then in step 11 you say plug it in again but it's already plugged in was there somewhere you should of unpluged it before you get to step 11?



Good point.. It is already plugged in at that point. I made an update above. Nice catch.



#347 Steps to restore an Erased Netduino

Posted by Jason Smith on 13 August 2010 - 02:37 PM in Netduino 2 (and Netduino 1)

Scratch that last request chris... i got it to work... Sorry about that. I will write up a step by step process if you like to save you the trouble...I am sure there are going to be some people like me that are new when it comes to this stuff :D


So here is the step by step process:

1. Download SAM-BA from Atmel here and install : http://www.atmel.com...sp?tool_id=3883

2. Download the latest Netduino firmware, and the TinyBooterDecompressor_v4.1.0.1.zip file. (Currently both are located Here.)

3. (**WARNING.. no turning back after this point.) Using a jumper, Connect the 3V3 power header to the ERASE pin (gold pad directly underneath digital pin 0) for about 2-3 seconds. After doing this, disconnect the Netduino from your PC.

4. Plug in your Netduino's usb cable back into your pc. At this point for me, windows vista searched automatically for a driver and found the right one for a virtual serial port. If yours does not do this, you may need to point to the driver file in the Program Files > Atmel SAM-BA > Drivers directory.

5. Run SAM-BA. Select the COM port that your device is connected to. In my case this was COM4. Select AT91SAM7X512-ex from the dropdown.

6. When in SAM-BA, you will need to run the following two scripts first: [a] enable boot from flash; [b] enable flash access.

7. Next you will need to flash the TinyBooterDecompressor.bin file to your Netduino. At this point you are asked "Do you want to lock involved regions(s) (0 to 2)".." I wasnt sure what to pick here but I believe I selected no. (Chris Walker confirmed in a later post that "NO" should be selected.) Once this has been completed (only takes a few seconds), you are done flashing the TinyBooterDecompressor.

8. At this point you can unplug the USB cable connecting your computer to your Netduino, and then plug it back in. Now we can readd the Netduino firmware.

9. Go to the Start Menu > Programs > Microsoft .NET Micro Framework 4.1 > Tools

10. Run MFDeploy.exe. Be careful to run MFDeploy.exe and not MFDeploy.exe.config (as file extensions are hidden by default)

11. In the Device section at top, select USB instead of Serial. Your Netduino should appear in the drop-down; if not, select it.

12. Click "Browse..." and select the unzipped Netduino firmware files from step #1 (ER_CONFIG and ER_FLASH).

13. Press "Deploy". It will take a few minutes to update your Netduino. At this point you should be finished. Disconnect then Reconnect your Netduino via usb and it should be back up and running.


Please let me know if I missed anything here. Thanks again for all your help on this issue Chris!

Jason.



#342 Steps to restore an Erased Netduino

Posted by Jason Smith on 13 August 2010 - 06:57 AM in Netduino 2 (and Netduino 1)

I may need a step by step write-up. :unsure: Basically, I attempted to do what you said, but didnt have much luck. I downloaded SAM-BA, and I got my Netduino to come up using COM4. I selected at91sam7x512-ek when prompted to select my board. I then selected the script "Boot from Flash (GPNVM2)" then "Enable Flash Access". Next I selected the TinyBooterDecompressor.bin file needed from "Send File Name" area, and sent the file. I was then prompted with "Do you want to lock involved regions(s) (0 to 2)"..I didnt know what to select here so I clicked yes. I received the following output:

(SAM-BA v2.10) 1 % send_file {Flash} "C:/Users/Jason/Desktop/TinyBooterDecompressor_v4.1.0.1/TinyBooterDecompressor.bin" 0x100000 0
-I- Send File C:/Users/Jason/Desktop/TinyBooterDecompressor_v4.1.0.1/TinyBooterDecompressor.bin at address 0x100000
first_sector 0 last_sector 2
-I- Writing: 0xA358 bytes at 0x0 (buffer addr : 0x202C88)
-I- 0xA358 bytes written by applet
-I- Sector 0 locked
-I- Sector 1 locked
-I- Sector 2 locked
(SAM-BA v2.10) 1 %


I then tried to redeploy the Netduino firmware via com4 in MFDeploy without luck.. Recieved the error "Error: No response from device"


Scratch that last request chris... i got it to work... Sorry about that. I will write up a step by step process if you like to save you the trouble...I am sure there are going to be some people like me that are new when it comes to this stuff :D



#340 Steps to restore an Erased Netduino

Posted by Jason Smith on 13 August 2010 - 06:46 AM in Netduino 2 (and Netduino 1)

Here is an overview:
Step 1: connect the 3V3 power header to the ERASE pin (gold pad directly underneath digital pin 0)
Step 2: use SAM-BA to flash TinyBooterDecompressor.bin to your erased Netduino
Step 3: use MFDeploy to deploy the Netduino firmware to your Netduino

Here are the files:
http://forums.netdui...e-v410-patch-1/

If you would like step-by-step instructions on how to use SAM-BA, I can write some up here... But basically, you [a] enable boot from flash; [b] enable flash access; [c] flash the TinyBooterDecompressor.bin file to your Netduino. Your erased Netduino will show up as a virtual serial port; you may need to manually point it to the driver in the Program Files > Atmel SAM-BA > Drivers directory.

Chris

I may need a step by step write-up. :unsure: Basically, I attempted to do what you said, but didnt have much luck. I downloaded SAM-BA, and I got my Netduino to come up using COM4. I selected at91sam7x512-ek when prompted to select my board. I then selected the script "Boot from Flash (GPNVM2)" then "Enable Flash Access". Next I selected the TinyBooterDecompressor.bin file needed from "Send File Name" area, and sent the file. I was then prompted with "Do you want to lock involved regions(s) (0 to 2)"..I didnt know what to select here so I clicked yes. I received the following output:

(SAM-BA v2.10) 1 % send_file {Flash} "C:/Users/Jason/Desktop/TinyBooterDecompressor_v4.1.0.1/TinyBooterDecompressor.bin" 0x100000 0
-I- Send File C:/Users/Jason/Desktop/TinyBooterDecompressor_v4.1.0.1/TinyBooterDecompressor.bin at address 0x100000
first_sector 0 last_sector 2
-I- Writing: 0xA358 bytes at 0x0 (buffer addr : 0x202C88)
-I- 0xA358 bytes written by applet
-I- Sector 0 locked
-I- Sector 1 locked
-I- Sector 2 locked
(SAM-BA v2.10) 1 %


I then tried to redeploy the Netduino firmware via com4 in MFDeploy without luck.. Recieved the error "Error: No response from device"



#337 Steps to restore an Erased Netduino

Posted by Jason Smith on 13 August 2010 - 06:08 AM in Netduino 2 (and Netduino 1)

All, Can someone provide the steps needed to restore an Netduino that has been erased? Believe it or not.. I managed to accidentally erase my Netduino during testing... Jason.



#297 Unboxing: first impressions?

Posted by Jason Smith on 12 August 2010 - 02:21 PM in Netduino 2 (and Netduino 1)

Ordered with Makershed 2 units to be shipped to the Netherlands, and they did come with a cable.
But not in a box, mine were in their anti static bags only..

They look very cool, even smaller than I thought they would be.


Wow.. No box.. I wonder if customs had something to do with that. ;)



#288 HXT 900 Servo

Posted by Jason Smith on 12 August 2010 - 05:58 AM in Netduino 2 (and Netduino 1)

Very cool!

I don't want to hijack this thread, but it brings up a quick thought. We're looking to add some additional functionality in the next version of the PWM classes. On the table are a few ideas: assignment of the PWM channels to one of two clocks; setting individual clock frequencies; possible interrupt-based sine and triangle wave functions; possible software PWM on hardware pins. Would any of those be useful in your projects?

BTW, just curious: what was the difference you noted between our PWM implementation and the GHI one?

Chris


Chris,

It looks like the difference is that the FEZ PWM.SetPulse method uses nanoseconds as seen in the below code... or its 100% possible I am using the Netduino Setpulse method incorrectly as I am very new to microcontroller's. The Netduino is my first board. I really need to get my "Google" degree in a lot of this stuff. On that note, and after "Googleing" the changes you have on the table to the PWM classes, I think all those additions would be very useful.



using System;
using System.Threading;
using Microsoft.SPOT;
using GHIElectronics.NETMF.Hardware;
using GHIElectronics.NETMF.FEZ;
class Program
{
    public static void Main()
    {
        PWM servo = new PWM((PWM.Pin)FEZ_Pin.PWM.Di5);
        while (true)
        {
            // 0 degrees. 20ms period and 1.25ms high pulse
            servo.SetPulse(20 * 1000 * 1000, 1250 * 1000);
            Thread.Sleep(1000);//wait for a second
            
            // 90 degrees. 20ms period and 1.50ms high pulse
            servo.SetPulse(20 * 1000 * 1000, 1500 * 1000);
            Thread.Sleep(1000);//wait for a second
            
            // 180 degrees. 20ms period and 1.75ms high pulse
            servo.SetPulse(20 * 1000 * 1000, 1750 * 1000);
            Thread.Sleep(1000);//wait for a second
        }
        Thread.Sleep(-1);
    }
}

Jason



#285 HXT 900 Servo

Posted by Jason Smith on 12 August 2010 - 04:59 AM in Netduino 2 (and Netduino 1)

All,

I was able to successfully control an HXT 900 servo using the Netduino board this evening and wanted everyone's thoughts on the code.

Basically, to figure out how to use the servo I read through a beginners guide to C# and the micro framework created by GHI located Here.

..after attempting to apply this code to the Netduino I realized that the logic for using the PWM.SetPulse method must be different on the Netduino, or I am just completely using it wrong...although was still able to get this to work. I know there are also different methods I could have used to get this to work, but this one really does seem to work well. I ran this servo for over an hour tonight without any issues.


using System;
using System.Threading;
using Microsoft.SPOT;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace Servo1
{
    public class Program
    {
        static PWM Servo1 = new PWM(Pins.GPIO_PIN_D9);
        static uint _left = 1000;
        static uint _center = 1500;
        static uint _right = 2000;
        static uint _lastposition = 0;

        public static void Main()
        {
            while (true)
            {
                MoveServo(Servo1,_left, 100);
                MoveServo(Servo1,_center,100);
                MoveServo(Servo1,_right, 100);
            }
        }

        //Move the servo between 1000(left) on 2000(right).
        static void MoveServo(PWM whatservo, uint whereto, int sleep = 0) 
        {
            uint HowLong = 0;
            //exit the void to avoid servo damage if the value's are not within range.
            if (whereto > 2000 || whereto < 1000) {return;}
            //Begin sending the pulse to the servo.
            whatservo.SetPulse(20000, whereto);
            //if the lastposition of the servo is unknown (the default 0 value set above),
            //default the value to 300, otherwise calculate how longe the servo shoud run.
            if (_lastposition == 0) { HowLong = 300; }
            else { HowLong = _lastposition > whereto ? (_lastposition - whereto) / 3 : (whereto - _lastposition) / 3; }
            //continue sending the pulse using the howlong calculation.
            Thread.Sleep((int)HowLong);
            //stop the pulse.
            whatservo.SetPulse(0, whereto);
            //reset the last position after the move.
            _lastposition = whereto;
            //sleep the specified amount of time if applicable.
            if (sleep != 0) { Thread.Sleep(sleep); }
        }
    }
}


ON a side note, the above code works for both 3.3v and 5v, but the servo seems to operate a lot smoother on 3.3v because of the "HowLong" calculation I am using.. a small adjustment to the calculation would fix this.

You see a video of the servo in action below:

http://www.youtube.com/watch?v=yUgzQP85qc4

Jason



#227 TMP36 Temperature Sensor/SB Protoshield

Posted by Jason Smith on 11 August 2010 - 05:57 AM in Netduino 2 (and Netduino 1)

Taking Chris's advice from above, I was able to get the TMP36 working easily this evening. To do this I did the following:

Using the following picture's as reference:

1. I connected the left pin to 3.3v.
2. I then Connected 3.3v to Aref as suggested in Chris's previous post.
3. I connected the center pin to Analog0.
4. I connected the Right pin to Ground.

Posted Image
Posted Image

Next up, I wrote the following code to handle the temperature in C and F.

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace temperature1
{
    public class Program
    {
        public static void Main()
        {
            //Declare your analog input
            AnalogInput a0 = new AnalogInput(Pins.GPIO_PIN_A0);

            while (true)
            {
                // Read the temp sensor
                int read = a0.Read();

                //convert the reading to voltage
                Double voltage = read * 3.3 / 1024;

                //calculate Celsius from voltage
                Double tempC = (voltage - 0.5) * 100;

                //calculate  Fahrenheit from Celsius 
                Double tempF = (tempC * 9 / 5) + 32;

                //Print your results
                Debug.Print("Temp in F is: " + tempF + " -- Temp in C is: " + tempC);

                //sleep and do it all over again.
                Thread.Sleep(1000);
            }

        }

    }
}


As you can see in the below debug output, I am now receiving a more accurate temperature reading:

Posted Image

Thanks for all your help Chris!

Jason.



#209 TMP36 Temperature Sensor/SB Protoshield

Posted by Jason Smith on 10 August 2010 - 09:50 PM in Netduino 2 (and Netduino 1)

A few quick things:
1. Netduino's analog inputs are 3.3V (instead of 5.0V). Power the temperature sensor from the 3.3V power header instead of the 5.0V power header.
2. The ARM chip on the Netduino (Rev A) does not have an internal analog reference (unlike the AVR used on the Arduino)--so you'll need to wire the 3.3V power header to the AREF pin header.

Other than that, I believe you should be good to go!

Chris



Chris,

Thanks for you help, I should have caught that by doing a little reading. I will make the changes and try that again tonight. I will let everyone know the outcome.

Thanks Again!

Jason.



#191 TMP36 Temperature Sensor/SB Protoshield

Posted by Jason Smith on 10 August 2010 - 06:05 PM in Netduino 2 (and Netduino 1)

I seem to be having an issue reading the TMP36 Temperature sensor. I setup the sensor using a SB(Solorbotics) Protoshield following the tutorial at the following link : http://www.ladyada.n...sors/tmp36.html. I have the sensor setup on the Netduino exactly as shown in the below Arduino Picture:

Posted Image

Here is the code I am using to attempt to read the sensor:

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace NetduinoApplication2
{
    public class Program
    {
        static AnalogInput Tmp36 = new AnalogInput(Pins.GPIO_PIN_A0);
        public static void Main()
        {
            // write your code here
            while (true)
            {
                double voltage = Tmp36.Read() * 5.0 / 1024;
                double tempC = (voltage - 0.5) * 100;
                double tempF = (tempC * 9 / 5) + 32;
                Debug.Print("Temp in C is: " + tempC);
                Debug.Print("Temp in F is: " + tempF);
                Thread.Sleep(1000);
            }
        }
    }
}


The above code seems to be fine, but I dont appear to be getting back any proper data from the sensor. I am getting a reading in the mid 800's all the time using this code...even without the sensor plugged in. I was wondering if someone could help me figure out what I might be doing wrong. It is possible (I am new to microcontroller projects, but work as a .net programmer...) that the temperature sensor may be defective, and I have not yet attempted to test it with a multimeter. Its also possible the issue might be with my protoshield. I have not attempted to connect the sensor without it.

Can anyone see any issues with the way I am trying to read this sensor before I check it with a multimeter?



#120 Unboxing: first impressions?

Posted by Jason Smith on 08 August 2010 - 05:32 AM in Netduino 2 (and Netduino 1)

Just curious...when you received and opened your Netduino, what were your first impressions?

Anything we can do better to improve the "unboxing" experience?

Chris


I received my Netduino around 8:00 this morning. Personally, I think the packaging is awesome. It comes in the perfect size box, and I love that the packaging isn't wasteful. I had no problems getting the board up and running, and so far everything is working perfectly... great product.

For my first couple of projects I plan on trying to integrate my Netduino with my Parkzone Radian R/C Sailplane. Thought I might mess around with the Memsic 2125 Dual-axis Accelerometer, an altimeter (maybe using a pressure sensor?) and eventually some type of GPS system for a Netduino autopilot. I've also thought it would be a lot of fun to use the Netduino to launch a few model rockets off of my Radian in mid-flight, but I will have to check some local laws to make sure that is legal. ;)

Super excited to begin working with the Netduino!




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.