Project - DL40 - I/O Module Firmware

I use it, but it’s so good I didn’t have to ask any questions :). I think there more ppl like me that download it, use it and go back to their own project. I like your firmware very much, I use it all the time now to make my proto’s.

Found 1 typo in your C# tho. In the UnregisterPin method of the DLIOModule I think the 2 !xxx.Contains are cut-copied from the RegisterPin method but they should be xxx.Contains (without the not). Second I saw your Create’X’Pin are returning IDisposable objects, so I would prefer also the IDisposable interface on your interfaces. So we can use the C# using() statement, without having to rely on the GC or try/finally. I know this is a personal preference.

Added a picture (early stage) of my current project, using your firmware. I agree we should offload as much as we can, to free up the ‘mainboard’. DL40 - I/O is perfect for that.

@ Terok Raes - Welcome to the forums and thank you for the feedback.

The two things you pointed out are excellent catches. I fixed the two issues you identified in the UnregisterPin. The point on IDisposable is a very good point, I don’t know what I was thinking, but now thanks to your feedback it is much better.

Fixes committed on codeplex:
https://dl40io.codeplex.com/SourceControl/changeset/27876

@ taylorza: I also check that code and I thing there is UnregisterPin is still very strange. I think _interruptPins and _pinRegister are swiched. If you remove Interrupt port, cahce should be update.


      if (_interruptPins.Contains(pin.Id))
      {
        _interruptPins.Remove(pin.Id);
        _interruptPins.Values.CopyTo(_interruptPinCache, 0);
        _interruptPinCount--;
      }

      if (_pinRegister.Contains(pin.Id))
      {
        _pinRegister.Remove(pin.Id);
      }

@ jernejk - Thanks, you are correct. I committed the fix.

@ taylorza @ jernejk : thanks, downloaded it and works like a charm

@ Terok Raes - Excellent, glad to hear that. Please let me know if you have any other suggestions or find any issues.

Chris, can you check the post on the PulseInOut module https://www.ghielectronics.com/community/forum/topic?id=12867&page=1#msg130937 and see if there’s any reason this DL40 firmware wouldn’t work ?

@ Brett - Thanks for drawing my attention to this post.

Unfortunately the DL40 I/O firmware will not work without a minor modification. The modules have minor differences in the pins mapped to the Gadgeteer sockets. For example, the downstream socket uses pin 1.2 on the DL40 while the Pulse I/O use pin 3.5 for the downstream signal line.

I made the Switch Adapter for DL40 I/O module with taylorzas firmware, as I wrote earlier in my post https://www.ghielectronics.com/community/forum/topic?id=12728&page=2#msg129711.

The Switch Adapter can be useful if you need to distinguish long press from short press or if you need to react for a long press. Switch Adapter can be found here: https://www.ghielectronics.com/community/codeshare/entry/778

Has anyone taken a DL40 or the LPC1113F and built a stand-alone module, based on the DL40/DL40IO codebase? I did my first successful compile of the firmware yesterday and before I got too excited and took a stab at it myself, I thought I’d ask first :slight_smile:

I’m not looking at hugely complex setup/code, just simple “blink LED, read buttons” stuff.

@ Brett, I have a plan to build a gadgeteer module based on DL40. But I’m very busy at my day job at the moment.
I also looked to buy stand-alone LPC1113F but I couldnt file and good deal for very small volume (processing fee or postage is 5 times of processors value). Any idea where to get it?

@ andre.m, I checked future electronics. 10 LPC1113F are $14.60, the cheapest postage is $58.63 so $73.23 altogether. And this is too much for me. Very similar story also at Mouser and similar.

But thank you for your help.

Element14 for me has a “local” representation, and I can buy the LPC1113 in 1’s for AU$2.41, or AU$2.03 for 10.
http://au.element14.com/nxp/lpc1113fbd48-302-1/mcu-32bit-cortex-m0-48lqfp/dp/2072186

If my order is $30 or more, shipping is free. My cart, that I’ve been sitting on for a long time, has a couple of hundred dollars worth of stuff there, so when I wanted to buy them I’d expect the postage to not be a problem.

I’m not sure where you’re based, but you should have someone who has similar pricing?

No bites so far huh :wink:

Hello,

