Analog Input Cerbuino Bee vs. Arduino

I am working with an analog shield that was designed for Arduino and am trying to port the Arduino sketch to .NETMF to run on a Cerbuino Bee. On the Arduino I can see data flowing for 6 independent channels that are mapped to the High and Low Bytes for each channel (6 Analog Channels). On the Arduino I am getting consistent and repeatable results.

On the Cerbuino, I am reading data from FEZCerbuinoBee.Pins.A0_AnalogChannel through FEZCerbuinoBee.Pins.A5_AnalogChannel and two of the channels A3 and A4 appear to not be used. The data coming off these channels on the Cerbuino Bee is very different than the data coming from the Arduino channels using the same shield.

Just to see if the data looked different, I then use Microsoft Spot Hardware to read AnalogInput(Cpu.AnalogChannel.ANALOG_0) through ANALOG_7. In this case Analog_4, Analog_5, and Analog_6 are not used or at least I got an error on them. Nothing else is attached to the board so I am assuming that these channels are just not used. The data using the Microsoft Spot library vs. the data using the GHI library is consistently different and they both are different from the Arduino.

I am completely confused. Even if the data is being routed through a multiplexer (not sure) shouldn’t it at least match? I can’t find an accurate or at least recent pin mapping of the Cerbuino board but shouldn’t the Arduino pins A0-A5 map 1 to 1 to the Arduino pins on my shield and then enable me to reference them exactly the same as I do on the Arduino Uno? Also, not sure what to make of the 6 channels on the Arduino all working and then on Cerbuino only getting data on 4 channels using the GHI library and 5 using Microsoft Spot.

I seem to be running in circles now. Any advice on how to do this would be awesome.

what shield ?

Looking at the schematic the pins are labelled ADC12_INx where x = 9, 5, 8, 13, 11, 4.

Looking at GHI.Pins (in SDK 2015 R1), you can also access them via

hope that helps.

Thank you for the reply. The board I am using is an Olimex EKG/EMG shield. I am running 4.3 with 2014 R3, but I was able to successfully get to the Analog Channels and Pins. The other issues are the main challenge. I can’t figure out why the mapping to the shield is so different between the Arduino and the Cerbuino.

There seems to be things going on within the Cerbuino board that are not in the Arduino. I am guessing that there is a multiplexer on the Cerbuino that is somehow combining Pins/Channels in a way that is not happening on the Arduino. I have data hitting my receiving application, I just can’t figure out what the data equates to.

Might this help?

you mention “not getting data”. That to me means you’re not using the right channels. Use the GHI.Pins definitions and see if that changes the data you see.

Yes there is a multiplexer involved at the processor. Make sure you do not provide more than 3v3 into the analog pins or you’ll damage the multiplexer. Otherwise, most micros will use the same method, have one ADC that has a multiplexer in front of it.

To further diagnose, I’d step away from the shield for a moment and use your 3v3 power supply and a 1.5v battery for testing. When you connect the A0 (or whichever) pin to GND or to 3v3, you should be able to see that clearly as each end of the scaled value. Then connect the 1.5v battery and you’ll see something less than half that value. If you see nothing in any of these tests, something strange is going on…

Sorry, maybe I wasn’t clear. I am getting data just not on all of the analog channels. It is confusing because it is not a 1 to 1 match with the data coming off of the Arduino. I am getting data on Analog 0 - 5 on Arduino but not on Cerbuino. Analog 3 and 4 on the Cerbuino throw an error with a null reference exception so I am assuming that this is because the Channels are unused. The data values are also much higher than what I see coming off of the Arduino. So, I am assuming that there is some kind of combining of channels within the board somewhere but no way to confirm. The shield is simply a signal amplifier with no active power supply. There is some basic noise filtering at 60hz but not much else happening on the board. Below is a random sample of the data coming off of the board when mounted to the Cerbuino. Since this is an EKG, the channel 0 and channel 5 data seem far too high to be coming from an individual channel.

Channel 0: 618
Channel 1: 309
Channel 2: 312
Channel 5: 594

null reference is not “unused”. Unused (assuming connected to a low level) should return 0 or close to. What pin definition are you using when you get a null reference ? I would expect that this error really means the channel you’re selecting is not programmed in the firmware, meaning it’s not wired to a header anywhere…

Voltage: check the shield uses 3v3 or 5v; from it seems you can select which one to use - make sure you use 3v3 !

Also note, there is no AREF on the cerbuino, make sure you don’t have that jumper connected.

@ slrbatman - How many analog input channels do you need and for what? For one Olimex ECG Module only one analog input is needed und it can be selected with the jumper to which analog input of the Mainboard the signal is proceeded. Do you want to use more than one ECG Module? Which Sockets of the Cerbuino Bee do you want to use for other Gadgeteer Modules?

Hi Ro,

I am only using the Olimex shield and a button module on socket one. Nothing else is attached to the board. I am getting a reading on Analog Channels 1, 2, 3, 4, 5, and 7. However all the values are high and they don’t seem to change much. There definitely is no change with motion when I have the electrodes on. On a normal ECG, the heart rate values will spike when the wearer moves an arm or leg because the heart rate goes up. This does not happen when I am testing with the Olimex ECG which seems to indicate that I am not getting a heart rate at all. When wearing the same electrodes with exactly the same activity with the Arduino it behaves as expected.

