Problem reading analog sensors from DL40 DaiyLink with .Net Micro Framework Driver

Notes: I tested the voltage on the DaisyLink 3.3 pin (it is 3.3.09), and the voltage coming from the Light Sensor (usually about 2.7). However, the raw and read methods always return 65535.0, and 1.0, respectively. Any suggestions would be appreciated.

Hardware:
GHI FEZ Cobra II Mainboard
GHI DaisyLink attached to socket 1 (Y socket)
GHI LightSensor (analog sensor)

Software / Firmware:
4.2.11.1 Firmware
NETMF 4.2
DaisyLink 2.42.0.0
Compiled the dotnetwarrior.NetMF.DL40.dll with Micro Framework 4.2

Code:
using dotnetwarrior.NetMF.DL40; //Also added reference to Gadgeteer.DaisyLink assembly

DLIOModule _dlioModule_4 = new DLIOModule(1); //Socket 1

// Using DaisyLink board pin marked P1.4
IAnalogInputPin AD1_4 = _dlioModule_4.CreateAnalogInputPin(AnalogInputPinId.PIO1_4);

double raw = AD1_4.ReadRaw(); //This always returns 65535.0
double read = AD1_4.Read(); //This always returns 1.0

@ rmurphy, Is the Light Sensor at the end of the Daisy link? Does the light sensor work when attached directly to the Cobra?

Thank you for your response.
Only 1 DaisyLink is attached to the Cobra II, and yes the light sensor works both when plugged into a socket on the Cobra II and when attached to pins on the Cobra II. I looks as though for some reason, I am not getting any readings from the DaisyLink. This is the first DaisyLink that I have tried, so I was not certain of the install and configuration. I have also tried the digital input, and always receive True.

Isn’t AnalogInputPinId.PIO1_4 pin 40 on the headers?

@ rmurphy - I will test this over the weekend and lget back to you.

