EnviroDIY / Arduino-SDI-12

An Arduino library for SDI-12 communication with a wide variety of environmental sensors. This library provides a general software solution, without requiring any additional hardware.
https://github.com/EnviroDIY/Arduino-SDI-12/wiki
BSD 3-Clause "New" or "Revised" License
159 stars 100 forks source link

Has anybody worked on porting this to 32-bit ARM boards? #15

Closed rkertesz closed 7 years ago

rkertesz commented 8 years ago

Before I jump in and try to figure out reworking this to avoid avr/interrupt.h and avr/parity.h, I would like to ask if anybody else has been working on this. It would take me a long time to accomplish this, given my total unfamiliarity with how these interrupts function. I am used to simply using attachInterrupt() on my 32 bit board.

Kevin-M-Smith commented 8 years ago

Hi Ruben -

I haven't done any work porting to 32-bit, but I might be able to investigate the plausibility if you have a particular board in mind.

At one point I looked into porting it to ARM CPUs (e.g. Arduino Due) but the interrupts are handled much differently, especially if there is a bona fide operating system on board.

Best, Kevin

rkertesz commented 8 years ago

Thanks Kevin,

I have a couple of konekt dash (cortex m4) boards. I may be able to send one to you to test with. I also have a particle electron (cortex m3). One interesting thing about the particle board (no pun intended) is that someone made some sort of interrupt header file as part of a larger port to particle . https://community.particle.io/t/implementing-timer-interrupts-for-pulse-sensor-solved/2997/14

Both allow for someone to use attach_interrupts. I presume this is not a practical option.

Thank you, Ruben

On Apr 28, 2016, at 5:44 PM, Kevin M. Smith notifications@github.com wrote:

be able to investigate the plausibility if you have a particular board in mind.

At one point I looked into porting

Kevin-M-Smith commented 8 years ago

Hi @rkertesz -

Apologies for the radio silence.

I think your original assessment was correct: the way these CPUs handle interrupts is fundamentally different from the Atmel ATMEGA series chips.

Unfortunately, I don't think this library will get you there, unless you want to spend one of your M3 or M4's UARTs to piggyback off of a separate ATMEGA chip running the library.

You would only need one per installation since the address space is enough to handle 64 sensors.

Did you come up with anything on your end?

Best, Kevin

ManuelJimenezBuendia commented 7 years ago

Hi Kevin.

Thank you so much for the library, it works great with AVR based Arduino Boards. Now I am moving to ARM boards (Arduino Zero) and I am having the same issue with avr/interrupt.h and avr/parity.h. I was wondering if you are planning to modify the library code to make it work with ARM processors. Probably it is not so complicated, but I don't feel as experienced at programming as to do it myself.

Best, Manuel.

Kevin-M-Smith commented 7 years ago

Hi Manuel,

Unfortunately the switch from AVR to ARM is not trivial, but @jrzondagh mentioned in issue #13 that he had managed to get a solution working. As far as I know the solution has not yet been made public.

Warm regards, Kevin

jrzondagh commented 7 years ago

Hi All,

Sorry for the delay in submitting the code online, will try get to it this week still. We have it working nicely on SAMD21 chip.

Cheers, Justin

Kevin-M-Smith commented 7 years ago

That's excellent news. Thanks Justin!

ManuelJimenezBuendia commented 7 years ago

That's good news indeed. I'm looking forward to testing it. Thanks Justin!

adnanoner commented 7 years ago

@jrzondagh Hi Justin, great that you are working on this. Any updates :)?

gppk commented 7 years ago

Hi @jrzondagh How are you getting on with the ARM conversion?

pirvanc commented 7 years ago

@jrzondagh , Hi Justin, we're also interested in this. Thanks.

locomundo commented 7 years ago

Yes, please!

ManuelJimenezBuendia commented 7 years ago

