University project - Electronic Stethoscope

Make sure you have latest SDK and firmware installed.

I have the latest SDK, and tiny CLR tells me that my device firmware is “solutionVersion: 4.2.0.1”, which i believe to be the newest?

ok ill try that now, thanks for the speedy feedback guys, its great!

Success! of sorts anyway, having updated my cerbuino bee realtime debuggin of values works to an extent, BUT the message “An unhandled exception of type ‘System.Exception’ occurred in Microsoft.SPOT.Hardware.dll” does pop up intermittently, which interrupts the real time analysis! what do you think is the source of this remaining issue?

Depends on where the exception occurs.

well, im finding it hard to identify where this occurs, you see its during the continuous loop that this error pops up. These are the associated messages however

A first chance exception of type 'System.Exception' occurred in Microsoft.SPOT.Hardware.dll
0.052258852258852261
An unhandled exception of type 'System.Exception' occurred in Microsoft.SPOT.Hardware.dll

Same code you have posted earlier?

yes the same. Having played with it a while, i think its because the output exceeds acceptable format? if I change analogin line to anything but the default accuracy in bits, say 3 for example, I get “An unhandled exception of type ‘System.Exception’ occurred in Microsoft.SPOT.Hardware.dll”. Could it be that the floating wire i currently have on the cerbuino sometimes exceeds the acceptable threshold?

could anyone point me in the right direction with regards to the error message “An unhandled exception of type ‘System.Exception’ occurred in Microsoft.SPOT.Hardware.dll”, its somewhat hindering my progress. On the plus side however, by pasting the data into excel and plotting an fft i notice a very distinct spike that can only be the heartbeat!

On the downside, it would be ideal to have this done for me in a windows form application/matlab import, but i may be biting off more than i can chew there :slight_smile:

Also, is it possible to create a windows form within a net-framework console application? having read the output it would be ideal to have the FFT take place in visual studio, right now I have to paste the values from the debug window into excel and computer the fft in excel!

failing a form, does anyone have any suggestions as to how I can have the output waveform displayed in visual studio?

You can have a stand alone windows form application that will read the values from serial port. Your netmf device can stream the data to a serial port.

In order to stream the values, do i need to run a netframework console application alongside a windows from application? Or is the data streamed from within the windows form?

Of course you do! Your console application on netmf device takes the measurements and streams them into a serial port.

You will also need Serial-USB module:
http://www.ghielectronics.com/catalog/product/287

Ah I see! well it just so happens I own a serial to USB module, my supervisor provided me with one! perhaps anticipating this!

I actually have a working windows form application that computes an fft I can adapt to me needs, Could you point me towards how i might go about streaming the serial data?

@ ks09aao - Check this codeshare:

http://www.tinyclr.com/codeshare/entry/517

It shows how to write data to/from serial port on netmf device and in Windows form application. You will need something similar.

Hi guys!
Im currently trying to get the FEZ to read analog values and send them to the virtual com port I have setup using a gadgeteer module.

The error im getting is that it cannot convert microsoft.spot.hardware to the type “byte”. Ive tried using “setlinearscale” but it doesnt seem to work for me, could someone point me in the right direction as to why?

using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;
using GHIElectronics.Gadgeteer;
using Microsoft.SPOT.Hardware;
using GHI.OSHW.Hardware;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;

namespace commmmmmmmmmmm
{
    public partial class Program
    {
        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {

            usbSerial.Configure(115200,
                    GT.Interfaces.Serial.SerialParity.None,
                    GT.Interfaces.Serial.SerialStopBits.One,
                    8);
            usbSerial.SerialLine.Open();
        }

            void SerialLine_DataReceived(GT.Interfaces.Serial sender, System.IO.Ports.SerialData data)
{

    AnalogInput lightSensor = new AnalogInput(FEZCerbuino.Pin.AnalogIn.A1);
    lightSensor.Scale(0, 100);

                int NumberOfBytesToRead = usbSerial.SerialLine.BytesToRead;
                byte[] readInputBuffer = new byte[NumberOfBytesToRead];
                usbSerial.SerialLine.Read(lightSensor, 0, NumberOfBytesToRead);
                usbSerial.SerialLine.Write(readInputBuffer);
                
   
   
                usbSerial.SerialLine.Close();
}

            
           
        }
    }



You need a separate read for the analog port. http://wiki.tinyclr.com/index.php?title=Analog_Inputs

The code posted waits for some serial data to be received and then it takes an analog reading. Is that what you want to happen.

After doing the read, you close the serial port. This means the data received event will never happen again.

You should create the analog input object in the ProgramStarted method, and not every time you want to do a read.

Not sure why you have the data received event, since you are only sending data.

When do you want to read the analog value? You need a trigger. When the trigger occurs, you can read the data,
and then format the value into a format for sending via the serial port.

Id like a continuous stream of data, the reading from the analog port to be continuously fed to the serial USB interface, the remaining data processing will be done in a windows form application

I’ve tidied the program up as you suggested, many thanks! I don’t think i’m using the usbserial command properly, how would I tell the cerbuino to stream the analog pin data through the com port?

using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;
using GHIElectronics.Gadgeteer;
using Microsoft.SPOT.Hardware;
using GHI.OSHW.Hardware;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;

namespace commmmmmmmmmmm
{
    public partial class Program
    {
        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            AnalogInput lightSensor = new AnalogInput(FEZCerbuino.Pin.AnalogIn.A1);
            double lightSensorReading = 0;
            usbSerial.Configure(115200,
                    GT.Interfaces.Serial.SerialParity.None,
                    GT.Interfaces.Serial.SerialStopBits.One,
                    8);
            usbSerial.SerialLine.Open();
        }
        

              
        void SerialLine_DataReceived(GT.Interfaces.Serial sender, System.IO.Ports.SerialData data)
{
                int NumberOfBytesToRead = usbSerial.SerialLine.BytesToRead;
                byte[] readInputBuffer = new byte[NumberOfBytesToRead];
                usbSerial.SerialLine.Write(readInputBuffer);
  
}

            
           
        }
    }