- Netduino Forums
- → nturpin77's Content
nturpin77's Content
There have been 20 items by nturpin77 (Search limited from 16-May 23)
#24555 Netduino Firmware v4.2.0 RC4 (Netduino + Netduino Plus)
Posted by nturpin77 on 22 February 2012 - 02:02 PM in Beta Firmware and Drivers
#13136 N+ Serial Read Frequency
Posted by nturpin77 on 11 May 2011 - 06:24 PM in Netduino Plus 2 (and Netduino Plus 1)
#13122 N+ Serial Read Frequency
Posted by nturpin77 on 11 May 2011 - 12:45 PM in Netduino Plus 2 (and Netduino Plus 1)
My question of the day is, is there a limit to the frequency that serial read can do. I have an IMU pack that outputs at 20Hz but when I read/log the data to the SD card we get about 1/3 of that. Obviously there is a limit to how fast the N+ can read from the serial UART but I wouldnt have thought it was 20Hz or less. Here is my code that reads/writes. We would like to read as much data as possible from the IMU, we can change the frequency up to 100Hz but 20Hz is as low as it can go.
public static void Main() { SerialPort port1 = new SerialPort("COM1", 57600, Parity.None, 8, StopBits.One); port1.Open(); SerialPort Port2 = new SerialPort("COM2", 115200, Parity.None, 8, StopBits.One); Port2.Open(); OutputPort led = new OutputPort(Pins.ONBOARD_LED, false); FileStream fs = new FileStream("\\SD\\CTAP.txt", FileMode.OpenOrCreate, FileAccess.Write, FileShare.None, 512); StreamWriter sw = new StreamWriter(fs); //int j = 0; double currentTime = 0; double lastTime = 0; //ArrayList accz = new ArrayList(); Stopwatch timing = Stopwatch.StartNew(); while (true) { int GPStoRead = port1.BytesToRead; //start reading the stream if (GPStoRead > 0) { //blink the LED to show we got data led.Write(true); //Thread.Sleep(100); led.Write(false); // get the waiting data byte[] GPSbuffer = new byte[GPStoRead]; port1.Read(GPSbuffer, 0, GPSbuffer.Length); port1.Write(GPSbuffer, 0, GPSbuffer.Length); if (GPSbuffer[0] != 36) continue; String GPSMessage = new String(System.Text.Encoding.UTF8.GetChars(GPSbuffer)); Debug.Print(GPSMessage); sw.Write(GPSMessage); } int CHRtoRead = Port2.BytesToRead; if (CHRtoRead > 37) { int i = 0; //blink the LED to show we got data led.Write(true); //Thread.Sleep(100); led.Write(false); // get the waiting data byte[] CHRbuffer = new byte[CHRtoRead]; byte[] CHRoutput = new byte[20]; //serialPort2.Flush(); Port2.Read(CHRbuffer, 0, CHRbuffer.Length); if (CHRbuffer[i] == 's') { //Print final result i = i + 7; YawVal = (int)((((CHRbuffer[i++] << 8) | CHRbuffer[i++]) << 16) >> 16); String ShowYaw = YawVal.ToString(); YawCalc = YawVal * 0.0109863; String ShowYCalc = YawCalc.ToString("F2"); PitchVal = (int)((((CHRbuffer[i++] << 8) | CHRbuffer[i++]) << 16) >> 16); String ShowPitch = PitchVal.ToString(); PitchCalc = PitchVal * 0.0109863; String ShowPCalc = PitchCalc.ToString("F2"); RollVal = (int)((((CHRbuffer[i++] << 8) | CHRbuffer[i++]) << 16) >> 16); String ShowRoll = RollVal.ToString(); RollCalc = RollVal * 0.0109863; String ShowRCalc = RollCalc.ToString("F2"); string CTAP = "$CTAP,R," + ShowRCalc + ",P," + ShowPCalc + ",Y," + ShowYCalc + "\r\n"; sw.Write(CTAP); CHRoutput = Encoding.UTF8.GetBytes(CTAP); Port2.Write(CHRoutput, 0, CHRoutput.Length); YRateVal = (int)((((CHRbuffer[i++] << 8) | CHRbuffer[i++]) << 16) >> 16); String ShowYRate = YRateVal.ToString(); YRateCalc = YRateVal * 0.0137329; String ShowYRateCalc = YRateCalc.ToString("F2"); PRateVal = (int)((((CHRbuffer[i++] << 8) | CHRbuffer[i++]) << 16) >> 16); String ShowPRate = PRateVal.ToString(); PRateCalc = PRateVal * 0.0137329; String ShowPRateCalc = PRateCalc.ToString("F2"); RRateVal = (int)((((CHRbuffer[i++] << 8) | CHRbuffer[i++]) << 16) >> 16); String ShowRRate = RRateVal.ToString(); RRateCalc = RRateVal * 0.0137329; String ShowRRateCalc = RRateCalc.ToString("F2"); xMagVal = (int)((((CHRbuffer[i++] << 8) | CHRbuffer[i++]) << 16) >> 16); String ShowxMag = xMagVal.ToString(); xMagCalc = xMagVal * 0.061035; String ShowxMagCalc = xMagCalc.ToString("F2"); yMagVal = (int)((((CHRbuffer[i++] << 8) | CHRbuffer[i++]) << 16) >> 16); String ShowyMag = yMagVal.ToString(); yMagCalc = yMagVal * 0.061035; String ShowyMagCalc = yMagCalc.ToString("F2"); zMagVal = (int)((((CHRbuffer[i++] << 8) | CHRbuffer[i++]) << 16) >> 16); String ShowzMag = zMagVal.ToString(); zMagCalc = zMagVal * 0.061035; String ShowzMagCalc = zMagCalc.ToString("F2"); xGyroVal = (int)((((CHRbuffer[i++] << 8) | CHRbuffer[i++]) << 16) >> 16); String ShowxGyro = xGyroVal.ToString(); xGyroCalc = xGyroVal * 0.01812; String ShowxGyroCalc = xGyroCalc.ToString("F2"); yGyroVal = (int)((((CHRbuffer[i++] << 8) | CHRbuffer[i++]) << 16) >> 16); String ShowyGyro = yGyroVal.ToString(); yGyroCalc = yGyroVal * 0.01812; String ShowyGyroCalc = yGyroCalc.ToString("F2"); zGyroVal = (int)((((CHRbuffer[i++] << 8) | CHRbuffer[i++]) << 16) >> 16); String ShowzGyro = zGyroVal.ToString(); zGyroCalc = zGyroVal * 0.01812; String ShowzGyroCalc = zGyroCalc.ToString("F2"); xAccVal = (int)((((CHRbuffer[i++] << 8) | CHRbuffer[i++]) << 16) >> 16); String ShowxAcc = xAccVal.ToString(); xAccCalc = xAccVal * 0.106812; String ShowxAccCalc = xAccCalc.ToString("F2"); yAccVal = (int)((((CHRbuffer[i++] << 8) | CHRbuffer[i++]) << 16) >> 16); String ShowyAcc = yAccVal.ToString(); yAccCalc = yAccVal * 0.106812; String ShowyAccCalc = yAccCalc.ToString("F2"); currentTime = timing.ElapsedMilliseconds; zAccVal = (int)((((CHRbuffer[i++] << 8) | CHRbuffer[i++]) << 16) >> 16); String ShowzAcc = zAccVal.ToString(); zAccCalc = zAccVal * 0.106812; //accz.Add(zAccCalc); String ShowzAccCalc = zAccCalc.ToString("F2"); string CTSens = "$CTSens,Rates,Y," + ShowYRateCalc + ",P," + ShowPRateCalc + ",R," + ShowRRateCalc + ",Mags,X," + ShowxMagCalc + ",Y," + ShowyMagCalc + ",Z," + ShowzMagCalc + ",Gyros,X," + ShowyGyroCalc + ",Y," + ShowxGyroCalc + ",Z," + ShowzGyroCalc + ",Accels,X," + ShowxAccCalc + ",Y," + ShowyAccCalc + ",Z," + ShowzAccCalc + "\r\n"; sw.Write(CTSens); } else { i++; } }
#11759 Elapsed time
Posted by nturpin77 on 07 April 2011 - 10:50 AM in Netduino Plus 2 (and Netduino Plus 1)
#11721 Elapsed time
Posted by nturpin77 on 06 April 2011 - 02:09 PM in Netduino Plus 2 (and Netduino Plus 1)
#11690 Strange Data on SDA/SCL
Posted by nturpin77 on 05 April 2011 - 12:01 PM in Netduino Plus 2 (and Netduino Plus 1)
#11567 Strange Data on SDA/SCL
Posted by nturpin77 on 01 April 2011 - 01:44 PM in Netduino Plus 2 (and Netduino Plus 1)
#11566 Strange Data on SDA/SCL
Posted by nturpin77 on 01 April 2011 - 01:40 PM in Netduino Plus 2 (and Netduino Plus 1)
Attached Files
- i2c.txt 42.9KB 8 downloads
#11564 Strange Data on SDA/SCL
Posted by nturpin77 on 01 April 2011 - 01:12 PM in Netduino Plus 2 (and Netduino Plus 1)
#11563 Strange Data on SDA/SCL
Posted by nturpin77 on 01 April 2011 - 12:41 PM in Netduino Plus 2 (and Netduino Plus 1)
#11561 Strange Data on SDA/SCL
Posted by nturpin77 on 01 April 2011 - 12:04 PM in Netduino Plus 2 (and Netduino Plus 1)
I have my logic analyzer and Im in the process of trying to get used to it. When I run this code I get an error for unhandled exception.
while (true) { new OutputPort(Pins.GPIO_PIN_A4, true); new OutputPort(Pins.GPIO_PIN_A5, true); }
Thats the only code I have in the program and is what I used to light up the LEDs to test the pins originally.
#11181 Strange Data on SDA/SCL
Posted by nturpin77 on 22 March 2011 - 06:04 PM in Netduino Plus 2 (and Netduino Plus 1)
#10816 Strange Data on SDA/SCL
Posted by nturpin77 on 11 March 2011 - 12:56 PM in Netduino Plus 2 (and Netduino Plus 1)
#10384 Strange Data on SDA/SCL
Posted by nturpin77 on 28 February 2011 - 12:28 PM in Netduino Plus 2 (and Netduino Plus 1)
#10330 Strange Data on SDA/SCL
Posted by nturpin77 on 27 February 2011 - 09:25 PM in Netduino Plus 2 (and Netduino Plus 1)
#10201 Strange Data on SDA/SCL
Posted by nturpin77 on 25 February 2011 - 02:55 PM in Netduino Plus 2 (and Netduino Plus 1)
#10194 Strange Data on SDA/SCL
Posted by nturpin77 on 25 February 2011 - 02:02 PM in Netduino Plus 2 (and Netduino Plus 1)
#10192 Strange Data on SDA/SCL
Posted by nturpin77 on 25 February 2011 - 01:45 PM in Netduino Plus 2 (and Netduino Plus 1)
#10181 Strange Data on SDA/SCL
Posted by nturpin77 on 25 February 2011 - 12:47 PM in Netduino Plus 2 (and Netduino Plus 1)
#10079 Strange Data on SDA/SCL
Posted by nturpin77 on 24 February 2011 - 01:18 PM in Netduino Plus 2 (and Netduino Plus 1)
- Netduino Forums
- → nturpin77's Content
- Privacy Policy