- Netduino Forums
- → bill.french's Content
bill.french's Content
There have been 260 items by bill.french (Search limited from 01-July 23)
#7305 Reading temperature from DS18B20 using OneWire
Posted by bill.french on 09 January 2011 - 02:35 AM in Netduino 2 (and Netduino 1)
#7876 Basic question about managing classes
Posted by bill.french on 19 January 2011 - 12:26 AM in Visual Studio
#3772 Features of NetDuino
Posted by bill.french on 11 October 2010 - 06:09 PM in General Discussion
Full disclosure: I'm listed as a contributor to the Screwturn project, but my contributions were more by accident than intentional...
#8469 Noob Motor Shield questions
Posted by bill.french on 26 January 2011 - 04:22 PM in Netduino 2 (and Netduino 1)
#7906 Basic question about managing classes
Posted by bill.french on 19 January 2011 - 12:58 PM in Visual Studio
#5984 AnalogInput hardware error
Posted by bill.french on 11 December 2010 - 02:11 AM in General Discussion
Maybe try something like this:
instead of:
AnalogInput analogPin = new AnalogInput(inputPin);try:
using(AnalogIntput analogPin = new AnalogInput(inputPin)) { ...your other code... }
... but then again analog input might not be idisposable, so this might not help.
I'm about to jump onto my other computer and can try it out myself.
#5986 AnalogInput hardware error
Posted by bill.french on 11 December 2010 - 03:52 AM in General Discussion
public static double ReadLM34(Cpu.Pin inputPin) { // Reads an LM34 analog temperature sensor several times and converts the // Code example for potentiometer at: // http://forums.netduino.com/index.php?/topic/638-basic-analog-input-circuit-and-program/ int vRef = 3300; // 3300 mV, or 3.3V int readingTot = 0; // Summed total of the iterations int numReads = 10; // Number of times to take a reading double tempF = 0.0; // AnalogInput analogPin = new AnalogInput(inputPin); // Take a number of readings and average them together to get the final // temperature calculation for (int i = 0; i < numReads; i++) { readingTot += analogPin.Read(); } tempF = (readingTot / numReads) / 1024 * vRef / 10; analogPin.Dispose(); return tempF; }
#5962 Reading temperature from DS18B20 using OneWire
Posted by bill.french on 10 December 2010 - 03:14 AM in Netduino 2 (and Netduino 1)
The DS18B20 is really awesome, seems very accurate and very responsive. Considering my struggles getting reliable readings from a thermistor, I am finally .
Here is my temperature reading code, and attached is a class I wrote to interface with the OneWire controller, in case someone finds it useful.
using System; using System.IO.Ports; using System.Text; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using PHAOneWire; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.Netduino; namespace SerialTest1 { public class Program { public static void Main() { int Tc, Tf; using (OneWire ow = new OneWire()) { while (true) { ow.Write("P0W0ccS044"); Thread.Sleep(1000); // need to wait for conversion ow.Write("P0W0ccW0be"); byte low = ow.ReadByte(); byte high = ow.ReadByte(); // it's dealing with temps as integers, for instance, 23.5F comes back 235000 // since it's 12bits of precision, the smallest difference in temp is .0625 Tc = ((high * 256 + low) * 10000) / 16; Tf = ((Tc * 18) / 10) + 320000; Debug.Print(Tf.ToString() + " - " + Tc.ToString()); Thread.Sleep(10); } } } } }
Attached Files
- PHAOneWire.cs 1.78KB 547 downloads
#5982 AnalogInput hardware error
Posted by bill.french on 11 December 2010 - 01:58 AM in General Discussion
#5867 Stepper Motor Control?
Posted by bill.french on 07 December 2010 - 06:04 PM in Netduino 2 (and Netduino 1)
#5659 Pre-Assembled Kits
Posted by bill.french on 02 December 2010 - 07:26 PM in General Discussion
#5875 Stepper Motor Control?
Posted by bill.french on 07 December 2010 - 07:57 PM in Netduino 2 (and Netduino 1)
#8806 Was: Netduino Firmware v4.1.0 (update 6) RC 1
Posted by bill.french on 01 February 2011 - 01:26 PM in Beta Firmware and Drivers
#8919 4Display Shields - Drivers
Posted by bill.french on 02 February 2011 - 11:26 PM in Project Showcase
#8890 4Display Shields - Drivers
Posted by bill.french on 02 February 2011 - 04:38 PM in Project Showcase
http://forums.netdui...ch__1#entry7992
http://forums.netdui...ch__1#entry7521
using System; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.NetduinoPlus; using System.IO.Ports; namespace uLCD_144_Test1 { class uLCD_144 { private byte currentline; public static byte[] GetByteArray(string s) { return System.Text.Encoding.UTF8.GetBytes(s); } public SerialPort _COMPORT; public void TextHome() { currentline = 0; } public void init() { using (OutputPort d4 = new OutputPort(Pins.GPIO_PIN_A5, true)) { d4.Write(false); d4.Write(true); } currentline = 0; Thread.Sleep(2000); _COMPORT.DiscardInBuffer(); _COMPORT.DiscardOutBuffer(); this.write(new byte[] { (byte)0x55 }); WaitForACK(); TextMode(false); } public void WaitForACK(string note = "") { while (_COMPORT.BytesToWrite > 0) { } while (_COMPORT.BytesToRead == 0) { } dumpbuffer(note); } public void CopyPaste(byte startx, byte starty, byte endx, byte endy, byte width, byte height) { write((byte)0x63); write(startx); write(starty); write(endx); write(endy); write(width); write(height); WaitForACK(); dumpbuffer("CopyPaste"); } public void TextMode(bool transparent = false) { if (transparent) { write((byte)0x4f); write((byte)0x00); } else { write((byte)0x4f); write((byte)0x01); } WaitForACK(); dumpbuffer("TextMode"); } public void Print(string s) { if (currentline > 15) { CopyPaste(0, 8, 0, 0, 128, 119); currentline = 15; //DrawASCIIString(" ", (ushort)0xFFFF, (byte)0, (byte)0, (byte)currentline); } //DrawASCIIString(" ", (ushort)0xFFFF, (byte)0, (byte)0, (byte)currentline); dumpbuffer("print-cl"); DrawASCIIString(s, (ushort)0xFFFF, (byte)0, (byte)0, (byte)currentline); currentline += (byte)(s.Length / 21 + 1); dumpbuffer("print"); } public void DrawASCIIString(string s, ushort color = (ushort)0xffff, byte font = 0, byte x = 0, byte y = 0) //2.3.6 Draw “String” of ASCII Text (text format) - 73hex //Command cmd, column, row, font, stringColour(msb:lsb), “string”, terminator { byte[] textba = GetByteArray(s); write((byte)0x73); write(x); write(y); write(font); write((byte)(color >> 8)); write((byte)(color & 0x00FF)); write(textba); write((byte)0x00); WaitForACK(); } public void clear() { currentline = 0; write((byte)0x45); WaitForACK(); dumpbuffer("Clear"); } public void DrawPixel(byte x, byte y, ushort color = 0xFFFF) { this.write(0x50); this.write(x); this.write(y); this.write(color); WaitForACK("Draw Pixel"); } public void drawbitmap(byte[] bmp) { //2.2.5 Draw Image-Icon - 49hex //Command cmd, x, y, width, height, colourMode, pixel1, .. pixelN byte[] cmd = new byte[] { (byte)0x49, (byte)0x00, (byte)0x2A, (byte)0x80, (byte)0x28, (byte)0x08 }; this.write(cmd); this.write(bmp); WaitForACK(); } public void write(byte B) { byte[] ba = new byte[1]; ba[0] = b; this.write(ba); } public void write(byte[] ba) { if (this._COMPORT.IsOpen) { this._COMPORT.Write(ba, 0, ba.Length); //int sleeptime = (ba.Length / 7) + 1; //(calculate transmission time, at 115200, it can send 14 bytes / mx //Debug.Print(sleeptime.ToString()); //if (pause) //{ ///Thread.Sleep(sleeptime); //} } else { } } public void write(ushort us) { write((byte)(us >> 8)); write((byte)(us & 0x00FF)); } public void dumpbuffer(string note = "") { //_COMPORT. Debug.Print("(" + note + ") In buffer: " + _COMPORT.BytesToRead.ToString()); while (_COMPORT.BytesToRead > 0) { byte[] buffer = new byte[1]; _COMPORT.Read(buffer, 0, 1); Debug.Print(buffer[0].ToString()); } } public uLCD_144(string sp = SerialPorts.COM1) { this._COMPORT = new SerialPort(sp, 115200); this._COMPORT.Open(); this.init(); } } }
#7336 Connecting an analog joystick to a netduino
Posted by bill.french on 09 January 2011 - 01:25 PM in Project Showcase
#6572 Visual Studio dies after deploy
Posted by bill.french on 27 December 2010 - 02:21 PM in Visual Studio
#7787 Fluent Interop 1.2
Posted by bill.french on 17 January 2011 - 01:19 AM in Project Showcase
#7804 Fluent Interop 1.2
Posted by bill.french on 17 January 2011 - 06:12 AM in Project Showcase
It certainly looks more responsive compared to your previous attempt, but what do you think?
#6361 my netduino made me a steak
Posted by bill.french on 22 December 2010 - 05:20 AM in Project Showcase
#7097 Suggested socket for a neduino mini?
Posted by bill.french on 05 January 2011 - 10:55 PM in Netduino Mini
#7513 Little Hydraulic Arm
Posted by bill.french on 12 January 2011 - 02:21 PM in General Discussion
#7866 IR Transmitter?
Posted by bill.french on 18 January 2011 - 06:54 PM in General Discussion
#7865 IR Transmitter?
Posted by bill.french on 18 January 2011 - 06:51 PM in General Discussion
#8554 Analog Read
Posted by bill.french on 27 January 2011 - 01:39 PM in Netduino 2 (and Netduino 1)
http://www.sparkfun.com/products/8883
- Netduino Forums
- → bill.french's Content
- Privacy Policy