My main issue is still that I am not sure which Analog Channel is actually passing the ECG data. I just looked at the example app that you wrote in July and what I am seeing does not match what you have there. I am getting data on all Analog Channels except 6. Channels 1 and 2 are returning a signal where it looks like they did not for you. How did you figure out which channel to pull the raw data from or did you just pick one? If so, how do you know that it is actually returning real ECG data and not just random electrical noise?

@ slrbatman - Do you have a way of verifying the voltages? A True RMS multimeter perhaps?

According to the schematic, and Roschmi’s explanation above, you need to put a jumper on to connect the output data onto a specific pin. How have you got the jumper set right now ?

@ slrbatman -
Hi, on the picture you can see the jumper positions I used.

Here are snippets from the code:

private AnalogInput Sensor_5;
Sensor_5 = new AnalogInput(Cpu.AnalogChannel.ANALOG_5);
Int Sensor_Raw_Reading = Sensor_5.ReadRaw();

I did have my jumpers set differently. After changing them to match yours, I am still getting data on all analog channels except 6 and the data values are very high. Below I have pasted a random sampling of what is coming off of the channels:

ECG Channel 0: 1013
ECG Channel 1: 1101
ECG Channel 2: 1164
ECG Channel 3: 1149
ECG Channel 4: 1156
ECG Channel 5: 1020
ECG Channel 7: 1007
ECG Channel 0: 1018
ECG Channel 1: 1104
ECG Channel 2: 1148
ECG Channel 3: 1173
ECG Channel 4: 1131
ECG Channel 5: 1017
ECG Channel 7: 1007
ECG Channel 0: 1025
ECG Channel 1: 1078
ECG Channel 2: 1152
ECG Channel 3: 1139
ECG Channel 4: 1141
ECG Channel 5: 1015
ECG Channel 7: 1001
ECG Channel 0: 1017
ECG Channel 1: 1095
ECG Channel 2: 1143
ECG Channel 3: 1173
ECG Channel 4: 1163
ECG Channel 5: 1028
ECG Channel 7: 986
ECG Channel 0: 1036
ECG Channel 1: 1087
ECG Channel 2: 1163
ECG Channel 3: 1150
ECG Channel 4: 1177
ECG Channel 5: 1036
ECG Channel 7: 993

The code is as follows:

            analogChannel0 = new AnalogInput(Cpu.AnalogChannel.ANALOG_0);
            analogChannel1 = new AnalogInput(Cpu.AnalogChannel.ANALOG_1);
            analogChannel2 = new AnalogInput(Cpu.AnalogChannel.ANALOG_2);
            analogChannel3 = new AnalogInput(Cpu.AnalogChannel.ANALOG_3);
            analogChannel4 = new AnalogInput(Cpu.AnalogChannel.ANALOG_4);
            analogChannel5 = new AnalogInput(Cpu.AnalogChannel.ANALOG_5);
            //analogChannel6 = new AnalogInput(Cpu.AnalogChannel.ANALOG_6);
            analogChannel7 = new AnalogInput(Cpu.AnalogChannel.ANALOG_7);

                channel0RawData = analogChannel0.ReadRaw();
                Debug.Print("ECG Channel 0: " + channel0RawData.ToString());

                channel1RawData = analogChannel1.ReadRaw();
                Debug.Print("ECG Channel 1: " + channel1RawData.ToString());

                channel2RawData = analogChannel2.ReadRaw();
                Debug.Print("ECG Channel 2: " + channel2RawData.ToString());

                channel3RawData = analogChannel3.ReadRaw();
                Debug.Print("ECG Channel 3: " + channel3RawData.ToString());

                channel4RawData = analogChannel4.ReadRaw();
                Debug.Print("ECG Channel 4: " + channel4RawData.ToString());

                channel5RawData = analogChannel5.ReadRaw();
                Debug.Print("ECG Channel 5: " + channel5RawData.ToString());

                //channel6RawData = analogChannel6.ReadRaw();
                //Debug.Print("ECG Channel 6: " + channel6RawData.ToString());

                channel7RawData = analogChannel7.ReadRaw();
                Debug.Print("ECG Channel 7: " + channel7RawData.ToString());

Here is a photo of my board and the jumper settings. (Hmmm, photo doesn’t show up in preview, not sure if it will show up in actual post. If it doesn’t I can email it to you). Thanks for the help!!

@ slrbatman -
I would now test if the analog Input of the Cerbuino works. Connect A5 with a Resistor (between 1000 Ohm and 10.000 Ohm) with the 3.3 Volt line of the board and intermittently connect the A5 Input with GND. You should see that your Programm reads intermittently either 0 or a high value.

Yes, working great. A question about the channel mapping. If I have the jumper on the Olimex board set to Channel 1 shouldn’t that enable Analog Channel 0 on the Cerbuino and pass the data through that Channel?

@ slrbatman -
yes, it should. In doubt it’s sometimes better to test if it is really connected on the board, may be it’s only connected on the paper.