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.

Shadi

Member Since 09 Jan 2013
Offline Last Active Jul 09 2013 10:30 PM
-----

Posts I've Made

In Topic: MPU 6050 Data are not constant

19 June 2013 - 12:45 AM

Heroduino,

  Pin 12 of the MPU6050 is an Interrupt pin. The MPU6050 will signal when data is ready.

Writing values to 0x38 will control when this interrupt is signaled. The MPU6050 reference sheet contains more information on bitflags in this register.


In Topic: MPU 6050 Data are not constant

30 May 2013 - 09:08 AM

#1 Many of the breakout boards already include pull-up resistors, so you don't need any. This could be the cause of mysterious data errors.

 

#2 the values are signed coming from the MPU6050, so you need to change from uint to short.

 

#3 The MPU6050 has a data ready interrupt pin you need to monitor and then use I2C read.

ipDataReady = new InterruptPort(pinDataReady, false, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeHigh);ipDataReady.OnInterrupt += new NativeEventHandler(ipDataReady_OnInterrupt);...public void SetDataReady(bool enabled){	var trans = new I2CDevice.I2CTransaction[] {		I2CDevice.CreateWriteTransaction(new byte[] { 0x38, enabled ? (byte)0x01 : (byte)0x0 }) // data ready interrupt	};	lock (lockI2C)	{ 		int r = i2cMPU9150.Execute(trans, 100);	}}

In Topic: Troubles with sonar sensors

15 May 2013 - 11:06 PM

The only way you're going to get somewhat accurate measurements is to use an Interrupt and calculate based off the time parameter.

public UltraSoundSensor(Cpu.Pin trigger, Cpu.Pin echo){	this.pinTrigger = new OutputPort(trigger, false);	this.pinEcho = new InterruptPort(echo, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth);	pinEcho.OnInterrupt += new NativeEventHandler(pinEcho_OnInterrupt);				isBusy = false;	LastEchoDelayTicks = 0;	LastEchoDelayMilliSeconds = 0;}
protected void pinEcho_OnInterrupt(uint data1, uint data2, DateTime time){	if (data2 == 0)	{		ticksEndEcho = time.Ticks;		LastEchoDelayTicks = ticksEndEcho - ticksStartEcho;		LastEchoDelayMilliSeconds = LastEchoDelayTicks / TimeSpan.TicksPerMillisecond;		LastEchoDelayMeters = LastEchoDelayMilliSeconds * 0.3432;		isBusy = false;		if (Pong != null)			Pong(LastEchoDelayMeters);	}	else	{		ticksStartEcho = time.Ticks;	}}

This won't be as accurate as baxter's temperature/smoothed version.


In Topic: PWM max freq.

09 May 2013 - 09:55 PM

Using the Microsoft.SPOT.Hardware.PWM class, what happens when you try SetPulse(500, 250)?


In Topic: Increasing the resolution of the system timer

26 April 2013 - 06:05 PM

If you use the InterruptPort class and compare the time parameter on the event with the last event, you can get pulse duration. On the DHT22, I watch for more/less than 500.

 

public const long PulseDurationBarrier = 500;public const int DataLength = 5;public const int BitShiftMax = 7;this.ipSensor = new InterruptPort(IOPin, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth);this.ipSensor.OnInterrupt += new NativeEventHandler(ipSensor_OnInterrupt);void ipSensor_OnInterrupt(uint data1, uint data2, DateTime time){	if (data2 == 0)	{		curPulse.LowTicks = time.Ticks;		if (curPulse.HighTicks > 0)		{			if (curPulse.GetDuration() > PulseDurationBarrier)			{				Data[idxData] |= (byte)(1 << bitData);			}			bitData--;			if (bitData < 0)			{				idxData++;				bitData = BitShiftMax;			}			if (idxData == DataLength)			{				ProcessResults();			}			this.curPulse = new Pulse();		}	}	else	{		curPulse.HighTicks = time.Ticks;	}}

Pulse is just a simple storage structure with LowTicks & HighTicks and a method that returns LowTicks - HighTicks


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.