I have a project where I use a few of the input pins of the DL40 to sense that a coin rolled by a certain place inside the device I’m building. The coin acts like a switch, when it rolls by, it connects two wires which is registered by the DL40. One wires goes to an input pin of the chip (which uses the internal pull-up resistor) and the other wire connects to GND.

There are 7 such places where coins can roll by, so I use 7 interrupt pins to sense these events.

The library works very well in most cases and I get notified about coins rolling by. However sometimes, I receive multiple interrupts on different pins although only one pin should actually be affected. It is possible that the interrupts occur on a pin of a different port (along with an interrupt on the correct port). I can’t make much sense of that.

When I use a jumper cable to simulate the rolling by of a coin by driving the pin low manually, this never happens. It does seem like this only happens on a very “glitchy switch”. Since in fact, the coin is a very glitchy switch which just connects two wires in a very loose way for a very short time, I can imagine that could be an issue.

Could there be a firmware issue which somehow messes up on book-keeping which pin got triggered? Or do I need to change my hardware design?

Thanks for any help

@ tybghi - I would check MCU datasheet, in case there is some interrupt channel sharing between pins on different ports. May be will try to use external pull-up as well.

@ tybghi - just to confirm, are you using the latest firmware from codeplex? How are you initializing the interrupt pins, for example are you configuring a pull up/down resistor, what glitch timeou are you using etc.

I downloaded the binaries from https://www.ghielectronics.com/community/codeshare/entry/633 (Version 13) since I did not see any binaries on codeplex. I looked at the source code but it seemed okay to me.

The interference happens even between ports which is weird. And also, the faster I roll the coin through the “gate”, the more other interrupts I get. I can solve any glitch issue on a single port by increasing the glitch timer, but when interrupts start to leak to other pins, I can’t solve it via software.

I talked to an electrical engineer and he figured it could be an EMC issue, he figured maybe it is some high frequency noise being generated and said perhaps I should try to put in a capacitor. I only had a 10uF capacitor, which I tried, but did not help.

The code looks like this:

this.module = new DLIOModule(4);

this.interruptPin1 = this.module.CreateInterruptPin(2, 0, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow, 100);
this.interruptPin1.Interrupt += this.interruptPin_Interrupt_1;

this.interruptPin2 = this.module.CreateInterruptPin(3, 1, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow, 100);
this.interruptPin2.Interrupt += this.interruptPin_Interrupt_2;

this.interruptPin3 = this.module.CreateInterruptPin(2, 7, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow, 100);
this.interruptPin3.Interrupt += this.interruptPin_Interrupt_3;

this.interruptPin4 = this.module.CreateInterruptPin(2, 5, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow, 100);
this.interruptPin4.Interrupt += this.interruptPin_Interrupt_4;

this.interruptPin5 = this.module.CreateInterruptPin(0, 7, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow, 100);
this.interruptPin5.Interrupt += this.interruptPin_Interrupt_5;
(more similar code follows...)

As you can see, I soldered the wires to completely random external pins on various ports in order to minimize issues, but also that did not seem to help. I tried different values for the glitch timer, too.

The “gate” where the coin falls through is made of two aluminum foils from the kitchen (DIY style). They’re soldered to two wires, and one is connected to an interrupt pin and the other to GND.

I might change the design to use a light barrier after all. I am posting this here to just make sure it’s not a bug in the firmware.

Other than that, I can only say, this firmware is really great and easy to use!

//Edit: fix typos

@ tybghi - Since I do not have a setup that I could use to test this I would hesitate to say that the issue does not lie with the firmware, but since the problem is intermittent it does sound like could related to interference rather than a software issue.

I would be very interested in your results if/when you use a ir beam to trigger the interrupts.

Hi taylorza

I have just completed my second setup using light barriers. I want to use pulldown resistors but they don’t seem to be working. To test, I defined a pulldown on a disconnected pin (0,2) and when I read the pin it is always giving me high. When I connect it to GND it goes to low. So in fact it is looking like the pin is using a pullup. I hooked up an oscilloscope and the pin is in fact high. Is this a bug?

// Setup
this.pin = this.module.CreateInputPin(0, 2, Port.ResistorMode.PullDown);

// In a timer:
Debug.Print("" + this.pin.Read());

When I use an external pull down everything works like a charm. But I’ve got quite a few channels and I would prefer to use the internal ones…

Thanks