@ rmurphy: did you flashed DL40IO firmware to DL40? New DL40 come with GHI firmware which don’t support most of features added by DL40IO. If you didnt, than you can use tool from Taylorza (https://www.ghielectronics.com/community/codeshare/entry/641).

If you did, try connecting this pin to the ground and try again. If even this wouldnt work, please provide me some test code.

1 Like

I did not apply the DL40IO firmware. I will try it this weekend, and send an update.

Then I’m sure that is the problem.

Sorry, but pretty new to this. Looking at the CerberusDL40Programmer code, and trying to translate it for the Cobra II mainboard (I will be using Socket 5 on the Cobra II since it is the only type U socket). Socket 5 maps to COM1. So, I will change the //UART3 on socket 6 portion of the code from COM3 to COM1. However, I am not certain how to translate the // set up pins to reset board into bootloader mode portion of the code.

  reset = new OutputPort(Cpu.Pin.GPIO_Pin13, true); // Port 6 Pin 6
  loader = new OutputPort((Cpu.Pin)21, true);       // Port 6 Pin 7

I cannot find a pin map for the Cobra II that would allow me to map the SPOT.Hardware.CPU Pins on Socket 5 of the Cobra mainboard to the pins used on the Cerberus. Again, any help would be appreciated.

The socket map is best seen in the Schematic - socket 5 has P0.13 on pin3 and p1.4 on pin6, besides the UART pins 4 and 5. This isn’t usually something a new user would need to go to - the routine that @ Taylorza wrote in a native netmf project not a Gadgeteer project was because the version that uses the Gadgeteer framework uses more memory so isn’t suited to a Cerberus - if you check out https://www.ghielectronics.com/docs/139/opendaisylink you will find the source for that alternate project.

Excellent catch…

Thank you for all of the help. I downloaded the
serial_communication_with_test_daisylink project, and performed the following:

• Replaced the mainboard with the Cobra II in Program.Gadgeteer.
• Replaced the DL40.bin in the Resources folder with the one from
the CerberusDL40Programmer project.
• Deleted all references to the T35 Display in the code.
• Changed the Deployment Device to G120_Gadgeteer
• Updated the following in the Program.cs code for Socket 5 of the Cobra II:

// set up pins to reset board into bootloader mode
reset = new GT.Interfaces.DigitalOutput(Gadgeteer.Socket.GetSocket(5, true, null, null), GT.Socket.Pin.Three, true, null);
loader = new GT.Interfaces.DigitalOutput(Gadgeteer.Socket.GetSocket(5, true, null, null), GT.Socket.Pin.Six, true, null);
serial = new SerialPort(Gadgeteer.Socket.GetSocket(5, true, null, null).SerialPortName, 9600, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
serial.Open();
new Thread(DisplayThread).Start();

However, the application hangs after issuing p.Connect()

Debug.Print(“Beginning chip reflash…”);
loader.Write(false);
Thread.Sleep(100);
reset.Write(false);
Thread.Sleep(100);
reset.Write(true);
Thread.Sleep(400);
NXPFlashLoader.CommunicationInterface com = new SerialPortToNXP(serial);
NXP.Programmer p = new NXP.Programmer(com, NXP.Chips.LPC1111, NXP.Frequency.MHz_72);
uint Xpos = 150;
Debug.Print(“Connecting…”);
p.Connect();
Debug.Print(“Connected!”);
Debug.Print(“Erasing…”);
p.EraseAll();
Debug.Print(“Erased!”);

Again, any help is greatly appreciated.

What is interesting is that I thought, and the docs page says, that the DL module processor is 50mhz, but the constructor you have there says 72mhz. That’s something I’d try changing to see if that’s the problem?

… plus, you did connect the * end ? Just asking the easy ones… while I’m modding this for myself :slight_smile:

ok… Houston, we have a problem.

I don’t know why I told you about pin 3. That was random of me :slight_smile: The DL programming needs pins 6 and 7.

By definition, the U socket doesn’t have to have pin 7.

On the Cobra 2, Socket 5 doesn’t have a pin 7.

So do you have an extender module, or a pair of them? If so, you can connect it through some hoops - you need to jumper from pin3 on the mainboard side of the connection to Pin 7 on the outboard side. Just doing that and testing…

Yes, that works. I added this:


to the frequency enum in nxp.cs, and jumpered pin 3 to pin 7, and it worked first time.

So you can achieve this a couple of ways. You will unfortunately need an extender or breakout module. If you have only one module, or only a breakout module, then you need to move away from using the Socket5 method, and just jumper the necessary pins from the edge connector to the extender/breakout, and then connect them to pins 4/5/6/7 (TX is 4, RX is 5).  If you have two extender modules, you can just make a really long chain from Socket 5 and jumper the pin3/pin7 thing as I suggested earlier (this is what I did)

@ Jeff@ GHI, looks like it's time to update the daisylink module documentation about needing a U socket !

What I also found interesting was that @ Taylorza had added a 168Mhz enum to the NXP programmer, and was using that.  I wonder if he's overclocked it or if he knows something more than I could piece together (I know he knows more than me - everyone knows it too I'm sure :) )

Brett. Thank you for all of the help. I did use extenders to bring pins 3 and 6 from socket 5 to 6 and 7 on the DL40 (sorry I didnt put that in the reply). However, I did not have the ribbon cable plugged into the * socket on the DL40. After changing the code to 50 MHz, and plugging into the * socket, it completed!

OK. Got it flashed. I used the DL40.bin file from the Cerberus project’s resource folder (dated 1/23/2013 7:40 PM). After flashing, I plugged the X/Y port on the DL40 into socket 4 of the mainboard (X), and changed the code to reflect socket 4. Plugged the GHI light sensor into an extender. Connected P1.4 on the DL40 to pin 3 on the extender (also connected +3.3 and gnd). Still have the same problem with readings as stated in the original post.

@ rmurphy: I’m sure that DL40.bin from Cerberus folder is too old. Please try ting bin from here: https://www.ghielectronics.com/community/codeshare/entry/633

Sorry to make so much troubles.

@ rmurphy, Can you send us a pic of your hookup?