Referring to this forum thread [url]http://www.tinyclr.com/forum/7/1140/[/url] I am running the IMU sampling and filtering process in a separate thread. My main thread sleeps infinitely after initializing all peripherals and starting the IMU thread. Incoming data from XBee is processed as an interrupt. All these work perfectly while debugging on the USB cable.
However when I tried running the system standalone, powering up with a 5V power source and try running the Artificial Horizon again, it didn’t tilt as what we see on that video clip. Instead it stays there as it wasn’t receiving any signals from XBee at all.
I run X-CTU to see the raw data, and found that all data transmitted is 0, which means the IMU thread wasn’t running at all.
I tried different approaches… Supplying 5v to the 5v pin… Plugging in a 9v battery to the dc jack… Nothing… All other functions work correctly but the IMU thread.
I have absolutely no idea why your program works in debug mode and not in stand alone. Have you tried to just power it from USB without being in debug mode?
But looking at your code I feel there is something wrong.
When pZigBee_DataReceived fires there is some activity on the serial channel but one can not know if it’s a full sentence or just fractions. It can be 100 bytes, it can be 9 bytes but most often it is only 1 byte. As far as i can see you read the buffer and tries to split at ‘\n’ Then if its not a full sentence you discharge the string and the buffer is lost.
@ Gus
I beg to differ, but in your GPS driver you state
_port.Open();// If you open the port after you set the event you will endup with problems
_port.DataReceived += new SerialDataReceivedEventHandler(_port_DataReceived);
So the event handler should be attached after the port i opened.
Maybe in a debug scenario the processing time is so slow that you actually get full sentences with your current setup? I have no idea.
But if your system works in debug mode, but not when just powered from USB i would think it has something to do with the debugger.
I actually run this a couple times, changing PWM pulse widths over Zigbee and reading motor measurements without any problem. So it won’t be the serial. And I do get the data from IMU, sent via zigbee, but it’s just zeroes.
9v …you maybe compunding issues, not sure I’d try doing too much wireless stuff using 9V anymore. what’s your power budget like? 9V 300-600mAH but you will never get anything like that as usable energy.
I’ve been doing some wifi struff on another MCU and binned alot of power ideas in favour of a 2A boost regulator with AA rechargeables 2500mAH much better than some of the other power ideas I had. things work much better.
On threading, in c# .net you need to use an invoke method or the connection blocks…nothing comes through until the connections is dropped if you are lucky. So not sure if that is applicable in netmf.