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.

dorathoto

Member Since 24 Mar 2014
Offline Last Active May 21 2015 08:30 PM
-----

Topics I've Started

Servo class in 4.3.1

26 March 2014 - 08:50 PM

I'm using the new version of the class of Chris:

/*
 * Servo NETMF Driver
 *      Coded by Chris Seto August 2010
 *      <chris@chrisseto.com> 
 *      
 * Use this code for whatveer you want. Modify it, redistribute it, I don't care.
 * I do ask that you please keep this header intact, however.
 * If you modfy the driver, please include your contribution below:
 * 
 * Chris Seto: Inital release (1.0)
 * Chris Seto: Netduino port (1.0 -> Netduino branch)
 * Chris Seto: bool pin state fix (1.1 -> Netduino branch)
 * 
 * 
 * */
using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace Servo_API
{
    public class Servo : IDisposable
    {
        /// <summary>
        /// PWM handle
        /// </summary>
        private PWM servo;

        /// <summary>
        /// Timings range
        /// </summary>
        private int[] range = new int[2];

        /// <summary>
        /// Set servo inversion
        /// </summary>
        public bool inverted = false;

        /// <summary>
        /// Create the PWM Channel, set it low and configure timings
        /// </summary>
        /// <param name="pin"></param>
        public Servo(Cpu.PWMChannel channelPin)
        {
            // Init the PWM pin
            servo = new PWM((Cpu.PWMChannel)channelPin, 20000, 1500, PWM.ScaleFactor.Microseconds, false);

            servo.DutyCycle = 0;
            // Typical settings
            range[0] = 1000;
            range[1] = 2000;
        }

        public void Dispose()
        {
            disengage();
            servo.Dispose();
        }

        /// <summary>
        /// Allow the user to set cutom timings
        /// </summary>
        /// <param name="fullLeft"></param>
        /// <param name="fullRight"></param>
        public void setRange(int fullLeft, int fullRight)
        {
            range[1] = fullLeft;
            range[0] = fullRight;
        }

        /// <summary>
        /// Disengage the servo. 
        /// The servo motor will stop trying to maintain an angle
        /// </summary>
        public void disengage()
        {
            // See what the Netduino team say about this... 
            servo.DutyCycle = 0; //SetDutyCycle(0);
        }

        /// <summary>
        /// Set the servo degree
        /// </summary>
        public double Degree
        {
            set
            {
                /// Range checks
                if (value > 180)
                    value = 180;

                if (value < 0)
                    value = 0;

                // Are we inverted?
                if (inverted)
                    value = 180 - value;

                // Set the pulse
                //servo.SetPulse(20000, (uint)map((long)value, 0, 180, range[0], range[1]));
                servo.Duration = (uint)map((long)value, 0, 180, range[0], range[1]);
            }
        }

        /// <summary>
        /// Used internally to map a value of one scale to another
        /// </summary>
        /// <param name="x"></param>
        /// <param name="in_min"></param>
        /// <param name="in_max"></param>
        /// <param name="out_min"></param>
        /// <param name="out_max"></param>
        /// <returns></returns>
        private long map(long x, long in_min, long in_max, long out_min, long out_max)
        {
            return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
        }
    }
}
 Servo servo = new Servo(PWMChannels.PWM_PIN_D5);
 servo.Degree = 30; // Change 'While' to 'For' to limit how many time it repeats
             for (int j = 0; j < 3; j++)
             {
                 for (int i = 0; i <= 180; i++)
                 {
                     servo.Degree = i;
                     Thread.Sleep(10);
                 }


                 for (int i = 180; i >= 0; i--)
                 {
                     servo.Degree = i;
                     Thread.Sleep(10);
                 }
             }
I connecting servo in
3.3v 
gnd 
port 5 digital
 
my servo is:
 
not working!
 
I tried as Chris Walker's book, 
but I realized that everything changed from 4.1 to 4.3 
Thus it greatly hinders learning.

 


Simple design 20x4 LCD I2c -from beginning to end - for beginners:

26 March 2014 - 07:51 PM

the display: 
IIc/I2c/Twi Serial LCD2004 2004 20 * 4 Module Shield Display Blue / White 
 
 
wanted to write a simple "Hello World"
 
I tried to use the library Cet Open Toolbox 
I found it extremely difficult and complex to be able to make a simple text. 
 
/ / draw some text 
             composition.DrawString (
                 "Ciao!" 
                 null, 
                 Brushes.White, 
                 new Point (3, 0) 
                 );
My connections:
 
Display / Netduino
GND     /  GND
VCC     / 3v3
SDA     / SD
SCL      / SC
 
there is nothing that I can write something like?
lcd.write(1,1, "hello word");  //example only

 


My first project - error mscorlib version

26 March 2014 - 11:27 AM

My First project and:

 

Error 1 Cannot deploy the base assembly 'mscorlib', or any of his satellite assemblies, to device - USB:Netduino twice. Assembly 'mscorlib' on the device has version 4.3.1.0, while the program is trying to deploy version 4.3.0.0
 
 
in my visual studio does not appear 4.3.1 only 4.3 framework
Visual studio 2012.
instaled: Netduino SDK v4.3.1 (feb 2014)

LCD in Netduino

25 March 2014 - 07:04 PM

seen in the library of drivers: 
netduinohelpers.codeplex.com
 
But other LCD are not supported then? 
ex: I bought 2 LCD to test with my new Netduino plus 2. 
 
Wholesale 1PC 2.2 Inch 240 * 320 TFT LCD Dots SPI Serial Port Module Display ILI9341 5V/3.3V New Hot 
 
and: 
IIc/I2c/Twi Serial LCD2004 2004 20 * 4 Module Shield Display Blue / White 
 

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.