I have modified the code to work with ARM (implemented the parity function and modified the interupt calls) but I am having issues with the Arduino Zero and the GPIO pin that uses the interrupt. The modified code works OK with UNO and Leonardo (both AVR) but fails with Zero. If anyone wants to have a look at the modified code and the issues, I can send it by email.

adnanoner commented 7 years ago

@ManuelJimenezBuendia sure, you could send it to adnanoner ๏นซ gmail.com ๐Ÿ‘

madvoid commented 7 years ago

Hi everyone, I've gotten this library working with an Arduino Zero Clone (this one specifically) and a Decagon anemometer that communicates via SDI12. I made very minimal changes to the library but I don't know if it would be ready to push yet. I've included the files below but I think it would be best if there was more testing with other sensors to make sure I didn't accidentally make it just work with my sensor.

The changes I made:

Enjoy!

SDI12_Zero.zip

Kevin-M-Smith commented 7 years ago

Thanks @madvoid!

adnanoner commented 7 years ago

Thanks @madvoid! I got this working (by coincidence I also have the SAMD21 board). For some reason I think there is a problem with flushing or something. The code does however works properly when I begin and end the serial communication after each command ๐Ÿ‘

ManuelJimenezBuendia commented 7 years ago

Hi, a got it working with SDI12_Zero library, but placing forcehold() before sending the command!! I attach an example code. There is some issue with setting the pin as output after having attached the interrupt.

2017-02-01 13:50 GMT+01:00 adnanoner notifications@github.com:

Thanks @madvoid https://github.com/madvoid! I got this working (by coincidence I also have the SAMD21 board). For some reason I think there is a problem with flushing or something. The code does however works properly when I begin and end the serial communication after each command ๐Ÿ‘

โ€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/EnviroDIY/Arduino-SDI-12/issues/15#issuecomment-276649746, or mute the thread https://github.com/notifications/unsubscribe-auth/AXKqpulexSWnQfYQXUossEsZEGLC2j05ks5rYH-cgaJpZM4ISWlk .

-- Dr. Manuel Jimenez

Universidad Politecnica de Cartagena / Technical University of Cartagena Departamento de Tecnologia Electronica Campus Muralla del Mar, s/n 30202 Cartagena. Spain. Pho: +34 968 338888 Fax: +34 968 325345 e-mail: manuel.jimenez@upct.es URL: http://www.dte.upct.es / http://www.dsie.upct.es

madvoid commented 7 years ago

I'm glad a few of you have gotten it working! I have been in email contact with @ManuelJimenezBuendia and I was interested to hear he had the exact same bug as me. I'll describe it now for future reference, and our solutions as well.

The problem we both had was odd. The sensor would respond after the first request for data, but none of the subsequent requests. For both of our sensors, it seemed that digital write didn't seem to change the pin state anymore after a request has been made.

It seems that @ManuelJimenezBuendia fixed it by issuing a forceHold() command before any request for data, I fixed it by issuing the forceHold() command after every request and response. It seems that the forceHold() is necessary to get the line into a state that's "open" again. @adnanoner, did you need to do this as well?

Finally, I would like to note that in my application, I was using a level shifter that had pullup resistors on the data line. I don't know if these are necessary or not.

ManuelJimenezBuendia commented 7 years ago

Hi! I finally made it work! Just by placing a pinMode(_dataPin,INPUT); before every pinMode(_dataPin,OUTPUT); I don't know why, but this way the pin changes state as output. There is probably some issue regarding pinMode and interrupts. If anybody finds an explanation, please share. Meanwhyle, here is the modified library with some working examples. I've used Decagon 5TE powered and operated at 3.3 V (that is directly connected to a Genuino Zero). SDI12_ARM.zip

ManuelJimenezBuendia commented 7 years ago

I have forked the original project with the modified versions of the files to work with Zero and compatible boards: Hope no have made any mistake!

SRGDamia1 commented 7 years ago

Pulled in and tested on an Adafruit Feather M0. See #33